Skip to content

feat(nimbus-mcp): implement get_tokens tool#1249

Open
valoriecarli wants to merge 4 commits intomainfrom
CRAFT-2135-implement-get-tokens-tool
Open

feat(nimbus-mcp): implement get_tokens tool#1249
valoriecarli wants to merge 4 commits intomainfrom
CRAFT-2135-implement-get-tokens-tool

Conversation

@valoriecarli
Copy link
Collaborator

@valoriecarli valoriecarli commented Mar 12, 2026

Summary

  • Adds get_tokens MCP tool with three modes: list categories, filter by category, and reverse-lookup by value
  • Large categories (> 55 tokens, e.g. color) are summarized to 20 tokens by default; the limit param controls how many are returned
  • Includes 15 behavioral tests covering all acceptance criteria from the ticket

Closes CRAFT-2135

Test plan

  • get_tokens() returns all categories with counts, sorted alphabetically
  • get_tokens(category: "spacing") returns spacing tokens including spacing.400 = 16px
  • get_tokens(category: "color") returns a 20-token summary with a note (total > 55)
  • get_tokens(category: "color", limit: 5) returns exactly 5 tokens
  • get_tokens(value: "16px") returns an array containing spacing.400
  • get_tokens(value: "#FEFDFB") case-insensitively resolves to a color token
  • get_tokens(category: "nonexistent") returns isError: true

🤖 Generated with Claude Code

Adds a new `get_tokens` MCP tool that provides three modes:
- No params: lists all token categories with counts
- category param: returns tokens in that category (large categories like color are summarised to 20 tokens by default, controllable via limit param)
- value param: reverse-lookup to find which tokens resolve to a given value (e.g. "16px" → spacing.400)

Includes 15 behavioural tests covering all acceptance criteria.

CRAFT-2135

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nimbus-documentation Ready Ready Preview, Comment Mar 12, 2026 8:24pm
nimbus-storybook Ready Ready Preview, Comment Mar 12, 2026 8:24pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: 4faaa4f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

import { getFlatTokenData, reverseLookup } from "../data-loader.js";

/** Threshold above which a category is considered "large". */
const LARGE_CATEGORY_THRESHOLD = 55;
Copy link
Collaborator Author

@valoriecarli valoriecarli Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 55? size has 54 tokens, while color has 1034.
54 was a weird number.

Copy link
Contributor

@tylermorrisford tylermorrisford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests pass, manual inspection tests pass, we'll clean up types later, I bestow my approval 🪄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants