classmcp
Multi-framework MCP server that enables AI to generate clean, semantic CSS class names (e.g., btn-primary) instead of verbose utility strings, with support for Tailwind, Bootstrap, UnoCSS, Tachyons, SSR safety, and minification for token savings.
README
classmcp
Multi-Framework MCP Server for AI-Optimized CSS Generation
Stop wasting tokens on long utility class strings. Let AI generate code with semantic class names like btn-primary and card - with full SSR safety awareness and optional minification.
Supports Tailwind CSS, Bootstrap 5, UnoCSS, and Tachyons.
The Problem
When AI generates utility-first CSS code, it creates verbose class strings:
<button class="inline-flex items-center justify-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Click me
</button>
This wastes:
- AI tokens - longer context = higher costs
- Your time - harder to read and debug
- Bundle size - repeated patterns bloat HTML
- SSR safety - easy to accidentally use client-only patterns
The Solution
classmcp provides semantic class names to AI assistants:
<!-- Semantic -->
<button class="btn-primary">Click me</button>
<!-- Or ultra-minified for maximum savings -->
<button class="a">Click me</button>
The AI queries available patterns, uses short names, and you get clean, readable code that's SSR-safe.
Installation
For Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"classmcp": {
"command": "npx",
"args": ["classmcp"]
}
}
}
For other MCP clients
npx classmcp
Features
Multi-Framework Support
Switch between CSS frameworks instantly:
set_framework: "tailwind" # Default
set_framework: "bootstrap" # Bootstrap 5
set_framework: "unocss" # UnoCSS
set_framework: "tachyons" # Tachyons
SSR Safety
Every pattern is marked for server-side rendering compatibility:
get_ssr_info: "modal-overlay"
→ Status: ⚠️ Requires Client JS
→ Warning: Modal visibility controlled by JS
→ Recommendations: Use useEffect to add client-only classes
Filter for SSR-safe patterns only:
list_classes: { ssrSafeOnly: true }
Minification
Generate ultra-short class names for maximum token savings:
get_class: { name: "btn-primary", minified: true }
→ Class: "a" (saves 11 chars per usage)
Custom Patterns
Define your own semantic class names by creating a .classmcp.json file in your project root:
Simple format:
{
"customPatterns": [
{ "id": "brand-btn", "classes": "px-4 py-2 bg-brand-600 text-white rounded-lg font-semibold" },
{ "id": "pricing-card", "classes": "p-8 border-2 border-gray-100 rounded-2xl shadow-xl" }
]
}
With states and metadata:
{
"customPatterns": [
{
"id": "brand-btn",
"category": "buttons",
"description": "Brand-colored primary button",
"classes": {
"base": "px-4 py-2 bg-brand-600 text-white rounded-lg font-semibold",
"hover": "hover:bg-brand-700 hover:shadow-md",
"focus": "focus:ring-2 focus:ring-brand-300"
}
}
],
"overrideBuiltins": false,
"defaultFramework": "tailwind"
}
Config options:
| Option | Description |
|---|---|
customPatterns |
Array of custom pattern definitions |
overrideBuiltins |
If true, custom patterns replace built-ins with same ID |
defaultFramework |
Default framework to use (tailwind, bootstrap, unocss, tachyons) |
Pattern options:
| Field | Required | Description |
|---|---|---|
id |
Yes | Unique identifier (e.g., "brand-btn") |
classes |
Yes | CSS classes (string or state object with base/hover/focus/active/disabled) |
category |
No | Category for organization (defaults to "custom") |
name |
No | Human-readable name (defaults to id) |
description |
No | Description of when to use |
frameworks |
No | Limit to specific frameworks (e.g., ["tailwind"]) |
ssr.safe |
No | Whether pattern is SSR-safe |
Alternative config locations:
.classmcp.json(recommended)classmcp.config.jsonpackage.jsonunder"classmcp"key
After modifying your config, use the reload_config tool to apply changes without restarting.
Available Tools
| Tool | Description |
|---|---|
set_framework |
Set CSS framework (tailwind, bootstrap, unocss, tachyons) |
get_class |
Get utility classes for a semantic name |
list_classes |
List available classes (filter by category, SSR-safe) |
search_classes |
Search for classes by name or description |
generate_css |
Generate CSS file with all class definitions |
get_component |
Get complete HTML component examples |
get_ssr_info |
Check SSR/hydration safety for a pattern |
list_frameworks |
List all available frameworks with statistics |
reload_config |
Reload custom patterns from config file |
list_custom_patterns |
List all user-defined custom patterns |
Class Categories
- buttons - btn-primary, btn-secondary, btn-danger, btn-ghost, btn-outline
- cards - card, card-bordered, card-header, card-body, card-footer
- forms - input, input-error, label, select, checkbox, textarea, toggle
- badges - badge-primary, badge-success, badge-warning, badge-danger
- alerts - alert-info, alert-success, alert-warning, alert-error
- avatars - avatar-sm, avatar-md, avatar-lg
- layout - container, flex-center, flex-between, stack, row, grid-2, grid-3
- typography - heading-xl, heading-lg, heading-md, text-body, text-muted
- navigation - nav, nav-link, nav-link-active
- modals - modal, modal-overlay, modal-header, modal-body, modal-footer
- tables - table, table-header, th, td, tr-hover
- lists - list, list-item, list-item-hover
- loading - spinner, skeleton, skeleton-text, skeleton-avatar
- dividers - divider, divider-vertical
Usage Example
Ask Claude:
"Create a card with a user profile, showing avatar, name, email, and action buttons"
Claude will use classmcp to generate:
<div class="card">
<div class="flex-start space-x-4">
<div class="avatar-lg">JD</div>
<div class="stack">
<h3 class="heading-sm">John Doe</h3>
<p class="text-muted">john@example.com</p>
</div>
</div>
<div class="card-footer">
<button class="btn-primary">Message</button>
<button class="btn-secondary">Profile</button>
</div>
</div>
Setup Your Project
- Generate the CSS:
# Ask Claude to use the generate_css tool, or:
npx classmcp generate-css > src/classmcp.css
- Import in your CSS:
Tailwind:
@import "tailwindcss";
@import "./classmcp.css";
Bootstrap:
@import "bootstrap/dist/css/bootstrap.min.css";
@import "./classmcp.css";
Token Savings
| Component | Without classmcp | With classmcp | Minified | Savings |
|---|---|---|---|---|
| Button | 180 chars | 12 chars | 1 char | 99% |
| Card | 85 chars | 5 chars | 1 char | 99% |
| Input | 145 chars | 6 chars | 1 char | 99% |
| Modal | 200+ chars | 12 chars | 1 char | 99% |
Over a full page with 50+ components, this adds up to thousands of tokens saved.
SSR Safety Guide
Safe for SSR (no JS needed)
- All button variants (hover/focus are CSS pseudo-classes)
- All card patterns
- Form inputs (base styling)
- Typography patterns
- Layout utilities
- Badges, alerts
Requires Client JS (may cause hydration issues)
modal-overlay- visibility needs JStoggle- checked statespinner- animation timingalert-dismissible- close button
Use ssrSafeOnly: true or check with get_ssr_info when building Next.js/Nuxt/Remix apps.
Framework Statistics
| Framework | Patterns | SSR-Safe | Categories |
|---|---|---|---|
| Tailwind CSS | 70+ | 65+ | 14 |
| Bootstrap 5 | 70+ | 65+ | 14 |
| UnoCSS | 70+ | 65+ | 14 |
| Tachyons | 70+ | 65+ | 14 |
How It Works
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Claude │────▶│ classmcp │────▶│ Your Code │
│ │ │ (MCP) │ │ │
│ "Make a │ │ │ │ <button │
│ button" │ │ get_class │ │ class= │
│ │◀────│ btn-primary │ │ "btn- │
│ │ │ (SSR-safe) │ │ primary"> │
└─────────────┘ └─────────────┘ └─────────────┘
- AI asks classmcp for available classes
- classmcp returns semantic names + SSR safety info
- AI generates code using short class names
- You add the generated CSS to your project
- Your CSS framework compiles it
Related: classpresso
- classmcp = AI layer (development time) - helps AI generate clean code
- classpresso = Build layer (build time) - optimizes existing code
They're complementary:
- Use classmcp when writing new code with AI
- Use classpresso to optimize existing/legacy code
License
MIT
Links
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。