ondrsh/mcp4k
A compiler-driven Kotlin framework for building both MCP clients and servers, generating JSON-RPC handlers and JSON Schema from annotated functions and data classes at compile time.
The Model Context Protocol (MCP) Kotlin SDK is an official multiplatform software development kit designed to facilitate client and server implementations for integrating context-aware large language model (LLM) interactions. It supports various platforms including JVM, WebAssembly, and iOS, enabling developers to build applications that communicate using the MCP specification. The SDK allows the creation of MCP clients that can connect to any MCP server and MCP servers that expose resources, prompts, and tools. It supports standard transport mechanisms such as stdio, Server-Sent Events (SSE), and WebSocket, handling all MCP protocol messages and lifecycle events seamlessly. The SDK provides comprehensive examples demonstrating its capabilities, including a multiplatform MCP server setup, a weather forecast server using stdio transport, and an interactive MCP client integrating with Anthropic’s API. Installation is straightforward via Maven Central, and the SDK offers easy-to-use APIs for creating clients and servers. For instance, clients can connect to servers, list available resources, and read specific resources, while servers can add resources and start with stdio transport. Additionally, the SDK integrates with Ktor for SSE transport, allowing developers to embed MCP servers within Ktor applications and routes. This SDK is essential for developers looking to implement context-aware LLM interactions in a standardized way, separating context provision from LLM interaction. It supports advanced features like resource subscription and change notifications, making it suitable for dynamic and interactive LLM applications. The project is open-source under the MIT License and encourages community contributions, providing guidelines and a code of conduct for contributors. Overall, the MCP Kotlin SDK is a robust, flexible, and multiplatform toolset that simplifies the development of context-aware LLM applications by adhering to the Model Context Protocol standards and supporting multiple transport protocols and platforms.
https://github.com/modelcontextprotocol/kotlin-sdk
A compiler-driven Kotlin framework for building both MCP clients and servers, generating JSON-RPC handlers and JSON Schema from annotated functions and data classes at compile time.