design-tokens-mcp

design-tokens-mcp

Manages design tokens (colors, spacing, fonts) in a JSON file and enables agents to read, write, export, and detect drift between tokens and CSS via MCP.

Category
Visit Server

README

design-tokens-mcp-server

デザイントークン(色・余白・フォント)を1つのJSONファイルで管理し、MCP経由でエージェントに読み書き・書き出し・ドリフト検知をさせる最小構成のMCPサーバーです。

FigmaのMCPサーバー+Skillエコシステムで注目される「デザイントークンをコードとデザインの間で同期し、ずれ(ドリフト)を検知する」というワークフローを、Figma契約なしで体験できる教材として実装しています。

できること

サーバーは5つのツールを公開します。

ツール 内容
tokens_list トークン一覧(type / 名前プレフィックスで絞り込み可)
tokens_get 1件取得。名前が違うときは近い候補を提示
tokens_set 追加・更新。型ごとに値を検証(colorはhex、dimensionは単位付き数値など)
tokens_export css / tailwind / figma-variables 形式で書き出し
tokens_check_drift CSSファイル内のハードコードされた色・px値をトークンと照合し、ずれを最寄りトークン付きで報告

トークンファイルはW3C Design Tokens(DTCG)風の $type / $value 形式です。tokens.example.json を参照してください。

動作要件

  • Node.js 18以上(動作確認は v22)

セットアップ

git clone <このリポジトリのURL>
cd design-tokens-mcp
npm install
npm run build
npm test

npm test はビルド済みサーバーをstdioで起動し、5ツールすべて(バリデーションエラーとドリフト検知を含む16項目)を検証します。すべてPASSすれば準備完了です。

Claude Codeへの登録

claude mcp add design-tokens \
  --env TOKENS_FILE=/絶対パス/tokens.json \
  -- node /絶対パス/design-tokens-mcp/dist/index.js

TOKENS_FILE を省略するとカレントディレクトリの tokens.json を使います。初回は tokens.example.json をコピーして始めてください。

cp tokens.example.json tokens.json

他のMCPクライアント(Cursor等)でも、stdioサーバーとして node dist/index.js を登録すれば動きます。

使用例

エージェントへの指示例:

  • 「トークン一覧を見せて」→ tokens_list
  • 「spacing.xl を 32px で追加して」→ tokens_set(32 だけを渡すと単位がないためエラーになり、修正方法が返ります)
  • 「トークンをCSS変数に書き出して styles/tokens.css に保存して」→ tokens_export
  • 「src/app.css がトークンからずれていないか調べて」→ tokens_check_drift

ドリフト検知の出力例(実際の実行結果):

{
  "checked_file": "/tmp/sample.css",
  "matched": 2,
  "drift_count": 2,
  "drift": [
    {
      "value": "#0e7a6f",
      "line": 3,
      "kind": "color",
      "nearest_token": "color.primary",
      "nearest_value": "#0F766E"
    },
    {
      "value": "23px",
      "line": 5,
      "kind": "dimension",
      "nearest_token": "spacing.lg",
      "nearest_value": "24px"
    }
  ]
}

設計メモ

Anthropicのmcp-builderスキルの指針に沿っています。

  • ツール名はサービス接頭辞付きのsnake_case(tokens_list など)
  • 入力はZodスキーマで検証し、制約違反時は「次に何をすべきか」を含むエラーメッセージを返す
  • 読み取り系ツールには readOnlyHint / idempotentHint のannotationsを付与
  • 出力は structuredContent(構造化データ)とテキストの両方で返す

ライセンス

MIT License. 詳細は LICENSE を参照してください。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured