list_tokens
List Aurum design tokens by category such as color, spacing, or typography, or get a summary of all categories with token counts.
Instructions
List Aurum design tokens by category: color (semantic + visual palette), spacing, radius, borderWidth, iconSize, elevation, typography. Omit category to get a summary of all categories with counts. Pass a category for the full table.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Token category to expand. Omit for a summary across all categories. |
Implementation Reference
- src/tools/list-tokens.ts:25-97 (handler)The async handler function that executes the list_tokens tool logic. It either returns a summary of all token categories (when no category arg is given) or a detailed markdown table for a specific category (color, spacing, radius, borderWidth, iconSize, elevation, typography).
async handler(manifest, args) { const category = args.category as TokenCategory | undefined; if (!category) { const t = manifest.tokens; const semCount = Object.values(t.color.semantic).reduce((a, b) => a + b.length, 0); const visCount = Object.values(t.color.visual).reduce((a, b) => a + b.length, 0); const lines: string[] = [ "# Aurum tokens (summary)", "", `- **color.semantic**: ${semCount} swatches across ${Object.keys(t.color.semantic).length} groups`, `- **color.visual**: ${visCount} swatches across ${Object.keys(t.color.visual).length} families`, `- **spacing**: ${t.spacing.length} steps`, `- **radius**: ${t.radius.length} steps`, `- **borderWidth**: ${t.borderWidth.length} steps`, `- **iconSize**: ${t.iconSize.length} steps`, `- **elevation**: ${t.elevation.length} levels`, `- **typography**: ${t.typography.length} roles`, "", "Call `list_tokens({ category: \"...\" })` for a specific table.", ]; return { content: [{ type: "text", text: withFooter(manifest, lines.join("\n")) }] }; } const lines: string[] = [`# Aurum tokens · ${category}`, ""]; if (category === "color") { lines.push("## Semantic colours"); lines.push(""); for (const group of Object.keys(manifest.tokens.color.semantic).sort()) { const swatches = manifest.tokens.color.semantic[group]; lines.push(`### ${group} (${swatches.length})`); lines.push(""); lines.push(mdTable([ ["name", "hex", "alpha", "figma path"], ...swatches.map((s) => [`\`${s.name}\``, `\`${s.hex}\``, s.alpha === 1 ? "1" : s.alpha.toFixed(2), `\`${s.path}\``]), ])); lines.push(""); } lines.push("## Visual palette"); lines.push(""); for (const family of Object.keys(manifest.tokens.color.visual).sort()) { const swatches = manifest.tokens.color.visual[family]; lines.push(`### ${family} (${swatches.length})`); lines.push(""); lines.push(mdTable([ ["name", "hex"], ...swatches.map((s) => [`\`${s.name}\``, `\`${s.hex}\``]), ])); lines.push(""); } } else if (category === "elevation") { lines.push(mdTable([ ["name", "offsetY (dp)", "blur (dp)", "tint"], ...manifest.tokens.elevation.map((e) => [`\`${e.name}\``, e.offsetY.toString(), e.blur.toString(), `\`${e.tintName}\``]), ])); } else if (category === "typography") { lines.push(mdTable([ ["name", "size (sp)", "lineHeight (sp)", "weight", "family"], ...manifest.tokens.typography.map((t) => [`\`${t.name}\``, t.sizeSp.toString(), t.lineHeightSp.toString(), t.weight, t.family]), ])); } else { // spacing | radius | borderWidth | iconSize — all DimensionToken const items = manifest.tokens[category]; lines.push(mdTable([ ["name", "dp", "comment"], ...items.map((d) => [`\`${d.name}\``, d.dp.toString(), d.comment ?? ""]), ])); } return { content: [{ type: "text", text: withFooter(manifest, lines.join("\n")) }] }; }, }; - src/tools/list-tokens.ts:14-24 (schema)The inputSchema for list_tokens, defining an optional 'category' property with an enum of valid token categories.
inputSchema: { type: "object", properties: { category: { type: "string", enum: ALL_CATEGORIES, description: "Token category to expand. Omit for a summary across all categories.", }, }, additionalProperties: false, }, - src/tools/index.ts:36-46 (registration)The tool registry where listTokensTool is listed in the tools array, making it available for dispatch.
export const tools: ToolDef[] = [ listComponentsTool, getComponentTool, listTokensTool, searchIconsTool, getIconTool, getChangelogTool, lookupFigmaNodeTool, searchTool, getAurumVersionTool, ]; - src/tools/index.ts:28-28 (registration)The import statement that pulls listTokensTool into the tool registry.
import { listTokensTool } from "./list-tokens.js";