首个最全面的 Tailwind CSS 模型上下文协议 (MCP) 服务器
生成组件 • 优化类 • 创建主题 • 获取最佳实践
</div>生成带有变体、尺寸和框架支持的生产就绪 Tailwind 组件
tailwind.config.js 文件npm install -g tailwind-mcp-server
git clone https://github.com/yourusername/tailwind-mcp-server.git
cd tailwind-mcp-server
npm install
添加到你的 claude_desktop_config.json 中:
选项 1: 全局安装(推荐)
{
"mcpServers": {
"tailwind-mcp-server": {
"command": "npx",
"args": ["tailwind-mcp-server"]
}
}
}
选项 2: 手动安装
{
"m_服务器": {
"tailwind-mcp-server": {
"command": "node",
"args": ["/path/to/tailwind-mcp-server/src/server.js"]
}
}
}
配置文件位置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json| 工具 | 描述 | 使用场景 |
|---|---|---|
generate_component | 生成 Tailwind 组件 | 创建按钮、卡片、导航 |
optimize_classes | 清理类列表 | 删除冗余项,合并冲突 |
validate_classes | 验证 Tailwind 类 | 检查语法,获取建议 |
generate_layout | 创建响应式布局 | 构建页面结构 |
create_theme | 生成设计系统 | 创建颜色调色板、排版 |
generate_config | 创建 Tailwind 配置 | 框架特定设置 |
convert_css_to_tailwind | 将 CSS 转换为 Tailwind | 迁移现有样式 |
get_responsive_patterns | 获取响应式模式 | 移动优先设计指导 |
get_best_practices | 最佳实践指导 | 性能、可访问性提示 |
suggest_plugins | 插件推荐 | 查找合适的插件 |
{
"component_type": "button",
"variant": "primary",
"size": "lg",
"responsive": true,
"dark_mode": true,
"framework": "react"
}
输出:
const Button = ({ children, onClick, disabled = false }) => {
return (
<button
onClick={onClick}
disabled={disabled}
className="inline-flex items-center justify-center px-6 py-3 text-lg font-medium text-white bg-blue-600 border border-transparent rounded-lg shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200 dark:bg-blue-500 dark:hover:bg-blue-600 sm:px-8 sm:py-4"
>
{children}
</button>
);
};
{
"theme_type": "colors",
"style": "modern",
"brand_color": "#6366F1",
"color_count": 9,
"include_config": true
}
{
"layout_type": "dashboard",
"complexity": "medium",
"responsive": true,
"content_areas": ["header", "sidebar", "main", "footer"]
}
{
"classes": "p-4 px-4 py-4 text-blue-500 text-blue-600 flex flex-row",
"merge_conflicts": true,
"remove_redundant": true,
"suggest_alternatives": true
}
输出:
{
"optimized_classes": "p-4 text-blue-600 flex",
"removed_redundant": ["px-4", "py-4", "text-blue-500", "flex-row"],
"suggestions": ["考虑使用 'space-x-*' 来设置 flex 项之间的间隙"]
}
<div class="min-h-screen bg-gray-50 dark:bg-gray-900">
<!-- 头部 -->
<header class="bg-white dark:bg-gray-800 shadow-sm border-b border-gray-200 dark:border-gray-700">
<!-- 头部内容 -->
</header>
<div class="flex">
<!-- 侧边栏 -->
<aside class="w-64 bg-white dark:bg-gray-800 shadow-sm">
<!-- 侧边栏内容 -->
</aside>
<!-- 主要内容 -->
<main class="flex-1 p-6">
<!-- 页面内容 -->
</main>
</div>
</div>
<section class="relative bg-gradient-to-r from-purple-600 to-blue-600 dark:from-purple-800 dark:to-blue-800">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-24 sm:py-32">
<div class="text-center">
<h1 class="text-4xl font-bold tracking-tight text-white sm:text-6xl">
美丽的 Tailwind 组件
</h1>
<p class="mt-6 text-lg leading-8 text-purple-100">
使用 AI 辅助生成、优化和完善你的 Tailwind CSS
</p>
</div>
</div>
</section>
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: {
50: '#eff6ff',
100: '#dbeafe',
200: '#bfdbfe',
300: '#93c5fd',
400: '#60a5fa',
500: '#3b82f6',
600: '#2563eb',
700: '#1d4ed8',
800: '#1e40af',
900: '#1e3a8a',
}
}
}
}
}
fontSize: {
'xs': ['0.75rem', { lineHeight: '1rem' }],
'sm': ['0.875rem', { lineHeight: '1.25rem' }],
'base': ['1rem', { lineHeight: '1.5rem' }],
'lg': ['1.125rem', { lineHeight: '1.75rem' }],
'xl': ['1.25rem', { lineHeight: '1.75rem' }],
'2xl': ['1.5rem', { lineHeight: '2rem' }],
'3xl': ['1.875rem', { lineHeight: '2.25rem' }],
'4xl': ['2.25rem', { lineHeight: '2.5rem' }],
}
我们欢迎贡献!以下是开始的方法:
git checkout -b feature/amazing-featuregit commit -m '添加精彩功能'git push origin feature/amazing-featuregit clone https://github.com/yourusername/tailwind-mcp-server.git
cd tailwind-mcp-server
npm install
npm run dev
本项目采用 MIT 许可证 - 详情见 LICENSE 文件。
如果这个项目对你有帮助,请考虑:
为 Tailwind CSS 社区用心打造
</div>