list_mock_endpoints
Retrieve all mocked API endpoints with method, service, path, and file. Access the mock server URL and interactive UI for inspection.
Instructions
List all endpoints currently mocked via mock_endpoint. Returns {endpoints: [{method, service, path, file}], server_url, ui_url}. If a managed server is running, ui_url is the mockzilla UI (opens in a browser, shows endpoints grouped by service plus request inspection). Suggest the UI to the user when they want to explore beyond what the agent can show in chat.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- lib/local.js:188-225 (handler)The handler function that executes the tool logic. Reads the MOCKS_STATIC_DIR, walks service directories using collectEndpoints, and returns endpoints array along with server_url and ui_url.
export async function listMockEndpoints() { const endpoints = []; const rootStat = await stat(MOCKS_STATIC_DIR).catch(() => null); if (!rootStat || !rootStat.isDirectory()) { return { endpoints: [], count: 0, server_url: managedServerUrl(), ui_url: managedServerUiUrl(), notes: "No mocks have been created yet. Use mock_endpoint to add one.", }; } const services = await readdir(MOCKS_STATIC_DIR, { withFileTypes: true }); for (const svc of services) { if (!svc.isDirectory()) continue; await collectEndpoints( path.join(MOCKS_STATIC_DIR, svc.name), svc.name, [], endpoints, ); } const serverUrl = managedServerUrl(); return { endpoints, count: endpoints.length, server_url: serverUrl, ui_url: managedServerUiUrl(), notes: serverUrl ? `Open ${managedServerUiUrl()} for the mockzilla UI ` + `(grouped by service, request inspection, response config).` : "No managed server is currently running. The next mock_endpoint " + "call will start one.", }; } - lib/local.js:242-266 (helper)Helper function that recursively walks the static mock directory structure to collect endpoint entries (method, service, path, file) into the output array.
async function collectEndpoints(dir, service, pathSegs, out) { const entries = await readdir(dir, { withFileTypes: true }).catch(() => []); for (const e of entries) { if (!e.isDirectory()) continue; const childDir = path.join(dir, e.name); if (ALLOWED_METHODS.has(e.name.toUpperCase())) { const childEntries = await readdir(childDir, { withFileTypes: true, }).catch(() => []); const idx = childEntries.find( (ce) => ce.isFile() && ce.name.startsWith("index."), ); if (idx) { out.push({ method: e.name.toUpperCase(), service, path: "/" + [service, ...pathSegs].join("/"), file: path.join(childDir, idx.name), }); } } else { await collectEndpoints(childDir, service, [...pathSegs, e.name], out); } } } - lib/local.js:268-277 (helper)Helper functions managedServerUrl() and managedServerUiUrl() that retrieve the URL and UI URL of the currently running managed server.
function managedServerUrl() { if (localServers.size === 0) return null; const [, entry] = localServers.entries().next().value; return entry.kind === "managed" ? entry.url : null; } function managedServerUiUrl() { const url = managedServerUrl(); return url ? url.replace(/\/$/, "") + "/" : null; } - lib/tools.js:205-219 (registration)Registration entry for list_mock_endpoints in the LOCAL_TOOLS registry, containing description, inputSchema (empty object), and handler reference to listMockEndpoints.
list_mock_endpoints: { description: "List all endpoints currently mocked via `mock_endpoint`. Returns " + "{endpoints: [{method, service, path, file}], server_url, ui_url}. " + "If a managed server is running, `ui_url` is the mockzilla UI " + "(opens in a browser, shows endpoints grouped by service plus " + "request inspection). Suggest the UI to the user when they want " + "to explore beyond what the agent can show in chat.", inputSchema: { type: "object", properties: {}, additionalProperties: false, }, handler: listMockEndpoints, }, - lib/tools.js:8-16 (registration)Import statement importing listMockEndpoints from ./local.js into the tools registry.
import { callEndpoint, clearMockEndpoints, listMockEndpoints, mockEndpoint, peekOpenapi, serveLocally, stopLocally, } from "./local.js";