You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - SSE: `--transport=sse` → use with `McpService.sse()`
25
+
* - Streaming: `--transport=streaming` → use with `McpService.streamableHttp()`
26
+
*
27
+
* ## Example 1: STDIO Transport (Direct Process Communication)
17
28
*
18
29
* This example uses an STDIO transport connection to the [Amazon Product Search](https://smithery.ai/server/@SiliconValleyInsight/amazon-product-search) service.
19
30
*
20
31
* IMPORTANT! If you use the STDIO transport type, consider calling the McpService#close() method to free resources.
21
32
*/
22
-
valmcpService=McpService.stdio(
33
+
valmcpServiceStdio=McpService.stdio(
23
34
listOf(
24
35
"npx",
25
36
"-y",
@@ -31,36 +42,72 @@ val mcpService = McpService.stdio(
31
42
)
32
43
)
33
44
45
+
/**
46
+
* ## Example 2: SSE Transport via Docker MCP Gateway
47
+
*
48
+
* This example demonstrates connecting to MCP services through Docker MCP Gateway.
49
+
* Docker MCP Gateway allows you to run MCP servers in containers and access them via HTTP.
50
+
*
51
+
* ### Setup:
52
+
* 1. See docker-compose.yml example at: activators/llm/src/main/kotlin/com/justai/jaicf/activator/llm/mcp/gateway/docker-compose.yml
53
+
* 2. Start the gateway: `docker-compose up`
54
+
* 3. Connect to the gateway via SSE transport as shown below
55
+
*
56
+
* ### Using MCP Services with API Keys:
57
+
* Some services require API keys. Pass them via environment variables in docker-compose.yml:
58
+
* ```
59
+
* environment:
60
+
* EXA_API_KEY: your-api-key-here
61
+
* ```
62
+
*
63
+
* ### StreamableHttp Transport:
64
+
* For streaming HTTP support, use `McpService.streamableHttp()` which corresponds to
65
+
* Docker MCP Gateway's `--transport=streaming` option. This provides HTTP-based streaming
66
+
* for better performance with long-running operations.
67
+
* ```
68
+
* val mcpStreamable = McpService.streamableHttp("http://localhost:8083/mcp")
69
+
* ```
70
+
*
71
+
* This example connects to DuckDuckGo search service running on port 8081 (SSE).
72
+
*/
73
+
val mcpServiceSse =McpService.sse(
74
+
urlString ="http://localhost:8081/sse"
75
+
)
76
+
34
77
/**
35
78
* IMPORTANT! Set up your OPENAI_API_KEY and OPENAI_BASE_URL env before running
36
79
*/
37
80
privateval scenario =Scenario {
38
81
llmState("main", {
39
82
model ="gpt-4.1-nano"
40
83
84
+
// Example using DuckDuckGo via Docker MCP Gateway
85
+
// Available tools: "search" and "fetch_content"
86
+
41
87
// Option 1: The most simple way to add a tool. Provide a tool name via `toolName` parameter.
42
-
tool(mcpService.getTool("find_products_to_buy"))
88
+
tool(mcpServiceSse.getTool("search"))
43
89
44
90
// Option 2: expose a subset of tools from the MCP service via the `tools` parameter.
45
-
// In this example, only the `find_products_to_buy` and `get_product_details` tools are available.
0 commit comments