The official Kotlin SDK for Model Context Protocol servers and clients. Maintained in collaboration with JetBrains
# Add to your Claude Code skills
git clone https://github.com/modelcontextprotocol/kotlin-sdkGuides for using mcp servers skills like kotlin-sdk.
kotlin-sdk is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by modelcontextprotocol. The official Kotlin SDK for Model Context Protocol servers and clients. Maintained in collaboration with JetBrains. It has 1,491 GitHub stars.
kotlin-sdk's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/modelcontextprotocol/kotlin-sdk" and add it to your Claude Code skills directory (see the Installation section above).
kotlin-sdk is primarily written in Kotlin. It is open-source under modelcontextprotocol on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh kotlin-sdk against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
Kotlin Multiplatform SDK for the Model Context Protocol. It enables Kotlin applications targeting JVM, Native, JS, and Wasm to implement MCP clients and servers using a standardized protocol interface.
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 Kotlin SDK implements the MCP specification, making it easy to:
io.modelcontextprotocol:kotlin-sdk – umbrella SDK (client + server APIs)io.modelcontextprotocol:kotlin-sdk-client – client-only APIsio.modelcontextprotocol:kotlin-sdk-server – server-only APIsAdd the Maven Central repository and the SDK dependency:
repositories {
mavenCentral()
}
dependencies {
// See the badge above for the latest version
implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
}
Use kotlin-sdk-client or kotlin-sdk-server if you only need one side of the API:
dependencies {
implementation("io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion")
implementation("io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion")
}
In a Kotlin Multiplatform project you can add the SDK to commonMain:
commonMain {
dependencies {
// Works as a common dependency as well as the platform one
implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
}
}
The Kotlin MCP SDK uses Ktor, but it does not add Ktor engine dependencies transitively. You need to declare Ktor client/server dependencies yourself (or reuse the ones already used in your project), for example:
dependencies {
// MCP client with Ktor
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion")
// MCP server with Ktor
implementation("io.ktor:ktor-server-netty:$ktorVersion")
implementation("io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion")
}
Let's create a simple MCP client and server to demonstrate the basic usage of the Kotlin SDK.
Create an MCP client that connects to a server via Streamable HTTP transport and lists available tools:
import io.ktor.client.HttpClient
import io.ktor.client.plugins.sse.SSE
import io.modelcontextprotocol.kotlin.sdk.client.Client
import io.modelcontextprotocol.kotlin.sdk.client.StreamableHttpClientTransport
import io.modelcontextprotocol.kotlin.sdk.types.Implementation
import kotlinx.coroutines.runBlocking
fun main(args: Array<String>) = runBlocking {
val url = args.firstOrNull() ?: "http://localhost:3000/mcp"
val httpClient = HttpClient { install(SSE) }
val client = Client(
clientInfo = Implementation(
name = "example-client",
version = "1.0.0"
)
)
val transport = StreamableHttpClientTransport(
client = httpClient,
url = url
)
// Connect to server
client.connect(transport)
// List available tools
val tools = client.listTools().tools
println(tools)
}
Create an MCP server that exposes a simple tool and runs on an embedded Ktor server with Streamable HTTP transport. For a full working project with all required dependencies, see the simple-streamable-server sample.
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer
import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
import io.modelcontextprotocol.kotlin.sdk.server.mcpStreamableHttp
import io.modelcontextprotocol.kotlin.sdk.types.CallToolResult
import io.modelcontextprotocol.kotlin.sdk.types.Implementation
import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities
import io.modelcontextprotocol.kotlin.sdk.types.TextContent
import io.modelcontextprotocol.kotlin.sdk.types.ToolSchema
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
fun main(args: Array<String>) {
val port = args.firstOrNull()?.toIntOrNull() ?: 3000
val mcpServer = Server(
serverInfo = Implementation(
name = "example-server",
version = "1.0.0"
),
options = ServerOptions(
capabilities = ServerCapabilities(
tools = ServerCapabilities.Tools(listChanged = true),
),
)
)
mcpServer.addTool(
name = "example-tool",
description = "An example tool",
inputSchema = ToolSchema(
properties = buildJsonObject {
put("input", buildJsonObject { put("type", "string") })
}
)
) { request ->
CallToolResult(content = listOf(TextContent("Hello, world!")))
}
embeddedServer(CIO, host = "127.0.0.1", port = port) {
mcpStreamableHttp {
mcpServer
}
}.start(wait = true)
}
You can run the server and then connect to it using the client or test with the MCP Inspector:
npx -y @modelcontextprotocol/inspector
In the inspector UI, connect to http://localhost:3000/mcp.
The MCP protocol defines core primitives that enable communication between servers and clients:
| Primitive | Server Role | Client Role | Description |
|---|---|---|---|
| Prompts | Provides prompt templates with optional arguments | Requests and uses prompts | Interactive templates for LLM interactions |
| Resources | Exposes data sources (files, API responses, etc.) | Reads and subscribes to resources | Contextual data for augmenting LLM context |
| Tools | Defines executable functions | Calls tools to perform actions | Functions the LLM can invoke to take actions |
| Sampling | Requests LLM completions from client | Executes LLM calls and returns results | Server-initiated LLM requests (reverse direction) |
Capabilities define what features a server or client supports. They are declared during initialization and determine what operations are available.
Servers declare their capabilities to inform clients what features they provide:
| Capability | Feature Flags | Description |
|---|---|---|
prompts |
listChanged |
Prompt template management and notifications |
resources |
subscribelistChanged |
Resource exposure, subscriptions, and update notification |