A cookiecutter for bootstrapping MCP servers in Go.
Answer a few questions → get a clean, tested, inspector-ready MCP server in seconds.
- Go 1.25
- Node.js (for inspector checks)
npx
go install github.com/alesr/mcpgen@latest
mcpgenYou’ll get a small interactive flow. Press Enter to accept defaults.
You can also run in non-interactive mode with flags:
mcpgen --helpInspector checks in flag mode run only when stdin is a TTY (matching the existing non-interactive default of skipping inspector checks).
Examples:
mcpgen --name weather --transport stdio
mcpgen --name weather --transport http --no-inspectorcmd/<server>/main.go– entrypointinternal/mcpapp/– server wiring + handlersinternal/mcpapp/tools/handlers/– stub tool handler(s)internal/mcpapp/prompts/– stub promptsinternal/mcpapp/resources/– stub resourcesinternal/mcpapp/stubs/– shared stub responses- unit tests for tools/prompts/resources (only for enabled features)
MCPGEN runs a quick sanity pipeline in this order:
go mod tidygofmt -w .go vet ./...go test ./...
If everything passes, it runs the inspector checks for any enabled features.
Start by editing:
internal/mcpapp/tools/handlers/handlers.gointernal/mcpapp/prompts/prompts.gointernal/mcpapp/resources/resources.go
Replace the stub logic with your real implementation.
- Default transport is stdio (best for local tools).
- You can switch to HTTP in the setup flow if you want a networked server.
- unit tests
- package API
- generate middleware
- generate http wrapper