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.
| Name | Required | Description | Default |
|---|---|---|---|
| dir | No | Project root; default . | |
| kind | Yes | tool, prompt, or resource | |
| spec | Yes | The capability spec object (same shape as the spec file) | |
| force | No | ||
| dryRun | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| fix | No | |
| code | No | |
| error | No | |
| result | No | |
| exit_code | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It says nothing about what files get written or overwritten, what happens when a capability of the same name exists (the force flag hints at overwrite but is never explained), whether dryRun defaults to false, or that this mutates the project on disk.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences, front-loaded with the action and scope, with the spec clarification tacked on usefully. Efficient, though the second sentence's pronoun ('spec') is slightly clipped.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists so return values needn't be described, and required params are named. But for a file-mutating tool with zero annotations, an undocumented force flag, and an unexplained dryRun option, the definition is thinner than the tool's complexity warrants.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Only 'spec' gets meaning beyond the schema ('the parsed JSON spec object', implying the caller must parse the file rather than pass a path), and 'kind' is just restated. With 60% schema coverage, the undocumented 'force' and 'dryRun' flags — both behaviorally significant for a mutating tool — are left entirely unexplained in both schema and description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Names a specific verb and resource ('Add a tool, prompt, or resource') scoped to 'an existing mcpgen-generated project', which implicitly distinguishes it from mcpgen_new (new project) and mcpgen_schema/check. It never names a sibling explicitly, so the differentiation is inferred rather than stated.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'to an existing mcpgen-generated project' implies the prerequisite and hints that project creation belongs to mcpgen_new, but there is no explicit when-to-use/when-not guidance, no mention of what to do if the capability already exists, and no routing to mcpgen_check for validation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| dir | No | Project root; default . | |
| inspector | No | Run the Inspector v2 smoke check | |
| timeoutSec | No | Overall pipeline timeout in seconds; default 600 | |
| conformance | No | Force the conformance stage on/off; default auto |
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| fix | No | |
| code | No | |
| error | No | |
| result | Yes | |
| exit_code | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations supplied, the description carries the burden, and it does disclose the outcome model: ok=true means green, stages enumerates per-stage status, and error.fix gives the first failure at file:line. That is genuinely useful behavioral context. However, it omits side effects (does the pipeline write anything to disk?), expected runtime, and whether it is safe to run repeatedly — important for a tool whose name suggests a full pipeline.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single dense sentence with the outcome semantics front-loaded and no filler. It could be split for readability, but nothing is redundant.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Because an output schema exists and the input schema is fully described, the description only needs to frame intent and outcome, which it does. Minor gaps remain around side effects and interaction between the description and the optional stages (inspector/conformance), but an agent has enough to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so all four parameters (dir, inspector, timeoutSec, conformance) and their defaults are already documented. The description adds no parameter-level meaning beyond the prose, so the baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ("Run the mcpgen verification pipeline") and ties it to the CLI command it wraps (`mcpgen check`), which makes the tool's job immediately identifiable. It doesn't explicitly contrast itself with siblings like `mcpgen_add` or `mcpgen_schema`, but the verify-vs-scaffold distinction is clear from the wording.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is only implied: an agent can infer it should call this to check a project's health, but there is no explicit when-to-use/when-not or reference to the sibling tools. No prerequisites (e.g. project must already be generated) are stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| dir | No | Output directory, e.g. ./weather | |
| name | No | Server name | |
| port | No | HTTP port when transport=http | |
| force | No | Allow generating into an existing non-empty directory | |
| tools | No | Tool spec objects | |
| dryRun | No | Plan only; write nothing | |
| module | No | Go module path, e.g. github.com/acme/weather | |
| noCheck | No | Skip the validation pipeline | |
| prompts | No | Prompt spec objects | |
| version | No | Server version (semver) | |
| features | No | Opt-in features: tasks, skills, oauth | |
| protocol | No | compat or latest-only | |
| resources | No | Resource spec objects | |
| transport | No | stdio or http |
Output Schema
| Name | Required | Description |
|---|---|---|
| ok | Yes | |
| dir | No | |
| fix | No | |
| code | No | |
| plan | No | |
| check | No | |
| error | No | |
| exit_code | No | |
| next_actions | No | |
| files_skipped | No | |
| files_written | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It usefully discloses that the tool writes files unless dryRun and runs a validation pipeline unless noCheck, but it omits that generation into an existing non-empty directory fails without force, does not say whether existing files can be overwritten, and gives no sense of reversibility or failure behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences, front-loaded with the core action, and no wasted wording. The dryRun and noCheck behavior is stated compactly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
This is a complex 14-parameter generator that writes files and runs validation, yet the description explains only two boolean side effects. The output schema covers return values, but the description does not prepare an agent for directory conflicts, force semantics, transport/module choices, or the relationship between tools, prompts, and resources.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds a little meaning for dryRun and noCheck by explaining their effect, but says nothing about the other 12 parameters, including force, dir, transport, or feature selection.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: generate a new Go MCP server project, with the CLI equivalent `mcpgen new`. It distinguishes itself reasonably from `mcpgen_add`, `mcpgen_check`, and `mcpgen_schema` by the word 'new', though it never explicitly contrasts them.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The only usage guidance is behavioral: writes files unless dryRun and runs validation unless noCheck. There is no guidance on when to use this tool instead of `mcpgen_add` or `mcpgen_check`, no prerequisite for existing directories, and no mention that `force` is needed for non-empty output.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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).
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are supplied, so the description carries the full burden. It usefully discloses what the returned payload contains (commands, flags, exit codes, JSON envelope, JSON Schema), which is effectively a return-value summary, but leaves the verb 'Emit' ambiguous: it does not say whether output goes to stdout or is written to a file, nor whether the call has side effects or is purely read-only.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with a compact colon-delimited list of contents; nearly every clause adds information. The trailing parenthetical '(mcpgen schema)' restates the tool name and is mildly redundant.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no parameters and no output schema, the description does the right thing by enumerating the returned document's sections, but it stops short of describing the transport/format of the emitted output or its size, which is the main thing an agent still needs to know before calling.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, so the baseline is 4; there is nothing for the description to disambiguate. It correctly implies the call is parameterless by describing a fixed document rather than configurable output.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Uses a specific verb ('Emit') with a concrete resource ('the mcpgen schema document') and enumerates its contents: commands, flags, exit codes, the JSON envelope, and the mcpgen.json JSON Schema. This clearly separates it from the sibling mutation/validation tools (mcpgen_add, mcpgen_check, mcpgen_new), though it never names them explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no when-to-use guidance, no statement of prerequisites, and no reference to alternatives such as mcpgen_check. The agent must infer from the purpose alone that this is the self-description/discovery call rather than a validation or scaffolding call.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.1.1- Changed
mcpgen_new15 fields changed- added
Input schema / properties / prompts / items / additionalPropertiesAdded value: +false - removed
Input schema / properties / prompts / items / itemsRemoved value: -{ - "maximum": 255, - "minimum": 0, - "type": "integer" -} - added
Input schema / properties / prompts / items / propertiesAdded value: +{ + "arguments": { + "description": "Prompt arguments", + "items": { + "additionalProperties": false, + "properties": { + "description": { + "description": "Argument description", + "type": "string" + }, + "name": { + "description": "Argument name", + "type": "string" + }, + "required": { + "description": "Whether the argument is required", + "type": "boolean" + }, + "title": { + "description": "Argument title", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": [ + "null", + "array" + ] + }, + "description": { + "description": "Prompt description", + "type": "string" + }, + "id": { + "description": "Prompt id (unique, [a-zA-Z0-9_-]+)", + "type": "string" + }, + "title": { + "description": "Prompt title", + "type": "string" + } +} - added
Input schema / properties / prompts / items / requiredAdded value: +[ + "id" +] - changed
Input schema / properties / prompts / items / typePrevious value: -[ - "null", - "array" -]New value: +"object" - added
Input schema / properties / resources / items / additionalPropertiesAdded value: +false - removed
Input schema / properties / resources / items / itemsRemoved value: -{ - "maximum": 255, - "minimum": 0, - "type": "integer" -} - added
Input schema / properties / resources / items / propertiesAdded value: +{ + "description": { + "description": "Resource description", + "type": "string" + }, + "id": { + "description": "Resource id (unique, [a-zA-Z0-9_-]+)", + "type": "string" + }, + "mimeType": { + "description": "Resource MIME type", + "type": "string" + }, + "text": { + "description": "Stub content served by the generated handler", + "type": "string" + }, + "title": { + "description": "Resource title", + "type": "string" + }, + "uri": { + "description": "Absolute URI. Exactly one of uri/uriTemplate", + "type": "string" + }, + "uriTemplate": { + "description": "RFC 6570 URI template. Exactly one of uri/uriTemplate", + "type": "string" + } +} - added
Input schema / properties / resources / items / requiredAdded value: +[ + "id" +] - changed
Input schema / properties / resources / items / typePrevious value: -[ - "null", - "array" -]New value: +"object" - added
Input schema / properties / tools / items / additionalPropertiesAdded value: +false - removed
Input schema / properties / tools / items / itemsRemoved value: -{ - "maximum": 255, - "minimum": 0, - "type": "integer" -} - added
Input schema / properties / tools / items / propertiesAdded value: +{ + "description": { + "description": "Tool description", + "type": "string" + }, + "id": { + "description": "Tool id (unique, [a-zA-Z0-9_-]+)", + "type": "string" + }, + "idempotent": { + "description": "Maps to the tool idempotentHint annotation", + "type": "boolean" + }, + "inputSchema": { + "additionalProperties": true, + "description": "JSON Schema object for tool input", + "type": "object" + }, + "outputSchema": { + "additionalProperties": true, + "description": "JSON Schema object for tool output", + "type": "object" + }, + "readOnly": { + "description": "Maps to the tool readOnlyHint annotation", + "type": "boolean" + }, + "title": { + "description": "Tool title", + "type": "string" + } +} - added
Input schema / properties / tools / items / requiredAdded value: +[ + "id" +] - changed
Input schema / properties / tools / items / typePrevious value: -[ - "null", - "array" -]New value: +"object"
4 tool updates
v0.1.0- First observed
mcpgen_add - First observed
mcpgen_check - First observed
mcpgen_new - First observed
mcpgen_schema
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.695MIT
- AlicenseNot gradedqualityCmaintenanceGenerates production-ready MCP servers from natural language, OpenAPI specs, database schemas, GraphQL schemas, or ontologies.58 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