mcp-go
A Go implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.
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:
-
Initialize your module (if you don’t have one yet): go mod init your-module-name
-
Install the MCP Go library (and dependencies) by running go get: go get github.com/mark3labs/mcp-go
-
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
trpc-agent-go
trpc-agent-go is a powerful Go framework for building intelligent agent systems using large language models (LLMs) and tools.
station
Station is our open-source runtime that lets teams deploy agents on their own infrastructure with full control.
tiger-cli
Tiger CLI is the command-line interface for Tiger Cloud. It includes an MCP server for helping coding agents write production-level Postgres code.
gopls
MCP server for golang projects development: Expand AI Code Agent ability boundary to have a semantic understanding and determinisic information for golang projects.
kubernetes
A Model Context Protocol (MCP) server for the Kubernetes API.
gcp-cost
💰 An MCP server that enables AI assistants to estimate Google Cloud costs, powered by Cloud Billing Catalog API and built with Genkit for Go