AI agents (MCP)
Give an AI agent your tokens and theme with @flexpixels/cortex-mcp, the Cortex MCP server.
@flexpixels/cortex-mcp serves Cortex over the Model Context Protocol.
An agent can read your tokens and theme, generate and validate theme configs, and check
typography, elevation and contrast — instead of guessing colour values or inventing
variable names. Its only FlexPixels dependency is @flexpixels/cortex.
Connect it
Add the server to your MCP client. Most clients (Claude Desktop, Claude Code, Cursor,
Windsurf) take an mcpServers entry:
{
"mcpServers": {
"cortex": {
"command": "npx",
"args": ["-y", "@flexpixels/cortex-mcp@beta"]
}
}
}With Claude Code you can add it from the terminal:
claude mcp add cortex -- npx -y @flexpixels/cortex-mcp@betaThe server needs Node 20 or later. It reads theme-config.json (or theme.config.json)
from the directory it starts in and picks up edits on the next call; without a config it
serves the default theme. If the file does not validate, each tool that reads it answers with an error naming the file and each bad field (the server still starts). A failed call is an isError result with readable text and the same failure as structuredContent.error: { code, message, fix, docsUrl, issues? }, where code is one of INVALID_ARGUMENTS, INVALID_THEME_CONFIG, PROJECT_CONFIG_INVALID, NOT_FOUND, UNAVAILABLE or TOOL_FAILED and issues lists each field at fault. An argument a tool does not take is rejected rather than ignored, and a tool’s own argument the theme cannot use (an odd size on the strict grid, an inverted viewport range) is INVALID_ARGUMENTS naming that argument.
Tools
| Tool | What it does |
|---|---|
search_tokens | Find tokens by name, value or purpose — the public tier, or every token — of the project’s theme or a candidate (configOverrides). |
get_tokens | The tokens of a category, with their values and purposes, of the project’s theme or a candidate (configOverrides). |
check_theme_contrast | WCAG ratio and APCA Lc between two colours. |
export_dtcg_tokens | W3C DTCG JSON: the index of token groups with their sizes, the groups you name, or ["all"]. |
export_design_md | The theme as DESIGN.md for a project with its own components: the public token tier by default, the whole theme with tier: "all". |
validate_theme_config | Check a partial theme config against the schema before writing it. |
generate_theme_css | The theme stylesheet for a config: lean, full, or the chart subset. |
generate_vision_palettes | Extra palettes for red-green, blue-yellow, monochrome and high-contrast vision, with a measured report. |
compute_typography | A typography system (scale, role styles, CSS preview) from an intent or an explicit scale. |
validate_typography | Check CSS or HTML against the type scale and its roles. |
pair_fonts | Companion families for a primary font. |
suggest_type_scale | A type scale for an intent: marketing, app, editorial or dashboard. |
compute_elevation | The elevation ladder for an intent and style. |
validate_elevation | Check CSS or HTML against the elevation tokens. |
suggest_elevation_style | An elevation style for an intent. |
pair_elevations_with_typography | An elevation config that suits a typography intent, with alternatives. |
generate_theme_css with subset: "charts" also needs @flexpixels/flexcharts, which is
not published yet, so that subset answers with an error outside the FlexPixels repository.
Resources
Look-ups are resources rather than tools, so they do not add to the tool list:
flexpixels://tokens/colorsandflexpixels://tokens/primitivesflexpixels://guide/token-api— the public token tier with values and purposes, then the full themeflexpixels://theme/config— the active config and its optionsflexpixels://typography/roles/{role}andflexpixels://typography/scenarios/{name}flexpixels://elevation/levels/{key},flexpixels://elevation/styles/{style}andflexpixels://elevation/scenarios/{name}
Without MCP
Two plain-text files describe Cortex for any model, with no server:
/llms.txt— an index of every docs page, one line each./llms-full.txt— every page as Markdown, plus reference tables computed from this site’s theme: the public API, the config keys, and the colour, type, spacing, shape, elevation, interaction and layout scales.
exportDesignMd(config) writes a DESIGN.md for your own theme; see
DESIGN.md export.
The combined FlexPixels server
The FlexPixels repository also has @flexpixels/mcp,
which serves these same tools and resources with the component, chart, layout and
accessibility tools beside them. It is not published yet; it runs from a clone of the
repository.