Mcp-Go
by mark3labs
A Go implementation of the Model Context Protocol for building your own MCP servers and clients in Go, with resources, tools, prompts, and stdio/SSE/HTTP transports out of the box.
Add to your Go project
go get github.com/mark3labs/mcp-go
About
mcp-go isn't a server you run. It's the library Go developers use to build one. It implements the three core MCP primitives (resources for exposing data, tools for actions with side effects, and prompts for reusable interaction templates) plus the transport layer, so you write a handler function and the library takes care of the protocol plumbing: session lifecycle, request/response framing, and serving over stdio, SSE, or streamable HTTP.
It also covers the parts of MCP that go beyond a basic tool call: task-augmented tools for operations that run longer than a single request/response cycle, per-client session state, and middleware you can hook into the request pipeline for things like auth or logging. Because it's a small, dependency-light Go module rather than a framework with its own opinions about your app structure, it drops into an existing Go service as easily as a fresh one.
Key features
- Implements MCP resources, tools, and prompts as first-class Go APIs
- Multiple transports built in: stdio, SSE, and streamable HTTP
- Session management for maintaining per-client state across requests
- Middleware support for cross-cutting concerns like auth and logging
- Task-augmented tools for operations that outlive a single request
- Small, dependency-light module that fits into an existing Go codebase
Use cases
- Wrapping an internal Go service's API as an MCP tool server for use with Claude or Cursor
- Exposing a database query layer as MCP resources without hand-rolling the protocol
- Building a long-running MCP tool (e.g. a batch job or crawl) using task-augmented tools
- Adding an MCP-compatible interface to an existing Go microservice with minimal new code
Available tools
server.NewMCPServer
Creates a new MCP server instance with a name and version.
mcp.NewTool
Defines a tool's name, description, and parameter schema.
server.AddTool
Registers a tool and its handler function on the server.
server.ServeStdio
Serves the MCP server over standard input/output.
server.NewSSEServer
Serves the MCP server over Server-Sent Events for remote clients.
mcp.NewToolResultText
Wraps a plain-text response for return from a tool handler.
Frequently asked questions
Is mcp-go a server I can run directly, or a library?
It's a library. You import it into your own Go program and define tools/resources; running the resulting binary is what produces an MCP server.
Which transports does it support?
stdio for local process-based clients, plus SSE and streamable HTTP for serving remote clients over the network.