$git clone https://github.com/modelcontextprotocol/kotlin-sdkKotlin 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.
| 1 | # MCP Kotlin SDK |
| 2 | |
| 3 | [](https://central.sonatype.com/artifact/io.modelcontextprotocol/kotlin-sdk) |
| 4 | [](https://github.com/modelcontextprotocol/kotlin-sdk/actions/workflows/build.yml) |
| 5 | |
| 6 | [](http://kotlinlang.org) |
| 7 | [](https://kotlinlang.org/docs/multiplatform.html) |
| 8 | [](http://java.com) |
| 9 | [](LICENSE) |
| 10 | |
| 11 | |
| 12 | Kotlin Multiplatform SDK for the [Model Context Protocol](https://modelcontextprotocol.io). |
| 13 | It enables Kotlin applications targeting JVM, Native, JS, and Wasm to implement MCP clients and servers using a |
| 14 | standardized protocol interface. |
| 15 | |
| 16 | ## Table of Contents |
| 17 | |
| 18 | <!--- TOC --> |
| 19 | |
| 20 | * [Overview](#overview) |
| 21 | * [Installation](#installation) |
| 22 | * [Artifacts](#artifacts) |
| 23 | * [Gradle setup (JVM)](#gradle-setup-jvm) |
| 24 | * [Multiplatform](#multiplatform) |
| 25 | * [Ktor dependencies](#ktor-dependencies) |
| 26 | * [Quickstart](#quickstart) |
| 27 | * [Creating a Client](#creating-a-client) |
| 28 | * [Creating a Server](#creating-a-server) |
| 29 | * [Core Concepts](#core-concepts) |
| 30 | * [MCP Primitives](#mcp-primitives) |
| 31 | * [Capabilities](#capabilities) |
| 32 | * [Server Capabilities](#server-capabilities) |
| 33 | * [Client Capabilities](#client-capabilities) |
| 34 | * [Server Features](#server-features) |
| 35 | * [Prompts](#prompts) |
| 36 | * [Resources](#resources) |
| 37 | * [Tools](#tools) |
| 38 | * [Completion](#completion) |
| 39 | * [Logging](#logging) |
| 40 | * [Pagination](#pagination) |
| 41 | * [Client Features](#client-features) |
| 42 | * [Roots](#roots) |
| 43 | * [Sampling](#sampling) |
| 44 | * [Transports](#transports) |
| 45 | * [STDIO Transport](#stdio-transport) |
| 46 | * [Streamable HTTP Transport](#streamable-http-transport) |
| 47 | * [SSE Transport](#sse-transport) |
| 48 | * [WebSocket Transport](#websocket-transport) |
| 49 | * [ChannelTransport (testing)](#channeltransport-testing) |
| 50 | * [Connecting your server](#connecting-your-server) |
| 51 | * [Examples](#examples) |
| 52 | * [Documentation](#documentation) |
| 53 | * [Contributing](#contributing) |
| 54 | * [License](#license) |
| 55 | |
| 56 | <!--- END --> |
| 57 | |
| 58 | ## Overview |
| 59 | |
| 60 | The Model Context Protocol allows applications to provide context for LLMs in a standardized way, |
| 61 | separating the concerns of providing context from the actual LLM interaction. |
| 62 | This Kotlin SDK implements the MCP specification, making it easy to: |
| 63 | |
| 64 | - Build MCP **clients** that can connect to any MCP server |
| 65 | - Create MCP **servers** that expose resources, prompts, and tools |
| 66 | - Target **JVM, Native, JS, and Wasm** from a single codebase |
| 67 | - Use standard transports like **stdio**, **SSE**, **Streamable HTTP**, and **WebSocket** |
| 68 | - Handle MCP protocol messages and lifecycle events with coroutine-friendly APIs |
| 69 | |
| 70 | ## Installation |
| 71 | |
| 72 | ### Artifacts |
| 73 | |
| 74 | - `io.modelcontextprotocol:kotlin-sdk` – umbrella SDK (client + server APIs) |
| 75 | - `io.modelcontextprotocol:kotlin-sdk-client` – client-only APIs |
| 76 | - `io.modelcontextprotocol:kotlin-sdk-server` – server-only APIs |
| 77 | |
| 78 | ### Gradle setup (JVM) |
| 79 | |
| 80 | Add the Maven Central repository and the SDK dependency: |
| 81 | |
| 82 | ```kotlin |
| 83 | repositories { |
| 84 | mavenCentral() |
| 85 | } |
| 86 | |
| 87 | dependencies { |
| 88 | // See the badge above for the latest version |
| 89 | implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion") |
| 90 | } |
| 91 | ``` |
| 92 | |
| 93 | Use _kotlin-sdk-client_ or _kotlin-sdk-server_ if you only need one side of the API: |
| 94 | |
| 95 | ```kotlin |
| 96 | dependencies { |
| 97 | implementation("io.modelcontextprotocol:kotlin-sdk-client:$mcpVersion") |
| 98 | implementation("io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion") |
| 99 | } |
| 100 | ``` |
| 101 | |
| 102 | ### Multiplatform |
| 103 | |
| 104 | In a Kotlin Multiplatform project you can add the SDK to commonMain: |
| 105 | |
| 106 | ```kotlin |
| 107 | commonMain { |
| 108 | dependencies { |
| 109 | // Works as a common dependency as well as the platfor |