mcp4k
by ondrsh·★ 69·Score 46
Kotlin Multiplatform framework for building MCP clients and servers with compile-time type safety.
Overview
mcp4k is a comprehensive Kotlin framework that implements the vast majority of the MCP specification. It provides a compiler-driven approach that enforces correct parameter typing at compile time rather than runtime. The framework supports both client and server implementations with features for tools, resources, prompts, and sampling. It uses a clean API with annotations like @McpTool and @McpPrompt to define server capabilities. The framework currently supports stdio transport with other transports planned for future releases.
Try asking AI
After installing, here are 5 things you can ask your AI assistant:
When to choose this
Choose mcp4k when building MCP servers/clients in Kotlin Multiplatform projects and you need compile-time type safety and automatic JSON-RPC handling.
When NOT to choose this
Not for projects requiring transports beyond stdio, or when you need to use a language other than Kotlin.
Tools this server exposes
7 tools extracted from the READMEreverseStringinput: StringReverses an input string
sendEmailrecipients: List<String>, email: EmailSends an email with specified recipients and email content
setUserNamename: StringSets the username in the server context
greetUserGreets the user whose name is stored in the server context
toolThatAddsSecondToolA tool that adds another tool to the server at runtime
codeReviewPromptcode: StringGenerates a code review prompt based on the provided code
slowToolOperationiterations: Int = 10Performs a slow operation with specified iterations
Comparable tools
Installation
Installation
Add mcp4k to your build:
plugins {
kotlin("multiplatform") version "2.3.21" // or kotlin("jvm")
kotlin("plugin.serialization") version "2.3.21"
id("sh.ondr.mcp4k") version "0.4.10" // <-- Add this
}Usage in Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mcp4k-example": {
"command": "java",
"args": ["-jar", "path/to/your/mcp4k-server.jar"]
}
}
}FAQ
- What Kotlin versions are compatible with mcp4k?
- Each mcp4k version is hard-linked to a specific Kotlin version. For example, version 0.4.10 requires Kotlin 2.3.21. Check the README for the full compatibility table.
- Does mcp4k support transports other than stdio?
- Currently, mcp4k only supports stdio transport, but HTTP-Streaming and other transports are planned for future releases.
Compare mcp4k with
Last updated · Auto-generated from public README + GitHub signals.