
A starter repo for building a go MCP server
概览
A feature-complete Model Context Protocol (MCP) server template in Go using the official go-sdk. This starter demonstrates all major MCP features with clean, idiomatic Go code. - Model Context Protocol - Go SDK - Building MCP Servers MCP sampling (ask_llm) is deprecated as of protocol version 2026-07-28 (SEP-2577). This workshop keeps the example during the supported deprecation window; new production servers should call LLM provider APIs directly. - Go 1.26.8+ - (Optional) air for live reload - (Optional) golangci-lint for linting Air and goimports are pinned in tools/go.mod, including their transitive dependencies, and updated by Dependabot alongside the server modules. Install them with go -C tools install tool. The HTTP endpoint requires JSON requests and rejects cross-origin browser requests. Native MCP clients without an Origin header and same-origin browser clients remain supported. This project includes VS Code configuration for seamless development: 1.
README
以下为原文 README 节选,完整内容请查看原文。
MCP Go Starter
A feature-complete Model Context Protocol (MCP) server template in Go using the official go-sdk. This starter demonstrates all major MCP features with clean, idiomatic Go code.
📚 Documentation
✨ Features
| Category | Feature | Description |
|---|---|---|
| Tools | hello |
Basic tool with annotations |
get_weather |
Tool returning structured data | |
ask_llm |
Tool that invokes LLM sampling | |
long_task |
Tool with 5-second progress updates | |
load_bonus_tool |
Dynamically loads a new tool | |
| Resources | info://about |
Static informational resource |
file://example.md |
File-based markdown resource | |
| Templates | greeting://{name} |
Personalized greeting |
data://items/{id} |
Data lookup by ID | |
| Prompts | greet |
Greeting in various styles |
code_review |
Code review with focus areas |
MCP sampling (ask_llm) is deprecated as of protocol version 2026-07-28
(SEP-2577).
This workshop keeps the example during the supported deprecation window; new
production servers should call LLM provider APIs directly.
🚀 Quick Start
Prerequisites
- Go 1.26.8+
- (Optional) air for live reload
- (Optional) golangci-lint for linting
Air and goimports are pinned in tools/go.mod, including their transitive
dependencies, and updated by Dependabot alongside the server modules.
Install them with go -C tools install tool.
Installation
# Clone the repository
git clone https://github.com/SamMorrowDrums/mcp-go-starter.git
cd mcp-go-starter
# Download dependencies
go mod download
Running the Server
stdio transport (for local development):
go run ./cmd/stdio
# Or: make run-stdio
HTTP transport (for remote/web deployment):
go run ./cmd/http
# Or: make run-http
# Server runs on http://localhost:3000
安装
npx @modelcontextprotocol/inspector -- go run ./cmd/stdio/main.go