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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| category | Yes |
Implementation Reference
- src/mcp/server.ts:217-229 (handler)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.` ) } - src/mcp/server.ts:209-215 (schema)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() } - src/mcp/server.ts:207-230 (registration)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.` ) } ) - src/mcp/server.ts:115-117 (helper)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 } } - src/mcp/server.ts:111-113 (helper)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)) }