- Explore MCP Servers
- mcp-kotlin-sdk
Mcp Kotlin Sdk
What is Mcp Kotlin Sdk
The mcp-kotlin-sdk is a Kotlin implementation of the Model Context Protocol (MCP), designed to facilitate the integration of applications with large language models (LLMs) by providing a standardized way to manage context.
Use cases
Use cases for the mcp-kotlin-sdk include creating chat applications that leverage LLMs for conversation, developing tools that require context-aware responses, and building servers that expose resources and prompts for LLMs.
How to use
To use the mcp-kotlin-sdk, add the repository to your build file and include the dependency. You can create clients and servers using the SDK, connecting to MCP servers and handling protocol messages seamlessly.
Key features
Key features of the mcp-kotlin-sdk include the ability to build MCP clients and servers, support for standard transport methods like stdio, SSE, and WebSocket, and comprehensive handling of MCP protocol messages and lifecycle events.
Where to use
The mcp-kotlin-sdk can be used in various fields where integration with LLMs is required, such as natural language processing applications, chatbots, and any system that needs to manage context for LLM interactions.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Kotlin Sdk
The mcp-kotlin-sdk is a Kotlin implementation of the Model Context Protocol (MCP), designed to facilitate the integration of applications with large language models (LLMs) by providing a standardized way to manage context.
Use cases
Use cases for the mcp-kotlin-sdk include creating chat applications that leverage LLMs for conversation, developing tools that require context-aware responses, and building servers that expose resources and prompts for LLMs.
How to use
To use the mcp-kotlin-sdk, add the repository to your build file and include the dependency. You can create clients and servers using the SDK, connecting to MCP servers and handling protocol messages seamlessly.
Key features
Key features of the mcp-kotlin-sdk include the ability to build MCP clients and servers, support for standard transport methods like stdio, SSE, and WebSocket, and comprehensive handling of MCP protocol messages and lifecycle events.
Where to use
The mcp-kotlin-sdk can be used in various fields where integration with LLMs is required, such as natural language processing applications, chatbots, and any system that needs to manage context for LLM interactions.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
This repository is moved
The new repo is located here: https://github.com/modelcontextprotocol/kotlin-sdk
MCP Kotlin SDK
Kotlin implementation of the Model Context Protocol (MCP), providing both client and server capabilities for integrating with LLM surfaces.
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 Kotlin SDK implements the full MCP specification, making it easy to:
- 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: shows how to set up Kotlin MCP server with different tools and other features.
Installation
Add the new repository to your build file:
repositories {
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlin-mcp-sdk/sdk")
}
Add the dependency:
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-mcp-sdk:0.1.0")
}
Quick Start
Creating a Client
import org.jetbrains.kotlinx.mcp.client.Client
import org.jetbrains.kotlinx.mcp.client.StdioClientTransport
import org.jetbrains.kotlinx.mcp.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 org.jetbrains.kotlinx.mcp.server.Server
import org.jetbrains.kotlinx.mcp.server.ServerOptions
import org.jetbrains.kotlinx.mcp.server.StdioServerTransport
import org.jetbrains.kotlinx.mcp.ServerCapabilities
val server = Server(
serverInfo = Implementation(
name = "example-server",
version = "1.0.0"
),
options = ServerOptions(
capabilities = ServerCapabilities(
resources = ServerCapabilities.Resources(
subscribe = true,
listChanged = true
)
)
)
)
// 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
import io.ktor.server.application.*
import org.jetbrains.kotlinx.mcp.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)
)
)
)
}
}
Contributing
Please see the contribution guide and the Code of conduct before contributing.
License
This project is licensed under the MIT License—see the LICENSE file for details.
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










