modelcontextprotocol/kotlin-sdk

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

What it solves

This SDK provides a standardized way for Kotlin applications to provide context to Large Language Models (LLMs). It separates the logic of providing context (data, tools, and prompts) from the actual LLM interaction, allowing developers to build interoperable clients and servers that can exchange information using the Model Context Protocol (MCP).

How it works

The SDK implements the MCP specification, allowing developers to create:

  • MCP Clients: Applications that connect to servers to discover and use available tools, prompts, and resources.
  • MCP Servers: Services that expose specific capabilities to clients, such as executable functions (Tools), data sources (Resources), or interactive templates (Prompts).

It supports multiple transports for communication, including stdio, SSE, Streamable HTTP, and WebSockets. The SDK is built as a Kotlin Multiplatform project, meaning it can target the JVM, Native, JS, and Wasm from a single codebase.

Who it’s for

Kotlin developers who want to integrate LLMs into their applications by building standardized context providers or clients that can interact with any MCP-compliant server.

Highlights

  • Multiplatform Support: Targets JVM, Native, JS, and Wasm.
  • Standardized Primitives: Built-in support for Prompts (templates), Resources (data sources), and Tools (executable functions).
  • Flexible Transports: Supports stdio, SSE, Streamable HTTP, and WebSocket communication.
  • Coroutine-friendly: Uses asynchronous APIs for handling protocol messages and lifecycle events.

Related

  • Project
  • Project
  • Project
  • Project
  • Project