01
+get_token
+Lookup by kebab-case name. Returns the enriched entry. mode reduces light/dark fields to one side.
{ "name": "core-color-black", "mode": "dark" }
+ diff --git a/README.md b/README.md index ace40675..8a56417d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,14 @@ Design tokens purpose is to: - **Narrow value set to only needed values.** Design System uses narrow set of values (spacings, colors, typography properties and others). Those are only values that are needed for visual description of the component. - **Keep visual consistency across all components of the library.** +## MCP server (AI coding assistants) + +This repo ships a Model Context Protocol server that lets AI coding +assistants query the design tokens — with both light and dark values, +the source `$description` context, and the resolved alias/layer chain. +See [`mcp/README.md`](./mcp/README.md) for what it does, how to run it, +and what its hardening guarantees. + ## Docs: - [Generating icons](./docs/icons.md) diff --git a/docs/mcp-demo.html b/docs/mcp-demo.html new file mode 100644 index 00000000..c38013d7 --- /dev/null +++ b/docs/mcp-demo.html @@ -0,0 +1,1043 @@ + + + +
+ + + +Index · 10 slides
+Space or Esc to close · click any tile · or use ← →
+A model context protocol server
+Light and dark values · source $description · resolved alias and layer chains. Built into the repo, ready for the upstream PR.
01 · Motivation
+An earlier external wrapper consumed only the published js/common export — flat key → value pairs. Three structural deficiencies drove the rewrite. Each is solved at the root.
A flat name-keyed index collides between modes. dark overwrites light during indexing — the light category vanishes. Fixed by merging both modes into one entry with value:{light,dark}.
Published dist outputs strip $description. The source data/tokens/ has it; the npm package doesn't ship those files. Building from source restores it — ${withDescription} tokens now carry their description.
The four-layer architecture (core → global → mode → component) and alias references live only in source. A new custom/json-enriched style-dictionary format keeps the references; the MCP exposes them as a resolved refChain.
02 · Architecture
+Source
+data/tokens/*.json
+ DTCG · $description · aliases · four layers
Artefact
+dist/mcp/tokens.json
+ Enriched · light + dark merged · refChain resolved
+Server
+mcp/server.js
+ Thin wrapper · @modelcontextprotocol/sdk · stdio
Consumer
+AI coding assistant
+ Claude Code · Cursor · any MCP client
+03 · Anatomy
+A real entry from dist/mcp/tokens.json — button-typical-primary-bg-default.
${jsonPretty(sampleToken)}
+ {light, dark} when the modes diverge.04 · Tools
+01
+Lookup by kebab-case name. Returns the enriched entry. mode reduces light/dark fields to one side.
{ "name": "core-color-black", "mode": "dark" }
+ 02
+Multi-word substring search. Optional category and layer filters.
{ "query": "button primary", "layer": "component" }
+ 03
+Every category with counts. Use it before searching to see what's available.
+{}
+ 04
+All tokens in a category — including their description where present.
+{ "category": "button", "limit": 50 }
+ 05 · Snapshot
+Numbers as of ${esc(branch)} · ${esc(commit)}
${totalTokens.toLocaleString("en-GB")}
+tokens served
+$description from the source
+ By layer
+ ${(() => { + const max = Math.max(...Object.values(byLayer)); + return Object.entries(byLayer).sort((a,b)=>b[1]-a[1]).map(([k,v]) => { + const pct = Math.round((v / max) * 100); + return `06 · Hardening
+Every token satisfies the schema; every alias chain terminates at a literal; every --var in dist/css/* exists as a token; values match for resolved layers.
Null, empty, oversized, Unicode, negative-limit inputs never crash. Response shapes stay stable.
Realistic multi-word queries, mode reduction, layer filters, alias-chain visibility — all return meaningful results.
The server is spawned as a subprocess and driven through the real wire protocol via @modelcontextprotocol/sdk Client.
No host-absolute paths, no legacy references, README sections present, sub-package reproducible, build runs without secrets.
07 · Use it
+npm install
+npm run build
+(cd mcp && npm install)
+ For Claude Code, add to ~/.claude.json under mcpServers:
"sage-design-tokens": {
+ "type": "stdio",
+ "command": "node",
+ "args": ["<absolute path>/mcp/server.js"]
+}
+ 08 · Roadmap
+Now
+The enriched build format and the server live inside @sage/design-tokens behind a feature branch. Fully hardened, self-contained. Consumers clone the repo and wire the server into their MCP client.
Next
+Contribute the custom/json-enriched format and the server entry point upstream to @sage/design-tokens. After acceptance, the MCP ships with the package and downstream consumers use it without cloning.
Ready when you are
+mcp/README.mdmcp/REPORT.mddocs/superpowers/specs/2026-05-27-…docs/superpowers/specs/2026-05-28-mcp-hardening-design.mdscripts/verify-fresh-clone.shIndex · ${slides.length} slides
+Space or Esc to close · click any tile · or use ← →
+