CSS MCP Server
Provides up-to-date CSS documentation and browser compatibility data from MDN through natural language queries. Features intelligent caching and supports all CSS properties, selectors, functions, and concepts with automatic normalization.
README
CSS MCP Server
An MCP (Model Context Protocol) server that provides up-to-date CSS documentation from MDN and comprehensive CSS code analysis.
Features
Documentation & Compatibility:
- Official MDN Docs - Fetches documentation directly from MDN's API
- Browser Compatibility - Includes browser support data from MDN's BCD
- Simple API - Just pass CSS property names like
"grid","flexbox", or":has" - Markdown Conversion - Converts HTML documentation to clean, readable markdown
- Auto-normalization - Supports both simple slugs (
"grid") and full paths ("Web/CSS/grid") - Smart Caching - SQLite-based cache with 7-day TTL for blazing-fast responses
CSS Analysis:
- 150+ Metrics - Comprehensive analysis of stylesheet quality and complexity
- Design Patterns - Detect color palettes, font sizes, spacing patterns
- Code Quality - Selector complexity, specificity analysis, property usage
- Performance Insights - Identify overly complex selectors and redundant code
Installation
For Claude Code
Install via the Claude Code CLI:
claude mcp add css -- npx -y css-mcp
For VS Code
One click install:
Install via VS Code CLI:
code --add-mcp '{\"name\":\"css\",\"command\":\"npx\",\"args\":[\"-y\",\"css-mcp\"],\"env\":{}}'
For MCP Clients (Claude Desktop, etc.)
Add to your MCP settings configuration:
{
"mcpServers": {
"css": {
"command": "npx",
"args": ["-y", "css-mcp"]
}
}
}
For Development
npm install -g css-mcp
Or use with npx:
npx css-mcp --self-test
Requirements
- Node.js 20+
- Build tools for native modules (usually pre-installed on most systems)
Usage
Available Tools
get_docs
Fetch CSS documentation for any property, selector, function, or concept.
Parameters:
slug(string) - CSS feature name or MDN path
Examples:
// Simple slugs (auto-normalized)
get_docs({ slug: "grid" });
get_docs({ slug: ":has" });
get_docs({ slug: "flexbox" });
get_docs({ slug: "@media" });
get_docs({ slug: "::before" });
// Full MDN paths also work
get_docs({ slug: "Web/CSS/grid" });
get_docs({ slug: "en-US/docs/Web/CSS/border-radius" });
Returns:
{
"source": "mdn-doc",
"slug": "/en-US/docs/Web/CSS/grid",
"url": "https://developer.mozilla.org/en-US/docs/Web/CSS/grid/index.json",
"title": "grid",
"mdn_url": "/en-US/docs/Web/CSS/grid",
"summary": "The grid CSS property is a shorthand...",
"body": [
{
"type": "prose",
"title": "Syntax",
"content": "The **`grid`** property is a shorthand..."
}
]
}
get_browser_compatibility
Fetch browser compatibility data for CSS features.
Parameters:
bcd_id(string) - Browser Compat Data ID (e.g.,"css.properties.grid")
Example:
get_browser_compatibility({ bcd_id: "css.properties.grid" });
get_browser_compatibility({ bcd_id: "css.selectors.has" });
analyze_css
Analyze CSS code for quality, complexity, and design patterns. Returns curated summary by default (lightweight, ~1-2k tokens). Use summaryOnly: false for complete 150+ metrics (uses ~10k+ tokens).
Parameters:
css(string, required) - CSS code to analyzesummaryOnly(boolean, optional) - Return summary instead of full analysis. Default:true
Examples:
// Summary mode (default, lightweight)
analyze_css({
css: `
.container {
display: grid;
color: #3b82f6;
}
`
});
// Full analysis with all 150+ metrics
analyze_css({
css: "...",
summaryOnly: false
});
Returns (default summary):
{
"analysis": {
"stylesheet": {
"sourceLinesOfCode": 5,
"size": 72
},
"rules": { "total": 1 },
"selectors": {
"total": 1,
"averageComplexity": 1.0,
"maxComplexity": 1
},
"colors": {
"unique": 1,
"uniqueColors": ["#3b82f6"]
}
},
"note": "Summary metrics only. Use summaryOnly: false for complete 150+ metrics."
}
analyze_project_css
Analyze all CSS files in a project. Finds CSS files recursively, combines them, and provides project-wide analysis. Framework-agnostic - works with built CSS from any framework (SvelteKit, React, Vue, etc.).
Returns curated summary metrics by default (lightweight, ~1-2k tokens). Use includeFullAnalysis: true for complete data (uses ~10k+ tokens).
Automatically excludes:
**/node_modules/****/*.min.css
Parameters:
path(string, required) - File path, directory, or glob patternincludeFullAnalysis(boolean, optional) - Return full 150+ metrics instead of summary. Default:falseexclude(array of strings, optional) - Additional glob patterns to exclude
Examples:
// Analyze all CSS in a directory (summary - default, lightweight)
analyze_project_css({ path: "dist" });
// Full analysis with all 150+ metrics (uses more tokens)
analyze_project_css({
path: "dist",
includeFullAnalysis: true
});
// Exclude additional patterns
analyze_project_css({
path: "dist",
exclude: ["**/vendor/**", "**/*.legacy.css"]
});
// Analyze specific file
analyze_project_css({ path: "public/styles.css" });
// Use glob patterns
analyze_project_css({ path: "dist/**/*.css" });
Returns (default summary):
{
"files": {
"total": 5,
"analyzed": 5,
"errors": 0,
"list": [
{ "path": "/path/to/style.css", "size": 2048 },
{ "path": "/path/to/theme.css", "size": 1024 }
]
},
"summary": {
"stylesheet": {
"sourceLinesOfCode": 450,
"size": 12800
},
"rules": { "total": 85 },
"selectors": {
"total": 120,
"averageComplexity": 1.4,
"maxComplexity": 5
},
"colors": {
"unique": 12,
"uniqueColors": ["#3b82f6", "#10b981", ...]
},
"fontSizes": {
"unique": 8,
"uniqueSizes": ["1rem", "1.5rem", ...]
}
},
"note": "Summary metrics only. Use includeFullAnalysis: true for complete data."
}
Cache Management
The server automatically:
- Creates cache at
~/.cache/css-mcp/cache.db - Cleans up expired entries on startup
- Tracks hit counts for each cached entry
- Uses WAL mode for better concurrent performance
To clear the cache:
rm -rf ~/.cache/css-mcp/
Self-Test
Verify the server is working correctly:
npm test
# or
css-mcp --self-test
# or
npx css-mcp --self-test
Expected output:
docs ok (simple slug): { input: 'grid', slug: '/en-US/docs/Web/CSS/grid', ... }
docs ok (pseudo-selector + markdown): { input: ':has', ... }
bcd ok: { bcd_id: 'css.properties.grid', has_compat: true, ... }
Example: Using with Claude Code
Once configured, you can ask Claude Code:
Documentation & Compatibility:
"Use the CSS MCP to get documentation for flexbox"
"What browser support does :has selector have?"
"Explain how CSS grid works"
CSS Analysis:
"Analyze this CSS and tell me what could be improved"
"What colors are used in my stylesheet?"
"Check the complexity of my selectors"
Project Analysis:
"Analyze all CSS in my dist folder"
"What's the total complexity of my project's CSS?"
"Show me all colors used across my entire project"
Claude will automatically use the MCP to fetch the latest MDN documentation and analyze CSS code.
Development
# Clone the repository
git clone https://github.com/stolinski/css-mcp.git
cd css-mcp
# Install dependencies
npm install
# Link for local development
npm link
# Run tests
npm test
Performance & Limits
Caching:
- First fetch: ~400-500ms (network + cache write)
- Cached fetch: ~100ms (~5x faster)
- Cache size: ~390KB for typical usage
Input Limits:
- Max file size: 10MB per CSS file
- Max total size: 50MB combined
- Max files: 500 CSS files per analysis
- Network timeout: 10 seconds for MDN API calls
Troubleshooting
"Module did not self-register"
This usually means native modules need rebuilding:
npm rebuild better-sqlite3
Cache not working
Check cache directory permissions:
ls -la ~/.cache/css-mcp/
Should show cache.db, cache.db-shm, and cache.db-wal files.
Contributing
This is an experimental MCP server for CSS documentation tooling, let's work on tools that make AI better at CSS
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。