mark3labs /mcp-go

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

★ 9,239⑂ 949👁 50⑃ 757● 401▤ 96
GoMITCreated 2024-11-27mcp-go.dev/
Download: Release v1.5.0Release-1.5.0 ↓1.5.02026-10-30
+2
Daily
9,239
stars
949
forks
50
watchers
757
prs
401
issues
96
releases

README

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







Discuss the SDK on Discord




go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/mark3labs/mcp-go/mcp"
    "github.com/mark3labs/mcp-go/server"
)

func main() {
    // Create a new MCP server
    s := server.NewMCPServer(
        "Demo 🚀",
        "1.0.0",
        server.WithToolCapabilities(false),
    )

    // Add tool
    tool := mcp.NewTool("hello_world",
        mcp.WithDescription("Say hello to someone"),
        mcp.WithString("name",
            mcp.Required(),
            mcp.Description("Name of the person to greet"),
        ),
    )

    // Add tool handler
    s.AddTool(tool, helloHandler)

    // Start the stdio server
    if err := server.ServeStdio(s); err != nil {
        fmt.Fprintf(os.Stderr, "Server error: %v\n", err)
    }
}

func helloHandler(ctx context.Context, request mcp.CallToolRequest) (mcp.CallToolResult, error) {
    name, err := request.RequireString("name")
    if err != nil {
        return mcp.NewToolResultError(err.Error()), nil
    }

    return mcp.NewToolResultText(fmt.Sprintf("Hello, %s!", name)), nil
}


That's it!

MCP Go handles all the complex protocol details and server management, so you can focus on building great tools. It aims to be high-level and easy to use.

 Key features:
 Fast: High-level interface means less code and faster development
 Simple: Build MCP servers with minimal boilerplate
 Complete: MCP Go aims to provide a full implementation of the core MCP specification

(\emphasis on aims)

🚨 🚧 🏗️ MCP Go is under active development, as is the MCP specification itself. Core features are working but some advanced capabilities are still in progress. 



 Table of Contents

- Installation
- Quickstart
- What is MCP?
- Core Concepts
  - Server
  - Resources
  - Tools
  - Prompts
- Examples
- Extras
  - Transports
  - OAuth Protected Resource Metadata
  - Session Management
    - Basic Session Handling
    - Per-Session Tools
    - Tool Filtering
    - Working with Context
  - Request Hooks
  - Tool Handler Middleware
  - Regenerating Server Code

 Installation

bash
go get github.com/mark3labs/mcp-go


 Quickstart

Let's create a simple MCP server that exposes a calculator tool and some data:

go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/mark3labs/mcp-go/mcp"
    "github.com/mark3labs/mcp-go/server"
)

func main() {
    // Create a new MCP server
    s := server.NewMCPServer(
        "Calculator Demo",
        "1.0.0",
        server.WithToolCapabilities(false),
        server.WithRecovery(),
    )

    // Add a calculator tool
    calculatorTool := mcp.NewTool("calculate",
        mcp.WithDescription("Perform basic arithmetic operations"),
        mcp.WithString("operation",
            mcp.Required(),
            mcp.Description("The operation to perform (add, subtract, multiply, divi

Top issues

Discussions

Latest release

Release v1.5.0 v1.5.0 2026-10-30
What's Changed
 fix(server): send a request's notifications on its POST stream by @QuentinBisson in https://github.com/mark3labs/mcp-go/pull/1117
 fix(server): bound the request body read by the SSE message endpoint by @QuentinBisson in https://github.com/mark3labs/mcp-go/pull/1119
 fix(client): bound the messages the HTTP transports read from the server by @QuentinBisson in https://github.com/mark3labs/mcp-go/pull/1121
 fix(oauth): accept case variants of localhost redirect hosts by @ezynda3 in https://github.com/mark3labs/mcp-go/pull/1125
 fix(stdio): cancel tool calls still waiting for

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON