mock_api_response
Generate realistic mock API responses from JSON Schema specifications for testing and development purposes.
Instructions
Generate realistic mock API responses from a JSON Schema. Supports nested objects, arrays, string formats (email, uuid, date-time, url), field-name heuristics, enums, and min/max constraints. Set seed for reproducible output. Returns 1–100 records.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | Yes | JSON Schema object describing the shape of the mock data | |
| count | No | Number of mock records to generate (1–100) | |
| seed | No | Optional seed for reproducible output |
Implementation Reference
- mcp-server/src/index.ts:825-840 (handler)Handler function for mock_api_response, which delegates the request to the Agent Toolbelt API via callToolApi.
async ({ schema, count, seed }) => { const result = await callToolApi("api-response-mocker", { schema, count, seed }); const data = result as any; const r = data.result; const lines = [ `**Generated ${r.count} mock record${r.count !== 1 ? "s" : ""}** (schema type: ${r.schema.type})`, "", "```json", JSON.stringify(r.data, null, 2), "```", ]; return { content: [{ type: "text" as const, text: lines.join("\n") }] }; } ); - mcp-server/src/index.ts:810-840 (registration)Registration of the mock_api_response tool.
server.registerTool( "mock_api_response", { title: "API Response Mocker", description: "Generate realistic mock API responses from a JSON Schema. " + "Supports nested objects, arrays, string formats (email, uuid, date-time, url), " + "field-name heuristics, enums, and min/max constraints. " + "Set seed for reproducible output. Returns 1–100 records.", inputSchema: { schema: z.record(z.unknown()).describe("JSON Schema object describing the shape of the mock data"), count: z.number().int().min(1).max(100).default(1).describe("Number of mock records to generate (1–100)"), seed: z.number().int().optional().describe("Optional seed for reproducible output"), }, }, async ({ schema, count, seed }) => { const result = await callToolApi("api-response-mocker", { schema, count, seed }); const data = result as any; const r = data.result; const lines = [ `**Generated ${r.count} mock record${r.count !== 1 ? "s" : ""}** (schema type: ${r.schema.type})`, "", "```json", JSON.stringify(r.data, null, 2), "```", ]; return { content: [{ type: "text" as const, text: lines.join("\n") }] }; } ); - mcp-server/src/index.ts:819-823 (schema)Input schema definition for mock_api_response.
inputSchema: { schema: z.record(z.unknown()).describe("JSON Schema object describing the shape of the mock data"), count: z.number().int().min(1).max(100).default(1).describe("Number of mock records to generate (1–100)"), seed: z.number().int().optional().describe("Optional seed for reproducible output"), },