Skip to main content
Glama

generate_test_data

Generate realistic relational test data for database tables from schemas or plain English descriptions, ensuring foreign key integrity and locale-aware values across multiple output formats.

Instructions

Generate realistic test data for database tables.

Send either a structured schema (tables with fields) or a plain English description. Supports relational data with foreign keys, locale-aware names and addresses, 22 locales, 157 field types, and multiple output formats (JSON, CSV, SQL).

The killer feature: define multiple tables with "ref" fields, and all foreign key relationships are correct — orders reference real user IDs, reviews link to real products. One call seeds your entire database.

Auto-locale: add a "country" field as an enum with country codes (DE, FR, US, etc.) and names, emails, phones automatically match each row's nationality.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tablesNoStructured schema — array of table definitions
promptNoPlain English description (e.g. "50 users with German names and 200 orders linked to them")
formatNoOutput formatjson
sql_dialectNoSQL dialect (only when format=sql)
localeNoDefault locale (en, de, fr, es, ja, etc.). Auto-detected from country field if present.
seedNoSeed for reproducible output. Same seed + same schema = identical data.

Implementation Reference

  • The main handler function for the `generate_test_data` MCP tool, which parses input arguments, performs the data generation, and optionally formats the output.
    async function handleGenerateTestData(
      args: Record<string, unknown>
    ): Promise<ToolResult> {
      // Parse and validate the schema
      const parsed = parseSchema(args);
      if (!parsed.success) {
        return err(
          `Schema validation failed:\n${parsed.errors
            .map((e) => `  - ${e.field}: ${e.message}`)
            .join("\n")}`
        );
      }
    
      // Generate data
      const result = await generate(parsed.data);
      if (!result.success) {
        if ("errors" in result) {
          return err(
            `Generation failed:\n${result.errors
              .map((e) => `  - ${e.field}: ${e.message}`)
              .join("\n")}`
          );
        }
        return err(`Generation failed: circular dependency between tables: ${result.cycle.join(" -> ")}`);
      }
    
      // Optionally format output
      const format = args.format as string | undefined;
      if (format && format !== "json") {
        const sqlDialect = args.sql_dialect as string | undefined;
        const formatted = formatOutput(
          result.result,
          parsed.data.tables,
          format as "csv" | "sql",
          sqlDialect as "postgres" | "mysql" | "sqlite" | undefined
        );
        return ok(formatted.body);
      }
    
      return ok({ data: result.result.data, meta: result.result.meta });
    }
  • The definition and schema for the `generate_test_data` tool, outlining input requirements like tables, field types, and supported formats.
    export const TOOL_DEFINITIONS: ToolDefinition[] = [
      {
        name: "generate_test_data",
        description:
          "Generate realistic test data for database tables. Supports 135+ field types, 20 locales, relational data with foreign keys, and multiple output formats (JSON, CSV, SQL).",
        inputSchema: {
          type: "object",
          properties: {
            tables: {
              type: "array",
              description:
                "Array of table definitions. Each table has: name (string), count (number), fields (array of {name, type, params?, nullable?}). Field types include: first_name, last_name, email, uuid, integer, boolean, datetime, price, enum, ref, and 125+ more.",
              items: {
                type: "object",
                properties: {
                  name: { type: "string", description: "Table name" },
                  count: {
                    type: "number",
                    description: "Number of rows to generate",
                  },
                  fields: {
                    type: "array",
                    description: "Array of field definitions",
                    items: {
                      type: "object",
                      properties: {
                        name: { type: "string", description: "Column name" },
                        type: {
                          type: "string",
                          description:
                            "Field type (e.g. first_name, email, uuid, integer, enum, ref)",
                        },
                        params: {
  • Registration logic within a handler switch statement that routes incoming tool requests for `generate_test_data` to `handleGenerateTestData`.
    switch (name) {
      case "generate_test_data":
        return handleGenerateTestData(args);
      case "detect_schema":
        return handleDetectSchema(args);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does well by describing key behaviors: supports relational data with foreign keys, locale-aware generation, multiple output formats, auto-locale detection, and reproducible output via seed. However, it doesn't mention potential limitations like rate limits, authentication needs, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. Most sentences add value, though some details like '22 locales, 157 field types' could be considered extraneous. The structure flows logically from general purpose to specific features.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 6 parameters and no output schema, the description provides good contextual completeness. It explains the tool's capabilities, relational data handling, and key features. However, without an output schema, it doesn't describe what the generated data looks like (structure, format details), which is a minor gap given the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds some context about parameters (e.g., 'ref' fields for foreign keys, 'country' field for auto-locale), but doesn't provide significant additional semantics beyond what the schema descriptions already cover. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate realistic test data for database tables.' It specifies the verb ('generate') and resource ('test data for database tables'), and distinguishes it from siblings by highlighting its 'killer feature' of handling relational data with correct foreign key relationships, unlike simpler generation tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: for generating realistic test data with relational integrity. It mentions alternatives like using structured schemas or plain English descriptions, but doesn't explicitly contrast with sibling tools like 'generate_from_template' or 'list_field_types', which could help avoid confusion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/dinosaur24/mockhero'

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