Skip to main content
Glama

get_tokens

Export design tokens as CSS custom properties, SCSS variables, Tailwind config, W3C or JSON. Specify context and category for targeted output.

Instructions

Export design tokens in a specific format: CSS custom properties, SCSS variables, Tailwind config, W3C Design Tokens format, or JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoDesign context to queryall
formatYesOutput format (required)
categoryNoToken category to exportall

Implementation Reference

  • The handler function that executes the get_tokens tool logic. It resolves the design context, filters by category (colors/typography), and delegates to the appropriate formatter (CSS, SCSS, Tailwind, W3C, or JSON).
    export function handler(index: DesignSystemIndex, args: GetTokensArgs) {
      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;
    
      const colors = args.category === 'typography' ? [] : resolved.colors;
      const typography = args.category === 'colors' ? [] : resolved.typography;
    
      let output: string;
      switch (args.format) {
        case 'css':
          output = toCSSFormat(colors, typography);
          break;
        case 'scss':
          output = toSCSSFormat(colors, typography);
          break;
        case 'tailwind':
          output = toTailwindFormat(colors, typography);
          break;
        case 'w3c':
          output = toW3CFormat(colors, typography);
          break;
        case 'json':
        default:
          output = toJSONFormat(colors, typography);
          break;
      }
    
      return [{ type: 'text' as const, text: output }];
    }
  • Input schema for the get_tokens tool, defining the context, format (required), and category parameters with their allowed values.
    export const INPUT_SCHEMA = {
      type: 'object' as const,
      properties: {
        context: { type: 'string', enum: ['marketing', 'product', 'shared', 'all'], default: 'all', description: 'Design context to query' },
        format: { type: 'string', enum: ['css', 'scss', 'tailwind', 'w3c', 'json'], description: 'Output format (required)' },
        category: { type: 'string', enum: ['colors', 'typography', 'all'], default: 'all', description: 'Token category to export' },
      },
      required: ['format'],
    };
  • TypeScript type definition (GetTokensArgs) for the get_tokens tool arguments, with typed context, format, and category fields.
    export interface GetTokensArgs {
      /** Filter tokens to a specific design context */
      context?: 'marketing' | 'product' | 'shared' | 'all';
    
      /**
       * Output format:
       * - "css": CSS custom properties
       * - "scss": SCSS variables
       * - "tailwind": Tailwind CSS theme extension
       * - "w3c": W3C Design Tokens Community Group format
       * - "json": Plain JSON key-value pairs
       */
      format: 'css' | 'scss' | 'tailwind' | 'w3c' | 'json';
    
      /** Restrict output to a specific token category */
      category?: 'colors' | 'typography' | 'spacing' | 'all';
    }
  • Registration of the get_tokens tool in the request handler switch statement, dispatching calls to tokens.handler(index, args).
    case tokens.TOOL_NAME:
      return { content: tokens.handler(index, args as never) };
  • The tokens module is included as one of the ALL_TOOLS in the registration list (line 43), and imported as 'import * as tokens from './get-tokens.js' (line 25).
      tokens,
      textures,
      css,
      searchBrand,
      contextDiff,
      validateUsage,
    ] as const;
Behavior3/5

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

Without annotations, the description carries the burden. It implies a read-only export but does not explicitly state side effects, permissions, or rate limits. The behavior is adequately suggested but not fully transparent.

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 that efficiently conveys the core purpose and key options. However, it is somewhat dense and could benefit from slight restructuring for readability.

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

Completeness3/5

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

The description covers the input parameters but fails to describe the output format or response structure, especially given the absence of an output schema. For a simple export tool, it is adequate but not complete.

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 description adds minimal new meaning beyond the parameter descriptions. It repeats the format options but does not clarify when each is appropriate or how to use them.

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 exports design tokens and lists the supported output formats (CSS, SCSS, Tailwind, W3C, JSON). This distinguishes it from sibling tools like get_css or get_colors, which focus on specific subsets.

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 does not provide guidance on when to use this tool versus alternatives, nor does it explain which format to choose or any prerequisites. The agent receives no usage context beyond the format list.

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