Skip to main content
Glama

create_form

Generate form structures using its-just-ui React components. Define fields, layouts, and validation to create functional forms for web applications.

Instructions

Generate a form structure using its-just-ui form components

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsYes
layoutNo
includeValidationNo

Implementation Reference

  • The primary handler function for the 'create_form' tool. It generates complete React form code using its-just-ui components based on provided fields, layout, and validation options. It dynamically creates form fields, imports necessary components, and optionally adds client-side validation.
      createForm(
        fields: FormField[],
        layout?: string,
        includeValidation?: boolean,
      ): string {
        const layoutClass =
          layout === "two-column"
            ? "grid grid-cols-1 md:grid-cols-2 gap-4"
            : layout === "inline"
              ? "flex flex-wrap gap-4"
              : "space-y-4";
    
        const formFields = fields
          .map((field) => {
            switch (field.type) {
              case "text":
              case "email":
              case "password":
              case "number":
                return `    <Input
          label="${field.label}"
          name="${field.name}"
          type="${field.type}"
          placeholder="${field.placeholder || `Enter ${field.label.toLowerCase()}`}"
          ${field.required ? "required" : ""}
        />`;
    
              case "select":
                return `    <Select
          label="${field.label}"
          name="${field.name}"
          options={${field.options ? JSON.stringify(field.options) : "[]"}}
          placeholder="${field.placeholder || `Select ${field.label.toLowerCase()}`}"
          ${field.required ? "required" : ""}
        />`;
    
              case "checkbox":
                return `    <Checkbox
          label="${field.label}"
          name="${field.name}"
        />`;
    
              case "radio":
                return `    <RadioGroup
          label="${field.label}"
          name="${field.name}"
          options={${field.options ? JSON.stringify(field.options) : "[]"}}
          ${field.required ? "required" : ""}
        />`;
    
              case "date":
                return `    <DatePicker
          label="${field.label}"
          name="${field.name}"
          placeholder="${field.placeholder || "Select date"}"
          ${field.required ? "required" : ""}
        />`;
    
              case "color":
                return `    <ColorPicker
          label="${field.label}"
          name="${field.name}"
        />`;
    
              case "file":
                return `    <Upload
          label="${field.label}"
          name="${field.name}"
          ${field.required ? "required" : ""}
        />`;
    
              default:
                return `    <Input
          label="${field.label}"
          name="${field.name}"
          ${field.required ? "required" : ""}
        />`;
            }
          })
          .join("\n\n");
    
        let formCode = `import { ${this.getRequiredComponents(fields).join(", ")} } from 'its-just-ui';
    ${includeValidation ? "import { useState } from 'react';" : ""}
    
    export default function CustomForm() {
      ${includeValidation ? this.generateValidationState(fields) : ""}
      
      const handleSubmit = (e: React.FormEvent) => {
        e.preventDefault();
        ${includeValidation ? this.generateValidationLogic(fields) : "// Handle form submission"}
      };
    
      return (
        <form onSubmit={handleSubmit} className="max-w-2xl mx-auto p-6">
          <div className="${layoutClass}">
    ${formFields}
          </div>
          
          <div className="mt-6 flex gap-4">
            <Button type="submit" variant="primary">
              Submit
            </Button>
            <Button type="reset" variant="outline">
              Reset
            </Button>
          </div>
        </form>
      );
    }`;
    
        return formCode;
      },
  • Zod schema defining the input structure for the 'create_form' tool, including fields array with types, labels, etc., optional layout and validation flag.
    const CreateFormSchema = z.object({
      fields: z.array(
        z.object({
          name: z.string(),
          type: z.enum([
            "text",
            "email",
            "password",
            "number",
            "select",
            "checkbox",
            "radio",
            "date",
            "color",
            "file",
          ]),
          label: z.string(),
          required: z.boolean().optional(),
          placeholder: z.string().optional(),
          options: z.array(z.string()).optional(),
        }),
      ),
      layout: z.enum(["single-column", "two-column", "inline"]).optional(),
      includeValidation: z.boolean().optional(),
    });
  • src/index.ts:278-322 (registration)
    Tool registration in the list_tools response, defining name, description, and inputSchema for 'create_form'.
    {
      name: "create_form",
      description:
        "Generate a form structure using its-just-ui form components",
      inputSchema: {
        type: "object",
        properties: {
          fields: {
            type: "array",
            items: {
              type: "object",
              properties: {
                name: { type: "string" },
                type: {
                  type: "string",
                  enum: [
                    "text",
                    "email",
                    "password",
                    "number",
                    "select",
                    "checkbox",
                    "radio",
                    "date",
                    "color",
                    "file",
                  ],
                },
                label: { type: "string" },
                required: { type: "boolean" },
                placeholder: { type: "string" },
                options: { type: "array", items: { type: "string" } },
              },
              required: ["name", "type", "label"],
            },
          },
          layout: {
            type: "string",
            enum: ["single-column", "two-column", "inline"],
          },
          includeValidation: { type: "boolean" },
        },
        required: ["fields"],
      },
    },
  • MCP server handler case for 'create_form' tool call, which parses input with schema and delegates to utilityTools.createForm.
    case "create_form": {
      const { fields, layout, includeValidation } =
        CreateFormSchema.parse(args);
      const formCode = utilityTools.createForm(
        fields,
        layout,
        includeValidation,
      );
      return {
        content: [
          {
            type: "text",
            text: formCode,
          },
        ],
      };
    }
  • TypeScript interface defining the structure of form fields used by the createForm handler.
    export interface FormField {
      name: string;
      type: string;
      label: string;
      required?: boolean;
      placeholder?: string;
      options?: string[];
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Generate a form structure', implying a creation operation, but does not specify whether this is a read-only simulation, a destructive update, requires authentication, or has rate limits. For a tool with zero annotation coverage, this lack of behavioral details is a significant gap.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It is appropriately sized and front-loaded, with zero waste, making it highly concise and well-structured.

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

Completeness2/5

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

Given the complexity of a form generation tool with 3 parameters, 0% schema description coverage, no annotations, and no output schema, the description is incomplete. It lacks details on parameter usage, behavioral traits, output format, and differentiation from siblings, making it insufficient for effective tool invocation.

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

Parameters2/5

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

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description does not add any meaning beyond the schema—it does not explain what 'fields', 'layout', or 'includeValidation' represent, their formats, or how they affect the form generation. With 3 parameters and no compensation in the description, this is inadequate.

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

Purpose3/5

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

The description states the tool 'Generate[s] a form structure using its-just-ui form components', which provides a clear verb ('Generate') and resource ('form structure'). However, it does not distinguish this from sibling tools like 'compose_components' or 'generate_component', which might also involve UI component generation, leaving the purpose somewhat vague in context.

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

Usage Guidelines2/5

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

The description offers no guidance on when to use this tool versus alternatives. There is no mention of prerequisites, specific contexts (e.g., for creating user input forms), or comparisons to siblings like 'create_responsive_layout' or 'generate_component', leaving the agent without usage direction.

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/its-just-ui/its-just-mcp'

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