Skip to main content
Glama

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
NameRequiredDescriptionDefault
schemaYesJSON Schema object describing the shape of the mock data
countNoNumber of mock records to generate (1–100)
seedNoOptional seed for reproducible output

Implementation Reference

  • 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") }] };
      }
    );
  • 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") }] };
      }
    );
  • 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"),
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marras0914/agent-toolbelt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server