A production-ready Model Context Protocol (MCP) server for managing CSS Custom Properties (design tokens). This server enables AI assistants and other MCP clients to read, query, search, and update design tokens from CSS files.
- 📖 Read CSS Custom Properties - Automatically parses CSS files to extract all design tokens
- 🔍 Query Specific Tokens - Retrieve individual token values by name
- 📋 List All Tokens - View all available tokens with optional category filtering
- 🔎 Search Functionality - Find tokens by name or value patterns
- ✏️ Update Tokens - Modify token values and persist changes back to CSS files
- ⚡ Production-Ready - Comprehensive error handling and validation
npm installnpm startOr make the file executable and run directly:
chmod +x index.js
./index.jsAdd this server to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"design-tokens": {
"command": "node",
"args": ["/path/to/design-tokens-mcp/index.js"]
}
}
}Retrieve the value of a specific design token.
Parameters:
name(string, required): Token name with or without--prefix
Example:
{
"name": "ks-brand-color-primary"
}Response:
{
"token": "--ks-brand-color-primary",
"value": "#3065c0"
}List all available design tokens with optional filtering.
Parameters:
category(string, optional): Filter by category (e.g., "color", "font", "spacing")
Example:
{
"category": "color"
}Response:
{
"totalTokens": 25,
"category": "color",
"tokens": [
{
"name": "--ks-brand-color-primary",
"value": "#3065c0"
},
...
]
}Search for tokens by pattern in names or values.
Parameters:
pattern(string, required): Search pattern (case-insensitive)searchIn(string, optional): Where to search - "name", "value", or "both" (default: "both")
Example:
{
"pattern": "primary",
"searchIn": "name"
}Response:
{
"pattern": "primary",
"searchIn": "name",
"totalMatches": 2,
"results": [
{
"name": "--ks-brand-color-primary",
"value": "#3065c0"
},
{
"name": "--ks-brand-color-primary-inverted",
"value": "#3065c0"
}
]
}Update a token value and save changes to the CSS file.
Parameters:
name(string, required): Token name to updatevalue(string, required): New value for the token
Example:
{
"name": "ks-brand-color-primary",
"value": "#4075d0"
}Response:
{
"success": true,
"message": "Token updated successfully",
"token": "--ks-brand-color-primary",
"oldValue": "#3065c0",
"newValue": "#4075d0"
}The server reads from tokens/branding-token.css which contains CSS Custom Properties:
:root {
--ks-brand-color-primary: #3065c0;
--ks-brand-color-bg: #fff;
--ks-brand-font-family-display: Montserrat, Baskerville, serif;
/* ... more tokens */
}The server includes comprehensive error handling for:
- Missing or inaccessible token files
- Invalid token names
- File write failures
- Malformed requests
- Non-existent tokens
All errors are returned in a consistent JSON format:
{
"error": "Error message description",
"tool": "tool_name",
"timestamp": "2026-01-21T12:00:00.000Z"
}The design tokens are organized by category:
- Colors: Primary, background, foreground, semantic colors
- Typography: Font families, weights, sizes
- Spacing: Base spacing and scale factors
- Borders: Width, radius
- Shadows: Blur values
design-tokens-mcp/
├── index.js # Main MCP server
├── package.json # Node.js configuration
├── README.md # Documentation
└── tokens/
└── branding-token.css # Design token definitions
To support multiple token files, modify the TOKENS_FILE constant in index.js or extend the parsing logic to read from multiple files.
- Node.js 16+ (for ES modules support)
- @modelcontextprotocol/sdk ^1.25.3
ISC
Contributions are welcome! Please ensure all changes include proper error handling and maintain the existing code style.