Go MCPGEN
You can use this server to generate, extend, and verify Go MCP server projects through MCP tool calls.
mcpgen_new: generate a new Go MCP server project with stdio/HTTP transport, tools, prompts, resources, opt-in features, and optional validation.mcpgen_add: add a tool, prompt, or resource to an existing mcpgen project, with dry-run and force options.mcpgen_check: run the verification pipeline (config, server.json, tidy, fmt, vet, build, race tests, conformance) and return stage-level results.mcpgen_schema: retrieve the machine-readable mcpgen contract, including commands, flags, exit codes, envelope format, andmcpgen.jsonschema.All tools return structured JSON with
ok,error,fix, and exit codes so an AI agent can loopnew → check → fixuntil green.
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.
Full documentation: stdout.alesr.me/mcpgen.
Why mcpgen
Safe regeneration. Every generated file is
mcpgen-owned oruser-owned, tracked with a sha256 in.mcpgen/manifest.json. Regeneration never overwrites your code.Built-in verification.
mcpgen checkruns config validation, tidy, fmt, vet, build,go test -race, and the official MCP conformance suite. Exit 0 means green.Agent-friendly. Every command emits one JSON envelope (
--json) with stable exit codes andfixhints, so agents loopnew → check → fixuntil exit 0. mcpgen can also run as an MCP server, so an AI client can drive it without shell access.
Related MCP server: MCP Tool Factory
Install
Requires Go 1.27+. Node.js/npx are optional (conformance suite only).
go install github.com/alesr/mcpgen@latestRelease binaries for Linux, macOS, and Windows are on the Releases page (tags vX.Y.Z, built by goreleaser).
Quickstart (60 seconds)
# 1. Generate an HTTP MCP server (runs the check pipeline after writing)
mcpgen new ./weather --name weather --module example.com/weather --transport http --json
# 2. Verify until green (exit 0 = every stage passed)
mcpgen check ./weather --json
# 3. Run it (loopback by default) and probe it
cd weather && go run ./cmd/weather &
curl -s http://127.0.0.1:8080/healthz # -> ok
# 4. Extend at any time; your files are never touched
mcpgen add tool tools/health.json --dir ./weather --json
mcpgen check ./weather --jsonReal check output (trimmed):
[passed] config — mcpgen.json valid (version 1, 1 tools, 1 prompts, 1 resources)
[passed] serverjson — server.json valid (MCP Registry descriptor)
[passed] tidy — go mod tidy
[passed] fmt — gofmt clean
[passed] vet — go vet clean
[passed] build — go build ok
[passed] test — go test -race ok
[passed] conformance — conformance passed against http://127.0.0.1:61255/mcp: 8/30 checks passed; ...mcpgen with no arguments runs an interactive flow. mcpgen schema prints the full machine-readable contract (commands, flags, exit codes, envelope, mcpgen.json JSON Schema), the self-discovery entry point for agents. The same walkthrough, step by step: Quickstart.
Use it from an AI agent
mcpgen mcp runs mcpgen itself as a stdio MCP server. An MCP client (Claude Desktop, Cursor, or any MCP host) can then generate, extend, and verify MCP servers for you. Add it to your client:
{ "mcpServers": { "mcpgen": { "command": "mcpgen", "args": ["mcp"] } } }The client gets four tools: mcpgen_new, mcpgen_add, mcpgen_check, mcpgen_schema. They use the same code path as the CLI. The model discovers the contract itself, calls mcpgen_new, implements the stubs, and loops mcpgen_check until green. Tool specs are passed as objects, not files. Writing the handler files needs a filesystem tool or shell on the host. See drive mcpgen from agents.
What you get
A fresh mcpgen new ./weather --name weather --module example.com/weather produces (verified against a real generation):
weather/
├── cmd/weather/main.go entrypoint (stdio, or HTTP server with -addr)
├── internal/mcpapp/
│ ├── mcpapp.go server wiring (stateless HTTP, protocol versions)
│ ├── tools.go / prompts.go / resources.go registration + // mcpgen:begin/end markers
│ ├── tools/handlers/greet.go (+_test.go) user-owned: your implementation
│ ├── prompts/welcome.go (+_test.go) user-owned
│ └── resources/readme.go (+_test.go) user-owned
├── mcpgen.json single source of truth (version 1)
├── .mcpgen/manifest.json owner + sha256 per file
├── server.json, Dockerfile, Makefile, .github/workflows/ci.yml, go.mod (pins go-sdk v1.8.0)Tool handlers are typed (mcp.AddTool[In, Out]): <Tool>Input/<Tool>Output structs are derived from the tool's JSON Schema, and the SDK validates arguments before your handler runs.
Features
Commands:
new,add tool|prompt|resource,check,schema,version,mcp(mcpgen itself as a stdio MCP server), plus an interactive TUI.Transports:
stdio(default) and stateless streamablehttpon/mcpwith/healthz. Loopback bind127.0.0.1:<port>by default; cross-siteOriginrejected (403).Protocol modes:
compat(default, negotiates down to legacy versions) orlatest-only(2026-07-28 only).Opt-in features (
--features tasks,skills,oauth): tasks stub, skills served fromskills/, commented OAuth wiring for 2026-07-28 authorization.Machine interface:
--jsonenvelope (ok,result,error{stage,code,message,fix,command,exit_code},next_actions). Exit codes: 0 ok, 1 failure, 2 usage, 3 exists/not-project, 4 permission, 5 conflict, 6 prerequisite missing.
Status and limitations
The conformance gate runs only the scenarios the official suite can run against a generated server: protocol-level scenarios gate; capability-fixture scenarios (which need well-known test tools) are reported as non-gating. A default server shows
8/30 checks passedwith 22 non-gating fixture failures; that is expected, not a bug.The generated HTTP server has no authentication unless you enable and wire the
oauthfeature. It binds to loopback and rejects cross-site Origins, which is the default protection.mcpgen.jsonsupports config version 1 only.mcpgenv0.3.2; generated servers pingo-sdk v1.8.0(thetidycheck stage enforces the pin).
Documentation
Docs site: quickstart, end-to-end tutorial, concepts (ownership model, marker regions, security), how-to guides, and a generated reference (CLI,
mcpgen.json, exit codes, file tree).AGENTS.md: repo guidance for coding agents.SKILL.md: the agent loop as a skill.Contributing: architecture, local checks (
make check), releases.Development:
make check(tidy, fmt, vet, race tests),make golden,make docs-gen/make docs-buildfor the docs site.
License
MIT. See LICENSE.
Available Tools
4 toolsmcpgen_addAdd a capability to an existing projectB
Add a tool, prompt, or resource to an existing mcpgen-generated project (mcpgen add). spec is the parsed JSON spec object.
Inputs: kind (required), spec (required), dir, force, +1 more. Returns: ok, fix, code, error, +2 more
mcpgen_checkVerify a projectA
Run the mcpgen verification pipeline (mcpgen check). ok=true means green; stages lists every stage status and error.fix carries the first failure file:line.
Inputs: dir, inspector, timeoutSec, conformance. Returns: ok, fix, code, error, +2 more
mcpgen_newGenerate a new MCP server projectB
Generate a new Go MCP server project (mcpgen new). Writes files unless dryRun. Runs the validation pipeline unless noCheck.
Inputs: dir, name, port, force, +10 more. Returns: ok, dir, fix, code, +7 more
mcpgen_schemaMachine-readable spec of mcpgenB
Emit the mcpgen schema document: commands, flags, exit codes, the JSON envelope, and the mcpgen.json JSON Schema (mcpgen schema).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a distinct mcpgen CLI subcommand: new creates a project, add extends one, check verifies it, and schema emits documentation. There is no overlap in purpose or resource, making selection unambiguous.
All tools use a consistent mcpgen_ prefix followed by a short identifier. The pattern is slightly broken by 'schema' being a noun while new/add/check are verbs, but the overall convention is predictable and readable.
Four tools is well-scoped for a CLI wrapper: one per core subcommand. Every tool earns its place without redundancy or missing obvious commands.
The surface covers project creation, extension, validation, and schema introspection, forming a coherent lifecycle. Minor gaps exist: no explicit removal, update, or listing operations, but agents can work around these via filesystem or CLI directly.
Maintenance
Related MCP Connectors
MEOK MCP Test MCP — golden-file + schema-drift + tool-failure tests for any MCP server. Drop-in
The official MCP Server for the Mux API
MCP server for progressive tool usage at any scale (see https://klavis.ai)
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceGo server implementing Model Context Protocol (MCP) for filesystem operations.698MIT
- AlicenseNot gradedqualityDmaintenanceGenerates production-ready MCP servers from natural language, OpenAPI specs, database schemas, GraphQL schemas, or ontologies.49 npm1MIT
- AlicenseAqualityFmaintenanceScaffolds new MCP servers for the OpenSIN-Code ecosystem with templates for Python, Node, Go; provides tools to add tools, test, validate, register, publish, and audit servers.8MIT
- AlicenseNot gradedqualityCmaintenanceA Go MCP server for inspecting and safely operating Audiobookshelf libraries.1MIT