Skip to main content
Glama
Tai-DT
by Tai-DT

generate_component

Create Tailwind CSS components using AI assistance. Specify component type, framework, and styling options to generate responsive, accessible UI elements.

Instructions

Generate Tailwind CSS components with AI assistance using Gemini

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesDescription of the component to generate
typeYesType of component
frameworkNoTarget frameworkreact
variantNoComponent variantprimary
sizeNoComponent sizemd
themeNoTheme preferencelight
useShadcnNoUse shadcn/ui components as base
responsiveNoMake component responsive
accessibilityNoInclude accessibility features

Implementation Reference

  • src/index.ts:40-98 (registration)
    Registers the generate_component tool in the TOOLS array, including name, description, and detailed input schema for MCP protocol.
    const TOOLS = [
      {
        name: 'generate_component',
        description: 'Generate Tailwind CSS components with AI assistance using Gemini',
        inputSchema: {
          type: 'object',
          properties: {
            description: {
              type: 'string',
              description: 'Description of the component to generate'
            },
            type: {
              type: 'string',
              enum: ['button', 'card', 'form', 'navigation', 'modal', 'table', 'custom'],
              description: 'Type of component'
            },
            framework: {
              type: 'string',
              enum: ['html', 'react', 'vue', 'svelte', 'angular'],
              default: 'react',
              description: 'Target framework'
            },
            variant: {
              type: 'string',
              enum: ['primary', 'secondary', 'outline', 'ghost', 'link'],
              default: 'primary',
              description: 'Component variant'
            },
            size: {
              type: 'string',
              enum: ['xs', 'sm', 'md', 'lg', 'xl'],
              default: 'md',
              description: 'Component size'
            },
            theme: {
              type: 'string',
              enum: ['light', 'dark', 'auto'],
              default: 'light',
              description: 'Theme preference'
            },
            useShadcn: {
              type: 'boolean',
              default: true,
              description: 'Use shadcn/ui components as base'
            },
            responsive: {
              type: 'boolean',
              default: true,
              description: 'Make component responsive'
            },
            accessibility: {
              type: 'boolean',
              default: true,
              description: 'Include accessibility features'
            }
          },
          required: ['description', 'type']
        }
      },
  • Core handler function that implements the generate_component tool logic, generating Tailwind CSS components using AI (Gemini) or fallback templates based on provided options.
    export async function generateComponent(args: ComponentGenerationOptions) {
      try {
        const {
          description,
          type,
          framework = 'html',
          variant = 'primary',
          size = 'md',
          theme = 'light',
          responsive = true,
          accessibility = true
        } = args;
    
        let componentCode = '';
    
        if (isGeminiAvailable()) {
          // Use AI to generate more sophisticated components
          const prompt = `Generate a ${type} component using Tailwind CSS with the following specifications:
    
    Description: ${description}
    Framework: ${framework}
    Variant: ${variant}
    Size: ${size}
    Theme: ${theme}
    Responsive: ${responsive}
    Accessibility: ${accessibility}
    
    Requirements:
    1. Use only Tailwind CSS classes
    2. Make it modern and visually appealing
    3. Include proper semantic HTML
    4. ${accessibility ? 'Include ARIA attributes and accessibility features' : ''}
    5. ${responsive ? 'Make it responsive with proper breakpoints' : ''}
    6. ${theme === 'dark' ? 'Include dark mode classes' : theme === 'auto' ? 'Include both light and dark mode support' : ''}
    7. Return only the ${framework} code without explanations
    
    ${framework === 'react' ? 'Return as a React functional component with TypeScript.' : ''}
    ${framework === 'vue' ? 'Return as a Vue 3 single file component.' : ''}
    ${framework === 'svelte' ? 'Return as a Svelte component.' : ''}
    ${framework === 'angular' ? 'Return as an Angular component template.' : ''}`;
    
          componentCode = await callGemini(prompt);
        } else {
          // Fallback to template-based generation
          componentCode = generateFromTemplate(type, variant, size, framework, responsive, accessibility);
        }
    
        // Clean up the generated code
        componentCode = componentCode.replace(/```[\w]*\n?/g, '').trim();
    
        return {
          content: [
            {
              type: 'text',
              text: `# Generated ${type} Component\n\n**Framework:** ${framework}\n**Variant:** ${variant}\n**Size:** ${size}\n\n\`\`\`${framework === 'html' ? 'html' : framework}\n${componentCode}\n\`\`\``
            }
          ]
        };
      } catch (error) {
        console.error('Component generation error:', error);
        throw new Error(`Failed to generate component: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • TypeScript interface defining the input options for the generate_component tool.
    export interface ComponentGenerationOptions {
      description: string;
      type: 'button' | 'card' | 'form' | 'navigation' | 'modal' | 'table' | 'custom';
      framework?: 'html' | 'react' | 'vue' | 'svelte' | 'angular';
      variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'link';
      size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
      theme?: 'light' | 'dark' | 'auto';
      responsive?: boolean;
      accessibility?: boolean;
    }
  • Placeholder/stub implementation of generateComponent imported and called by src/index.ts.
    export async function generateComponent(args: ComponentGenerationOptions) {
      return {
        content: [
          {
            type: 'text',
            text: `Generated ${args.type} component: ${args.description}\nFramework: ${args.framework || 'react'}\nVariant: ${args.variant || 'primary'}`
          }
        ]
      };
    }
  • src/index.ts:431-432 (registration)
    Dispatch handler in switch statement that routes tool calls to the generateComponent function.
    case 'generate_component':
      return await generateComponent(args as unknown as ComponentGenerationOptions);
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 'AI assistance using Gemini,' hinting at external API usage, but lacks details on rate limits, authentication needs, output format (e.g., code snippets), error handling, or whether the generation is deterministic. For a tool with 9 parameters and no annotations, this is a significant gap in transparency.

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: 'Generate Tailwind CSS components with AI assistance using Gemini.' It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity. Every part of the sentence earns its place by specifying key elements.

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 (9 parameters, AI-driven generation, no output schema, and no annotations), the description is incomplete. It lacks information on output format (e.g., returns code as a string), behavioral traits (e.g., rate limits, Gemini integration details), and usage context relative to siblings. Without annotations or an output schema, the description should provide more context to guide the 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%, meaning all parameters are documented in the schema with clear descriptions and enums. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain interactions between parameters like 'useShadcn' and 'framework'). With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to heavily.

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 Tailwind CSS components with AI assistance using Gemini.' It specifies the verb ('Generate'), resource ('Tailwind CSS components'), and method ('with AI assistance using Gemini'), which is specific and actionable. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_shadcn_component' or 'create_layout', which might also involve component generation or creation.

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 sibling tools like 'get_shadcn_component' (which might retrieve existing components) or 'create_layout' (which might focus on broader layouts), nor does it specify prerequisites, ideal use cases, or exclusions. This leaves the agent without context for tool selection.

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/Tai-DT/mcp-tailwind-gemini'

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