MCP Go SDK
The official Go SDK for building Model Context Protocol servers and clients, maintained in collaboration with Google.
Repository Health
Technical Analysis
MCP Go SDK is the official Go implementation of the Model Context Protocol, the open standard for connecting AI applications to external tools, data sources, and services. It gives Go developers a typed, idiomatic API for constructing both MCP servers (exposing tools, prompts, and resources) and MCP clients (consuming them), without hand-rolling the JSON-RPC message handling and protocol negotiation that MCP requires underneath.
The SDK is organized as a small set of composable packages: mcp for the core client/server APIs, jsonrpc for developers implementing custom transports, and auth/oauthex for OAuth-based authorization flows and protocol extensions. It tracks the evolving MCP specification directly, supporting multiple protocol versions with automatic negotiation, so servers and clients built against different spec revisions can still interoperate.
What You Get
- A
Servertype for registering tools, prompts, resources, and resource templates, then running them over stdio, HTTP, or a custom transport - A
Clienttype for connecting to MCP servers, listing their capabilities, and invoking tools with typed request/response structs - Automatic negotiation across multiple supported MCP protocol versions, so servers and clients on different spec revisions still interoperate
- Generic
mcp.AddToolhelpers that derive JSON Schema from Go struct tags, removing manual schema authoring for tool inputs and outputs - OAuth primitives in the
authpackage plus protocol extensions (like Protected Resource Metadata) inoauthexfor securing MCP servers - A
jsonrpcpackage exposed separately for teams that need to implement their own transport layer - Over twenty runnable examples covering stdio and HTTP servers, SSE, middleware, elicitation, rate limiting, and distributed setups
Common Use Cases
- Building an MCP server in Go that exposes internal tools or APIs to AI assistants like Claude
- Writing an MCP client embedded in a Go application or agent runtime to call out to external MCP servers
- Adding OAuth-protected access to a self-hosted MCP server using the SDK’s
auth/oauthexpackages - Implementing a custom MCP transport (beyond stdio/HTTP) using the standalone
jsonrpcpackage - Migrating a server built on a third-party Go MCP implementation (e.g. mcp-go) onto the official SDK as MCP tooling consolidates
Under The Hood
Architecture
The SDK centers on two core types in the mcp package: Server and Client, both defined in mcp/server.go and driven over an mcp.Transport. A Server holds mutex-guarded featureSet collections for prompts, tools, resources, and resource templates, tracks active ServerSessions, and negotiates a protocol version per session from a descending-ordered list of supported MCP spec revisions — so a server built against a newer spec can still serve older clients. Session state (ServerSessionState in session.go) captures the initialize handshake, negotiated protocol version, and logging level per connection. Transport-level JSON-RPC framing is isolated in internal/jsonrpc2 and re-exposed publicly via the standalone jsonrpc package for SDK consumers who need to implement their own transport. Authorization is a separate concern layered on top: auth provides OAuth client/server primitives and oauthex implements protocol extensions like resource metadata and dynamic client registration, keeping transport, protocol, and auth cleanly separated. What would break if the core abstraction changed: the featureSet generic collection and the per-session protocol-version negotiation are load-bearing for every server example in the repo.
Tech Stack
The SDK targets Go 1.25 and keeps its dependency footprint deliberately small: google/jsonschema-go for deriving and validating JSON Schema from Go struct tags (used by the generic mcp.AddTool helper), golang-jwt/jwt/v5 and golang.org/x/oauth2 for the OAuth/auth packages, segmentio/encoding for faster JSON encoding on the hot path, yosida95/uritemplate/v3 for RFC 6570 URI templates in resource routing, and golang.org/x/time/golang.org/x/tools for rate limiting and tooling support. There is no web framework dependency — HTTP transport support is built directly on the standard library’s net/http, and the examples/http and examples/server trees show it wired into both plain handlers and SSE-based streaming.
Code Quality
Testing is extensive and central to the project: 61 of 146 Go files in the repository are test files, including protocol-conformance tests (conformance_test.go, a dedicated conformance/ directory, and a conformance.yml CI workflow), example-driven doc tests (*_example_test.go files that double as documentation), and copyright-header enforcement (copyright_test.go). CI runs a full test workflow, CodeQL static analysis, an OpenSSF Scorecard check, and a nightly workflow, indicating active investment in supply-chain and code-quality signals beyond unit tests. Error handling favors explicit, typed error returns over panics, consistent with idiomatic Go and the maintainers’ own AGENTS.md/CONTRIBUTING.md guidance for contributors.
What Makes It Unique
This is the officially blessed Go SDK for MCP, developed by the Model Context Protocol maintainers in collaboration with Google, explicitly positioned to supersede a prior generation of community-built Go MCP implementations (the README credits and points to mcp-go, mcp-golang, and go-mcp as prior art). Its mcp.AddTool pattern — deriving JSON Schema directly from Go struct field tags via generics — removes a class of hand-written schema bugs common in earlier community SDKs, and its explicit multi-version protocol negotiation table is unusually rigorous documentation of exactly which MCP spec revisions each SDK version supports, a compatibility concern most client libraries leave implicit.
Used by 12 apps in this directory
agentgateway
AI Development · Developer Tools
An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.
BrowserOS
Browser · AI Assistants
The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.
Bytebase
Devops
An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.
Crush
Developer Tools · AI Code Assistants · AI Assistants
Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.
FerretDB
Databases
An open-source MongoDB alternative that translates wire protocol queries to SQL and stores documents in PostgreSQL
GitLab
Devops · Developer Tools
The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.
hoop
Security · Monitoring
A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.
memos
Note Taking
Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.
Nightingale
Monitoring
Open-source alerting engine that connects to any time-series or log data source and routes alarms to 20+ notification channels with AI-assisted triage.