Skip to main content
Glama

Schema Generator

generate_schema

Create JSON Schema, TypeScript interfaces, or Zod validation schemas from natural language descriptions of data structures like user profiles or product listings.

Instructions

Generate a JSON Schema, TypeScript interface, or Zod validation schema from a natural language description of a data structure. Examples: 'a user profile with name, email, and signup date', 'a product listing with title, price, and inventory count'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesNatural language description of the data structure you want a schema for
formatNoOutput format: json_schema (standard JSON Schema), typescript (TS interface), or zod (Zod validation schema)json_schema
strictNoIf true, all fields are required. If false, optional fields are marked as optional

Implementation Reference

  • Registration and implementation of the "generate_schema" tool. It calls the remote API "schema-generator".
    server.registerTool(
      "generate_schema",
      {
        title: "Schema Generator",
        description:
          "Generate a JSON Schema, TypeScript interface, or Zod validation schema from a natural language description of a data structure. " +
          "Examples: 'a user profile with name, email, and signup date', 'a product listing with title, price, and inventory count'.",
        inputSchema: {
          description: z
            .string()
            .describe(
              "Natural language description of the data structure you want a schema for"
            ),
          format: z
            .enum(["json_schema", "zod", "typescript"])
            .default("json_schema")
            .describe(
              "Output format: json_schema (standard JSON Schema), typescript (TS interface), or zod (Zod validation schema)"
            ),
          strict: z
            .boolean()
            .default(true)
            .describe(
              "If true, all fields are required. If false, optional fields are marked as optional"
            ),
        },
      },
      async ({ description, format, strict }) => {
        const result = await callToolApi("schema-generator", {
          description,
          format,
          strict,
        });
    
        const data = result as any;
        const schema = data.result?.schema;
    
        // Format output nicely for the LLM
        const output =
          typeof schema === "string"
            ? schema
            : JSON.stringify(schema, null, 2);
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Generated ${format || "json_schema"} schema:\n\n\`\`\`${format === "typescript" ? "typescript" : format === "zod" ? "typescript" : "json"}\n${output}\n\`\`\`\n\nGenerated in ${data.durationMs}ms.`,
            },
          ],
        };
      }
    );
Behavior3/5

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

No annotations provided, so description carries full burden. It clarifies the three output format options, but omits safety information (determinism, error handling), return value structure (string vs object), or behavior with vague descriptions. Sufficient for basic operation but lacks operational context.

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?

Exactly two sentences with zero redundancy. First sentence establishes capability and variants; second provides illustrative examples. Information density is optimal with no filler text.

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?

With 100% input schema coverage and only 3 simple parameters, the description adequately covers inputs. Minor deduction for lack of output structure hint (critical since no output schema exists), though the three format options partially compensate by indicating return type variety.

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

Parameters4/5

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

Schema coverage is 100%, establishing baseline 3. The examples add significant semantic value for the 'description' parameter, demonstrating expected natural language patterns and complexity levels. This goes beyond the schema's technical definition.

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 uses a specific verb ('Generate') and clearly identifies the three output formats (JSON Schema, TypeScript, Zod) and input method (natural language). It distinguishes from siblings like build_regex or build_cron by explicitly targeting data structure schemas rather than other code artifacts.

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

Usage Guidelines3/5

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

Provides concrete examples showing valid inputs ('a user profile with name, email...'), which implies usage context. However, lacks explicit 'when to use' guidance, prerequisites, or differentiation from potentially similar tools like build_regex. No mention of error cases or ambiguous input handling.

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/marras0914/agent-toolbelt'

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