Skip to main content
Glama

get_token

Look up a specific design token by name and optional category to retrieve its value and type. Use when you know the token name and need its details.

Instructions

Look up a specific design token by name. Read-only, no side effects. Returns the token's name, value, and category, or an error if not found. Pass category to narrow search: colors, spacing, typography, borderRadius, shadows. Pass empty string to search all. Use this when you know the token name. For a broad overview of all tokens, use get_design_context with category 'tokens' instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
categoryYes

Implementation Reference

  • Handler function for get_token tool. Looks up a token by name (and optional category) in the contract's token map, iterating over categories if none specified.
    async (args) => {
      if (!this.contract) return this.noContract()
      const categories = args.category ? [args.category] : Object.keys(this.contract.tokens)
      for (const cat of categories) {
        const tokens = this.contract.tokens[cat]
        if (tokens?.[args.name]) {
          return this.json({ ...tokens[args.name], category: cat })
        }
      }
      return this.err(
        `Token '${args.name}' not found. Use get_design_context with category 'tokens' to see all available tokens.`
      )
    }
  • Schema and description for get_token. Defines input as name (string) and category (string).
    {
      description:
        "Look up a specific design token by name. Read-only, no side effects. Returns the token's name, value, and category, or an error if not found. Pass category to narrow search: colors, spacing, typography, borderRadius, shadows. Pass empty string to search all. Use this when you know the token name. For a broad overview of all tokens, use get_design_context with category 'tokens' instead.",
      inputSchema: {
        name: z.string(),
        category: z.string()
      }
  • Registration of the get_token tool on the MCP server via registerTool.
    this.server.registerTool(
      "get_token",
      {
        description:
          "Look up a specific design token by name. Read-only, no side effects. Returns the token's name, value, and category, or an error if not found. Pass category to narrow search: colors, spacing, typography, borderRadius, shadows. Pass empty string to search all. Use this when you know the token name. For a broad overview of all tokens, use get_design_context with category 'tokens' instead.",
        inputSchema: {
          name: z.string(),
          category: z.string()
        }
      },
      async (args) => {
        if (!this.contract) return this.noContract()
        const categories = args.category ? [args.category] : Object.keys(this.contract.tokens)
        for (const cat of categories) {
          const tokens = this.contract.tokens[cat]
          if (tokens?.[args.name]) {
            return this.json({ ...tokens[args.name], category: cat })
          }
        }
        return this.err(
          `Token '${args.name}' not found. Use get_design_context with category 'tokens' to see all available tokens.`
        )
      }
    )
  • Helper function err() used by the handler to return an error response when token is not found.
    private err(msg: string) {
      return { content: [{ type: "text" as const, text: msg }], isError: true as const }
    }
  • Helper function json() used by the handler to return a successful token result as formatted JSON.
    private json(v: unknown) {
      return this.text(JSON.stringify(v, null, 2))
    }
Behavior5/5

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

Since no annotations are provided, the description fully addresses behavioral traits: 'Read-only, no side effects. Returns the token's name, value, and category, or an error if not found.' This is comprehensive and accurate.

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 four sentences, front-loaded with the primary purpose, and each sentence adds essential information without redundancy. No filler or unnecessary details.

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

Completeness5/5

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

Given the tool has two parameters, no output schema, and no annotations, the description covers purpose, usage, parameter details, side effects, and error behavior, providing complete context for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It explains the 'category' parameter (acceptable values and empty string for all) and implicitly describes 'name' as the token name. While helpful, it could be more explicit about the format of 'name'.

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 explicitly states 'Look up a specific design token by name', providing a clear verb and resource. It distinguishes itself from the sibling tool 'get_design_context' by specifying when to use each, ensuring no ambiguity.

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

Usage Guidelines5/5

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

The description gives direct guidance: 'Use this when you know the token name. For a broad overview of all tokens, use get_design_context with category 'tokens' instead.' It also explains how to optionally narrow search by category, making usage clear.

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/AI-by-design/primitiv'

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