explaingit

mark3labs/mcp-go

8,695GoAudience · developerComplexity · 3/5Setup · moderate

TLDR

A Go library for building MCP servers, programs that let AI assistants like Claude call custom tools, read data sources, and use prompt templates you define, with a working hello-world example in about 30 lines.

Mindmap

mindmap
  root((repo))
    What it does
      MCP server library
      AI tool integration
    Exposes
      Tools
      Resources
      Prompt templates
    Transport
      Stdio mode
      HTTP SSE mode
    Advanced
      Session management
      Request hooks
      Middleware
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build an MCP server in Go that exposes a database query tool so an AI assistant can look up live information from your database.

USE CASE 2

Create custom action tools that an AI assistant can trigger to interact with your internal systems or external APIs.

USE CASE 3

Expose read-only data resources so an AI client can fetch and use content from your application.

USE CASE 4

Set up reusable prompt templates that structure how an AI handles specific types of requests to your server.

Tech stack

Go

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Go installed. Install with a single go get command. Some advanced features are still under active development.

In plain English

This library provides a way to build MCP servers in Go. MCP, or Model Context Protocol, is a standard that lets AI assistants (like Claude or similar chat tools) connect to external programs and data sources in a structured way. Instead of an AI only knowing what you type to it, MCP lets it call out to tools you define, read data from sources you expose, and use prompt templates you set up. This library is the Go language implementation of that protocol. The core idea is that you write a small Go program that defines what tools and data your server offers. A tool might do something like perform a calculation, query a database, or look something up. The MCP library handles all the protocol-level communication between your program and whatever AI client is connecting to it. You define what the tool does and what inputs it accepts, the library handles the rest. The README opens with a working example that creates a hello-world tool in about 30 lines of code. Servers built with this library can expose three kinds of things: resources (read-only data the AI can load, similar to a web page you fetch), tools (actions the AI can trigger, similar to a form submission), and prompts (reusable templates for structuring AI interactions). The library supports two transport modes for connecting clients to servers: standard input/output for simple integrations, and HTTP with Server-Sent Events for web-based setups. More advanced features documented in the README include session management (so different connected clients can have different tool sets), request hooks (code that runs before or after each request), and middleware for tool handlers. The library targets the MCP specification version 2025-11-25 and is backward compatible with several earlier versions. The project is written in Go and installed with a single go get command. It is under active development, and the README notes that while core features work, some advanced capabilities are still being built. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Using mark3labs/mcp-go, help me create an MCP server in Go that exposes a tool which fetches the current weather for a city name the AI provides.
Prompt 2
I want to build an MCP server that lets Claude query my PostgreSQL database. Show me how to define a query tool with proper input validation using mcp-go.
Prompt 3
Using mcp-go, show me how to set up an HTTP transport with Server-Sent Events so a web-based AI client can connect to my Go MCP server.
Prompt 4
Help me add session management to my mcp-go server so two different connected AI clients each see a different set of available tools.
Open on GitHub → Explain another repo

← mark3labs on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.