Skip to main content
Glama
reallygood83

UI Expert MCP Server

by reallygood83

generate_design_tokens

Create design token systems for consistent UI styling by defining colors, styles, and dark mode preferences to maintain visual harmony across applications.

Instructions

Generate a comprehensive design token system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
primaryColorNoPrimary brand color
styleYesOverall design style
darkModeNoInclude dark mode tokens

Implementation Reference

  • The primary handler function that generates a complete design token system (colors, typography, spacing, shadows, etc.) based on the provided style and optional parameters.
    function generateDesignTokens(params: z.infer<typeof GenerateDesignTokensSchema>): string {
      const { primaryColor = '#3b82f6', style, darkMode } = params;
      
      const tokens = {
        modern: {
          borderRadius: { sm: '0.375rem', md: '0.5rem', lg: '0.75rem', xl: '1rem' },
          shadow: { sm: '0 1px 2px rgba(0,0,0,0.05)', md: '0 4px 6px rgba(0,0,0,0.07)', lg: '0 10px 15px rgba(0,0,0,0.1)' },
        },
        minimal: {
          borderRadius: { sm: '0', md: '0', lg: '0', xl: '0' },
          shadow: { sm: 'none', md: '0 1px 0 rgba(0,0,0,0.1)', lg: '0 1px 0 rgba(0,0,0,0.1)' },
        },
        corporate: {
          borderRadius: { sm: '0.25rem', md: '0.375rem', lg: '0.5rem', xl: '0.625rem' },
          shadow: { sm: '0 1px 3px rgba(0,0,0,0.12)', md: '0 4px 6px rgba(0,0,0,0.15)', lg: '0 10px 20px rgba(0,0,0,0.15)' },
        },
        playful: {
          borderRadius: { sm: '0.75rem', md: '1rem', lg: '1.5rem', xl: '2rem' },
          shadow: { sm: '0 4px 6px rgba(0,0,0,0.1)', md: '0 8px 12px rgba(0,0,0,0.15)', lg: '0 16px 24px rgba(0,0,0,0.2)' },
        },
        elegant: {
          borderRadius: { sm: '0.125rem', md: '0.25rem', lg: '0.375rem', xl: '0.5rem' },
          shadow: { sm: '0 2px 4px rgba(0,0,0,0.06)', md: '0 4px 8px rgba(0,0,0,0.08)', lg: '0 8px 16px rgba(0,0,0,0.1)' },
        },
      };
    
      const selectedTokens = tokens[style];
    
      return `export const designTokens = {
      colors: {
        primary: {
          50: '${lightenColor(primaryColor, 0.95)}',
          100: '${lightenColor(primaryColor, 0.9)}',
          200: '${lightenColor(primaryColor, 0.8)}',
          300: '${lightenColor(primaryColor, 0.6)}',
          400: '${lightenColor(primaryColor, 0.3)}',
          500: '${primaryColor}',
          600: '${darkenColor(primaryColor, 0.1)}',
          700: '${darkenColor(primaryColor, 0.2)}',
          800: '${darkenColor(primaryColor, 0.3)}',
          900: '${darkenColor(primaryColor, 0.4)}',
        },
        neutral: {
          50: '#f9fafb',
          100: '#f3f4f6',
          200: '#e5e7eb',
          300: '#d1d5db',
          400: '#9ca3af',
          500: '#6b7280',
          600: '#4b5563',
          700: '#374151',
          800: '#1f2937',
          900: '#111827',
        },
        success: {
          50: '#ecfdf5',
          500: '#10b981',
          600: '#059669',
        },
        warning: {
          50: '#fffbeb',
          500: '#f59e0b',
          600: '#d97706',
        },
        error: {
          50: '#fef2f2',
          500: '#ef4444',
          600: '#dc2626',
        },
      },
      
      typography: {
        fontFamily: {
          sans: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
          mono: 'ui-monospace, "Cascadia Mono", "Roboto Mono", monospace',
        },
        fontSize: {
          xs: '0.75rem',
          sm: '0.875rem',
          base: '1rem',
          lg: '1.125rem',
          xl: '1.25rem',
          '2xl': '1.5rem',
          '3xl': '1.875rem',
          '4xl': '2.25rem',
          '5xl': '3rem',
        },
        fontWeight: {
          normal: 400,
          medium: 500,
          semibold: 600,
          bold: 700,
        },
        lineHeight: {
          tight: 1.25,
          normal: 1.5,
          relaxed: 1.75,
        },
      },
      
      spacing: {
        0: '0',
        1: '0.25rem',
        2: '0.5rem',
        3: '0.75rem',
        4: '1rem',
        5: '1.25rem',
        6: '1.5rem',
        8: '2rem',
        10: '2.5rem',
        12: '3rem',
        16: '4rem',
        20: '5rem',
        24: '6rem',
      },
      
      borderRadius: ${JSON.stringify(selectedTokens.borderRadius, null, 2).replace(/"/g, "'")},
      
      boxShadow: ${JSON.stringify(selectedTokens.shadow, null, 2).replace(/"/g, "'")},
      
      transitions: {
        fast: '150ms ease-in-out',
        base: '250ms ease-in-out',
        slow: '350ms ease-in-out',
      },
      
      breakpoints: {
        sm: '640px',
        md: '768px', 
        lg: '1024px',
        xl: '1280px',
        '2xl': '1536px',
      },
    ${darkMode ? `
      
      dark: {
        colors: {
          background: '#0f172a',
          surface: '#1e293b',
          surfaceHover: '#334155',
          text: '#f1f5f9',
          textMuted: '#94a3b8',
          border: '#334155',
        },
      },` : ''}
    };
    
    // CSS custom properties
    export const cssVariables = \`
    :root {
      /* Colors */
      --color-primary: \${designTokens.colors.primary[500]};
      --color-primary-hover: \${designTokens.colors.primary[600]};
      
      /* Typography */
      --font-sans: \${designTokens.typography.fontFamily.sans};
      --font-mono: \${designTokens.typography.fontFamily.mono};
      
      /* Spacing */
      --space-1: \${designTokens.spacing[1]};
      --space-2: \${designTokens.spacing[2]};
      --space-3: \${designTokens.spacing[3]};
      --space-4: \${designTokens.spacing[4]};
      
      /* Shadows */
      --shadow-sm: \${designTokens.boxShadow.sm};
      --shadow-md: \${designTokens.boxShadow.md};
      --shadow-lg: \${designTokens.boxShadow.lg};
      
      /* Transitions */
      --transition-fast: \${designTokens.transitions.fast};
      --transition-base: \${designTokens.transitions.base};
    }\`;`;
    }
  • Zod schema defining the input parameters for the generate_design_tokens tool.
    const GenerateDesignTokensSchema = z.object({
      primaryColor: z.string().optional().describe("Primary brand color in hex format"),
      style: z.enum(["modern", "minimal", "corporate", "playful", "elegant"]).describe("Overall design style"),
      darkMode: z.boolean().optional().describe("Include dark mode tokens"),
    });
  • src/index.ts:76-92 (registration)
    Registration of the tool in the ListTools response, including name, description, and input schema.
    {
      name: "generate_design_tokens",
      description: "Generate a comprehensive design token system",
      inputSchema: {
        type: "object",
        properties: {
          primaryColor: { type: "string", description: "Primary brand color" },
          style: { 
            type: "string", 
            enum: ["modern", "minimal", "corporate", "playful", "elegant"],
            description: "Overall design style" 
          },
          darkMode: { type: "boolean", description: "Include dark mode tokens" },
        },
        required: ["style"],
      },
    },
  • Switch case dispatcher in CallToolRequestSchema handler that validates input and invokes the main generateDesignTokens function.
    case "generate_design_tokens": {
      const parsed = GenerateDesignTokensSchema.parse(args);
      return {
        content: [
          {
            type: "text", 
            text: generateDesignTokens(parsed),
          },
        ],
      };
    }
  • Helper functions for color manipulation used within generateDesignTokens to create color scales.
    function lightenColor(color: string, amount: number): string {
      // Simple color lightening - in production use a proper color library
      return color + Math.round(amount * 100).toString(16);
    }
    
    function darkenColor(color: string, amount: number): string {
      // Simple color darkening - in production use a proper color library
      return color + Math.round((1 - amount) * 100).toString(16);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Generate' implies a creation operation, but the description doesn't disclose whether this creates persistent resources, requires authentication, has rate limits, or what format the output takes. No behavioral traits beyond the basic action are described.

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

Conciseness4/5

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

The description is a single sentence with zero waste - 'Generate a comprehensive design token system' is front-loaded and efficient. However, it's arguably too concise given the lack of behavioral context and usage guidance needed for a generation tool with no annotations.

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?

For a generation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what a 'design token system' entails, what format it returns, whether it's persistent, or how it relates to sibling tools. The 100% schema coverage helps with parameters, but overall context is incomplete for effective tool selection.

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%, so the schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters or how they affect the generated tokens. Baseline 3 is appropriate when schema does the heavy lifting.

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 'Generate a comprehensive design token system' states what the tool does (generate design tokens) but is somewhat vague about scope and output. It doesn't specify what constitutes 'comprehensive' or how this differs from sibling tools like create_component or improve_component. The verb+resource is clear but lacks specificity about the generated artifact.

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. There's no mention of when this tool is appropriate versus analyze_ui, create_component, or improve_component. No context about prerequisites, typical use cases, or exclusions is provided.

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/reallygood83/ui-expert-mcp'

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