Skip to content

Commit 41e80fa

Browse files
committed
Update module documentation
1 parent 746dff9 commit 41e80fa

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

docs/moduledoc.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ fun Application.module() {
8383
)),
8484
) {
8585
addTool(name = "echo", description = "Echo text back") { request ->
86-
CallToolResult(content = listOf(TextContent("You said: ${request.params.arguments["text"]}")))
86+
val text = request.params.arguments?.get("text")?.jsonPrimitive?.content ?: ""
87+
CallToolResult(content = listOf(TextContent("You said: $text")))
8788
}
8889
}
8990
}

kotlin-sdk-client/Module.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ protocol types from `kotlin-sdk-core` and ships with transports for CLI and Ktor
1313
`listPrompts`, `complete`, `setLoggingLevel`, and subscription helpers for resources.
1414
- **Capability enforcement**: Methods fail fast if the server does not advertise the needed capability; optional
1515
strictness mirrors the protocol options used by the server SDK.
16-
- **Transports**: Ready-to-use implementations for STDIO (CLI interoperability), Ktor SSE (`SSEClientTransport` with
16+
- **Transports**: Ready-to-use implementations for STDIO (CLI interoperability), Ktor SSE (`SseClientTransport` with
1717
POST back-channel), Ktor WebSocket, and Streamable HTTP for environments that prefer request/response streaming.
1818
- **Ktor client integration**: Extension helpers wire MCP over Ktor client engines with minimal setup for SSE,
1919
Streamable HTTP, or WebSocket.
2020

2121
## Typical client setup
2222

23-
1. Declare client capabilities with `ClientOptions` (e.g., tools, prompts, resources, logging, roots, sampling,
24-
elicitation).
23+
1. Declare client capabilities with `ClientOptions` (e.g., sampling, roots, elicitation, experimental).
2524
2. Create a transport suitable for your environment.
2625
3. Connect using `mcpClient` or instantiate `Client` and call `connect(transport)`.
2726
4. Use typed APIs to interact with the server; results and errors use the shared MCP types.
@@ -37,7 +36,10 @@ val client = mcpClient(
3736
resources = ClientCapabilities.Resources(subscribe = true),
3837
)
3938
),
40-
transport = StdioClientTransport(System.`in`.source(), System.out.sink())
39+
transport = StdioClientTransport(
40+
System.`in`.asSource().buffered(),
41+
System.out.asSink().buffered()
42+
)
4143
)
4244

4345
val tools = client.listTools()
@@ -47,10 +49,12 @@ println(result.content)
4749

4850
### Ktor-based transports
4951

50-
- **SSE** (streaming GET + POST back-channel): create `SSEClientTransport(baseUrl, httpClient)`; sessions are keyed by
51-
`sessionId` managed by the SDK.
52-
- **WebSocket**: use `WebSocketClientTransport(url, httpClient)` to get bidirectional messaging in one connection.
53-
- **Streamable HTTP**: `StreamableHttpClientTransport` enables MCP over streaming HTTP where WebSockets are unavailable.
52+
- **SSE** (streaming GET + POST back-channel): create `SseClientTransport(httpClient, url)` (or
53+
`HttpClient.mcpSseTransport(url)`); sessions are keyed by `sessionId` managed by the SDK.
54+
- **WebSocket**: use `WebSocketClientTransport(httpClient, url)` (or `HttpClient.mcpWebSocketTransport(url)`) to get
55+
bidirectional messaging in one connection.
56+
- **Streamable HTTP**: `StreamableHttpClientTransport(httpClient, url)` enables MCP over streaming HTTP
57+
(or `HttpClient.mcpStreamableHttpTransport(url)`).
5458

5559
## Feature usage highlights
5660

kotlin-sdk-server/Module.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ val server = Server(
4141
name = "hello",
4242
description = "Greets the caller by name"
4343
) { request ->
44-
val name = request.params.arguments["name"]?.jsonPrimitive?.content ?: "there"
44+
val name = request.params.arguments?.get("name")?.jsonPrimitive?.content ?: "there"
4545
CallToolResult(
4646
content = listOf(TextContent("Hello, $name!")),
4747
isError = false,
4848
)
4949
}
5050
}
5151

52-
val transport = StdioServerTransport(System.`in`.source(), System.out.sink())
52+
val transport = StdioServerTransport(
53+
System.`in`.asSource().buffered(),
54+
System.out.asSink().buffered()
55+
)
5356
server.createSession(transport)
5457
```
5558

0 commit comments

Comments
 (0)