modelcontextprotocol /go-sdk
The official Go SDK for Model Context Protocol servers and clients. Maintained in collaboration with Google.
★ 5,348⑂ 621👁 55⑃ 936● 561▤ 32
More from this author
+2
Daily
5,348
stars
621
forks
55
watchers
936
prs
561
issues
32
releases
README
MCP Go SDK
This repository contains an implementation of the official Go software
development kit (SDK) for the Model Context Protocol (MCP).
Package / Feature documentation
The SDK consists of several importable packages:
- The
github.com/modelcontextprotocol/go-sdk/mcp
package defines the primary APIs for constructing and using MCP clients and
servers.
- The
github.com/modelcontextprotocol/go-sdk/jsonrpc package is for users implementing
their own transports.
- The
github.com/modelcontextprotocol/go-sdk/auth
package provides some primitives for supporting OAuth.
- The
github.com/modelcontextprotocol/go-sdk/oauthex
package provides extensions to the OAuth protocol, such as ProtectedResourceMetadata.
The SDK endeavors to implement the full MCP spec. The docs/ directory
contains feature documentation, mapping the MCP spec to the packages above.
Version Compatibility
The following table shows which versions of the Go SDK support which versions of the MCP specification:
| SDK Version | Latest MCP Spec | All Supported MCP Specs |
|-----------------|-------------------|------------------------------------------------------------------|
| v1.7.0+ | 2026-07-28 | 2026-07-28, 2025-11-25\, 2025-06-18, 2025-03-26, 2024-11-05 |
| v1.4.0 - v1.6.1 | 2025-11-25\ | 2025-11-25\, 2025-06-18, 2025-03-26, 2024-11-05 |
| v1.2.0 - v1.3.1 | 2025-11-25\\ | 2025-11-25\\, 2025-06-18, 2025-03-26, 2024-11-05 |
| v1.0.0 - v1.1.0 | 2025-06-18 | 2025-06-18, 2025-03-26, 2024-11-05 |
\ Client side OAuth has experimental support.
\\ Partial support for 2025-11-25 (client side OAuth and Sampling with tools not available).
The roots, sampling, and logging features are deprecated as of protocol version
2026-07-28 by
SEP-2577.
The SDK continues to support them for compatibility during the deprecation
window (at least twelve months). See the individual feature documentation for
migration guidance.
New releases of the SDK target only supported versions of Go. See
https://go.dev/doc/devel/releasepolicy for more information.
Getting started
To get started creating an MCP server, create an mcp.Server instance, add
features to it, and then run it over an mcp.Transport. For example, this
server adds a single simple tool, and then connects it to clients over
stdin/stdout:
go
package main
import (
"context"
"log"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
type Input struct {
Name string json:"name" jsonschema:"the name of the person to greet"
}
type Output struct {
Greeting string json:"greeting" jsonschema:"the greeting to tell to the user"
}
func SayHi(ctx context.Context, req mcp.CallToolRequest, input Input) (
mcp.CallToolResult,
Output,
error,
) {
return nil, Output{Greeting: "Hi " + input.Name}, nil
}
func main() {
// Create a server with a single tool.
server := mcp.NewServer(&mcp.ImplemeTop issues
#720Add examples to modelcontextprotocol.io14 comments · 2025-12-12#1189streamable client: Connect blocks far past its context deadline against an unresponsive server (detached-context cleanup)13 comments · 2026-08-20#745Expose generic `SendNotification` on `ServerSession` for custom protocol extensions13 comments · 2026-01-06#626SEP-1686 (experimental): Implement Tasks12 comments · 2025-11-07#479Proposal: Export callback to StreamableHTTPHandler for closed transports12 comments · 2025-09-17#579Proposal: Provide better error handling for HTTP errors when using a Streamable Client10 comments · 2025-10-14#1265mcp: a resource update cannot be delivered to one session, and the caller's context never reaches the sending middleware8 comments · 2026-09-13#657Proposal: allow `mcp.streamableClientConn` to listen to SSE stream without using `mcp.Client`8 comments · 2025-11-25
Discussions
#1161Supporting the new stateless map spec 2026-07-280 comments · 2026-08-13#899Might need to migrate from Mkdocs0 comments · 2026-04-16#839Client side oauth token refresh3 comments · 2026-03-11#831DNS rebinding protection1 comments · 2026-03-02#830DNS rebinding protection2 comments · 2026-03-02#727Please test the v1.2.0-pre.1 prerelease!0 comments · 2025-12-16#670Create a MCP Server with Go and OAuth0 comments · 2025-12-01#669when tools/call request is complete, but notifications/progress is still sent, will get a error "rejected by transport"2 comments · 2025-12-01
Latest release
v1.8.0 v1.8.0 2026-09-14_This release is equivalent to v1.8.0-pre.2. Thank you to those who tested the pre-release._ In this release we introduce several fixes and improvements on top of v1.7.0. It adds no new protocol revision: the supported set is unchanged, and 2026-07-28 remains the newest version the SDK negotiates. The bulk of the work is hardening the transports against resource exhaustion, closing session leaks, deadlocks and teardown hangs found by users running the new protocol at scale, and giving servers explicit control over which protocol versions they advertise. Two behavior changes are guarde