Skip to main content
Glama

export_tailwind

Generate Tailwind CSS configuration, plugins, and utility classes from color palettes for web development projects.

Instructions

Generate Tailwind CSS configuration, plugins, and utility classes for color palettes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the tool logic: validates input parameters, processes color inputs, generates Tailwind CSS configurations, plugins, and utility classes in various formats.
    async function exportTailwind(
      params: ExportTailwindParams
    ): Promise<ToolResponse | ErrorResponse> {
      const startTime = Date.now();
    
      try {
        // Validate parameters
        const { error, value: validatedParams } =
          exportTailwindSchema.validate(params);
        if (error) {
          return createErrorResponse(
            'export_tailwind',
            'INVALID_PARAMETERS',
            `Invalid parameters: ${error.details.map(d => d.message).join(', ')}`,
            Date.now() - startTime
          );
        }
    
        // Parse colors
        const colors: UnifiedColor[] = [];
        for (const colorStr of validatedParams.colors) {
          try {
            const color = new UnifiedColor(colorStr);
            colors.push(color);
          } catch {
            return createErrorResponse(
              'export_tailwind',
              'INVALID_COLOR',
              `Invalid color format: ${colorStr}`,
              Date.now() - startTime,
              {
                details: { provided: colorStr },
                suggestions: [
                  'Use hex format like #FF0000',
                  'Use RGB format like rgb(255, 0, 0)',
                  'Use HSL format like hsl(0, 100%, 50%)',
                ],
              }
            );
          }
        }
    
        // Generate Tailwind configuration
        const tailwindConfig = generateTailwindConfig(colors, validatedParams);
        const tailwindPlugin = generateTailwindPlugin(colors, validatedParams);
        const tailwindCSS = generateTailwindCSS(colors, validatedParams);
    
        // Determine output based on format
        let output = '';
        switch (validatedParams.format) {
          case 'config':
            output = tailwindConfig;
            break;
          case 'plugin':
            output = tailwindPlugin;
            break;
          case 'css':
            output = tailwindCSS;
            break;
          case 'all':
            output = `// Tailwind Config\n${tailwindConfig}\n\n// Tailwind Plugin\n${tailwindPlugin}\n\n// Generated CSS\n${tailwindCSS}`;
            break;
        }
    
        // Generate additional export formats
        const exportFormats = {
          tailwind: output,
          config: tailwindConfig,
          plugin: tailwindPlugin,
          css: tailwindCSS,
          json: {
            colors: colors.map((color, index) => ({
              index: index + 1,
              hex: color.hex,
              rgb: color.rgb,
              hsl: color.hsl,
              semantic_name: validatedParams.semantic_names?.[index],
              tailwind_name: getTailwindColorName(index, validatedParams),
            })),
            format: validatedParams.format,
            prefix: validatedParams.prefix,
            metadata: {
              total_colors: colors.length,
              includes_shades: validatedParams.include_shades,
              extends_default: validatedParams.extend_default,
              utilities: validatedParams.generate_utilities,
            },
          },
        };
    
        const executionTime = Date.now() - startTime;
    
        return createSuccessResponse(
          'export_tailwind',
          {
            tailwind_output: output,
            format: validatedParams.format,
            color_count: colors.length,
            prefix: validatedParams.prefix,
            includes_shades: validatedParams.include_shades,
            extends_default: validatedParams.extend_default,
            utilities: validatedParams.generate_utilities,
          },
          executionTime,
          {
            recommendations: [
              'Use semantic color names for better maintainability',
              'Consider including shade variations for more design flexibility',
              'Test the configuration in your Tailwind CSS setup',
            ],
            exportFormats,
          }
        );
      } catch (error) {
        return createErrorResponse(
          'export_tailwind',
          'PROCESSING_ERROR',
          error instanceof Error ? error.message : 'Unknown error occurred',
          Date.now() - startTime
        );
      }
    }
  • Joi schema defining the input parameters for the export_tailwind tool, including colors array, format, prefix, shades, etc.
    const exportTailwindSchema = Joi.object({
      colors: Joi.array()
        .items(Joi.string())
        .min(1)
        .max(100)
        .required()
        .description('Array of colors to export'),
    
      format: Joi.string()
        .valid('config', 'plugin', 'css', 'all')
        .default('config')
        .description('Tailwind export format'),
    
      prefix: Joi.string()
        .pattern(/^[a-zA-Z][a-zA-Z0-9-]*$/)
        .default('custom')
        .description('Prefix for color names'),
    
      include_shades: Joi.boolean()
        .default(true)
        .description('Include shade variations (50, 100, 200, etc.)'),
    
      semantic_names: Joi.array()
        .items(Joi.string())
        .description('Optional semantic names for colors'),
    
      extend_default: Joi.boolean()
        .default(true)
        .description('Extend default Tailwind colors instead of replacing'),
    
      generate_utilities: Joi.array()
        .items(
          Joi.string().valid(
            'background',
            'text',
            'border',
            'ring',
            'shadow',
            'all'
          )
        )
        .default(['all'])
        .description('Which utility classes to generate'),
    });
  • ToolHandler object definition and export, which wraps the handler function and schema for registration.
    export const exportTailwindTool: ToolHandler = {
      name: 'export_tailwind',
      description:
        'Generate Tailwind CSS configuration, plugins, and utility classes for color palettes',
      parameters: exportTailwindSchema.describe(),
      handler: async (params: unknown) =>
        exportTailwind(params as ExportTailwindParams),
    };
  • Global registration of the exportTailwindTool in the central ToolRegistry singleton.
    toolRegistry.registerTool(exportTailwindTool);
  • Helper function to generate the Tailwind CSS configuration file content.
    function generateTailwindConfig(
      colors: UnifiedColor[],
      params: ExportTailwindParams
    ): string {
      const { prefix, include_shades, semantic_names, extend_default } = params;
    
      let config = `/** @type {import('tailwindcss').Config} */\n`;
      config += `module.exports = {\n`;
      config += `  theme: {\n`;
      config += `    ${extend_default ? 'extend: {' : ''}\n`;
      config += `      colors: {\n`;
    
      colors.forEach((color, index) => {
        const name = semantic_names?.[index] || `${prefix}-${index + 1}`;
        const safeName = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
    
        if (include_shades) {
          config += `        '${safeName}': {\n`;
    
          // Generate shade variations
          const shades = generateColorShades(color);
          Object.entries(shades).forEach(([shade, shadeColor]) => {
            config += `          '${shade}': '${shadeColor}',\n`;
          });
    
          config += `        },\n`;
        } else {
          config += `        '${safeName}': '${color.hex}',\n`;
        }
      });
    
      config += `      },\n`;
      config += `    ${extend_default ? '},' : ''}\n`;
      config += `  },\n`;
      config += `  plugins: [],\n`;
      config += `}`;
    
      return config;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions what is generated but lacks details on output format, file creation, error handling, or any side effects. For a tool with 7 parameters and no annotations, this is insufficient to inform the agent adequately.

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 purpose without unnecessary words. It is front-loaded and appropriately sized, making it easy for an agent to parse quickly.

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 (7 parameters, no output schema, and no annotations), the description is incomplete. It doesn't address behavioral aspects, output details, or usage context, which are crucial for an agent to invoke the tool correctly in this environment.

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?

The schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as explaining parameter interactions or use cases. This meets the baseline for high schema coverage.

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 configuration, plugins, and utility classes for color palettes.' It specifies the verb ('generate') and resource ('Tailwind CSS configuration, plugins, and utility classes'), making the function evident. However, it doesn't explicitly differentiate from sibling tools like 'export_css' or 'export_json', which lowers it from a perfect score.

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, context for use, or compare it to sibling tools such as 'export_css' or 'export_json', leaving the agent without clear usage instructions.

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/keyurgolani/ColorMcp'

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