Tools
openapi_query & openapi_diff
Query OpenAPI specs in a read-only QuickJS sandbox and compare two specs for breaking changes.
OpenAPI MCP exposes two read-only MCP tools: openapi_query for inspecting resolved specs and openapi_diff for comparing two spec versions.
openapi_query
Runs a synchronous JavaScript expression, arrow function, or function body with return inside an isolated QuickJS WASM sandbox. Inside the sandbox, you have read-only access to the frozen, $ref-resolved spec object and built-in helpers.
Common Query Examples
// 1. Inspect an endpoint's merged parameters, request body, responses, and effective security
helpers.op('POST', '/orders')
// 2. Generate a deterministic JSON sample payload for a specific status code
helpers.example('POST', '/orders', '422')
// 3. Find every endpoint that references a shared schema
helpers.schemaRefs('ProblemDetails')
// 4. Run custom filtering directly on the resolved spec
Object.keys(spec.paths).filter((p) => p.startsWith('/v2/'))
How the Built-in Helpers Work
helpers.op(method, path): Merges path-level and operation-level parameters and resolves effective security requirements for that operation.helpers.example(method, path, status?): Builds a deterministic sample JSON payload by walking schema fields in priority order:example→const→default→enum→format→type.helpers.schemaRefs(schemaName): Returns all endpoints that reference a given component schema.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
code | string (required) | — | Synchronous JS query (up to 16,384 characters). |
root | string | server root | Workspace root directory. |
spec_path | string | default spec | Relative path to a specific spec file (useful in monorepos). |
max_bytes | integer | 16384 | Maximum UTF-8 output size (up to 1 MiB). |
Sandbox Limits & Budgets
- Timeouts:
2,000 mssetup cap for parsing and freezing the spec, plus a150 msexecution timeout per query. - Memory & stack: Capped at
64 MiBmemory and512 KiBstack. Async functions and Promises are rejected. - Response budget: Output defaults to
16 KiBUTF-8. If a query returns too much data, the tool returnsRESPONSE_BUDGET_EXCEEDEDalong with available keys and hints to narrow the expression.
openapi_diff
Compares two local OpenAPI specs (base_spec_path vs. target_spec_path) and separates changes into breaking and nonBreaking.
{
"base_spec_path": "openapi.yml",
"target_spec_path": "docs/openapi-v2.yml"
}
How Changes Are Classified
| Category | Examples |
|---|---|
| Breaking | Removed endpoints, removed response status codes or media types, new required parameters or request fields, optional-to-required request fields, required-to-optional response fields, schema type changes, removed request enum values, added response enum values. |
| Non-breaking | Added endpoints, newly deprecated endpoints, new optional parameters or request fields, added response status codes or fields, new request media types. |