A Model Context Protocol (MCP) server for CSS debugging with a comprehensive 5-phase investigation protocol.
- 5-Phase Investigation Protocol: Systematic approach to CSS debugging
- CSS Knowledge Base: Built-in solutions for common CSS issues (centering, z-index, flexbox, grid, overflow, etc.)
- Framework-Aware: Understands defaults for Material-UI, Tailwind, Bootstrap, Ant Design, and more
- File System Integration: Search and read CSS/component files in your workspace
- Stateful Investigations: Track findings across multiple phases
-
css_investigate_start - Initialize a new CSS investigation
- Returns investigation ID, protocol overview, and relevant CSS knowledge
- Parameters:
issue(description),workspacePath(optional)
-
css_phase1_structure - Phase 1: Structure Analysis
- Search for components, read files, map hierarchy
- Parameters:
investigationId,componentPattern,workspacePath
-
css_phase2_cascade - Phase 2: Cascade Tracing
- Search CSS files for matching selectors and rules with specificity analysis
- Parameters:
investigationId,cssPattern,selector,workspacePath
-
css_phase3_conflicts - Phase 3: Conflict Detection
- Analyze for duplicates, !important usage, specificity issues
- Parameters:
investigationId
-
css_phase4_multilevel - Phase 4: Multi-Level Cascade Analysis
- Trace how styles combine across levels
- Parameters:
investigationId
-
css_phase4b_browser - Phase 4b: Live Browser Inspection (Optional)
- Auto-connect to Edge/Chrome DevTools to inspect actual computed styles
- Parameters:
investigationId,elementSelector,chromePort(default: 9222),autoLaunch(default: false) - Auto-detects running browser or can auto-launch Edge
-
css_phase5_solution - Phase 5: Solution Design
- Generate fix with code and explanation based on static and/or live browser analysis
- Parameters:
investigationId,originalIssue
-
css_search_files - Search for CSS/SCSS/LESS files
- Parameters:
pattern(glob),workspacePath
- Parameters:
-
css_read_component - Read component file contents
- Parameters:
filePath
- Parameters:
-
css_get_knowledge - Query CSS knowledge base
- Parameters:
query(e.g., "centering", "flexbox", "z-index")
- Parameters:
For Phase 4b live browser inspection, Edge or Chrome can be used:
Option 1: Manual Launch (Recommended)
# Edge (recommended for Windows)
msedge.exe --remote-debugging-port=9222
# Chrome
chrome.exe --remote-debugging-port=9222Option 2: Auto-Launch
Set autoLaunch: true when calling css_phase4b_browser - it will automatically start Edge if not already running.
Why use Phase 4b?
- Static analysis predicts cascade behavior, but JavaScript, timing, and browser quirks can change the outcome
- Phase 4b connects to Chrome DevTools Protocol to fetch actual computed styles
- Compares static predictions vs browser reality
- Generates fixes based on truth, not guesses
When to skip Phase 4b:
- Simple CSS-only issues without JavaScript interaction
- Quick static analysis sufficient
- Chrome debugging not available/desired
npm install
npm run buildAdd to your workspace's .vscode/mcp.json:
{
"mcpServers": {
"css-helper": {
"command": "node",
"args": [
"c:\\Users\\RichardHogan\\Development\\CSS-Helper MCP\\build\\index.js"
],
"type": "stdio"
}
}
}Important:
- Replace the path with your actual installation path
- VS Code MCP configuration is workspace-specific - copy this to each project's
.vscode/mcp.json
Once configured, use the CSS Helper via GitHub Copilot Chat:
@workspace Use css_investigate_start to debug: "Button not centered in container"
Follow the 5-phase protocol to systematically diagnose and fix CSS issues.
- Start: Use
css_investigate_startwith issue description - Structure: Use
css_phase1_structurewith component pattern (e.g.,**/*Button*.tsx) - Cascade: Use
css_phase2_cascadewith CSS pattern (e.g.,**/*.css) and selector (e.g.,.button)- Now includes CSS specificity calculation and cascade prediction
- Conflicts: Use
css_phase3_conflictsto detect issues - Analysis: Use
css_phase4_multilevelfor cascade layers - Solution: Use
css_phase5_solutionto get the fix
Option A: Manual Browser Launch
- Start Edge with debugging:
msedge.exe --remote-debugging-port=9222 - Open your webpage in that Edge instance
- Run phases 1-4 as normal
- Add Phase 4b: Use
css_phase4b_browserwithelementSelector(e.g.,.button,#header)
Option B: Fully Automated (Zero Manual Steps)
- Run phases 1-4 as normal
- Add Phase 4b: Use
css_phase4b_browserwithelementSelectorandautoLaunch: true- Automatically launches Edge if not running
- Fetches actual computed styles from browser
- Compares static predictions vs reality
- Generate solution: Use
css_phase5_solution- Now uses browser data for accurate fixes
- Shows "Static predicted X but browser applied Y" insights
The server includes solutions for:
- Centering: Flexbox, Grid, and absolute positioning approaches
- Z-Index: Stacking context and positioning issues
- Flexbox: Wrap, flex-basis, and min-width problems
- Grid: Template columns, auto-fit, and minmax issues
- Overflow: Text wrapping and scrollable containers
- Specificity: Selector hierarchy and !important usage
- Positioning: Relative, absolute, fixed, and sticky
- Responsive: Media queries and fluid layouts
npx @modelcontextprotocol/inspector node "c:\Users\RichardHogan\Development\CSS-Helper MCP\build\index.js"Look for:
- Green "Running" indicator
- All 9 tools listed
- Server name "css-helper" version "1.0.0"
- Copy
.vscode/mcp.jsonto your ACRE project - Restart VS Code
- Use GitHub Copilot Chat with
@workspaceto access tools
npm run build # Compile TypeScript
npm run prepare # Pre-commit build hookServer not showing in VS Code:
- Verify
.vscode/mcp.jsonexists with correct path - Restart VS Code after configuration changes
- Check VS Code MCP panel for connection status
Module errors:
- Run
npm installto ensure dependencies are installed - Check
build/index.jsexists afternpm run build
ISC