Get a REST endpoint
get_endpointRetrieve the complete OpenAPI operation object (parameters, request body, responses, security) for any REST endpoint by providing its HTTP method and path template.
Instructions
Get the full OpenAPI operation object (parameters, request body, responses, security) for a single REST endpoint.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | HTTP method, e.g. `POST`. | |
| path | Yes | OpenAPI path template, e.g. `/v1/analyze/audio`. |
Implementation Reference
- src/lib/openapi.ts:71-80 (handler)The core handler function 'getEndpoint' that looks up an OpenAPI operation by HTTP method and path from the cached OpenAPI spec. Returns the method, path, and full operation object, or null if not found.
export async function getEndpoint(method: string, path: string): Promise<{ method: string; path: string; operation: OpenApiOperation; } | null> { const spec = await loadOpenApi(); const op = spec?.paths?.[path]?.[method.toLowerCase()]; if (!op) return null; return { method: method.toUpperCase(), path, operation: op }; } - src/lib/openapi.ts:3-12 (schema)TypeScript type 'OpenApiOperation' used as the return type for the endpoint operation data, defining the shape (summary, description, tags, parameters, requestBody, responses, security, operationId).
interface OpenApiOperation { summary?: string; description?: string; tags?: string[]; parameters?: unknown[]; requestBody?: unknown; responses?: Record<string, unknown>; security?: unknown[]; operationId?: string; } - src/server.ts:171-187 (registration)Tool registration for 'get_endpoint' via server.registerTool, including the input schema (method and path) and the handler that calls getEndpoint() and returns a JSON response.
server.registerTool( "get_endpoint", { title: "Get a REST endpoint", description: "Get the full OpenAPI operation object (parameters, request body, responses, security) for a single REST endpoint.", inputSchema: { method: z.string().describe("HTTP method, e.g. `POST`."), path: z.string().describe("OpenAPI path template, e.g. `/v1/analyze/audio`."), }, }, async ({ method, path }) => { const result = await getEndpoint(method, path); if (!result) return textResponse(`No endpoint ${method.toUpperCase()} ${path}.`); return jsonResponse(result); }, ); - src/lib/openapi.ts:24-34 (helper)Helper function 'loadOpenApi' that loads and caches the OpenAPI spec from the content store — called by getEndpoint to retrieve the spec.
export async function loadOpenApi(): Promise<OpenApiSpec | null> { if (cached) return cached; const entry = await getEntry("api/openapi"); if (!entry) return null; try { cached = JSON.parse(entry.body) as OpenApiSpec; return cached; } catch { return null; } }