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

★ 5,348⑂ 621👁 55⑃ 936● 561▤ 32
GoNOASSERTIONCreated 2025-04-23modelcontextprotocol.io
下载:v1.8.0v1.8.0 ↓1.8.02026-09-14
+2
日增长
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.Impleme

Top issues

Discussions

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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON