CLI reference¶
The package installs three commands. The help text on this page is rendered from the commands' argument parsers each time the documentation is built.
generate-mcp¶
Generates a server from a spec. All output goes to the current working directory; see Architecture for the layout.
usage: generate-mcp [-h] [--file FILE] [--url URL] [--enable-storage] [--enable-caching]
[--enable-resources] [--enable-apps] [--generate-ui]
[--schema-depth SCHEMA_DEPTH] [--overlay OVERLAY] [--auto-overlay]
[--enable-a2a] [--fastmcp-target {3,4}]
Generate a FastMCP server from an OpenAPI or Swagger specification.
options:
-h, --help show this help message and exit
--file FILE Path to OpenAPI specification file (default: ./openapi.json)
--url URL URL to download OpenAPI specification from (overrides --file)
--enable-storage Enable persistent storage backend (for OAuth tokens, session
state, user data)
--enable-caching Generate cache.py, a TTL cache decorator for tool functions
(requires --enable-storage)
--enable-resources Generate MCP resource templates from GET endpoints (exposes API
data as resources)
--enable-apps Generate MCP Apps display tools (interactive tables, charts,
forms) and optional GenerativeUI
--generate-ui Generate API-specific display tools from OpenAPI response
schemas (requires --enable-apps)
--schema-depth SCHEMA_DEPTH
Max nesting depth for response schema parsing used by
--generate-ui (default: 3, increase for deeply nested APIs)
--overlay OVERLAY Overlay name or path. Bundled: 'fhir'. Or a path to an Overlay
1.0.0 file
--auto-overlay Auto-generate a rule-based overlay to enhance API descriptions
for AI agents
--enable-a2a Generate A2A (Agent-to-Agent) adapter and AgentCard for multi-
agent orchestration
--fastmcp-target {3,4}
FastMCP major version the generated server targets (default: 4).
Target 4 drops server-side sampling and reports missing
parameters back to the caller instead of eliciting them
Examples:
# Basic generation (minimal server)
generate-mcp
# With custom OpenAPI file
generate-mcp --file ./my-api-spec.yaml
# Download from URL
generate-mcp --url https://petstore3.swagger.io/api/v3/openapi.json
# With optional features
generate-mcp --enable-storage --enable-caching
generate-mcp --enable-resources
generate-mcp --enable-apps
generate-mcp --enable-apps --generate-ui
# Enrich descriptions with an overlay or auto-enhance
generate-mcp --overlay ./my-overlay.yaml
generate-mcp --overlay fhir --schema-depth 5
generate-mcp --auto-overlay
# Generate A2A agent adapter
generate-mcp --enable-a2a
Documentation: https://quotentiroler.github.io/mcp-generator-4.x/
Notes:
--urlsaves the download asopenapi.json, oropenapi.yamlwhen the URL ends in.yamlor.yml, in the current directory.--enable-cachinghas no effect without--enable-storage, and--generate-uihas no effect without--enable-apps. The generator prints a warning and skips them.--overlay fhirapplies the overlay bundled inmcp_generator/overlays/fhir.overlay.yaml.- After a run, the generator prints the optional flags that were not used, with a command to regenerate with them.
The flags are described in Optional features.
register-mcp¶
Keeps a local registry of generated servers for run-mcp. A path given without a subcommand
is treated as add, so register-mcp ./generated_mcp and register-mcp add ./generated_mcp
are equivalent.
usage: register-mcp [-h] {add,remove,list,export} ...
Register local MCP servers for use with run-mcp
positional arguments:
{add,remove,list,export}
Command to execute
add Register a new MCP server
remove Unregister an MCP server
list List all registered MCP servers
export Export server metadata as server.json for MCP Registry
publishing
options:
-h, --help show this help message and exit
usage: register-mcp add [-h] path
positional arguments:
path Path to the MCP server directory
options:
-h, --help show this help message and exit
usage: register-mcp remove [-h] name
positional arguments:
name Name of the server to unregister
options:
-h, --help show this help message and exit
usage: register-mcp list [-h] [--json]
options:
-h, --help show this help message and exit
--json Output registry as JSON (for scripting/automation)
usage: register-mcp export [-h] [-o OUTPUT] name
positional arguments:
name Name of the server to export
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output file path (default: print to stdout)
add reads the server name and entry point from the
[project.entry-points."mcp_servers"] table of the server's pyproject.toml. export writes
a server.json draft for a registered server. Its publisher, source URL, homepage and license
fields are TODO placeholders to fill in before publishing to an MCP registry.
Registry location¶
The first match wins:
MCP_REGISTRY_PATH, a full path to the registry file$XDG_DATA_HOME/mcp-generator/servers.json~/.mcp-generator/servers.json
run-mcp¶
Starts a registered server by name.
usage: run-mcp [-h] [--list] [--mode {stdio,http}] [--host HOST] [--port PORT]
[--validate-tokens]
[server_name]
Run a registered MCP server
positional arguments:
server_name Name of the MCP server to run (use --list to see available
servers)
options:
-h, --help show this help message and exit
--list List all registered MCP servers
--mode {stdio,http}, --transport {stdio,http}
Transport protocol to use (default: stdio)
--host HOST Host to bind to for HTTP transport (default: 0.0.0.0)
--port PORT Port to bind to for HTTP transport (default: 8000)
--validate-tokens Enable JWT token validation for HTTP transport
run-mcp imports the server's entry point and calls it with --transport. In HTTP mode it
also passes --host, --port and, when set, --validate-tokens. Only servers generated from
a spec with security schemes accept --validate-tokens.
Generated server¶
The main module of a generated server has its own command line:
python generated_mcp/<title>_mcp_generated.py [--transport {stdio,http}] [--host HOST] [--port PORT] [--validate-tokens]
| Option | Default | Description |
|---|---|---|
--transport |
stdio |
stdio or http (Streamable HTTP at /mcp) |
--host |
0.0.0.0 |
Bind address for HTTP |
--port |
8000 |
Port for HTTP |
--validate-tokens |
middleware.config.authentication.validate_tokens in fastmcp.json |
Validate JWTs on HTTP requests. Present only when the spec declares security schemes. |
Helper scripts¶
These modules ship with the package and run with python -m:
| Command | Purpose |
|---|---|
python -m mcp_generator.scripts.validate_openapi [--spec PATH] [--strict] |
Checks a JSON spec for problems that affect generation |
python -m mcp_generator.scripts.generate_jwt_keypair |
Writes an RSA key pair and a JWKS file to a keys/ directory inside the installed mcp_generator package, for local JWT testing |