Mirror of https://github.com/modelcontextprotocol/kotlin-sdk — The official Kotlin SDK for Model Context Protocol servers and clients. Maintained in collaboration with JetBrains
  • Kotlin 98%
  • TypeScript 1.7%
  • Shell 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
dependabot[bot] 9d4535b53f
Bump com.vanniktech:gradle-maven-publish-plugin from 0.35.0 to 0.36.0 (#484)
Bumps
[com.vanniktech:gradle-maven-publish-plugin](https://github.com/vanniktech/gradle-maven-publish-plugin)
from 0.35.0 to 0.36.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/vanniktech/gradle-maven-publish-plugin/releases">com.vanniktech:gradle-maven-publish-plugin's
releases</a>.</em></p>
<blockquote>
<h2>0.36.0</h2>
<p><strong>BREAKING</strong></p>
<ul>
<li>Updated minimum supported JDK, Gradle, Android Gradle Plugin and
Kotlin versions.</li>
<li>Removed support for Dokka v1, it's now required to use Dokka in v2
mode.</li>
<li>Mark <code>DirectorySignatureType</code> internal.</li>
</ul>
<p><strong>Behavior changes</strong></p>
<ul>
<li><code>validateDeployment</code> now has the
<code>DeploymentValidation</code> enum as type instead of being a
boolean. The default
is now to just wait for the <code>VALIDATED</code> state. The previous
behavior can be achieved by setting it to <code>PUBLISHED</code>.
<code>NONE</code> can be used for disabling the validation
completely.</li>
<li>When calling <code>configure(...)</code> manually to configure what
to publish and not passing <code>javadocJar</code> explicity,
the plugin now defaults to publishing an empty javadoc jar.</li>
</ul>
<p><strong>Features</strong></p>
<ul>
<li>Android projects now support using Dokka for javadoc creation, this
will happen automatically
when using the default options and the Dokka plugin is applied to the
project.</li>
<li>Added consistent <code>JavadocJar</code> and <code>SourcesJar</code>
options to <code>configureBasedOnAppliedPlugins</code> and to all
applicable project types that can be passed to <code>configure</code>.
The previous <code>Boolean</code> based versions have
been deprecated.</li>
<li>When enabling Maven Central publishing through the DSL, the
<code>mavenCentralDeploymentValidation</code> and
<code>mavenCentralAutomaticPublishing</code> are used for the default
values of the 2 parameters when they are not passed
explicitly. This allows to more easily override them in certain
environments.</li>
<li>When isolated projects is enabled the module/project specific
<code>gradle.properties</code> files are now considered in
the same way they are when isolated projects is disabled.</li>
</ul>
<p><strong>Improvements</strong></p>
<ul>
<li>Better error message when Maven Central credentials are
missing.</li>
</ul>
<h4>Minimum supported versions</h4>
<ul>
<li>JDK 17</li>
<li>Gradle 9.0.0</li>
<li>Android Gradle Plugin 8.13.0</li>
<li>Kotlin Gradle Plugin 2.2.0</li>
</ul>
<h4>Compatibility tested up to</h4>
<ul>
<li>JDK 25</li>
<li>Gradle 9.3.0</li>
<li>Gradle 9.4.0-milestone-4</li>
<li>Android Gradle Plugin 8.13.2</li>
<li>Android Gradle Plugin 9.0.0</li>
<li>Android Gradle Plugin 9.1.0-alpha05</li>
<li>Kotlin Gradle Plugin 2.3.0</li>
<li>Kotlin Gradle Plugin 2.3.20-Beta1</li>
</ul>
<h2>0.36.0-rc2</h2>
<p><strong>BREAKING</strong></p>
<ul>
<li>Updated minimum supported JDK, Gradle, Android Gradle Plugin and
Kotlin versions.</li>
<li>Removed support for Dokka v1, it's now required to use Dokka in v2
mode.</li>
<li>Mark <code>DirectorySignatureType</code> internal.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md">com.vanniktech:gradle-maven-publish-plugin's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/vanniktech/gradle-maven-publish-plugin/releases/tag/0.36.0">0.36.0</a>
<em>(2026-01-13)</em></h2>
<p><strong>BREAKING</strong></p>
<ul>
<li>Updated minimum supported JDK, Gradle, Android Gradle Plugin and
Kotlin versions.</li>
<li>Removed support for Dokka v1, it's now required to use Dokka in v2
mode.</li>
<li>Mark <code>DirectorySignatureType</code> internal.</li>
</ul>
<p><strong>Behavior changes</strong></p>
<ul>
<li><code>validateDeployment</code> now has the
<code>DeploymentValidation</code> enum as type instead of being a
boolean. The default
is now to just wait for the <code>VALIDATED</code> state. The previous
behavior can be achieved by setting it to <code>PUBLISHED</code>.
<code>NONE</code> can be used for disabling the validation
completely.</li>
<li>When calling <code>configure(...)</code> manually to configure what
to publish and not passing <code>javadocJar</code> explicity,
the plugin now defaults to publishing an empty javadoc jar.</li>
</ul>
<p><strong>Features</strong></p>
<ul>
<li>Android projects now support using Dokka for javadoc creation, this
will happen automatically
when using the default options and the Dokka plugin is applied to the
project.</li>
<li>Added consistent <code>JavadocJar</code> and <code>SourcesJar</code>
options to <code>configureBasedOnAppliedPlugins</code> and to all
applicable project types that can be passed to <code>configure</code>.
The previous <code>Boolean</code> based versions have
been deprecated.</li>
<li>When enabling Maven Central publishing through the DSL, the
<code>mavenCentralDeploymentValidation</code> and
<code>mavenCentralAutomaticPublishing</code> are used for the default
values of the 2 parameters when they are not passed
explicitly. This allows to more easily override them in certain
environments.</li>
<li>When isolated projects is enabled the module/project specific
<code>gradle.properties</code> files are now considered in
the same way they are when isolated projects is disabled.</li>
</ul>
<p><strong>Improvements</strong></p>
<ul>
<li>Better error message when Maven Central credentials are
missing.</li>
</ul>
<h4>Minimum supported versions</h4>
<ul>
<li>JDK 17</li>
<li>Gradle 9.0.0</li>
<li>Android Gradle Plugin 8.13.0</li>
<li>Kotlin Gradle Plugin 2.2.0</li>
</ul>
<h4>Compatibility tested up to</h4>
<ul>
<li>JDK 25</li>
<li>Gradle 9.3.0</li>
<li>Gradle 9.4.0-milestone-4</li>
<li>Android Gradle Plugin 8.13.2</li>
<li>Android Gradle Plugin 9.0.0</li>
<li>Android Gradle Plugin 9.1.0-alpha05</li>
<li>Kotlin Gradle Plugin 2.3.0</li>
<li>Kotlin Gradle Plugin 2.3.20-Beta1</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="0a5fa58778"><code>0a5fa58</code></a>
rc2 and wait for published</li>
<li><a
href="695e18a932"><code>695e18a</code></a>
rc1</li>
<li><a
href="f92dc3a37b"><code>f92dc3a</code></a>
Changelog for 0.36.0</li>
<li><a
href="bddd1e6d7b"><code>bddd1e6</code></a>
Update dependency org.jetbrains.kotlin.jvm to v2.3.20-Beta1 (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1289">#1289</a>)</li>
<li><a
href="22f90b2df5"><code>22f90b2</code></a>
Update Gradle to v9.3.0 (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1301">#1301</a>)</li>
<li><a
href="d7d5f34301"><code>d7d5f34</code></a>
Update android.gradle to v9 (major) (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1298">#1298</a>)</li>
<li><a
href="3d262a6a47"><code>3d262a6</code></a>
Update dependency com.android.library to v9.1.0-alpha05 (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1300">#1300</a>)</li>
<li><a
href="a8573eda99"><code>a8573ed</code></a>
Update plugin com.gradle.develocity to v4.3.1 (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1299">#1299</a>)</li>
<li><a
href="ee0f2e3bba"><code>ee0f2e3</code></a>
Fix typo in default <code>DeploymentValidation</code> and correct
documentation (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1296">#1296</a>)</li>
<li><a
href="783599f03e"><code>783599f</code></a>
Update dependency com.android.library to v9.0.0 (<a
href="https://redirect.github.com/vanniktech/gradle-maven-publish-plugin/issues/1297">#1297</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/vanniktech/gradle-maven-publish-plugin/compare/0.35.0...0.36.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=com.vanniktech:gradle-maven-publish-plugin&package-manager=gradle&previous-version=0.35.0&new-version=0.36.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-06 00:40:43 +02:00
.github ci: integrate Detekt static analysis tool (#493) 2026-01-26 19:02:22 +02:00
.idea ci: integrate Detekt static analysis tool (#493) 2026-01-26 19:02:22 +02:00
buildSrc ci: integrate Detekt static analysis tool (#493) 2026-01-26 19:02:22 +02:00
config/detekt Detekt configuration (#501) 2026-02-04 17:02:58 +02:00
conformance-test fix conformance tests (#483) 2026-01-19 15:45:54 +02:00
docs Add module documentation and enhance Dokka configuration (#261) 2025-09-15 17:44:43 +02:00
gradle Bump com.vanniktech:gradle-maven-publish-plugin from 0.35.0 to 0.36.0 (#484) 2026-02-06 00:40:43 +02:00
integration-test Bump hono from 4.11.4 to 4.11.7 in /integration-test/src/jvmTest/typescript in the npm_and_yarn group across 1 directory (#495) 2026-02-06 00:40:21 +02:00
kotlin-sdk Kotlin-MCP can't be used without ktor-bom starting from 0.7.5 (#390) (#392) 2025-11-12 15:32:54 +02:00
kotlin-sdk-client [WIP]test(integration): Add Streamable HTTP transport integration tests (#486) 2026-02-05 14:49:47 +02:00
kotlin-sdk-core Deprecation cycle (#498) 2026-02-04 20:04:11 +01:00
kotlin-sdk-server Deprecation cycle (#498) 2026-02-04 20:04:11 +01:00
samples Fix kotlin-mcp-server sample (#459) 2025-12-08 23:25:55 +02:00
test-utils fix conformance tests (#483) 2026-01-19 15:45:54 +02:00
.editorconfig Detekt configuration (#501) 2026-02-04 17:02:58 +02:00
.gitignore ci: integrate Detekt static analysis tool (#493) 2026-01-26 19:02:22 +02:00
AGENTS.md Mark DSL functions for types as public (#472) 2026-01-10 01:12:29 +02:00
build.gradle.kts Detekt configuration (#501) 2026-02-04 17:02:58 +02:00
CODE_OF_CONDUCT.md Update license 2024-12-16 21:20:35 +01:00
CONTRIBUTING.md Update package name across the project (#2) 2024-12-17 07:28:51 +01:00
gradle.properties bump: update version to 0.8.3 (#488) 2026-01-21 12:21:11 +02:00
gradlew Update Gradle to version 9.2.0 across all projects (#377) 2025-11-07 17:07:20 +02:00
gradlew.bat Update Gradle to version 9.2.0 across all projects (#377) 2025-11-07 17:07:20 +02:00
LICENSE chore: update licensing to Apache 2.0 for new contributions (#481) 2026-01-13 14:21:52 +02:00
README.md chore: update licensing to Apache 2.0 for new contributions (#481) 2026-01-13 14:21:52 +02:00
settings.gradle.kts test: Refactor test utilities, fix conformance (#476) 2026-01-10 16:51:15 +02:00

MCP Kotlin SDK

Maven Central Build Conformance Tests Kotlin Kotlin Multiplatform JVM License

Kotlin Multiplatform implementation of the Model Context Protocol (MCP), providing both client and server capabilities for integrating with LLM surfaces across various platforms.

Overview

The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This SDK implements the MCP specification for Kotlin, enabling you to build applications that can communicate using MCP on the JVM, WebAssembly and iOS.

  • Build MCP clients that can connect to any MCP server
  • Create MCP servers that expose resources, prompts and tools
  • Use standard transports like stdio, SSE, and WebSocket
  • Handle all MCP protocol messages and lifecycle events

Samples

  • kotlin-mcp-server: demonstrates a multiplatform (JVM, Wasm) MCP server setup with various features and transports.
  • weather-stdio-server: shows how to build a Kotlin MCP server providing weather forecast and alerts using STDIO transport.
  • kotlin-mcp-client: demonstrates building an interactive Kotlin MCP client that connects to an MCP server via STDIO and integrates with Anthropic’s API.

Installation

Add the new repository to your build file:

repositories {
    mavenCentral()
}

Add the dependency:

dependencies {
    // See the badge above for the latest version
    implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
}

MCP SDK uses Ktor, but does not come with a specific engine dependency. You should add Ktor client and/or Ktor server dependency to your project yourself, e.g.:

dependencies {
    // for client:
    implementation("io.ktor:ktor-client-cio:$ktorVersion")
    // for server:
    implementation("io.ktor:ktor-server-netty:$ktorVersion")
    
}

Quick Start

Creating a Client

import io.modelcontextprotocol.kotlin.sdk.client.Client
import io.modelcontextprotocol.kotlin.sdk.client.StdioClientTransport
import io.modelcontextprotocol.kotlin.sdk.Implementation

val client = Client(
    clientInfo = Implementation(
        name = "example-client",
        version = "1.0.0"
    )
)

val transport = StdioClientTransport(
    inputStream = processInputStream,
    outputStream = processOutputStream
)

// Connect to server
client.connect(transport)

// List available resources
val resources = client.listResources()

// Read a specific resource
val resourceContent = client.readResource(
    ReadResourceRequest(uri = "file:///example.txt")
)

Creating a Server

import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
import io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport
import io.modelcontextprotocol.kotlin.sdk.ServerCapabilities

val server = Server(
    serverInfo = Implementation(
        name = "example-server",
        version = "1.0.0"
    ),
    options = ServerOptions(
        capabilities = ServerCapabilities(
            resources = ServerCapabilities.Resources(
                subscribe = true,
                listChanged = true
            )
        )
    )
){ 
    "This server provides example resources and demonstrates MCP capabilities." 
}

// Add a resource
server.addResource(
    uri = "file:///example.txt",
    name = "Example Resource",
    description = "An example text file",
    mimeType = "text/plain"
) { request ->
    ReadResourceResult(
        contents = listOf(
            TextResourceContents(
                text = "This is the content of the example resource.",
                uri = request.uri,
                mimeType = "text/plain"
            )
        )
    )
}

// Start server with stdio transport
val transport = StdioServerTransport()
server.connect(transport)

Using SSE Transport

Directly in Ktor's Application:

import io.ktor.server.application.*
import io.modelcontextprotocol.kotlin.sdk.server.mcp

fun Application.module() {
    mcp {
        Server(
            serverInfo = Implementation(
                name = "example-sse-server",
                version = "1.0.0"
            ),
            options = ServerOptions(
                capabilities = ServerCapabilities(
                    prompts = ServerCapabilities.Prompts(listChanged = null),
                    resources = ServerCapabilities.Resources(subscribe = null, listChanged = null)
                )
            ),
        ) { 
            "This SSE server provides prompts and resources via Server-Sent Events."
        }
    }
}

Inside a custom Ktor's Route:

import io.ktor.server.application.*
import io.ktor.server.sse.SSE
import io.modelcontextprotocol.kotlin.sdk.server.mcp

fun Application.module() {
    install(SSE)

    routing {
        route("myRoute") {
            mcp {
                Server(
                    serverInfo = Implementation(
                        name = "example-sse-server",
                        version = "1.0.0"
                    ),
                    options = ServerOptions(
                        capabilities = ServerCapabilities(
                            prompts = ServerCapabilities.Prompts(listChanged = null),
                            resources = ServerCapabilities.Resources(subscribe = null, listChanged = null)
                        )
                    ),
                ) {
                    "Connect via SSE to interact with this MCP server."
                }
            }
        }
    }
}

Contributing

Please see the contribution guide and the Code of conduct before contributing.

License

This project is licensed under Apache 2.0 for new contributions, with existing code under MIT—see the LICENSE file for details.