peek_openapi
Summarize an OpenAPI spec to inspect its title, version, endpoints, and paths before serving or deploying. Accepts a file path or public URL.
Instructions
Summarise an OpenAPI spec without serving it. Returns {title, version, openapi_version, endpoint_count, paths}. Pass input as a file path or a public https URL. Use this when the user wants to know what's in a spec before deciding whether to serve or deploy it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes |
Implementation Reference
- lib/local.js:342-360 (handler)The main handler function for the peek_openapi tool. Accepts an `input` argument (file path or URL), resolves the mockzilla CLI, and runs `mockzilla info <input>` to summarise an OpenAPI spec. Returns JSON with {title, version, openapi_version, endpoint_count, paths}.
export async function peekOpenapi(args) { const input = args.input; if (typeof input !== "string" || input.length === 0) { throw new Error("`input` must be a non-empty string"); } const resolved = await resolveMockzilla(); if (!resolved) { throw new Error("mockzilla is not installed. Call install_cli first."); } const [cmd, ...prefix] = resolved.type === "binary" ? [resolved.path] : resolved.invocation; const cmdline = [cmd, ...prefix, "info", input].map(shellEscape).join(" "); try { const { stdout } = await exec(cmdline); return JSON.parse(stdout); } catch (err) { throw new Error((err.stderr && err.stderr.trim()) || err.message); } } - lib/tools.js:346-362 (registration)Registration of the 'peek_openapi' tool in the LOCAL_TOOLS registry, including its description and input schema.
peek_openapi: { description: "Summarise an OpenAPI spec without serving it. Returns " + "{title, version, openapi_version, endpoint_count, paths}. " + "Pass `input` as a file path or a public https URL. Use this " + "when the user wants to know what's in a spec before deciding " + "whether to serve or deploy it.", inputSchema: { type: "object", properties: { input: { type: "string" }, }, required: ["input"], additionalProperties: false, }, handler: peekOpenapi, }, - lib/tools.js:353-360 (schema)Input schema for peek_openapi: expects an object with a required string property 'input' (file path or URL).
inputSchema: { type: "object", properties: { input: { type: "string" }, }, required: ["input"], additionalProperties: false, }, - lib/util.js:3-9 (helper)shellEscape is used by peekOpenapi to safely escape shell arguments when constructing the `mockzilla info <input>` command line.
export function shellEscape(s) { if (process.platform === "win32") { // Conservative quote: wrap and double internal quotes. return `"${String(s).replace(/"/g, '""')}"`; } return `'${String(s).replace(/'/g, "'\\''")}'`; }