+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, diviTop issues
#896feature: built-in per-session RateLimit middleware6 comments · 2026-05-27#1233GetInt / RequireInt return a wrong value for a JSON number outside the int range2 comments · 2026-11-12#1107Bound Streamable HTTP request body reads2 comments · 2026-10-25#980fix: support SEP-2663 Tasks Extension2 comments · 2026-09-13#897Task goroutine context is canceled when HTTP response is flushed (executeRegularToolAsTask)2 comments · 2026-05-28#1245bug: SchemaCache.Save can overwrite a valid cache with malformed JSON1 comments · 2026-11-15#1243bug: closed SSE requests do not return ErrTransportClosed1 comments · 2026-11-13#1240test: cover foreign-Host rejection for SSE streams and session-bearing messages1 comments · 2026-11-13
Discussions
#1105Temporary restriction on external contributions0 comments · 2026-10-19#1022[TDCA Notice] Your project has been selected — thank you for building it0 comments · 2026-09-29#972Respectful notice — a lightweight collaboration possibility under the open-source license0 comments · 2026-09-07#947Agent Only with mcp-go: reusable troubleshooting memory over stdio0 comments · 2026-08-03#899mcp-gateway example with 0.540 comments · 2026-05-30#806How to send ProgressNotification to clients1 comments · 2026-04-17#781mcp-go is listed on Shypd — AI Tool Directory0 comments · 2026-04-02#746The “SendNotificationToSpecificClient” interface quickly sends a disconnect notification to the client0 comments · 2026-03-11
Latest release
Release v1.5.0 v1.5.0 2026-10-30What'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