kotlin-sdk/samples/kotlinlang-mcp-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
dependabot[bot] 14c848db41
chore(deps): bump mcp-kotlin from 0.13.0 to 0.14.0 in /samples/kotlinlang-mcp-server (#877)
Bumps `mcp-kotlin` from 0.13.0 to 0.14.0.
Updates `io.modelcontextprotocol:kotlin-sdk-server` from 0.13.0 to
0.14.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fc7916fdc7"><code>fc7916f</code></a>
release: 0.14.0 (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/867">#867</a>)</li>
<li><a
href="57e546d378"><code>57e546d</code></a>
feat: SEP-1686 Tasks (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/844">#844</a>)</li>
<li><a
href="35da063c23"><code>35da063</code></a>
fix: bound request body size in SSE and Streamable HTTP transports (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/839">#839</a>)</li>
<li><a
href="bbf77bae93"><code>bbf77ba</code></a>
chore(deps): bump <code>@​types/node</code> from 26.0.0 to 26.0.1 in
/integration-test/src/...</li>
<li><a
href="d2b1509147"><code>d2b1509</code></a>
chore(deps): bump the other-dependencies group across 5 directories with
5 up...</li>
<li><a
href="0221b8db3d"><code>0221b8d</code></a>
fix(client): close stdio read sources during shutdown (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/798">#798</a>)</li>
<li><a
href="19db4b04e3"><code>19db4b0</code></a>
fix(client): gate completion/complete on the completions capability (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/846">#846</a>)</li>
<li><a
href="64cf29fea7"><code>64cf29f</code></a>
chore(deps): bump gradle-wrapper from 9.6.0 to 9.6.1 (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/856">#856</a>)</li>
<li><a
href="cd91652be1"><code>cd91652</code></a>
fix: validate Origin against localhost by default in DNS rebinding
protection...</li>
<li><a
href="4103b87d69"><code>4103b87</code></a>
chore(deps): bump org.jetbrains.kotlinx:kotlinx-io-core from 0.9.0 to
0.9.1 i...</li>
<li>Additional commits viewable in <a
href="https://github.com/modelcontextprotocol/kotlin-sdk/compare/0.13.0...0.14.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `io.modelcontextprotocol:kotlin-sdk-client` from 0.13.0 to
0.14.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fc7916fdc7"><code>fc7916f</code></a>
release: 0.14.0 (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/867">#867</a>)</li>
<li><a
href="57e546d378"><code>57e546d</code></a>
feat: SEP-1686 Tasks (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/844">#844</a>)</li>
<li><a
href="35da063c23"><code>35da063</code></a>
fix: bound request body size in SSE and Streamable HTTP transports (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/839">#839</a>)</li>
<li><a
href="bbf77bae93"><code>bbf77ba</code></a>
chore(deps): bump <code>@​types/node</code> from 26.0.0 to 26.0.1 in
/integration-test/src/...</li>
<li><a
href="d2b1509147"><code>d2b1509</code></a>
chore(deps): bump the other-dependencies group across 5 directories with
5 up...</li>
<li><a
href="0221b8db3d"><code>0221b8d</code></a>
fix(client): close stdio read sources during shutdown (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/798">#798</a>)</li>
<li><a
href="19db4b04e3"><code>19db4b0</code></a>
fix(client): gate completion/complete on the completions capability (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/846">#846</a>)</li>
<li><a
href="64cf29fea7"><code>64cf29f</code></a>
chore(deps): bump gradle-wrapper from 9.6.0 to 9.6.1 (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/856">#856</a>)</li>
<li><a
href="cd91652be1"><code>cd91652</code></a>
fix: validate Origin against localhost by default in DNS rebinding
protection...</li>
<li><a
href="4103b87d69"><code>4103b87</code></a>
chore(deps): bump org.jetbrains.kotlinx:kotlinx-io-core from 0.9.0 to
0.9.1 i...</li>
<li>Additional commits viewable in <a
href="https://github.com/modelcontextprotocol/kotlin-sdk/compare/0.13.0...0.14.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `io.modelcontextprotocol:kotlin-sdk-testing` from 0.13.0 to
0.14.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fc7916fdc7"><code>fc7916f</code></a>
release: 0.14.0 (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/867">#867</a>)</li>
<li><a
href="57e546d378"><code>57e546d</code></a>
feat: SEP-1686 Tasks (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/844">#844</a>)</li>
<li><a
href="35da063c23"><code>35da063</code></a>
fix: bound request body size in SSE and Streamable HTTP transports (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/839">#839</a>)</li>
<li><a
href="bbf77bae93"><code>bbf77ba</code></a>
chore(deps): bump <code>@​types/node</code> from 26.0.0 to 26.0.1 in
/integration-test/src/...</li>
<li><a
href="d2b1509147"><code>d2b1509</code></a>
chore(deps): bump the other-dependencies group across 5 directories with
5 up...</li>
<li><a
href="0221b8db3d"><code>0221b8d</code></a>
fix(client): close stdio read sources during shutdown (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/798">#798</a>)</li>
<li><a
href="19db4b04e3"><code>19db4b0</code></a>
fix(client): gate completion/complete on the completions capability (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/846">#846</a>)</li>
<li><a
href="64cf29fea7"><code>64cf29f</code></a>
chore(deps): bump gradle-wrapper from 9.6.0 to 9.6.1 (<a
href="https://redirect.github.com/modelcontextprotocol/kotlin-sdk/issues/856">#856</a>)</li>
<li><a
href="cd91652be1"><code>cd91652</code></a>
fix: validate Origin against localhost by default in DNS rebinding
protection...</li>
<li><a
href="4103b87d69"><code>4103b87</code></a>
chore(deps): bump org.jetbrains.kotlinx:kotlinx-io-core from 0.9.0 to
0.9.1 i...</li>
<li>Additional commits viewable in <a
href="https://github.com/modelcontextprotocol/kotlin-sdk/compare/0.13.0...0.14.0">compare
view</a></li>
</ul>
</details>
<br />

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-06 13:29:15 +02:00
..
gradle chore(deps): bump mcp-kotlin from 0.13.0 to 0.14.0 in /samples/kotlinlang-mcp-server (#877) 2026-07-06 13:29:15 +02:00
src sample: kotlinlang mcp server (#713) 2026-04-27 15:07:03 +02:00
build.gradle.kts sample: kotlinlang mcp server (#713) 2026-04-27 15:07:03 +02:00
Dockerfile sample: kotlinlang mcp server (#713) 2026-04-27 15:07:03 +02:00
gradle.properties sample: kotlinlang mcp server (#713) 2026-04-27 15:07:03 +02:00
gradlew chore(deps): bump the other-dependencies group across 5 directories with 3 updates (#854) 2026-06-24 15:31:46 +02:00
gradlew.bat chore(deps): bump the other-dependencies group across 5 directories with 3 updates (#854) 2026-06-24 15:31:46 +02:00
README.md sample: kotlinlang mcp server (#713) 2026-04-27 15:07:03 +02:00
settings.gradle.kts sample: kotlinlang mcp server (#713) 2026-04-27 15:07:03 +02:00

Kotlinlang MCP Server

A Streamable HTTP MCP server that exposes the official Kotlin documentation to LLM clients — full-text search via Algolia plus page retrieval in markdown through kotlinlang.org's _llms endpoints.

Overview

This sample demonstrates an MCP server that wraps a real external documentation source. It uses the recommended Streamable HTTP transport, supports multiple concurrent client sessions, and caches responses in memory to reduce upstream load. The server is intentionally read-only — it exposes two tools, no prompts, no resources.

Prerequisites

  • JDK 21+
  • Algolia credentials for kotlinlang.org (exported as environment variables, see Configuration)

Build & Run

export ALGOLIA_APP_ID=...
export ALGOLIA_API_KEY=...
export ALGOLIA_INDEX_NAME=...

./gradlew run

The server starts on http://localhost:8080/mcp by default.

Connect with the MCP Inspector:

npx @modelcontextprotocol/inspector

In the Inspector UI, select Streamable HTTP transport and enter http://localhost:8080/mcp.

MCP Capabilities

Tools

Name Description
search_kotlinlang Full-text search across Kotlin documentation. Returns up to 5 results filtered to /docs/ pages. Responses cached for 10 minutes.
get_kotlinlang_page Fetches a documentation page as markdown via kotlinlang.org's _llms endpoint. Accepts a path relative to /docs/. Cached for 1 hour.

Example paths accepted by get_kotlinlang_page: coroutines-overview, multiplatform/compose-multiplatform-and-jetpack-compose. Leading/trailing slashes and an optional .html suffix are normalized before resolution.

Configuration

Variable Required Default Description
ALGOLIA_APP_ID yes — Algolia application ID
ALGOLIA_API_KEY yes — Algolia search API key
ALGOLIA_INDEX_NAME yes — Algolia index name
SERVER_PORT no 8080 HTTP server port
SERVER_HOST no 0.0.0.0 HTTP server bind address

The server does not provide fallback values for ALGOLIA_*. Startup fails if any of those variables are missing.

Docker

Multi-stage build with Alpine-based images. Runs as a non-root user.

docker build -t kotlinlang-mcp-server .

docker run \
  -p 8080:8080 \
  -e ALGOLIA_APP_ID=... \
  -e ALGOLIA_API_KEY=... \
  -e ALGOLIA_INDEX_NAME=... \
  kotlinlang-mcp-server

Connecting an MCP client

Any MCP client that supports Streamable HTTP transport can connect:

{
  "mcpServers": {
    "kotlinlang": {
      "url": "http://localhost:8080/mcp"
    }
  }
}

Limitations

This sample is intended for demonstration only. Before production use, consider:

  • In-memory cache only — cached data is lost on server restart.
  • No authentication or authorization — run behind a trusted proxy or restrict network access.
  • No rate limiting on outgoing requests to Algolia and kotlinlang.org.
  • Permissive CORS (anyHost()) — restrict to specific origins for any non-local deployment.
  • Streamable HTTP only — no STDIO transport for local-only usage.
  • Tools only — no MCP resources or prompts are exposed.