$git clone https://github.com/modelcontextprotocol/go-sdk# MCP Go SDK
| 1 | <!-- Autogenerated by weave; DO NOT EDIT --> |
| 2 | # MCP Go SDK |
| 3 | |
| 4 | [](https://codespaces.new/modelcontextprotocol/go-sdk) |
| 5 | |
| 6 | [](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk) |
| 7 | [](https://scorecard.dev/viewer/?uri=github.com/modelcontextprotocol/go-sdk) |
| 8 | |
| 9 | This repository contains an implementation of the official Go software |
| 10 | development kit (SDK) for the Model Context Protocol (MCP). |
| 11 | |
| 12 | ## Package / Feature documentation |
| 13 | |
| 14 | The SDK consists of several importable packages: |
| 15 | |
| 16 | - The |
| 17 | [`github.com/modelcontextprotocol/go-sdk/mcp`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp) |
| 18 | package defines the primary APIs for constructing and using MCP clients and |
| 19 | servers. |
| 20 | - The |
| 21 | [`github.com/modelcontextprotocol/go-sdk/jsonrpc`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/jsonrpc) package is for users implementing |
| 22 | their own transports. |
| 23 | - The |
| 24 | [`github.com/modelcontextprotocol/go-sdk/auth`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/auth) |
| 25 | package provides some primitives for supporting OAuth. |
| 26 | - The |
| 27 | [`github.com/modelcontextprotocol/go-sdk/oauthex`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/oauthex) |
| 28 | package provides extensions to the OAuth protocol, such as ProtectedResourceMetadata. |
| 29 | |
| 30 | The SDK endeavors to implement the full MCP spec. The [`docs/`](/docs/) directory |
| 31 | contains feature documentation, mapping the MCP spec to the packages above. |
| 32 | |
| 33 | ## Version Compatibility |
| 34 | |
| 35 | The following table shows which versions of the Go SDK support which versions of the MCP specification: |
| 36 | |
| 37 | | SDK Version | Latest MCP Spec | All Supported MCP Specs | |
| 38 | |-----------------|-------------------|------------------------------------------------------------------| |
| 39 | | v1.7.0+ | 2026-07-28 | 2026-07-28, 2025-11-25\*, 2025-06-18, 2025-03-26, 2024-11-05 | |
| 40 | | v1.4.0 - v1.6.1 | 2025-11-25\* | 2025-11-25\*, 2025-06-18, 2025-03-26, 2024-11-05 | |
| 41 | | v1.2.0 - v1.3.1 | 2025-11-25\*\* | 2025-11-25\*\*, 2025-06-18, 2025-03-26, 2024-11-05 | |
| 42 | | v1.0.0 - v1.1.0 | 2025-06-18 | 2025-06-18, 2025-03-26, 2024-11-05 | |
| 43 | |
| 44 | \* Client side OAuth has experimental support. |
| 45 | |
| 46 | \*\* Partial support for 2025-11-25 (client side OAuth and Sampling with tools not available). |
| 47 | |
| 48 | The roots, sampling, and logging features are deprecated as of protocol version |
| 49 | 2026-07-28 by |
| 50 | [SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging). |
| 51 | The SDK continues to support them for compatibility during the deprecation |
| 52 | window (at least twelve months). See the individual feature documentation for |
| 53 | migration guidance. |
| 54 | |
| 55 | New releases of the SDK target only supported versions of Go. See |
| 56 | https://go.dev/doc/devel/release#policy for more information. |
| 57 | |
| 58 | ## Getting started |
| 59 | |
| 60 | To get started creating an MCP server, create an `mcp.Server` instance, add |
| 61 | features to it, and then run it over an `mcp.Transport`. For example, this |
| 62 | server adds a single simple tool, and then connects it to clients over |
| 63 | stdin/stdout: |
| 64 | |
| 65 | ```go |
| 66 | package main |
| 67 | |
| 68 | import ( |
| 69 | "context" |
| 70 | "log" |
| 71 | |
| 72 | "github.com/modelcontextprotocol/go-sdk/mcp" |
| 73 | ) |
| 74 | |
| 75 | type Input struct { |
| 76 | Name string `json:"name" jsonschema:"the name of the person to greet"` |
| 77 | } |
| 78 | |
| 79 | type Output struct { |
| 80 | Greeting string `json:"greeting" jsonschema:"the greeting to tell to the user"` |
| 81 | } |
| 82 | |
| 83 | func SayHi(ctx context.Context, req *mcp.CallToolRequest, input Input) ( |
| 84 | *mcp.CallToolResult, |
| 85 | Output, |
| 86 | error, |
| 87 | ) { |
| 88 | return nil, Output{Greeting: "Hi " + input.Name}, nil |
| 89 | } |
| 90 | |
| 91 | func main() { |
| 92 | // Create a server with a single tool. |
| 93 | server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v1.0.0"}, nil) |
| 94 | mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say h |