Get the FREE Ultimate OpenClaw Setup Guide →

mcp-go

A Go implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mark3labs-mcp-go go run ./... \
  --env GOMOD="auto" \
  --env GOWORK="auto"

How to use

MCP Go is a Go implementation of the Model Context Protocol (MCP). It provides a high-level, type-safe API to expose Tools, Resources, and Prompts that an LLM can interact with. The example in the README shows how to instantiate an MCP server, define a Tool (including its arguments and descriptions), attach a handler that processes a CallToolRequest, and then serve the server over stdio. This enables you to rapidly build modular capabilities (like a calculator or data fetcher) that your LLM can invoke securely and consistently. The library focuses on reducing boilerplate while giving you full control over how requests are validated and how results are returned to the LLM, including helper methods for typed argument access and error handling.

How to install

Prerequisites:

  • Go installed (1.18+ recommended).
  • A working Go module and network access to fetch dependencies.

Install steps:

  1. Initialize your module (if you don’t have one yet): go mod init your-module-name

  2. Install the MCP Go library (and dependencies) by running go get: go get github.com/mark3labs/mcp-go

  3. Create your MCP server code (as shown in the README examples) and build/run it: go build ./... ./your-binary

Notes:

  • The repository provides examples for creating a basic server, adding tools, and starting the server over stdio. You can adapt those patterns to your own tools and resources.
  • If you want to run the server as part of a larger application, you can integrate the MCP server initialization in your main package and start it in-process.

Additional notes

Tips and common considerations:

  • The MCP Go implementation emphasizes a high-level API for Tool definitions and request handling. Use the provided helper methods (e.g., RequireString, RequireNumber) to validate and extract arguments safely.
  • When exposing resources, consider static vs. dynamic resources and MIME types appropriate to your data (e.g., application/json for JSON data, text/plain for plain text).
  • The README notes that MCP Go is under active development; for production use, pin to a specific version and monitor the repository for changes that may affect compatibility.
  • If you need to run the server in different environments, you can adapt the mcp_config to point to a binary or script that starts the MCP server logic in a separate process, or keep it in-process as shown in the examples.

Related MCP Servers

Sponsor this space

Reach thousands of developers