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:

json
{
  "mcpServers": {
    "cortex": {
      "command": "npx",
      "args": ["-y", "@flexpixels/cortex-mcp@beta"]
    }
  }
}

With Claude Code you can add it from the terminal:

bash
claude mcp add cortex -- npx -y @flexpixels/cortex-mcp@beta

The 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

ToolWhat it does
search_tokensFind tokens by name, value or purpose — the public tier, or every token — of the project’s theme or a candidate (configOverrides).
get_tokensThe tokens of a category, with their values and purposes, of the project’s theme or a candidate (configOverrides).
check_theme_contrastWCAG ratio and APCA Lc between two colours.
export_dtcg_tokensW3C DTCG JSON: the index of token groups with their sizes, the groups you name, or ["all"].
export_design_mdThe 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_configCheck a partial theme config against the schema before writing it.
generate_theme_cssThe theme stylesheet for a config: lean, full, or the chart subset.
generate_vision_palettesExtra palettes for red-green, blue-yellow, monochrome and high-contrast vision, with a measured report.
compute_typographyA typography system (scale, role styles, CSS preview) from an intent or an explicit scale.
validate_typographyCheck CSS or HTML against the type scale and its roles.
pair_fontsCompanion families for a primary font.
suggest_type_scaleA type scale for an intent: marketing, app, editorial or dashboard.
compute_elevationThe elevation ladder for an intent and style.
validate_elevationCheck CSS or HTML against the elevation tokens.
suggest_elevation_styleAn elevation style for an intent.
pair_elevations_with_typographyAn 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/colors and flexpixels://tokens/primitives
  • flexpixels://guide/token-api — the public token tier with values and purposes, then the full theme
  • flexpixels://theme/config — the active config and its options
  • flexpixels://typography/roles/{role} and flexpixels://typography/scenarios/{name}
  • flexpixels://elevation/levels/{key}, flexpixels://elevation/styles/{style} and flexpixels://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.