Awesome MCPKotlin

ondrsh/mcp4k

⭐ 70 Kotlin added to this list on 2025-05-14 repository created 2024-12-20

mcp4k is a Kotlin Multiplatform framework for the Model Context Protocol that covers both sides of the protocol and implements most of the specification, including resources, prompts, tools and sampling. It ships as a Gradle plugin, sh.ondr.mcp4k, that pulls in a compiler plugin, so JSON-RPC handlers, schema metadata and lifecycle management are generated rather than written by hand. Because the compiler plugin is involved, each release is hard-linked to one exact Kotlin version, and the README carries a compatibility table mapping mcp4k releases from 0.4.2 through 0.4.11 to Kotlin 2.2.0 through 2.4.0. On the server side, a function annotated with @McpTool becomes a tool callable through tools/call under its own name, and its KDoc supplies the descriptions that clients see. Parameter types are checked at compile time, so an incorrectly described parameter fails the build instead of mismatching at run time. Data classes and enums annotated with @JsonSchema and @Serializable are turned into nested JSON Schema objects, so a tool can accept structured arguments such as a list of recipients plus an email object with title, body and a priority enum. Servers are assembled with Server.Builder by registering tools and a transport, and clients with Client.Builder by supplying client info and a transport; capability negotiation and JSON-RPC id handling are done for you. A started client can call initialize, discover available tools with getAllTools, invoke one with callTool and deserialize the typed result, and register a withOnToolsChanged callback to be notified when the server changes its tool list. Both builders accept withTransportLogger lambdas that surface raw incoming and outgoing messages, which is useful in tests and debugging. Transport support is stdio today, with HTTP streaming planned. The project is published on Maven Central under the Apache 2.0 licence.

https://github.com/ondrsh/mcp4k

mcp-frameworkkotlinkotlin-multiplatformcompiler-pluginjson-rpcjson-schemasdk

Also in Kotlin

modelcontextprotocol/kotlin-sdk

The MCP Kotlin SDK is a multiplatform toolkit providing client and server implementations to integrate context-aware large language model interactions using the Model Context Protocol with support for standard transports like stdio, SSE, and WebSocket.