| Filename | Latest commit message | Latest commit date |
|---|---|---|
Bumps [io.modelcontextprotocol:kotlin-sdk-client](https://github.com/modelcontextprotocol/kotlin-sdk) from 0.12.0 to 0.13.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/modelcontextprotocol/kotlin-sdk/releases">io.modelcontextprotocol:kotlin-sdk-client's releases</a>.</em></p> <blockquote> <h2>0.13.0</h2> <h2>Description</h2> <p>Adds a <code>tasks</code> capability and a typed <code>elicitation</code> capability, hardens transport lifecycle, dispatchers, and back-pressure, and enables DNS rebinding protection by default.</p> <h3>Breaking Changes</h3> <p><strong>Typed <code>elicitation</code> capability and new <code>tasks</code> capability</strong> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/732">#732</a></p> <p><code>ClientCapabilities.elicitation</code> is now a typed <code>ClientCapabilities.Elicitation</code> (<code>form</code>, <code>url</code>) instead of a raw <code>JsonObject?</code>, and both <code>ClientCapabilities</code> and <code>ServerCapabilities</code> gained a typed <code>tasks</code> capability. The constructors of both types changed and are binary-incompatible; recompilation is required.</p> <p><strong>Transport handlers now run on <code>Dispatchers.Default</code></strong> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/778">#778</a></p> <p>Handlers moved from <code>Dispatchers.IO</code> to <code>Dispatchers.Default</code> (override via <code>handlerDispatcher</code>), <code>send()</code> now suspends under back-pressure instead of buffering unbounded, and the two-argument <code>StdioServerTransport(input, output)</code> constructor is deprecated in favor of the builder-lambda form. Also fixes a <code>start()</code>/<code>close()</code> race, consistent <code>CancellationException</code> propagation, and an input-<code>Source</code> leak (closes <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/573">#573</a>, <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/574">#574</a>, <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/708">#708</a>).</p> <p><strong>DNS rebinding protection enabled by default</strong> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/659">#659</a></p> <p><code>enableDnsRebindingProtection</code> now defaults to <code>true</code> on <code>mcpStreamableHttp</code>/<code>mcpStatelessStreamableHttp</code>, and the <code>Route.mcp()</code> / <code>Application.mcp()</code> overloads gained <code>enableDnsRebindingProtection</code>, <code>allowedHosts</code>, and <code>allowedOrigins</code> parameters (binary-incompatible on JVM). Only <code>localhost</code>, <code>127.0.0.1</code>, and <code>[::1]</code> are allowed by default; opt out with <code>enableDnsRebindingProtection = false</code>. The <code>Configuration.enableDnsRebindingProtection</code>, <code>.allowedHosts</code>, and <code>.allowedOrigins</code> properties are deprecated in favor of the new <code>DnsRebindingProtection</code> plugin.</p> <h3>Features</h3> <ul> <li>Add a <code>tasks</code> capability (<code>list</code>, <code>cancel</code>, and per-request augmentation for sampling and elicitation) on <code>ClientCapabilities</code> and <code>ServerCapabilities</code>, with assertions for <code>tasks/*</code> and <code>notifications/tasks/status</code> enforced by <code>Client</code> and <code>ServerSession</code> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/732">#732</a></li> <li>Configurable <code>handlerDispatcher</code> and <code>ioDispatcher</code>, plus an optional caller-supplied <code>CoroutineScope</code>, on transports by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/778">#778</a></li> </ul> <h3>Fixed</h3> <ul> <li>Fire <code>onClose</code> callbacks on <code>SseClientTransport</code> when the SSE session ends — whether closed gracefully or terminated by an error — matching the other client transports by <a href="https://github.com/jskjw157"><code>@jskjw157</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/738">#738</a></li> </ul> <h3>Security</h3> <ul> <li>Enable DNS rebinding protection by default across all HTTP transports, including the SSE endpoints that previously had none (see Breaking Changes for migration) by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/659">#659</a></li> <li>Cap a single stdio JSON-RPC frame at 16 MiB, throwing the new <code>TooLongFrameException</code> instead of buffering unbounded when a peer never sends a newline terminator by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href=" |
||
| .. | ||
| gradle | ||
| src/main | ||
| build.gradle.kts | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| README.md | ||
| settings.gradle.kts | ||
Kotlin MCP Client
An interactive CLI client that connects to any MCP server over STDIO and pipes queries through Anthropic's Claude API.
Overview
This sample demonstrates a complete MCP client workflow: launching an MCP server as a subprocess, discovering its tools, converting them to Anthropic's tool format, and running an interactive chat loop where Claude can call server tools on behalf of the user.
Prerequisites
- JDK 17+
- An
ANTHROPIC_API_KEYenvironment variable set with a valid Anthropic API key - An MCP server script to connect to (
.js,.py, or.jar)
Build & Run
Run the client, passing the path to an MCP server:
# Connect to a JVM server
./gradlew run --args="path/to/server.jar"
# Connect to a Python server
./gradlew run --args="path/to/server.py"
# Connect to a Node.js server
./gradlew run --args="path/to/build/index.js"
Note
The client uses STDIO transport, so it launches the MCP server as a subprocess. Ensure the server script is executable and is a valid
.js,.py, or.jarfile.
MCP Capabilities
From the client perspective, this sample demonstrates:
- Tool discovery — lists tools from the connected server and converts them to Anthropic's tool format.
- Tool invocation — when Claude's response requests a tool call, the client invokes the corresponding MCP tool and feeds the result back into the conversation.