mcpgen
mcpgen is a CLI that generates, extends, and verifies MCP (Model Context Protocol) servers in Go. Generated projects build on the official go-sdk v1.8.0 and target MCP spec 2026-07-28.
Why mcpgen exists
Section titled “Why mcpgen exists”Three properties make it different from hand-written scaffolds:
- Safe regeneration. Every generated file has an owner (
mcpgenoruser). A manifest at.mcpgen/manifest.jsonstores a sha256 per file. Regeneration never overwrites your files and skips mcpgen-owned files you edited. - Built-in verification.
mcpgen checkruns config validation,go mod tidy,gofmt,go vet,go build,go test -race, and the official MCP conformance suite. Exit 0 means green. - AI-native interface. mcpgen is not only a CLI. It is itself an MCP server, so an AI client can generate, extend, and verify MCP servers for you. Both surfaces share one code path and emit one JSON envelope with stable exit codes and
fixhints.
Two ways to drive it
Section titled “Two ways to drive it”From a terminal — every command works manually, with a JSON envelope for scripts and agents:
mcpgen new ./weather --name weather --module example.com/weather --transport http --jsonmcpgen check ./weather --jsonFrom an AI client — Claude Desktop, Cursor, or any MCP host installs mcpgen as a server and lets the model do the work:
{ "mcpServers": { "mcpgen": { "command": "mcpgen", "args": ["mcp"] } } }The model gets four tools: mcpgen_new, mcpgen_add, mcpgen_check, mcpgen_schema. It discovers the contract via mcpgen_schema and loops until mcpgen_check returns green. mcpgen needs no shell access. Writing the handler files still needs a filesystem tool or shell on the host. See drive mcpgen from agents.
Who it is for
Section titled “Who it is for”- Developers who want a production-shaped Go MCP server in seconds, not days.
- AI clients and coding agents that build MCP servers for their users.
- Teams that regenerate servers from a spec (
mcpgen.json) and need their edits to survive.
Install
Section titled “Install”Requires Go 1.26+. Node.js/npx are optional — used only for the conformance suite and the Inspector smoke check.
go install github.com/alesr/mcpgen@latestRelease binaries for Linux, macOS, and Windows are published on the GitHub Releases page (goreleaser, tags vX.Y.Z).
Next steps
Section titled “Next steps”- Quickstart — generate and verify a server in 60 seconds.
- Tutorial — build a weather MCP server end to end.
- Concepts — how the ownership model keeps your code safe.
- Reference — every command, flag, field, and exit code.