Get the FREE Ultimate OpenClaw Setup Guide →

kotlin-sdk

The official Kotlin SDK for Model Context Protocol servers and clients. Maintained in collaboration with JetBrains

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio modelcontextprotocol-kotlin-sdk docker run -i modelcontextprotocol/kotlin-sdk-server:latest \
  --env JAVA_OPTS="Optional Java runtime options (e.g., -Xmx2g)." \
  --env MCP_LOG_LEVEL="Logging level (e.g., INFO, DEBUG)." \
  --env MCP_SERVER_PORT="Port to expose MCP API (default 3000)."

How to use

The MCP Kotlin SDK provides tooling to build both MCP clients and MCP servers in Kotlin, with multiplatform support targeting JVM, Native, JS, and Wasm. This server-focused SDK exposes resources, prompts, and tools via standard MCP transports such as stdio, SSE, and Streamable HTTP, allowing you to implement MCP servers that can be consumed by any MCP client. With the Kotlin MCP server APIs, you can register tools, define input/output schemas, and handle tool invocations in a coroutine-friendly manner. This enables you to publish a server that describes its capabilities, lists available tools, and processes client requests in a scalable, multiplatform way.

How to install

Prerequisites:

  • Java 11+ and a working Java toolchain
  • Kotlin/Gradle project setup or your favorite Kotlin build system

Installation steps:

  1. Ensure you have Gradle installed or use the Gradle wrapper in your project.
  2. Add the Kotlin MCP server dependency to your build file (examples shown for Gradle):

For a full JVM project with both client and server APIs:

repositories {
    mavenCentral()
}

dependencies {
    implementation("io.modelcontextprotocol:kotlin-sdk:$mcpVersion")
}

If you only need the server APIs:

dependencies {
    implementation("io.modelcontextprotocol:kotlin-sdk-server:$mcpVersion")
}
  1. Build the project:
./gradlew build
  1. Run a sample server (example snippet provided in the repository):
# If using a runnable example, you might do something like:
java -jar build/libs/kotlin-sdk-server-example.jar

Note: The Kotlin MCP SDK is designed for multiplatform usage; ensure your Gradle setup includes the necessary Kotlin Multiplatform plugin if targeting JVM plus other platforms.

Additional notes

Tips and caveats:

  • The server APIs expect coroutine-friendly handling of requests; leverage Kotlin coroutines for non-blocking processing.
  • When publishing a server, declare its capabilities clearly (tools, prompts, resources, etc.) so clients can discover and use them efficiently.
  • If using transports, ensure the correct dependencies for the chosen transport (e.g., SSE or HTTP) are included in your project.
  • For debugging, enable verbose logging (MCP_LOG_LEVEL) and verify that the MCP server port (MCP_SERVER_PORT) is accessible from clients.
  • This repository focuses on the Kotlin server APIs; for client usage, refer to the client module and its transport implementations.
  • If you are packaging as a Docker image, define appropriate environment variables for port and log settings to simplify deployment.

Related MCP Servers

Sponsor this space

Reach thousands of developers