npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@formtrieb/tokens-mcp

v2.2.0

Published

MCP server exposing Tokens-Studio-shaped design token systems to LLM clients — browse, resolve, theme compose/compare, validation. Per-call tokens_path with walk-up auto-detection and mtime-aware LRU cache for live brand iteration.

Readme

@formtrieb/tokens-mcp

MCP server exposing Tokens-Studio-shaped design token systems to LLM clients — browse, resolve, theme compose/compare, validation. Per-call tokens_path with walk-up auto-detection and mtime-aware LRU cache for live brand iteration.

This package is a thin MCP adapter over @formtrieb/tokens-core. The 10 tools below let an LLM client (Claude Desktop, MCP Inspector, custom runtimes) inspect a Tokens-Studio workspace, resolve token references through theme composition, compare themes, and audit the system for placeholders or broken references.

Status

v2.0.0 — initial public release. Hard-break vs. private [email protected]. Three structural changes power the new surface:

  1. Per-call tokens_path — every tool accepts an optional tokens_path parameter; walk-up from process.cwd() resolves it when omitted. The old startup-load via TOKENS_PATH env var is deprecated (still works, emits console.warn).
  2. Stateless tools — no global set_tokens_path initialization; each call resolves its context independently. One MCP process can serve multiple token directories.
  3. mtime-aware LRU cache — the same path stays cached across calls (capacity 8); any .json file mtime change in the tree evicts and reloads. Edits flow through to the next tool call without restart.

License: Apache-2.0. Requires Node ≥ 20.

Install + configure

The recommended path is per-project .mcp.json via npx:

{
  "mcpServers": {
    "formtrieb-tokens": {
      "command": "npx",
      "args": ["-y", "@formtrieb/tokens-mcp"]
    }
  }
}

That's it. The walk-up resolver finds tokens/ automatically when you work in any subdirectory of a project that contains a Tokens-Studio workspace (i.e. a tokens/ directory with $metadata.json at its root).

Path resolution order

Every tool resolves tokens_path through three layers, first match wins:

  1. Explicit argument{ tokens_path: "/abs/path/to/tokens" }. Always wins. Use when working with multiple DSes in one session.
  2. Walk-up from cwd — climbs from process.cwd() looking for tokens/$metadata.json. First match wins (closest to cwd).
  3. TOKENS_PATH env var — deprecated bridge from v1.0.0. Emits console.warn("DEPRECATED: TOKENS_PATH …"). Will be removed in 3.0.0.

If all three are empty, the tool throws an Error listing the three paths it tried.

Standalone install

For non-MCP usage (testing, scripting):

npm install -g @formtrieb/tokens-mcp
tokens-mcp  # launches the stdio server

Tools

| Tool | Purpose | |------|---------| | list_token_sets | List all sets in order with layer + token count. Read-only overview. | | list_themes | List all themes grouped by axis (Semantic, Device, Shape, Theme, …). Discover valid values for theme: arguments. | | browse_tokens | Browse tokens as a nested tree, filterable by set, path-prefix, DTCG $type. Configurable depth. | | search_tokens | Case-insensitive substring search across token dot-paths. Up to 100 results. | | resolve_token | Resolve a single dot-path to its computed value for a given theme, returning the full reference chain. | | resolve_batch | Resolve multiple dot-paths in one call. Useful for a variant's full state matrix. | | compose_theme | Show which token sets are active (enabled vs. source) for a given axis selection. | | compare_themes | Diff resolved values between two theme configurations. Caps: 200 changed paths, 50 per only-in-A/B list. | | find_placeholders | List all #f305b7/#ff00ff placeholder tokens. Audit token completeness. | | check_design_rules | Run controls/component-reference + naming + broken-reference + Light/Dark parity checks. Reports violations grouped by rule. |

Every tool accepts an optional tokens_path: string parameter (omit for walk-up).

Brand-iteration loop

The single biggest UX win in 2.0.0 is the live edit loop. With v1.0.0 you had to restart the MCP server every time you touched a token file. With 2.0.0:

  1. Ask Claude to resolve a brand token: "What's color.controls.brand.background.enabled in Light mode?"
  2. Claude calls resolve_token → returns current value via cache.
  3. Edit your token JSON file (via the Tokens Studio Figma plugin or any editor).
  4. Ask Claude to resolve again. The mtime-walk on the next call detects the change, evicts the cache, reloads the tree. New value returned.

No restart. No path argument needed. Cost of the per-call mtime walk is ~5–15 ms on typical DS sizes (verified via perf-smoke test).

Migrating from v1.0.0

| Before (v1.0.0) | After (v2.0.0) | |---|---| | TOKENS_PATH=/abs/path env var, loaded once at startup | Walk-up auto-detect from cwd; or pass tokens_path per call. ENV var still works with a deprecation warning. | | Server restart needed after token-file edits | mtime-aware cache reloads on next call. | | One MCP process = one DS | One process can serve any number of DSes (LRU cap 8). | | Package: formtrieb-tokens-mcp (private) | Package: @formtrieb/tokens-mcp (public, npm). |

If you have an existing .mcp.json that points at this package, dropping the env block is the only required change:

 {
   "mcpServers": {
     "tokens": {
       "command": "npx",
-      "args": ["tsx", "packages/tokens-mcp/src/index.ts"],
-      "env": {
-        "TOKENS_PATH": "./tokens"
-      }
+      "args": ["-y", "@formtrieb/tokens-mcp"]
     }
   }
 }

Relationship to other packages

| Package | Role | |---|---| | @formtrieb/tokens-core | Pure-function library for parsing + resolving + composing Tokens-Studio workspaces. This MCP server is a thin wrapper. | | @formtrieb/cdf-mcp | Component Description Format MCP. Independent product. Use both side-by-side in a single Claude session if you author components against tokens. |

Format support

Currently TS-shape only — Tokens Studio JSON workspaces with $metadata.json + $themes.json + per-set *.json files. DTCG-flat (single tokens.json with $value/$type leaves) is a 2.1.0 candidate.

Development

pnpm install
pnpm --filter @formtrieb/tokens-mcp build
pnpm --filter @formtrieb/tokens-mcp test

License

Apache-2.0