This repository provides code adapted from Kotlin and TypeScript SDKs for the Model Context Protocol (MCP), offering client and server implementations for interacting with tools and handling JSON RPC communication.
This code is adapted from the kotlin-sdk and typescript-sdk. More information is available at https://modelcontextprotocol.io/introduction.
To create an MCP Client, define its capabilities. Then, client.Connect(transport) establishes a connection to the Transport via the Protocol (which the Client extends), initiating the initialize process. After initialization, methods like client.ListTools() and CallTool() can be used.
Creating an MCP Server mirrors the client creation process: define its capabilities and call server.Connect(transport). This starts the server, enabling it to listen for incoming messages through the specified Transport.
The Transport classes and Protocol are independent of MCP and can be used for other JSON-based RPC systems like LSP.
The Transport interface and its client/server implementations (stdio, sse, in_memory) handle the sending and receiving of JSON RPC messages. The Transport interface does not handle message formatting or parsing.
The Protocol class formats and parses JSON into Request/Response/Notification/Error messages, delegating the actual sending and receiving to the Transport.
nalbion/go-mcp
February 8, 2025
March 20, 2025
Go