| Filename | Latest commit message | Latest commit date |
|---|---|---|
Bumps `mcp-kotlin` from 0.14.0 to 0.15.0. Updates `io.modelcontextprotocol:kotlin-sdk-client` from 0.14.0 to 0.15.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.15.0</h2> <h2>Description</h2> <p>This release makes inbound message handling concurrent after the initialization handshake, adds SSE heartbeats and elicitation schema validation, and fixes several Streamable HTTP response and session-lifecycle bugs.</p> <h3>Breaking Changes</h3> <p><strong>Concurrent inbound dispatch</strong> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/884">#884</a></p> <p>Inbound messages were processed serially on the transport read loop, so one slow or peer-awaiting handler (sampling, elicitation, roots) blocked every later message on the connection, including the responses and <code>notifications/cancelled</code> those handlers depend on. After the handshake, handlers may now run concurrently; processing stays serial during initialization.</p> <ul> <li><code>ProtocolOptions</code> / <code>ClientOptions</code> / <code>ServerOptions</code> gain a <code>handlerCoroutineContext</code> parameter (defaults to <code>Dispatchers.Default</code>). Concurrency is bounded internally; there is no opt-out flag by design.</li> <li><code>RequestHandlerExtra</code> is now a <code>CoroutineContext.Element</code> and is no longer user-constructible. It exposes <code>requestId</code>, <code>method</code>, <code>sendRequest</code>, and <code>sendNotification</code>, and can be read inside a handler via the new <code>currentRequestHandlerExtra()</code>.</li> </ul> <pre lang="diff"><code>- val extra = RequestHandlerExtra() + val extra = currentRequestHandlerExtra() </code></pre> <p><strong>Duplicate feature names are rejected at registration</strong> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/883">#883</a></p> <p><code>addTool</code>/<code>addPrompt</code>/<code>addResource</code>/<code>addResourceTemplate</code> silently replaced an existing entry and emitted a spurious <code>list_changed</code> notification. They now throw <code>IllegalArgumentException</code> and leave the existing registration intact. The batch variants (<code>addTools</code>/<code>addPrompts</code>/<code>addResources</code>) are all-or-nothing. To replace a feature, remove it first.</p> <pre lang="diff"><code>- server.addTool(name = "search", ...) // silently overwrote + server.removeTool("search") + server.addTool(name = "search", ...) </code></pre> <p><strong><code>eventStore</code> removed from <code>mcpStatelessStreamableHttp</code></strong> by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/909">#909</a></p> <p>The parameter was never read or written: a stateless endpoint answers <code>GET</code> with <code>405</code>, so no stream exists to store or replay events on. The old overload is retained at <code>DeprecationLevel.ERROR</code> with a <code>ReplaceWith</code> migration hint. Use <code>mcpStreamableHttp</code> when you need resumability.</p> <pre lang="diff"><code> application.mcpStatelessStreamableHttp( path = "/mcp", - eventStore = myEventStore, ) { server } </code></pre> <h3>Features</h3> <ul> <li>Optional SSE heartbeats for Streamable HTTP servers via <code>mcpStreamableHttp(sseHeartbeatConfig = { ... })</code>, keeping long-lived streams alive against clients that disconnect on idle. Heartbeats stay off by default, by <a href="https://github.com/UnscientificJsZhai"><code>@UnscientificJsZhai</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/761">#761</a></li> <li>Accepted form-mode elicitation content is now validated against <code>requestedSchema</code>; a mismatch fails <code>createElicitation</code> with <code>McpException</code> (<code>INVALID_PARAMS</code>) instead of reaching server code unchecked, by <a href="https://github.com/rea9r"><code>@rea9r</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/896">#896</a></li> <li>The Streamable HTTP client now sends the standard <code>Mcp-Method</code> and <code>Mcp-Name</code> POST headers, by <a href="https://github.com/AndreKalberer"><code>@AndreKalberer</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/894">#894</a></li> </ul> <h3>Fixed</h3> <ul> <li>Stateless Streamable HTTP now closes its per-request session, fixing unbounded growth of the session registry and notification subscriptions, by <a href="https://github.com/KlyneChrysler"><code>@KlyneChrysler</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/872">#872</a></li> <li>Streamable HTTP responses keep their status and body when the client accepts only <code>text/event-stream</code>, by <a href="https://github.com/devcrocod"><code>@devcrocod</code></a> in <a href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/pull/911">#911</a></li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href=" |
||
| .. | ||
| gradle | ||
| src | ||
| build.gradle.kts | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| mcp-inspector-config.json | ||
| README.md | ||
| settings.gradle.kts | ||
Kotlin MCP Server
A sample MCP server demonstrating multiple transport modes: STDIO, SSE (plain), and SSE (Ktor plugin).
Note: The SSE transport modes are provided for backward compatibility. For new projects, consider using the simple-streamable-server sample, which uses the recommended Streamable HTTP transport.
Overview
This sample registers a prompt, a tool, and a resource, then lets you choose how to expose them.
STDIO mode is the default and is best for process-based clients. The two SSE modes show how to
serve MCP over HTTP using either a manual Ktor routing setup or the built-in mcp { } Ktor plugin.
Prerequisites
- JDK 17+
- MCP Inspector (optional, for testing)
Build & Run
STDIO mode (default)
./gradlew run
Or explicitly:
./gradlew run --args="--stdio"
Connect with the MCP Inspector:
npx @modelcontextprotocol/inspector --config samples/kotlin-mcp-server/mcp-inspector-config.json --server stdio-server
SSE with Ktor plugin
./gradlew run --args="--sse-server-ktor 3002"
Connect with the MCP Inspector:
npx @modelcontextprotocol/inspector --config samples/kotlin-mcp-server/mcp-inspector-config.json --server sse-ktor-server
SSE with plain configuration
Known issue: This mode may not work correctly at this time.
./gradlew run --args="--sse-server 3001"
Connect with the MCP Inspector:
npx @modelcontextprotocol/inspector --config samples/kotlin-mcp-server/mcp-inspector-config.json --server sse-server
MCP Capabilities
Tools
| Name | Description |
|---|---|
kotlin-sdk-tool |
A test tool that returns a "Hello, world!" greeting. |
Prompts
| Name | Description |
|---|---|
Kotlin Developer |
Generates a prompt to develop a small Kotlin application for a given project name. |
Resources
| Name | URI | Description |
|---|---|---|
Web Search |
https://search.com/ |
A placeholder resource demonstrating resource handling. |