MCP Go SDK logo

MCP Go SDK

by SetiabudiResearch

This SDK provides a Go implementation of the Model Context Protocol (MCP), enabling bidirectional communication between clients and servers for tool execution, resource access, and prompt handling.

View on GitHub

Last updated: N/A

What is MCP Go SDK?

The MCP Go SDK is a Go library that provides a comprehensive implementation of the Model Context Protocol (MCP). It facilitates bidirectional communication between clients and servers, enabling features like tool execution, resource access, and prompt handling using various transport layers.

How to use MCP Go SDK?

To use the MCP Go SDK, first install it using go get github.com/SetiabudiResearch/mcp-go-sdk. Then, create a server instance, add tools, resources, and prompts, and configure a transport layer (stdio, SSE, or WebSocket). Finally, start the transport to enable communication.

Key features of MCP Go SDK

  • Multiple transport options (stdio, SSE, WebSocket)

  • Bidirectional communication

  • Tool registration and execution

  • Resource pattern matching and access

  • Prompt template rendering

  • Session management

  • Reflection-based handler invocation

  • JSON-RPC message handling

Use cases of MCP Go SDK

  • Building CLI applications that interact with remote services

  • Creating web applications that leverage server-side tools and resources

  • Developing chatbots and conversational AI systems

  • Implementing file servers with secure resource access

  • Integrating with existing systems using a standardized protocol

FAQ from MCP Go SDK

What transport layers are supported?

The SDK supports Stdio, Server-Sent Events (SSE), and WebSocket transport layers.

How do I add a tool to the server?

Use the AddTool or AddAsyncTool methods on the server instance.

Can I access files using resources?

Yes, you can define resources with pattern matching to access files or other data sources.

How do I configure the WebSocket transport?

Use the NewWebSocketTransport function and provide the desired address using the WithAddress option.

Where can I find example applications?

See the examples directory in the repository for complete example applications like a file server, calculator, and chat bot.