What stylespeak MCP server does
The stylespeak MCP server gives coding agents a structured way to inspect CSS before changing it. It can determine which declaration wins for a selector, identify overridden rules, follow custom-property chains, and estimate which selectors may change after an edit. The same functionality is available through an MCP server and a command-line interface.
Analysis can cover regular CSS, SCSS with nesting, CSS Modules, and compiled output from vanilla-extract, Linaria, or StyleX. Styled-components, Emotion, and CSS-in-JS object syntax are not supported.
How it works
The server reads the supplied files and builds an in-memory representation of selectors, declarations, specificity, variables, and cascade relationships. Its file-based matcher uses confidence levels rather than claiming browser certainty: exact matches are certain, subset matches are likely, and combinator-based relationships are possible because the DOM is unavailable.
CSS custom properties are resolved in the returned data. Results can include the original value, the resolved value, the variable chain, and alternate values from media contexts. Chained variables, fallbacks, nested fallbacks, scoped variables, and circular-reference protection are supported.
For browser-backed inspection, live_resolve connects to Chromium through the Chrome DevTools Protocol. It reports computed styles and matched rules from the running browser, using the browser's resolution rather than the file-analysis heuristics. Chromium must be started with remote debugging enabled, such as --remote-debugging-port=9222; that port should not be exposed to untrusted networks.
Setup and configuration
Install the CLI globally with npm:
npm install -g @patrizzos/stylespeak
The project requires Node.js 21 or newer and has no external dependencies. To run the MCP server, add a stdio entry to the client configuration. Cursor uses .cursor/mcp.json, while VS Code uses .vscode/mcp.json:
{
"mcpServers": {
"stylespeak": {
"command": "node",
"args": ["/absolute/path/to/stylespeak/src/server.js"]
}
}
}
CLI examples include stylespeak resolve ".btn.primary" src/styles/main.css, stylespeak trace "color" --projectRoot src/styles, stylespeak impact ".btn" "background-color" src/styles/main.css --newValue "#ff0000", and stylespeak manifest --projectRoot src/styles.
Tools and capabilities
The stylespeak MCP server exposes five tools:
resolve_styles calculates the properties received by a selector, identifies the winning rule, lists overridden rules, and reports confidence.
trace_property finds declarations for a property, groups competing selectors, and shows their cascade chains.
impact_preview estimates value changes, shielded selectors, cascade uncertainty, inheritance effects, and downstream variable impacts before an edit.
style_manifest creates a compact project-level summary of selectors, properties, variables, competition groups, and risk hotspots.
live_resolve retrieves browser-computed styles and matched rules for a selector.
Tool inputs can include selectors, properties, file lists, project roots, optional component files, maximum selector counts, new values, browser ports, and tab URLs as applicable.
Limitations and notes
File-based results are predictions when DOM structure or rendering context affects selector matching. Use live_resolve when exact browser computation is required. The live tool needs an accessible Chromium debugging endpoint and should be used only on a trusted local machine.
The project is intended for CSS explanation and pre-edit analysis. It can be paired with stylesafe, which checks CSS problems after edits, but stylesafe is a separate package and is not required by the documented zero-dependency setup.