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:
- Workspace root
api/docs/
Local $ref Resolution & Workspace Boundaries
OpenAPI MCP resolves multi-file specifications locally while enforcing strict workspace boundaries:
- Workspace confinement: Relative
$reftargets are resolved from the referring file. Remote URLs (http://,https://) and paths whose canonicalrealpathescapes 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 viaallOfalongside the local keywords. ($id,$anchor, and$dynamicRefare 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 reverseschemaUsagesbefore$refinlining 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).
| Limit | Cap |
|---|---|
| Referenced source files | Max 128 files |
| Cumulative input size | Max 8 MiB |
| Expansion node visits | Max 250,000 nodes |
| Reference nesting depth | Max 128 levels |
| Serialized snapshot size | Max 8 MiB |