MCP Go SDK

The official Go SDK for building Model Context Protocol servers and clients, maintained in collaboration with Google.

SDK
Go
vv1.7.0
5,036stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity96
Maintenance100
Community80
Maturity40
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
87/100Excellent
Architecture88
Code Quality92
Innovation78
Learning Curve90

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 Server type for registering tools, prompts, resources, and resource templates, then running them over stdio, HTTP, or a custom transport
  • A Client type 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.AddTool helpers that derive JSON Schema from Go struct tags, removing manual schema authoring for tool inputs and outputs
  • OAuth primitives in the auth package plus protocol extensions (like Protected Resource Metadata) in oauthex for securing MCP servers
  • A jsonrpc package 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/oauthex packages
  • Implementing a custom MCP transport (beyond stdio/HTTP) using the standalone jsonrpc package
  • 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

Rust
65%
Apache 2.0

agentgateway

AI Development · Developer Tools

4,640

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.

View details
87
Repo Health
82
Technical
71
Dependency
Built with
Rust65%
Go23%
Updated 3 days ago
TypeScript
48%
AGPL 3.0

BrowserOS

Browser · AI Assistants

13,400

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript48%
Rust21%
Python17%
Updated today
Go
52%
MIT

Bytebase

Devops

14,449

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.

View details
91
Repo Health
73
Technical
69
Dependency
Built with
Go52%
TypeScript39%
Updated yesterday
Go
98%
Other

Crush

Developer Tools · AI Code Assistants · AI Assistants

27,798

Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.

View details
87
Repo Health
86
Technical
69
Dependency
Built with
Go98%
Updated today
Go
91%
Apache 2.0

FerretDB

Databases

11,059

An open-source MongoDB alternative that translates wire protocol queries to SQL and stores documents in PostgreSQL

View details
56
Repo Health
86
Technical
72
Dependency
Built with
Go91%
Updated 2 months ago
Ruby
67%
Other

GitLab

Devops · Developer Tools

24,546

The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.

View details
87
Repo Health
86
Technical
69
Dependency
Built with
Ruby67%
JavaScript20%
Updated today
Go
58%
MIT

hoop

Security · Monitoring

805

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
85
Repo Health
80
Technical
65
Dependency
Built with
Go58%
Clojure19%
JavaScript14%
Updated 2 days ago
Go
53%
MIT

memos

Note Taking

62,642

Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.

View details
91
Repo Health
78
Technical
66
Dependency
Built with
Go53%
TypeScript46%
Updated today
Go
98%
Apache 2.0

Nightingale

Monitoring

13,272

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.

View details
96
Repo Health
77
Technical
68
Dependency
Built with
Go98%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search