Skip to main content
Glama

scaffold_component

Generate component templates for forms, lists, detail views, cards, modals, and navigation elements with optional features like validation, internationalization, state management, data fetching, animations, and drag-and-drop functionality.

Instructions

Generate a NoJS component template following framework conventions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesComponent type to scaffold
featuresNoOptional features to include: "validation", "i18n", "state", "fetch", "animation", "dnd"

Implementation Reference

  • The `scaffold_component` tool is defined and implemented directly in `src/tools/index.ts`. It takes a `type` and an optional list of `features`, and returns a string containing a scaffolded HTML template for a NoJS component.
        // ── scaffold_component ──
        server.tool(
            "scaffold_component",
            "Generate a NoJS component template following framework conventions",
            {
                type: z
                    .enum(["form", "list", "detail", "card", "modal", "nav"])
                    .describe("Component type to scaffold"),
                features: z
                    .array(z.string())
                    .optional()
                    .describe(
                        'Optional features to include: "validation", "i18n", "state", "fetch", "animation", "dnd"'
                    ),
            },
            async ({ type, features = [] }) => {
                const templates: Record<string, string> = {
                    form: `<div state="{ email: '', password: '', loading: false }">
      <h2>Login</h2>
      <form validate on:submit.prevent="loading = true">
        <div class="field">
          <label>Email</label>
          <input model="email" type="email" validate="required,email"
                 error-required="Email is required" error-email="Invalid email">
        </div>
        <div class="field">
          <label>Password</label>
          <input model="password" type="password" validate="required"
                 error-required="Password is required">
        </div>
        <p if="$form.firstError" class="error" bind="$form.firstError"></p>
        <button type="submit" class-disabled="!$form.valid || loading">
          <span hide="loading">Submit</span>
          <span show="loading">Loading...</span>
        </button>
      </form>
    </div>`,
    
                    list: `<div state="{ search: '' }">
      <input model="search" placeholder="Search...">
      <div get="/items" as="items">
        <div each="item in items" key="item.id"
             animate="fadeIn" animate-stagger="50">
          <h3 bind="item.title"></h3>
          <p bind="item.description | truncate(100)"></p>
        </div>
        <p if="items.length === 0">No items found.</p>
      </div>
    </div>`,
    
                    detail: `<div get="/items/{$route.params.id}" as="item">
      <template if="item">
        <h1 bind="item.title"></h1>
        <p bind="item.description"></p>
        <span bind="item.createdAt | relative"></span>
      </template>
      <template else>
        <p>Loading...</p>
      </template>
    </div>`,
    
                    card: `<div class="card" state="{ expanded: false }">
      <div class="card-header">
        <h3 bind="title"></h3>
        <button on:click="expanded = !expanded">
          <span hide="expanded">▸</span>
          <span show="expanded">▾</span>
        </button>
      </div>
      <div class="card-body" show="expanded" animate="slideDown">
        <p bind="description"></p>
      </div>
    </div>`,
    
                    modal: `<div state="{ open: false }">
      <button on:click="open = true">Open Modal</button>
      <div class="modal-overlay" show="open" on:click.self="open = false"
           animate-enter="fadeIn" animate-leave="fadeOut">
        <div class="modal-content" animate-enter="slideUp" animate-leave="slideDown">
          <div class="modal-header">
            <h2>Modal Title</h2>
            <button on:click="open = false">×</button>
          </div>
          <div class="modal-body">
            <p>Modal content goes here.</p>
          </div>
          <div class="modal-footer">
            <button on:click="open = false">Close</button>
          </div>
        </div>
      </div>
    </div>`,
    
                    nav: `<nav class="navbar">
      <a route="/" class="logo">App</a>
      <div class="nav-links">
        <a route="/" route-active="active">Home</a>
        <a route="/features" route-active="active">Features</a>
        <a route="/about" route-active="active">About</a>
        <a route="/contact" route-active="active">Contact</a>
      </div>
    </nav>`,
                };
    
                let html = templates[type] || templates["card"];
                let description = `NoJS ${type} component template`;
    
                // Add feature hints
                const featureNotes: string[] = [];
                if (features.includes("i18n")) {
                    featureNotes.push(
                        "Add t=\"key\" to text elements for i18n support"
                    );
                }
                if (features.includes("animation")) {
                    featureNotes.push(
                        'Add animate="fadeIn" or transition="slide" for animations'
                    );
                }
                if (features.includes("dnd")) {
                    featureNotes.push(
                        "Add drag/drop attributes for drag-and-drop support"
                    );
                }
    
                let output = `## Generated ${type} template\n\n\`\`\`html\n${html}\n\`\`\`\n`;
                if (featureNotes.length > 0) {
                    output += `\n## Feature Notes\n\n${featureNotes.map((n) => `- ${n}`).join("\n")}\n`;
                }
    
                return {
                    content: [{ type: "text" as const, text: output }],
                };
            }
        );
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'following framework conventions', which hints at behavioral consistency, but lacks critical details: whether this creates files in a specific location, overwrites existing files, requires authentication, has side effects like modifying configuration, or what the output looks like (e.g., file paths or content). For a generative tool with zero annotation coverage, this 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 with zero waste. It front-loads the core action ('Generate') and resource, making it easy to scan. Every word earns its place by specifying the template type and framework alignment.

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 tool's complexity (generative with potential side effects), lack of annotations, and no output schema, the description is incomplete. It doesn't address what the tool returns (e.g., success message, generated code), error conditions, or behavioral nuances like idempotency. For a tool that creates artifacts, more context is needed to guide an agent effectively.

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%, with clear descriptions for both parameters (type with enum values and features with optional items). The description adds no parameter-specific semantics beyond what the schema provides (e.g., it doesn't explain interactions between type and features or default behaviors). Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('Generate') and resource ('NoJS component template'), specifying it follows 'framework conventions'. It distinguishes from siblings like explain_directive or validate_template by focusing on creation rather than explanation or validation. However, it doesn't explicitly differentiate from potential overlapping tools (e.g., if there were a 'scaffold_page' tool).

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a project setup), when not to use it (e.g., for existing components), or direct comparisons to sibling tools like list_directives. Usage is implied only through the action 'Generate'.

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/ErickXavier/nojs-mcp'

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