Engine

Spec Loader & $ref Resolution

How OpenAPI MCP discovers specs, resolves multi-file local $refs safely, tracks source lines, and caches snapshots.

Every MCP resource, diagnostic check, diff, and sandbox query reads from a frozen, resolved snapshot of your specification.

Automatic Spec Discovery

When --spec or spec_path is omitted, OpenAPI MCP looks for openapi.yml, openapi.yaml, or openapi.json in this order:

  1. Workspace root
  2. api/
  3. docs/

Local $ref Resolution & Workspace Boundaries

OpenAPI MCP resolves multi-file specifications locally while enforcing strict workspace boundaries:

  • Workspace confinement: Relative $ref targets are resolved from the referring file. Remote URLs (http://, https://) and paths whose canonical realpath escapes the workspace root are rejected (REMOTE_REF_DENIED, PATH_TRAVERSAL_DENIED).
  • Circular references: Cycles are detected by object identity and replaced with [Circular: <ref>] so recursive schemas remain inspectable without infinite loops.
  • OpenAPI 3.1 sibling keywords: When a Schema Object has sibling keywords alongside $ref, the target schema is preserved via allOf alongside the local keywords. ($id, $anchor, and $dynamicRef are outside the supported subset and return an explicit error.)
  • Source line tracking: YAML and JSON files are parsed in a single pass to record 1-based { file, line, col } source locations and reverse schemaUsages before $ref inlining merges files together.

Caching & Safety Limits

Up to 8 entry specs are cached in memory and automatically invalidated whenever any referenced file's mtime, ctime, size, or SHA-256 hash changes (including deleted $ref files).

LimitCap
Referenced source filesMax 128 files
Cumulative input sizeMax 8 MiB
Expansion node visitsMax 250,000 nodes
Reference nesting depthMax 128 levels
Serialized snapshot sizeMax 8 MiB