golang -sdk
MCP server from FreePeak/golang-mcp-server-sdk
claude mcp add --transport stdio freepeak-golang-mcp-server-sdk go run ./cmd/server/main.go \ --env GOMOD="module mode if needed" \ --env GO111MODULE="on"
How to use
This MCP server SDK for Go lets you build MCP-compliant servers that expose resources, tools, and prompts to LLMs using the MCP protocol. The repository provides a ready-to-run example and a simple “Echo Server” workflow to illustrate how to define a server, create a tool, attach a handler, and run the server over stdio. Tools are defined with a name, description, and typed parameters; handlers implement the logic and interact with the MCP protocol messages, returning structured responses that the LLM can interpret. You can expose multiple tools and, using the provided transport options (stdio, HTTP with SSE, or multi-protocol), choose how the LLM communicates with your server.
In practice, you create an MCPServer instance, register Tools with handlers, and then start serving. The Quickstart example demonstrates wiring an echo tool that simply returns the input message. This SDK aligns with MCP’s core concepts: Resources (read-only data), Tools (executable functions), and Prompts (reusable templates) to enable rich, context-aware interactions with LLMs.
How to install
Prerequisites:
- Go 1.18+ installed on your system
- A working GOPATH or Go modules enabled workspace
Installation steps:
-
Initialize a Go module (if not already): go mod init github.com/FreePeak/golang-mcp-server-sdk
-
Download or update the SDK package: go get github.com/FreePeak/golang-mcp-server-sdk
-
Build and run the example server (adjust path as needed to your project structure):
From the repository root or your module workspace
go run ./cmd/server/main.go
-
If you prefer to build a binary first: go build -o mcp-server ./cmd/server/main.go ./mcp-server
Note: The README provides a complete Quickstart example showing how to construct an MCPServer, add a tool, and serve over stdio. You can adapt that example to your own tools and resources inside your Go project.
Additional notes
Tips and common considerations:
- Transport options: The SDK demonstrates serving via stdio and SSE/HTTP; choose the transport that best fits your deployment (CLI tools via stdio, or web integrations via HTTP with SSE).
- Tool definitions: Each tool is created with a name, description, and a set of typed parameters. Implement the handler to parse request parameters and return MCP-compliant responses.
- Prompts and resources are supported concepts; while the README shows their usage, ensure you align your implementation with the latest MCP specification for compatibility.
- Environment configuration: Use standard Go environment settings (GOPATH, GO111MODULE). If distributing as a binary, ensure runtime dependencies are bundled or available on the host.
- Debugging: Start with a minimal echo tool to verify transport and protocol handling, then expand to more complex tools.
- MCP protocol updates: The SDK is kept in alignment with the MCP specification; periodically pull updates to stay compatible with new MCP features.
Related MCP Servers
trpc-agent-go
trpc-agent-go is a powerful Go framework for building intelligent agent systems using large language models (LLMs) and tools.
station
Station is our open-source runtime that lets teams deploy agents on their own infrastructure with full control.
tiger-cli
Tiger CLI is the command-line interface for Tiger Cloud. It includes an MCP server for helping coding agents write production-level Postgres code.
gopls
MCP server for golang projects development: Expand AI Code Agent ability boundary to have a semantic understanding and determinisic information for golang projects.
kubernetes
A Model Context Protocol (MCP) server for the Kubernetes API.
gcp-cost
💰 An MCP server that enables AI assistants to estimate Google Cloud costs, powered by Cloud Billing Catalog API and built with Genkit for Go