Get the FREE Ultimate OpenClaw Setup Guide →

mcp-sdk-go

Model Context Protocol(MCP) SDK for Go

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio voocel-mcp-sdk-go docker run -i voocel/mcp-sdk-go:latest \
  --env MCP_PORT="Port for HTTP/Streamable HTTP or SSE transport (default 8080)" \
  --env MCP_LOG_LEVEL="log level (e.g., INFO, DEBUG)"

How to use

The MCP Go SDK provides a Go library to build MCP servers and clients following the MCP specifications. With this SDK you can register tools, define input schemas, and run a server that can communicate over multiple transports such as STDIO, Streamable HTTP, or SSE. The examples show how to create a simple server, register a tool, and run the server using STDIO transport, which is ideal for CLI tools and desktop integrations. You can also expose the server over HTTP for web clients or enable SSE for real-time notifications. The SDK emphasizes multi-session support, concurrency-safe message processing, and built-in security checks. Tools you register can specify input schemas and return results (text, structured content, or other content types) that clients can consume and branch on in subsequent steps.

How to install

Prerequisites:\n- Go 1.18+ installed on your system.\n- Basic Go module knowledge.\n\nInstallation steps:\n1) Create a new Go module for your MCP server project or use an existing one.\n2) Add the MCP Go SDK module as a dependency:\n go get github.com/voocel/mcp-sdk-go@latest\n3) Create your server main file (example below) and run it locally.\n\nExample setup (conceptual):\n1. Initialize server and protocol objects, register tools, and run with a transport (STDIO or HTTP).\n2) Build and run:\n go build -o my-mcp-server .\n ./my-mcp-server\n\nNote: The repository provides examples for using the STDIO and HTTP transports within Go. Adapt the sample code to your server logic and tool definitions.

Additional notes

Tips and common issues:\n- Ensure your Go module uses Go modules (GO111MODULE=on).\n- When using STDIO transport, consider launching from a controlled subprocess or CLI tool to simplify I/O handling.\n- For HTTP transport, you can leverage the Streamable HTTP transport to expose a REST-like interface for tool discovery and invocation.\n- Validate input schemas for tools to prevent invalid requests from propagating into your tool logic.\n- If you enable multi-session support, be mindful of resource limits per session to avoid exhausting system resources.\n- Use the provided tooling patterns (AddTool, Tool structs, and CallToolParams) to ensure compatibility with MCP clients.\n- Monitor MCP protocol version compatibility when upgrading to newer MCP specs.

Related MCP Servers

Sponsor this space

Reach thousands of developers