Usage¶
mcp4api SPEC reads an OpenAPI document and writes the artifacts under --out.
Commands¶
mcp4api SPEC
mcp4api ingest SPEC
mcp4api curate
mcp4api emit
mcp4api verify
mcp4api record --sandbox URL
SPEC is a file path or URL. The primary command runs ingest, curate, emit, and verify. Each stage command reads the previous artifact from --out, so a run can resume.
mcp4api SPECreads the OpenAPI document and writes every stage artifact.mcp4api ingest SPECwritesendpoints.json.mcp4api curatereadsendpoints.jsonand writestools.yaml.mcp4api emitreadstools.yamlandendpoints.jsonand writesgenerated/.mcp4api verifyreadsgenerated/,tools.yaml, andendpoints.json, and writestests/andreport/.mcp4api recordreads those same inputs plus a sandbox URL and writestests/cassettes/.
Paths other than SPEC are relative to --out. Flags may appear before or after the command. A flag that the command does not accept is a parse error.
Flags¶
--out DIRis the artifact root. It defaults to the current directory.--jsonprints application errors as one JSON object on stdout.--versionprintsmcp4api <version>and exits 0.--quietlogs errors only.--verboselogs debug messages. Using both is a usage error.--offlinereads local files only. A URL, or a$refthat needs the network, is a usage error.--allow-ref-host HOSTallows a remote$reffromHOST. Repeat it for more than one host.--model IDselects the Claude model. The default isclaude-opus-5-5.--budget-tokens Nand--budget-usd Ncap agent curation. The defaults are 200000 tokens and 5 USD.--curation MODEisagent,heuristic, ormanual. The default isagent.--max-tools Nis the tool-count target. The default is 20. Exceeding it requires a rationale.--namespace NAMEprefixes each tool name.--include-tag TAGkeeps a tag or a category. Repeat it to include more than one.--dry-runprints a token and cost estimate and does not writetools.yaml.--recuratecurates again even when the input hash matches.--forceoverwrites generated files that were edited after the last emit.--deterministicomitsstarted_atand durations from the verification report.--livecalls the spec server. A host outside the sandbox set needs--allow-host.--sandbox URLcalls that URL instead of the fixture server.--allow-host HOSTis a host the verification proxy may dial. Repeat it for more than one host.--allow-writescalls destructive and non-idempotent tools during--live.--isolatereruns verification inside a Linux network namespace.--htmlalso writesreport/verification.html.--on-failure MODEisexcludeorkeep.excludeis the default and drops a failed tool fromgenerated/.keepleaves it and prefixes its description with a warning.
--json applies to errors raised by mcp4api. The parser's own usage errors stay as text and still exit 2.
Remote $refs are followed only for the input URL's host, plus each --allow-ref-host. A file input has no host, so every remote $ref needs the flag.
Exit codes¶
- 0 means every generated tool verified.
- 1 is an internal error.
- 2 is a usage or configuration error, including a missing input. The message names the path.
- 3 means at least one tool is a known gap.
--jsonprints the same error object with"exit_code": 3. - 4 is an ingest, network, model, or upstream API failure.
--offline with record, --sandbox, or --live exits 2 before any connection. --live and --sandbox together is a usage error. A missing ANTHROPIC_API_KEY in agent mode is exit 2. --dry-run exits 0 after the estimate. --offline --dry-run exits 2. A file under generated/ that was edited after the last emit is exit 2 unless --force is set.
overrides.yaml¶
overrides.yaml sits next to tools.yaml. mcp4api never writes it. It is applied to the cached base, so a second run does not apply it twice.
renames:
list_books: search_books
descriptions:
list_books: Search the catalog.
exclude_endpoints:
- endpoint_id: GET /books/{book_id}/stats
reason: low-value
note: Stats are folded into get_book.
include_endpoints:
- GET /admin/audit-events
fixed:
- tool: list_books
endpoint_id: GET /books
param: limit
in: query
value: 2
reason: hidden plumbing
outputs:
get_book:
- id
- title
Descriptions, fixed values, and outputs use the tool name from the base, before renames. Renames do not chain. An included endpoint comes back as a one-endpoint tool. Unsupported auth stays excluded. Unknown names print stale override: on stderr and are skipped.
Run it on your API¶
Agent curation reads ANTHROPIC_API_KEY. --curation heuristic does not. Commit tools.yaml and tests/cassettes/ when the same result should come back without a model call:
generated/README.md names the environment variables. Add the server to Claude Code from the artifact root:
report/verification.md lists every tool. A known gap names the field that failed. Exit code 3 means at least one tool is a known gap.