Skip to main content
Glama

get_colors

Retrieve color palettes with hex and RGB values, usage guidelines, and semantic role filters for marketing or product contexts. Choose output format: JSON, CSS, SCSS, or Tailwind.

Instructions

Get the color palette with hex values, RGB values, usage guidelines, and semantic roles. Supports context filtering (marketing vs product) and output format selection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoDesign context to queryall
roleNoFilter by semantic role: primary, secondary, accent, neutral, error, success, warning, info
formatNoOutput formatjson

Implementation Reference

  • The main handler function for the get_colors tool. It resolves the design context, filters colors by optional role, and returns colors in the requested format (JSON, CSS, SCSS, or Tailwind).
    export function handler(index: DesignSystemIndex, args: GetColorsArgs) {
      const ctx = args.context ?? 'all';
      const resolved = ctx === 'all' ? index.resolved.all :
        ctx === 'marketing' ? index.resolved.marketing :
        ctx === 'product' ? index.resolved.product :
        index.resolved.all;
    
      let colors = resolved.colors;
    
      if (args.role) {
        colors = colors.filter((c) => c.role?.toLowerCase() === args.role!.toLowerCase());
      }
    
      if (colors.length === 0) {
        return [{ type: 'text' as const, text: `No colors found${args.role ? ` with role "${args.role}"` : ''} in ${ctx} context.` }];
      }
    
      switch (args.format) {
        case 'css':
          return [{ type: 'text' as const, text: colorsToCSSFormat(colors) }];
        case 'scss':
          return [{ type: 'text' as const, text: colorsToSCSSFormat(colors) }];
        case 'tailwind':
          return [{ type: 'text' as const, text: colorsToTailwindFormat(colors) }];
        default:
          return [{ type: 'text' as const, text: JSON.stringify(colors, null, 2) }];
      }
    }
  • The input schema for the get_colors tool, specifying the context (marketing/product/shared/all), role filter, and output format (json/css/scss/tailwind) parameters.
    export const INPUT_SCHEMA = {
      type: 'object' as const,
      properties: {
        context: { type: 'string', enum: ['marketing', 'product', 'shared', 'all'], default: 'all', description: 'Design context to query' },
        role: { type: 'string', description: 'Filter by semantic role: primary, secondary, accent, neutral, error, success, warning, info' },
        format: { type: 'string', enum: ['json', 'css', 'scss', 'tailwind'], default: 'json', description: 'Output format' },
      },
    };
  • The TypeScript interface `GetColorsArgs` defining the typed arguments for the get_colors tool handler.
    export interface GetColorsArgs {
      /** Filter colors to a specific design context */
      context?: 'marketing' | 'product' | 'shared' | 'all';
    
      /** Filter by semantic role (e.g. "primary", "secondary", "accent") */
      role?: string;
    
      /** Output format for the color list */
      format?: 'json' | 'css' | 'scss' | 'tailwind';
    }
  • Registers all MCP tools including get_colors. The tool is imported as 'colors' from './get-colors.js'. It is listed in ALL_TOOLS (line 38) and wired to the CallToolRequestSchema handler (line 80-81) where `colors.handler` is invoked with the index and parsed args.
    export function registerAllTools(
      server: Server,
      getIndex: () => DesignSystemIndex,
    ): void {
      // ---- Tools --------------------------------------------------------------
    
      server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: ALL_TOOLS.map((t) => ({
          name: t.TOOL_NAME,
          description: t.TOOL_DESCRIPTION,
          inputSchema: t.INPUT_SCHEMA,
        })),
      }));
    
      server.setRequestHandler(CallToolRequestSchema, async (request) => {
        const { name, arguments: args = {} } = request.params;
        const index = getIndex();
    
        try {
          switch (name) {
            case brandOverview.TOOL_NAME:
              return { content: brandOverview.handler(index) };
            case colors.TOOL_NAME:
              return { content: colors.handler(index, args as never) };
            case typography.TOOL_NAME:
              return { content: typography.handler(index, args as never) };
            case logos.TOOL_NAME:
              return { content: await logos.handler(index, args as never) };
            case components.TOOL_NAME:
              return { content: components.handler(index, args as never) };
            case guidelines.TOOL_NAME:
              return { content: guidelines.handler(index, args as never) };
            case tokens.TOOL_NAME:
              return { content: tokens.handler(index, args as never) };
            case textures.TOOL_NAME:
              return { content: textures.handler(index, args as never) };
            case css.TOOL_NAME:
              return { content: css.handler(index, args as never) };
            case searchBrand.TOOL_NAME:
              return { content: searchBrand.handler(index, args as never) };
            case contextDiff.TOOL_NAME:
              return { content: contextDiff.handler(index, args as never) };
            case validateUsage.TOOL_NAME:
              return { content: validateUsage.handler(index, args as never) };
            default:
              return {
                content: [{ type: 'text' as const, text: `Unknown tool: ${name}` }],
                isError: true,
              };
          }
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          return {
            content: [{ type: 'text' as const, text: `Error executing ${name}: ${message}` }],
            isError: true,
          };
        }
      });
    
      // ---- Resources ----------------------------------------------------------
    
      server.setRequestHandler(ListResourcesRequestSchema, async () => ({
        resources: listResources(getIndex()),
      }));
    
      server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
        return readResource(request.params.uri, getIndex());
      });
    
      // ---- Prompts ------------------------------------------------------------
    
      server.setRequestHandler(ListPromptsRequestSchema, async () => ({
        prompts: listPrompts(),
      }));
    
      server.setRequestHandler(GetPromptRequestSchema, async (request) => {
        return getPrompt(request.params.name, request.params.arguments ?? {}, getIndex());
      });
    }
  • Helper formatter that converts DesignColor[] to CSS custom properties format, used when format='css'.
    export function colorsToCSSFormat(colors: DesignColor[]): string {
      if (colors.length === 0) return '/* No colors defined */';
      const lines = colors.map((c) => `  ${c.token}: ${c.value};`);
      return `:root {\n${lines.join('\n')}\n}`;
    }
  • Helper formatter that converts DesignColor[] to SCSS variable declarations, used when format='scss'.
    export function colorsToSCSSFormat(colors: DesignColor[]): string {
      if (colors.length === 0) return '// No colors defined';
      return colors
        .map((c) => {
          const varName = c.token.replace(/^--/, '$');
          return `${varName}: ${c.value};`;
        })
        .join('\n');
    }
  • Helper formatter that converts DesignColor[] to a Tailwind CSS theme extension JSON object, used when format='tailwind'.
    export function colorsToTailwindFormat(colors: DesignColor[]): string {
      const colorMap: Record<string, string | Record<string, string>> = {};
    
      for (const c of colors) {
        const key = c.token
          .replace(/^--color-/, '')
          .replace(/^--/, '');
    
        // Handle nested keys like "primary-light" -> { primary: { light: value } }
        const parts = key.split('-');
        if (parts.length === 1) {
          colorMap[parts[0]] = c.value;
        } else {
          const group = parts[0];
          const variant = parts.slice(1).join('-');
          if (typeof colorMap[group] === 'string') {
            colorMap[group] = { DEFAULT: colorMap[group] as string, [variant]: c.value };
          } else if (typeof colorMap[group] === 'object') {
            (colorMap[group] as Record<string, string>)[variant] = c.value;
          } else {
            colorMap[group] = { [variant]: c.value };
          }
        }
      }
    
      return JSON.stringify({ theme: { extend: { colors: colorMap } } }, null, 2);
    }
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. It discloses basic return contents (hex, RGB, guidelines, roles) and filtering options, but does not mention any behavioral traits like data source, caching, read-only semantics, or error scenarios.

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?

Two concise sentences, front-loaded with core purpose, then additional capabilities. Every sentence adds value without redundancy.

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

Completeness4/5

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

Given no required parameters, no output schema, and no annotations, the description adequately covers the tool's output and filtering options. It lacks details on return structure or error handling, but is sufficient for a simple retrieval tool.

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 coverage is 100%, so the baseline is 3. The description adds context about filtering ('marketing vs product') and output format selection, but does not significantly enhance meaning beyond the schema descriptions.

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

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves the color palette with specific elements (hex, RGB, usage guidelines, semantic roles). It distinguishes from siblings like get_tokens and get_typography by focusing on color-specific data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for retrieving color palette with optional filtering, but does not explicitly mention when to use this over alternatives (e.g., get_tokens) or provide 'when not to use' guidance.

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/ejwhite7/brandkit-mcp'

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