Skip to main content
Glama

generate_from_template

Generate realistic test data using pre-built schema templates for ecommerce, blog, SaaS, or social applications. Customize scale, locale, format, and seed to populate databases with relational integrity.

Instructions

Generate test data using a pre-built schema template.

Pick a template (ecommerce, blog, saas, social) and optionally adjust the scale, locale, format, and seed. The template handles all the table definitions, field types, and foreign key relationships for you.

Scale multiplier: 1.0 = default counts, 2.0 = double, 0.5 = half. Example: ecommerce template at scale 2.0 generates 100 users, 200 products, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYesTemplate name
scaleNoScale multiplier for record counts (default 1.0)
localeNoDefault locale (en, de, fr, es, etc.)
formatNoOutput formatjson
sql_dialectNoSQL dialect (only when format=sql)
seedNoSeed for reproducible output

Implementation Reference

  • The handler function for the 'generate_from_template' tool, responsible for parsing input, generating data, and formatting the response.
    async function handleGenerateFromTemplate(
      args: Record<string, unknown>
    ): Promise<ToolResult> {
      const { template, locale, scale, format, seed } = args as {
        template: string;
        locale?: string;
        scale?: number;
        format?: string;
        seed?: number;
      };
    
      if (!template) {
        return err("'template' is required. Available templates: ecommerce, blog, saas, social");
      }
    
      let request: GenerateRequest;
      try {
        request = generateFromTemplate({
          template,
          locale: locale as GenerateRequest["locale"],
          scale,
          format: format as GenerateRequest["format"],
          seed,
        });
      } catch (e) {
        return err(`Template error: ${e instanceof Error ? e.message : String(e)}`);
      }
    
      const result = await generate(request);
      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
      if (format && format !== "json") {
        const sqlDialect = args.sql_dialect as string | undefined;
        const formatted = formatOutput(
          result.result,
          request.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 registration definition for the 'generate_from_template' tool in the tool definitions array.
      {
        name: "generate_from_template",
        description:
          "Generate test data using a pre-built template. Available templates: ecommerce, blog, saas, social. Use 'scale' to multiply record counts.",
        inputSchema: {
          type: "object",
          properties: {
            template: {
              type: "string",
              description:
                "Template ID: ecommerce, blog, saas, or social",
            },
            locale: {
              type: "string",
              description: "Locale for generated data. Default: en",
            },
            scale: {
              type: "number",
              description:
                "Multiplier for all table record counts. E.g. scale=10 generates 10x the default rows.",
            },
            format: {
              type: "string",
              enum: ["json", "csv", "sql"],
              description: "Output format. Default: json",
            },
            seed: {
              type: "number",
              description: "PRNG seed for reproducible output.",
            },
          },
          required: ["template"],
        },
      },
    ];
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool generates data (not destructive), handles table definitions and relationships automatically, and provides scaling behavior. However, it doesn't mention output format details, error conditions, or performance characteristics that would be helpful for an agent.

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

Conciseness5/5

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

The description is efficiently structured with three focused paragraphs: purpose statement, parameter overview, and scale explanation. Every sentence adds value without repetition. It's appropriately sized for a 6-parameter tool with complex functionality.

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 data generation tool with 6 parameters, 100% schema coverage, and no output schema, the description provides good context about what the tool does and how scaling works. The main gap is the lack of information about return values/output format, which would be important since there's no output schema. However, the description of format parameter and template behavior partially compensates.

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 baseline is 3. The description adds some value by explaining the scale parameter's meaning with examples (1.0=default, 2.0=double) and mentioning that templates handle table definitions automatically. However, it doesn't provide additional semantics beyond what the schema already documents for most parameters.

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 with specific verbs ('generate test data') and resources ('using a pre-built schema template'). It distinguishes from sibling tools by focusing on template-based generation rather than schema detection, raw data generation, or listing functions. The mention of specific templates (ecommerce, blog, saas, social) adds specificity.

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: when you need test data with pre-defined schemas and relationships. It doesn't explicitly state when NOT to use it or name specific alternatives among siblings, but the template-based approach implies it's for structured scenarios rather than custom schema generation.

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