克劳德对话Figma MCP-DaisyUI版
一个模型上下文协议(MCP)插件,允许Claude Desktop和其他AI工具直接与Figma交互, 增强了智能DaisyUI组件检测、用于快速查询的本地缓存、HTMX/Tailwind代码生成、设计令牌提取、可访问性审计和实时更改通知.
叉子: 阿林斯珀克/克劳德与费玛·麦克普对话 Sonny Lazuardi和Xúlio Zé的原创作品
______________________________________________________________________
项目上下文
这个分叉是为一个需要增强Figma编码工作流功能的项目开发的。虽然针对特定的工作流程(HTMX+DaisyUI+Tailwind+Playwright)进行了定制,但这些工具是通用的,可以与任何Figma项目配合使用。
此分叉中的自定义设置:
- 组件注册表格式使用
docs/ui/component-registry/*.yaml结构 - 页面对象生成遵循Playwright测试惯例
- 针对Tailwind配置优化设计令牌提取
所有工具都是独立工作的,可以适应其他项目结构。
______________________________________________________________________
v0.9.0中的新功能-变量绑定和每文档缓存
| 特性 | 描述 |
|---|---|
| 变量绑定 | 将DaisyUI颜色变量绑定到主题兼容颜色的节点(亮/暗模式) |
| 样式绑定 | 以编程方式应用填充、笔划和文本样式 |
| 变量缓存 | 使用FTS5搜索存储在本地SQLite索引中的变量 |
| 每个文档数据库 | 每个Figma文件都能无缝地获得自己的缓存切换文件 |
| DaisyUI自动检测 | 自动映射到语义名称的变量(主、100进制等) |
上一篇:v0.8.0-全面的Figma到Code流水线
| 特性 | 描述 |
|---|---|
| 设计令牌提取 | 提取颜色、间距、排版、阴影→ 顺风配置或CSS变量 |
| i18n文本提取 | 使用建议的i18n键和命名空间提取所有文本节点 |
| 可访问性审计 | WCAG 2.1 AA/AAA审核(对比度、触摸目标、文本大小) |
| 组件注册表同步 | 将Figma设计与本地组件注册表YAML进行比较 |
| 可视化回归导出 | 导出用于视觉回归测试的框架 |
| 实时变更通知 | Figma文档更改时自动同步索引 |
______________________________________________________________________
DaisyUI版功能
此分叉为DaisyUI+Tailwind+HTMX工作流添加了强大的功能:
| 特点 | 优点 |
|---|---|
| 本地SQLite索引 | 查询速度提高100倍-无Figma往返 |
| 每文档缓存 | 每个Figma文件都能无缝地获得自己的数据库切换文件 |
| FTS5模糊搜索 | 使用自然语言查找组件(“主按钮”) |
| DaisyUI自动检测 | Figma节点到DaisyUI类的自动映射 |
| 尾风提取 | 将Figma样式转换为Tailwind实用程序 |
| Jinja/HTMX模板 | 从设计生成服务器渲染模板 |
| 页面对象生成器 | 从Figma创建Playwright测试对象 |
| 更改时自动同步 | Figma文档更改时索引会自动更新 |
| 代理优化响应 | 使用即用型克隆命令可减少99%的响应 |
______________________________________________________________________
所有工具
索引和搜索工具
| 工具 | 说明 |
|---|---|
build_index | 从Figma文档构建本地SQLite索引(第一次查询时自动运行) |
index_status | 检查索引运行状况、同步状态、无效状态 |
list_cached_documents | 列出已在本地索引的所有Figma文档 |
search | 自然语言搜索:“主按钮”、“登录表单” |
list_components | 列出一个类别中的所有组件(按钮、表单、卡片) |
get_by_daisyui | 按DaisyUI类查找组件(btn-primary) |
list_pages | 快速浏览所有页面 |
get_page_tree | 分层页面结构(比完全导出小得多) |
代码生成工具
| 工具 | 说明 |
|---|---|
generate_template | 使用HTMX和Alpine.js属性生成Jinja/HTML |
extract_tailwind | 从Figma节点样式中提取Tailwind类 |
generate_page_object | 创建剧作家页面对象(TypeScript或Python) |
generate_registry_entry | 生成组件注册表YAML条目 |
设计令牌工具(新)
| 工具 | 说明 |
|---|---|
extract_design_tokens | 提取颜色、间距、排版、阴影→ 顺风配置或CSS变量 |
i18n和辅助工具(新)
| 工具 | 说明 |
|---|---|
extract_text_nodes | 使用建议的密钥提取i18n验证的所有文本 |
audit_accessibility | WCAG 2.1 AA/AAA审核(对比度、触摸目标、文本大小) |
组件注册表工具(新)
| 工具 | 说明 |
|---|---|
sync_component_registry | 将Figma与本地注册表YAML进行比较,检测漂移 |
视觉测试工具(新)
| 工具 | 说明 |
|---|---|
export_for_comparison | 导出用于视觉回归测试的框架 |
变量和样式绑定工具
| 工具 | 说明 |
|---|---|
get_bound_variables | 检查哪些变量绑定到节点的属性 |
set_fill_variable | 将颜色变量绑定到节点的填充(主题兼容) |
set_stroke_variable | 将颜色变量绑定到节点的笔划 |
set_fill_style_id | 将填充样式应用于节点 |
set_stroke_style_id | 将笔划样式应用于节点 |
set_text_style_id | 将文本样式应用于文本节点 |
resolve_variable_by_name | 按名称查找变量ID(例如,“base-100”、“primary”) |
clear_variable_binding | 从节点属性中删除变量绑定 |
备注:get_local_variables和get_variable_collections由于响应大小过大(约25k令牌),在v1.1.0中被删除。使用下面的缓存替代方案。
可变缓存和搜索工具(新v0.9.0)
| 工具 | 说明 |
|---|---|
search_cached_variables | 按名称/DaisyUI映射搜索本地缓存的变量 |
list_cached_color_variables | 列出按DaisyUI类别分组的所有颜色变量 |
list_cached_variable_collections | 列出具有模式和计数的变量集合 |
get_cached_variable_by_daisyui | 按DaisyUI名称查找变量(例如,“primary”、“base-100”) |
原型和交互工具
| 工具 | 说明 |
|---|---|
set_prototype_link | 在框架之间创建交互式链接(单击以导航) |
get_prototype_links | 列出节点/框架中的所有原型链接 |
remove_prototype_link | 从节点中删除原型交互 |
set_scroll_behavior | 在帧上配置滚动溢出 |
实用工具
| 工具 | 说明 |
|---|---|
extract_node_styles | 提取针对顺风/DaisyUI映射优化的样式 |
get_page_structure | 用于索引的紧凑页面结构 |
batch_get_nodes | 用最少的数据批量获取多个节点 |
rename_node | 重命名任何Figma节点 |
set_visibility | 显示/隐藏节点 |
set_opacity | 设置节点不透明度(0-1) |
lock_node | 从编辑中锁定/解锁节点 |
______________________________________________________________________
安装
1.先决条件
2.克隆和构建
git clone https://github.com/morteng/claude-talk-to-figma-mcp-daisyui.git
cd claude-talk-to-figma-mcp-daisyui
bun install
bun run build3.配置克劳德桌面
添加到 ~/.claude.json:
{
"mcpServers": {
"figma": {
"command": "/path/to/bun",
"args": ["run", "/path/to/claude-talk-to-figma-mcp-daisyui/dist/talk_to_figma_mcp/server.js"],
"env": {
"FIGMA_CACHE_DIR": "/path/to/cache/dir"
}
}
}
}4.设置Figma插件
导入 src/claude_mcp_plugin/manifest.json 在Figma→ 插件→ 发展
5.首次连接
# Terminal 1: Start WebSocket server
bun socket
# Terminal 2: Use Claude
"Connect to Figma channel abc-123"
"Search for primary buttons" # Index auto-builds on first query______________________________________________________________________
使用示例
设计令牌提取
"Extract design tokens as Tailwind config"
→ Generates theme.extend with colors, spacing, typography, shadows
"Extract design tokens as CSS variables"
→ Generates :root { --color-primary: #...; } format可访问性审计
"Audit the login page for accessibility"
→ Returns WCAG 2.1 AA/AAA violations with severity levels
Example output:
- Error: Contrast ratio 2.1 (needs 4.5 for AA)
- Warning: Touch target 32x32px (recommended 44x44px)
- Error: Text size 10px below minimum 12pxi18n文本提取
"Extract text nodes from the settings page with namespace 'settings'"
→ Returns all text with suggested i18n keys
Example output:
- "Save Changes" → settings.save_changes
- "Account Settings" → settings.account_title组件注册表同步
"Sync component registry for the dashboard page"
→ Compares Figma with local YAML files
Example output:
- in_registry_not_figma: ["old-component"]
- in_figma_not_registry: ["new-feature-card"]
- name_mismatches: [{"figma": "Stats Card", "registry": "stat-card"}]可视化回归导出
"Export the dashboard frames for visual regression testing"
→ Exports frames as PNG at specified scale代码生成
"Generate a Jinja template from node 123:456"
→ Produces HTMX-ready template with DaisyUI classes
"Generate a Playwright Page Object for the Login page in Python"
→ Creates Python test helper with selectors变量和样式绑定(新v0.9.0)
"Get all DaisyUI color variables"
→ Lists all color variables organized by collection (base, primary, secondary, etc.)
"Bind the base-100 variable to the navbar background"
→ Makes the fill theme-compatible (auto-switches light/dark)
Example workflow:
1. resolve_variable_by_name("base-100") → Get variable ID
2. set_fill_variable(nodeId, variableId) → Bind to node
→ Now the node's fill automatically adapts to theme changes
"Check what variables are bound to this card"
→ Shows all variable bindings for fills, strokes, and other properties原型交互
"Link the Login button to the Dashboard frame"
→ Creates ON_CLICK prototype link with smooth transition
"Show all prototype links in the navigation bar"
→ Lists all interactive elements and their destinations______________________________________________________________________
自动同步行为
索引会自动与您的Figma文档保持同步:
| 事件 | 行为 |
|---|---|
| 第一个查询 | 如果为空,则自动构建索引 |
| 文档更改 | 索引在节点创建/删除或>5次属性更改时无效 |
| 陈旧指数 | 如果超过5分钟,则自动重建 |
| 未连接 | 使用缓存索引并发出警告 |
随时检查同步状态 index_status.
变更通知流程
Figma Document Change
↓
Plugin Event Listener (throttled, 1s minimum)
↓
WebSocket Notification
↓
MCP Server Handler
↓
Index Invalidation Flag
↓
Next Query → Auto-rebuild______________________________________________________________________
建筑
┌─────────────────────────────────────────────────────────────────┐
│ CLAUDE CODE │
└───────────────────────────────────┬─────────────────────────────┘
│ MCP Protocol
▼
┌─────────────────────────────────────────────────────────────────┐
│ DAISYUI EDITION MCP SERVER │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────────┐ │
│ │ SQLite FTS5 │ │ DaisyUI │ │ Code Generator │ │
│ │ Index │ │ Component │ │ - Jinja/HTMX │ │
│ │ - Nodes │ │ Detector │ │ - Tailwind │ │
│ │ - Components│ │ - Colors │ │ - Page Objects │ │
│ │ - Pages │ │ - Patterns │ │ - Registry YAML │ │
│ └──────┬──────┘ └──────┬───────┘ └────────────────────┘ │
│ │ │ │
│ ┌──────┴────────────────┴───────────────────────────────────┐ │
│ │ NEW TOOLS (v0.8.0) │ │
│ │ - Design Token Extraction - Accessibility Audit │ │
│ │ - i18n Text Extraction - Component Registry Sync │ │
│ │ - Visual Regression Export - Change Notifications │ │
│ └───────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ Original Tools (50+) │ │
│ │ Document, Creation, Modification, Text, Components │ │
│ └────────────────────────────────────────────────────────────┘ │
└───────────────────────────────┬─────────────────────────────────┘
│ WebSocket + Change Notifications
▼
┌─────────────────────────────────────────────────────────────────┐
│ FIGMA PLUGIN │
│ - Document change listener │
│ - Selection change listener │
│ - Page change listener │
│ - Throttled notification relay │
└─────────────────────────────────────────────────────────────────┘______________________________________________________________________
DaisyUI组件类别
该索引会自动对组件进行分类:
| 类别 | 组件 |
|---|---|
buttons | btn、btn初级、btn次级、btn幽灵等。 |
forms | 输入、选择、复选框、单选、切换、文本区域 |
cards | 卡片,卡片紧凑型,卡片边框 |
navigation | 导航栏、标签、面包屑、菜单 |
feedback | 警报、吐司、模态、工具提示、进度、加载 |
data-display | 统计数据、头像、徽章、表格 |
layout | 英雄、页脚、分隔符、抽屉 |
misc | 崩溃、评级、链接 |
______________________________________________________________________
测试
bun run test # Unit tests
bun run test:coverage # Coverage report
bun run test:integration # Integration testing______________________________________________________________________
版本历史记录
1.1.0(上下文优化)
- 已移除:
get_local_variables,get_variable_collections,get_document_info-这些返回的大量响应(约25000个令牌)迅速填充了上下文 - 请改用:缓存的替代方案,如
get_cached_variable_by_daisyui(),search_cached_variables(),list_pages(),get_page_tree() - 为什么:上下文窗口保留,更快的响应,更好的代理行为
1.0.0(DaisyUI+顺风版)
- 完整的顺风CSS调色板:全面支持所有22个颜色系列和所有色调
- 增强型变量分类:颜色系统、标记类型、语义角色
- 多模式主题支持:在亮/暗模式下存储和查询变量值
- 变量绑定跟踪:跟踪哪些变量绑定到哪些节点
- 间隔和大小标记:支持非颜色设计标记
0.9.0(变量绑定和缓存)
- 变量绑定:将Figma变量(设计标记)绑定到节点填充和笔划
- 主题兼容颜色:使用
set_fill_variable而不是硬编码RGB以支持亮/暗主题 - 变量发现:
resolve_variable_by_name用于按名称查找变量 - 样式绑定:
set_fill_style_id,set_stroke_style_id,set_text_style_id - 计量检验:
get_bound_variables查看绑定到节点的内容 - 清除绑定:
clear_variable_binding删除变量连接 - 变量缓存:使用FTS5搜索存储在SQLite中的变量(
search_cached_variables,list_cached_color_variables) - 每个文档数据库:每个Figma文件都有自己的SQLite数据库(
list_cached_documents) - DaisyUI自动映射:自动映射到语义名称的变量(主、100进制等)
0.8.0(DaisyUI扩展版)
- 设计令牌提取:提取颜色、间距、排版→ 顺风配置或CSS变量
- i18n文本提取:使用建议的i18n键提取文本节点
- 可访问性审计:WCAG 2.1 AA/AAA审核(对比度、触摸目标、文本大小)
- 组件注册表同步:将Figma与本地YAML注册表进行比较
- 可视化回归导出:导出用于视觉测试的框架
- 实时变更通知:文档更改时自动同步索引
- 增强插件:文档/选择/页面更改事件侦听器
- 自动索引无效:基于更改类型的智能缓存失效
0.7.0(DaisyUI版)
- 本地SQLite索引:快速查询,无需Figma往返
- FTS5搜索:自然语言组件搜索
- DaisyUI检测:自动组件到类映射
- 尾风提取:Figma风格→ 尾风公用设施
- 代码生成:Jinja/HTMX模板,页面对象
- 代理优化:具有即用型命令的较小响应
上一页(来自上游)
看 更改日志.md 上游历史。
______________________________________________________________________
许可证和信用证
许可证:MIT
这个叉子:
- DaisyUI版本增强了全面的Figma到代码管道
- 用于设计令牌提取、可访问性审计和代码生成的其他工具
上游:
- 阿林斯珀克/克劳德与费玛·麦克普对话 -克劳德改编自Xúlio Zé
- 光标与figma mcp对话 -Sonny Lazuardi原创
______________________________________________________________________
贡献
- 分叉此回购
- 创建要素分支:
git checkout -b feature/amazing - 进行更改和测试
- 提交带有清晰描述的PR
重点贡献领域:
- 其他DaisyUI组件模式
- 更多顺风测绘覆盖范围
- 增强的代码生成(React、Vue模板)
- 更好的主题令牌提取
- 其他可访问性检查
- 更多i18n密钥生成模式
