Figma Forge
Allows AI agents to create, modify, and read Figma designs directly via a Bridge Server and Figma Plugin, providing semantic tools for UI components, layouts, variables, variants, templates, exports, and more.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Figma Forge
为什么需要 Figma Forge
痛点 | 现状 | Figma Forge |
官方 API 限流 | 120 req/min,复杂文件频繁 429 | Plugin API,无调用限制 |
只能读不能写 | REST API 单向 | 完整的创建 / 修改 / 删除 |
每次调用走网络 | 高延迟、易超时 | WebSocket 本地通信,毫秒级响应 |
手动设计效率低 | 重复操作、无法批量 | AI 一次指令,64 个语义工具自动编排 |
Related MCP server: F_MCP
架构
flowchart TD
A["Claude Code<br/>AI 理解意图, 调用语义工具"]
B["Figma Forge Bridge<br/>MCP Server · Semantic Layer · REST API"]
C["Figma Plugin<br/>在 Figma 沙箱中执行 Plugin API"]
D["Figma Desktop<br/>设计稿实时渲染"]
A -- "MCP (stdio)" --> B
B -- "WebSocket (localhost:37849)" --> C
C -- "Plugin API" --> D核心设计:AI 只说"做什么"(create_button({ variant: "primary" })),Bridge 负责"怎么做"(自动编排 createNode → setLayout → createText)。一次 Tool Call 完成复杂设计操作。
特性一览
一次调用即可生成完整的 UI 组件,无需手动拼装底层 API。
类别 | 工具 |
基础 |
|
UI 组件 |
|
布局 |
|
曲线与矢量 |
|
支持按 ID 精确操作,也支持按语义标签批量操作。
工具 | 说明 |
| 更新属性(单个 / 批量) |
| 删除节点(单个 / 批量) |
| 移动与重排 |
工具 | 说明 |
| 文档名称、页面列表 |
| 递归获取节点层级 |
| 获取节点属性 |
| 按名称 / 类型 / 语义搜索 |
| 样式信息 |
| 语义注册表 |
能力 | 工具 | 说明 |
Layout |
| Auto Layout 配置与绝对定位(含 6 种预设:centered, stretch-fill, hug-content, sidebar-left, stack-vertical, grid-cell) |
Layout 计算 |
| 纯计算(无 Figma 交互)+ 容器自适应 + 边界校验(可自动修复) |
Variables |
| 设计 Token CRUD,支持 light/dark 多模式 |
Variants |
| 组件变体的创建与实例化 |
Diff Engine |
| 增量更新,只发送变化的属性 |
Templates |
| 预定义模板 + 参数化生成 |
Batch |
| 批量执行,失败可选回滚 |
Events |
| 实时监听文档变化 |
Export |
| 导出为 PNG / JPG / SVG / PDF |
快速开始
前置条件
依赖 | 版本 | 说明 |
Figma Desktop | — | ⚠️ Web 版不支持 Plugin API |
Node.js | ≥ 22 | 运行 Bridge Server(支持仍维护的 LTS;18/20 已 EOL,CI 在 22/24 上验证) |
Claude Code | — | CLI 或 VS Code 插件均可 |
安装
方式一:从 npm(推荐)
npx @figma-forge/core setup方式二:从源码
git clone <repo-url> && cd Figma-Forge
pnpm install && pnpm build加载 Plugin(自动注册,无需手动 Import)
figma-forge setup 会把插件自动注册进 Figma Desktop(等价于手动 Import plugin from manifest,零前台操作)。之后只需:
figma-forge launch # 或双击仓库根目录的 figma-forge-launch.cmd
figma-forge launch --file <key> # 顺便打开/聚焦指定 Figma 文件launch 会:检查注册(缺失则补上)→ 启动/聚焦 Figma Desktop → 提示运行插件。
⚠️ 注册写入必须在 Figma 未运行时进行——Figma 退出时会回写配置文件把注册冲掉。launch/setup 会自动检测并提示先关闭 Figma。安装时 Figma 若正开着,关掉后跑一次
figma-forge launch即可收尾;Bridge 每次启动也会自愈补注册。
Figma 的 URL try-plugin 机制只对已发布的社区插件生效(实测 dev 插件不行)。发布一次后,launch 就能全自动完成「打开 Figma → 自动运行插件 → 自动连上 Bridge」:
# 发布步骤见 docs/community-publish.md(一次性,约 5 分钟)
figma-forge launch --community-id <社区插件id> # 保存配置
figma-forge launch # 之后每次:全自动装载配置存 ~/.figma-forge/community.json;--clear-community 可回退 dev 链路。改代码后重新 Publish 到 Community 即发新版(用 try-plugin-id 跟随最新版,无需改配置)。
打开 Figma Desktop(不是 Web 版)
Plugins→Development→Import plugin from manifest...选择文件:
npm 安装 →
~/.figma-forge/plugin/manifest.json源码安装 →
packages/plugin/manifest.json
开始使用
# 在项目目录启动 Claude Code(它会自动启动 Bridge Server)
cd <your-project>
claude在 Figma 中右键 → Plugins → Figma Forge,看到 "Connected to Bridge" 后即可对话:
你: 帮我创建一个登录页面
Claude: (调用 create_form → create_button → create_input,Figma 中实时生成)插件每个 Figma 会话需手动启动一次(Figma 平台限制:插件无法自启或后台运行)。面板保持打开即全程有效——同一 Figma 会话内 MCP 随便用,Bridge 重启也会自动重连。
⚠️ 不要手动启动 Bridge Server。 Claude Code 通过
.mcp.json自动管理其生命周期,手动启动会导致端口冲突。
提升体验的小技巧
设置快捷键:
Figma → Settings → Keyboard shortcuts → Plugins → Figma Forge,绑定一个顺手的组合键(如Ctrl+Shift+F),每次打开 Figma 一键启动。保持面板常驻:Plugin 面板启动后不要关闭,WebSocket 连接会一直保持。只要 Figma 不退出,整个会话期间只需启动一次。
自动重连:如果 Bridge Server 重启,Plugin 会自动尝试重连(最多 20 次,指数退避:3 秒起逐次翻倍,30 秒封顶);超过上限后点击面板中的 Retry 按钮手动重连。
工作区布局
使用时需要三个窗口同时工作:
flowchart LR
subgraph T1["Terminal 1"]
A["Claude Code<br/>输入设计需求<br/>AI 调用 Semantic Tools"]
end
subgraph APP["App Window"]
B["Figma Desktop<br/>设计稿实时生成<br/>64 个语义工具可用"]
end
subgraph EMBED["Figma 内嵌"]
C["Plugin Panel<br/>显示连接状态<br/>执行日志"]
end
A <--> B
C -. "WebSocket" .-> BBridge Server 由 Claude Code 在后台自动启动,无需额外操作。
开发
pnpm build # 构建所有包
pnpm dev:bridge # 单独调试 Bridge(⚠️ 不要和 Claude Code 同时使用)技术栈
层级 | 技术 |
Plugin | TypeScript · Figma Plugin API |
Bridge | TypeScript · Node.js · |
构建 | esbuild + tsc · pnpm monorepo |
REST API
Bridge Server 同时提供 HTTP 接口,可作为 MCP 的补充:
curl http://localhost:37850/health # 健康检查
curl -X POST http://localhost:37850/tools/get_document_info # 获取文档信息
curl -X POST http://localhost:37850/tools/create_container \
-H "Content-Type: application/json" \
-d '{"name": "my-frame", "direction": "VERTICAL", "padding": 16}' # 创建容器常用工作流
导出落盘(不要让 base64 占用上下文)
传 outputPath / outputDir 时,图片直接写入本地文件,响应只回路径摘要(<1KB);
不传则响应内联 base64(仅适合小图)。
# 单节点导出到文件(父目录自动创建)
curl -X POST http://localhost:37850/tools/export_node \
-H "Content-Type: application/json" \
-d '{"nodeId": "1:23", "format": "PNG", "scale": 2, "outputPath": "/tmp/out/logo.png"}'
# → { "savedTo": "/tmp/out/logo.png", "format": "PNG", "width": 120, "height": 40, "bytes": 8421 }
# 按语义标签批量导出到目录
curl -X POST http://localhost:37850/tools/export_by_semantic \
-H "Content-Type: application/json" \
-d '{"semantic": "icon", "format": "SVG", "outputDir": "/tmp/out/icons", "limit": 50}'
# → { "exported": 12, "files": [{ "nodeId": "1:2", "name": "Icon Home", "savedTo": "...", "bytes": 913 }], "totalMatches": 12 }导入大 SVG(用 filePath,别拼字符串)
curl -X POST http://localhost:37850/tools/import_svg \
-H "Content-Type: application/json" \
-d '{"filePath": "/tmp/poster-traced.svg", "name": "Poster", "semantic": "artwork"}'filePath与svg二选一;同时传以svg优先上限 10MB,超出报错并带路径
文件不存在时错误信息含完整路径
改文本排版(字距 / 行高 / 段落)
值结构沿用 Figma Plugin API;不在属性清单内的键会被拒绝(报 Unsupported properties: ...)。
curl -X POST http://localhost:37850/tools/update_node \
-H "Content-Type: application/json" \
-d '{"nodeId": "1:23", "properties": {
"letterSpacing": {"unit": "PERCENT", "value": -8},
"lineHeight": {"unit": "PIXELS", "value": 24},
"paragraphSpacing": 6,
"textCase": "UPPER",
"textDecoration": "UNDERLINE"
}}'支持的属性全集(按类别)见 update_node 的工具描述(GET /tools 可查):
类别 | 属性 |
通用 |
|
几何/位置 |
|
填充与描边 |
|
外观 |
|
文本(仅 TEXT) |
|
工具参数速查
工具 | 新参数 | 说明 |
|
| 落盘路径;传了就只回 |
|
| 批量落盘目录;传了就只回 |
|
| 读本地 SVG 文件(推荐,避免大字符串占用上下文) |
|
| 默认 |
|
| 默认 |
|
|
|
|
| 只描摹指定区域。⚠️ 会截断跨区域笔画,需要完整笔画改用 |
|
| 命名区域, |
| — | 字体解析透明化:返回 |
trace_image 的 per-component 返回:
{
"componentCount": 3,
"pathCount": 41,
"components": [
{ "name": "Logo", "nodeId": "1:40", "bbox": {"x": 12, "y": 8, "width": 96, "height": 72}, "pathCount": 17, "paths": ["M0 0 ..."] }
],
"originalSize": { "width": 800, "height": 600 }
}Figma 插件开发须知
dev 插件注册表(settings.json)
Figma Desktop「Import plugin from manifest」的注册信息落盘在 %APPDATA%\Figma\settings.json(macOS: ~/Library/Application Support/Figma/settings.json)的 localFileExtensions,三条一组:
[
{ "id": 1, "manifestPath": "…/manifest.json", "lastKnownName": "Figma Forge",
"lastKnownPluginId": "figma-forge-plugin",
"fileMetadata": { "type": "manifest", "codeFileId": 2, "uiFileIds": [3] },
"cachedContainsWidget": false },
{ "id": 2, "manifestPath": "…/dist/code.js", "fileMetadata": { "type": "code", "manifestFileId": 1 } },
{ "id": 3, "manifestPath": "…/ui.html", "fileMetadata": { "type": "ui", "manifestFileId": 1 } }
]注册/注销可程序化(
packages/bridge/src/figma-register.ts:幂等、合并不动其他 dev 插件、按 pluginId 或 manifest 路径匹配)必须在 Figma 未运行时写:Figma 运行中会频繁回写该文件(窗口/标签状态同存于此),写入会被冲掉;注册本身也要 Figma 重启才生效
注册目标:开发模式指向源码树
packages/plugin(构建产物就地更新);npm 模式指向~/.figma-forge/plugin副本(npx 缓存路径不稳定,不能注册包内嵌副本)URL 自动运行不可用:桌面端 URL 的
try-plugin-id/try-plugin-name参数(社区插件 "Try it" 机制)实测只对已发布社区插件生效,拉不起本地 dev 插件(design/new、file/new、已有文件三种 URL 形式均验证),插件启动仍需每会话手动一次
manifest networkAccess 的正确写法
Figma 校验 allowedDomains 只接受精确 URL,不支持通配符端口、也不接受 IP 字面量:
// packages/plugin/manifest.json
"networkAccess": {
"allowedDomains": ["ws://localhost:37849"], // ✅ 精确 scheme + host + 端口
"devAllowedDomains": ["ws://localhost:37849"]
}写法 | 结果 |
| ✅ 通过 |
| ❌ 拒绝(不支持端口通配) |
| ❌ 拒绝(IP 字面量不合法,必须写 |
| ❌ 与用途不符,插件只连 WebSocket |
改端口必须同步两处:manifest.json 的 allowedDomains/devAllowedDomains,以及 packages/plugin/src/ui.html 里的连接地址。只改一处会连不上(面板显示 Disconnected)。
插件沙箱限制
限制 | 说明 |
| 可能抛 |
| 走 structured clone: |
SVG 导入 |
|
网络 | 只能访问 |
Figma 平台限制
限制 | 说明 |
文本节点横向缩放 | Figma 不支持字形横向压缩(scale 变形);需要精确压缩版式请走 SVG 成品( |
文本样式修改 | 任何文本属性写入前必须 |
| 当前 manifest 未声明 |
安全与多会话
机制 | 说明 |
多会话代理模式 | 端口 37849 已被另一个 Figma Forge Bridge 占用时,新实例自动进入代理模式:命令转发给已有 Bridge,多个 Claude Code 会话可同时驱动同一个 Figma 插件(事件监听仅主会话可见) |
自举接管 | 主级 Bridge 死亡后,次级不再永久转发失败:每 10s 探测一次 |
运行态可观测 |
|
| 设置后 Plugin 面板需填入相同 token 才能握手(防本机其他进程冒充 Plugin) |
| 设置后 REST 调用需携带 |
默认绑定 |
|
curl http://localhost:37850/health
# → { "status": "ok", "version": "0.1.0", "mode": "primary", "pluginConnected": true }转正瞬间仍在途的命令允许失败(结果未知,与命令超时同语义);转正后 Plugin 会按面板的自动重连逻辑连到新的主级。
版本与端口元数据
版本号与端口分散在多个文件,改任意一处时按下表同步(端口漏改的典型症状是面板 Disconnected):
元数据 | 当前值 | 权威来源 | 需手动同步的位置 |
Bridge 版本 |
|
| 三个包 |
WS 端口 |
|
|
|
REST 端口 |
|
| 本文档的 curl 示例 |
/health 的 version、MCP serverInfo.version、启动横幅统一读 BRIDGE_VERSION;
Plugin 侧的 manifest/ui.html 是静态文件,无法运行时共享常量,发版时按上表手动对齐。
故障排查
问题 | 排查步骤 |
插件不会随 Figma 自动启动 | dev 插件:Figma 平台限制,每个 Figma 会话需手动启动一次(右键 → Plugins → Figma Forge;绑快捷键可一键)。零点击方案:发布到 Community 后 |
launch/setup 提示先关闭 Figma | 注册写入必须在 Figma 未运行时进行(退出回写会冲掉写入)。关闭 Figma Desktop 后重跑 |
Plugin 显示 "Disconnected" | ① 确认 Figma Desktop(非 Web) ② 确认 Claude Code 已启动 ③ 查看终端是否有 |
MCP server failed to start | ① |
端口冲突 EADDRINUSE | 多个 Claude Code 会话会自动进入代理模式共享一个 Plugin 连接,无需处理。若提示端口被非 Bridge 进程占用:查找占用进程 |
代理态报 | 看错误尾部的 |
| 属性不在 |
字体报错 / |
|
导出响应巨大 | 给 |
| 保持 |
| 用 |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
The Figma MCP server brings Figma design context directly into your AI workflow.
Hosted Notion MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to interact with Figma designs for tasks like reading document info, creating elements, and managing auto layouts. It facilitates real-time design automation via a custom Figma plugin and WebSocket server integration.MIT
- FlicenseNot gradedqualityNot gradedmaintenanceAn MCP bridge that enables Claude Code to directly control Figma via a WebSocket-connected plugin. It allows users to create elements, modify styles, manage layouts, and interact with Figma designs using natural language commands.1,057 npm-
- AlicenseNot gradedqualityDmaintenanceMCP server that connects AI clients to Figma, enabling real-time reading, creation, and modification of designs using natural language.MIT
- AlicenseCqualityDmaintenanceA comprehensive MCP server that enables Claude to read, create, edit, and generate code from Figma designs. Supports design tokens, code generation to multiple frameworks, and accessibility checks.1004MIT