gitmyhub

go-sdk

Go ★ 4.7k updated 2d ago

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

The Model Context Protocol (MCP) is a standard that lets AI assistants connect to external tools, data sources, and services in a structured way. This repository is the official Go SDK for building that kind of integration using the Go programming language. It is maintained in collaboration with Google.

If you are building a server that an AI assistant can call into, such as a tool that searches a database, reads files, or calls an API, this SDK gives you the building blocks to do that in Go. You define your tools as Go functions, register them with an MCP server, and the SDK handles the communication layer that lets AI clients discover and call those tools.

The same SDK covers the client side too. If you are building something that needs to call out to an MCP server, you can use the client package to connect to one, list what tools are available, and invoke them by name with typed arguments.

The SDK supports all versions of the MCP specification going back to late 2024, with the most recent SDK versions also covering a newer 2025 revision of the spec. OAuth support for authenticated connections is present, with some parts still marked as experimental.

Structurally the code is split into several packages. The main mcp package covers servers and clients. A jsonrpc package handles lower-level transport concerns. Auth and oauthex packages support authenticated connections. The repository also includes an examples directory with working client and server code.

The project acknowledges several earlier community-built Go MCP libraries that were published before this official SDK existed, including mcp-go, mcp-golang, and go-mcp, and notes they remain viable alternatives.