/ Directory / Playground / mcp-go (SDK)
● Community mark3labs ⚡ Instant

mcp-go (SDK)

by mark3labs · mark3labs/mcp-go

Go SDK for building MCP servers — minimal boilerplate, type-safe tool definitions, used by half the production-grade Go MCPs in the wild.

mcp-go is the de-facto Go SDK for the Model Context Protocol. It handles transport (stdio + SSE + streamable HTTP), JSON-RPC framing, tool/resource/prompt registration, and request validation so you can focus on the MCP server logic. Used by GitHub's mcp-server, dbhub, k8s-mcp, and many others.

Why use it

Key features

Live Demo

What it looks like in practice

mcp-go-mark3labs.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "mcp-go-mark3labs": {
      "command": "go",
      "args": [
        "install",
        "github.com/mark3labs/mcp-go/cmd/example@latest"
      ],
      "_inferred": true
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "mcp-go-mark3labs": {
      "command": "go",
      "args": [
        "install",
        "github.com/mark3labs/mcp-go/cmd/example@latest"
      ],
      "_inferred": true
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "mcp-go-mark3labs": {
      "command": "go",
      "args": [
        "install",
        "github.com/mark3labs/mcp-go/cmd/example@latest"
      ],
      "_inferred": true
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "mcp-go-mark3labs": {
      "command": "go",
      "args": [
        "install",
        "github.com/mark3labs/mcp-go/cmd/example@latest"
      ],
      "_inferred": true
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "mcp-go-mark3labs",
      "command": "go",
      "args": [
        "install",
        "github.com/mark3labs/mcp-go/cmd/example@latest"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "mcp-go-mark3labs": {
      "command": {
        "path": "go",
        "args": [
          "install",
          "github.com/mark3labs/mcp-go/cmd/example@latest"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add mcp-go-mark3labs -- go install github.com/mark3labs/mcp-go/cmd/example@latest

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use mcp-go (SDK)

Build an internal MCP server for your company API in under 100 LOC

👤 Go devs at companies wanting to expose internal tools to Claude ⏱ ~45 min intermediate

When to use: You have a Go service and want Claude to call it without writing OpenAPI schemas.

Prerequisites
  • Go 1.21+ — Install via brew or asdf
Flow
  1. Scaffold the server
    Create a new Go project. Add mcp-go and define one tool: search_orders(customer_id) that calls our internal /v1/orders API.✓ Copied
    → main.go ~50 lines, builds clean
  2. Test with mcp-inspector
    Run the server in stdio mode. Open mcp-inspector and verify the tool shows up.✓ Copied
    → Tool callable from inspector
  3. Register in Claude
    Add the binary to claude_desktop_config.json. Test from Claude with a real customer ID.✓ Copied
    → Live response from the API

Outcome: Internal Go API exposed to Claude with type-safe MCP tools.

Pitfalls
  • Long-running calls block stdio — Use SSE or streamable HTTP transport for >5s calls
Combine with: mcp-python-sdk

Port an existing REST API to MCP without breaking the REST clients

👤 Backend teams adopting MCP without forcing migration ⏱ ~60 min intermediate

When to use: You want both REST and MCP coexisting on the same handlers.

Flow
  1. Extract handler logic
    Take the existing /api/v1/search handler. Extract the core function so both gin and mcp-go can call it.✓ Copied
    → Handler split — http handler delegates to pure func
  2. Wrap in MCP tool
    Register the pure func as an mcp-go tool. Map URL params to tool inputs.✓ Copied
    → Same logic, two surfaces
  3. Single binary, two transports
    Build one binary that runs gin on :8080 and the MCP server over stdio when invoked with --mcp.✓ Copied
    → Multi-mode binary

Outcome: REST and MCP served from one Go binary with shared core.

Host an MCP server on the public internet with SSE

👤 Devs publishing public MCPs (like git-mcp.io) ⏱ ~90 min advanced

When to use: You want users to add your MCP without installing anything locally.

Prerequisites
  • A domain and TLS — Caddy/nginx with Let's Encrypt
Flow
  1. Switch to SSE transport
    Convert the stdio server to SSE. Add CORS for the relevant origins.✓ Copied
    → Server accepts /sse connections
  2. Add per-user auth
    Validate Bearer token on each connection; reject unknown.✓ Copied
    → 401 on bad tokens, ok on valid
  3. Deploy + test
    Deploy to fly.io. Add the URL to Claude via mcp-remote.✓ Copied
    → Tool callable from Claude pointing at remote URL

Outcome: Public-internet MCP server with auth, ready for users.

Pitfalls
  • SSE behind a load balancer drops long connections — Configure idle timeouts >5min on LB

Combinations

Pair with other MCPs for X10 leverage

mcp-go-mark3labs + mcp-python-sdk

Same project but two SDKs for different surfaces

Use mcp-go for the perf-critical core; mcp-python-sdk for the data-science adjacency.✓ Copied
mcp-go-mark3labs + mcp-registry

Publish your built MCP to the official registry

Once your mcp-go server works, submit it to the modelcontextprotocol/registry.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
AddTool name, description, handler At server startup for each tool 0
AddResource uri, name, handler Expose a readable resource 0
AddPrompt name, description, handler Expose reusable prompts 0
ServeStdio () Local stdio mode (most common) 0
ServeSSE addr, opts Network/remote mode 0

Cost & Limits

What this costs to run

API quota
N/A — library
Tokens per call
N/A
Monetary
Free (MIT)
Tip
Pin to a specific minor version; the API stabilized in 2025 but minor deltas happen

Security

Permissions, secrets, blast radius

Credential storage: Whatever your tool handlers need
Data egress: Controlled by your handlers

Troubleshooting

Common errors and fixes

Tool not visible to Claude

Check capabilities are negotiated; tools must be registered before ServeStdio call

Verify: Use mcp-inspector to confirm tool listing
stdio messages malformed

Don't print to stdout in your handlers — that's the JSON-RPC channel. Use stderr for logs.

SSE drops on idle

Add periodic keepalives; configure proxy timeouts

Alternatives

mcp-go (SDK) vs others

AlternativeWhen to use it insteadTradeoff
mcp-python-sdk (official)You're building in PythonDifferent language; both are first-class
TypeScript SDK (official)Node/Bun ecosystem fitJS-first; less perf headroom than Go

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills