Skip to main content
Glama

create_form

Generate form structures with its-just-ui by defining fields (text, email, select, etc.), selecting layout (single-column, two-column, inline), and enabling validation.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsYes
layoutNo
includeValidationNo

Implementation Reference

  • The `createForm` method on `utilityTools` object. Takes FormField[], optional layout, and optional includeValidation, generates a complete form component JSX code using its-just-ui components.
      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 `CreateFormSchema` defining input validation for create_form: fields array (name, type, label, required, placeholder, options), optional layout (single-column/two-column/inline), optional includeValidation boolean.
    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 with name 'create_form', description, and inputSchema JSON schema for MCP tool listing.
    {
      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"],
      },
    },
  • The switch case handler in CallToolRequestHandler that invokes CreateFormSchema.parse(args) and utilityTools.createForm(), returning the generated form code.
    case "create_form": {
      const { fields, layout, includeValidation } =
        CreateFormSchema.parse(args);
      const formCode = utilityTools.createForm(
        fields,
        layout,
        includeValidation,
      );
      return {
        content: [
          {
            type: "text",
            text: formCode,
          },
        ],
      };
    }
  • Helper `getRequiredComponents` that determines which UI components need to be imported based on field types.
    getRequiredComponents(fields: FormField[]): string[] {
      const components = new Set(["Button"]);
    
      fields.forEach((field) => {
        switch (field.type) {
          case "text":
          case "email":
          case "password":
          case "number":
            components.add("Input");
            break;
          case "select":
            components.add("Select");
            break;
          case "checkbox":
            components.add("Checkbox");
            break;
          case "radio":
            components.add("RadioGroup");
            break;
          case "date":
            components.add("DatePicker");
            break;
          case "color":
            components.add("ColorPicker");
            break;
          case "file":
            components.add("Upload");
            break;
        }
      });
    
      return Array.from(components).sort();
    },
Behavior2/5

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

No annotations are present, so the description must fully disclose behavioral traits. It states the tool 'generates' a form structure, implying a non-destructive creation, but omits important details such as whether the result is returned, stored, or requires specific permissions. The lack of output schema further reduces transparency.

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

Conciseness2/5

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

The description is a single sentence, which is too minimal given the tool's complexity. It lacks structure and does not break down the purpose or parameters. While concise, it sacrifices useful information, making it inefficient.

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

Completeness1/5

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

Considering the absence of annotations, output schema, and only 0% schema coverage, the description is grossly insufficient. It does not explain return values, field structure, layout options, or validation behavior, leaving the agent without critical context for correct usage.

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

Parameters1/5

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

The input schema has three parameters with 0% description coverage. The description does not explain any parameter, leaving the agent to infer meaning from names and enums alone. For example, 'fields' is a complex array of objects but is not described. The description adds no semantic value beyond the schema.

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

Purpose4/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 a form structure using specific components. The verb 'generate' and resource 'form structure' are specific. However, it could be more precise by mentioning that the form is a JSON definition with fields, layout, and validation. Still, it distinguishes this tool from siblings like 'generate_component' or 'compose_components' by focusing on forms.

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?

No guidance is provided about when to use this tool versus alternatives. There is no mention of prerequisites, context, or situations where it is appropriate. Users are left to infer usage from the name and description only.

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