remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
Converts Figma design elements into standard CSS style properties for accurate code implementation.
Fetches design data from Figma files and converts it to AI-friendly formats, retrieving layouts, styles, and images for use in code generation.
Supports downloading SVG assets from Figma designs for use in development projects.
Figma MCP 服务器
本项目基于开源项目 Figma-Context-MCP 改进,优化了数据结构和转换逻辑。
English Version | 中文版
这是一个基于模型上下文协议(MCP)的服务器,允许您将Figma设计文件与Cursor、Windsurf、Cline等AI编码工具无缝集成。
当AI工具能够访问Figma设计数据时,它们能够更准确地一次性生成符合设计的代码,比截图等传统方式效果更好。
功能特点
- 将Figma设计数据转换为AI模型易于理解的格式
- 支持获取Figma文件、画板或组件的布局和样式信息
- 支持下载Figma中的图片和图标资源
- 减少提供给模型的上下文量,提高AI响应的准确性和相关性
与原版的主要区别
设计稿返回数据格式
数据结构说明
SimplifiedDesign
设计文件的顶层结构,包含基本信息和所有可见节点。
SimplifiedNode
代表设计中的一个元素,可以是画板、框架、文本或形状等。主要字段包括:
id
: 节点唯一标识符name
: 节点在Figma中的名称type
: 节点类型(FRAME, TEXT, RECTANGLE等)text
: 文本内容(仅文本节点有)cssStyles
: CSS样式对象,包含所有样式属性fills
: 填充信息数组exportInfo
: 导出信息(图片和SVG节点)children
: 子节点数组
CSSStyle
包含转换为Web标准的CSS样式属性,如字体、颜色、边框、阴影等。
ExportInfo
图片和SVG节点的导出信息,包含:
type
: 导出类型(IMAGE或IMAGE_GROUP)format
: 推荐的导出格式(PNG, JPG, SVG)nodeId
: 用于API调用的节点IDfileName
: 建议的文件名
安装与使用
安装及使用
Installing via Smithery
To install Figma MCP 服务器 for Claude Desktop automatically via Smithery:
本地开发和打包
- 克隆本仓库
- 安装依赖:
pnpm install
- 复制
.env.example
为.env
并填入您的Figma API访问令牌 - 本地开发:
pnpm run dev
- 构建项目:
pnpm run build
- 本地打包:
pnpm run publish:local
打包后会在项目根目录生成一个.tgz
文件,如figma-mcp-server-1.0.0.tgz
本地安装使用
有两种方式可以使用该服务:
方式1:从NPM安装(推荐)
方式2:从本地包安装
方式3:在项目中使用
命令行参数
--version
: 显示版本号--figma-api-key
: 您的Figma API访问令牌(必需)--port
: 服务器运行的端口(默认:3333)--stdio
: 以命令模式运行服务器,而不是默认的HTTP/SSE模式--help
: 显示帮助菜单
与AI工具连接
在配置文件中使用
许多工具如Cursor、Windsurf和Claude Desktop使用配置文件来启动MCP服务器。 您可以在配置文件中添加以下内容:
与Cursor连接
- 启动服务器:
figma-mcp --figma-api-key=<your-figma-api-key>
- 在Cursor的设置→功能选项卡中连接MCP服务器:
http://localhost:3333
- 确认连接成功后,在Agent模式下使用Composer
- 粘贴Figma文件链接并要求Cursor实现设计
可用工具
服务器提供以下MCP工具:
get_figma_data
获取Figma文件或特定节点的信息。
参数:
fileKey
:Figma文件的密钥nodeId
:节点ID(强烈推荐使用)depth
:遍历节点树的深度
download_figma_images
下载Figma文件中的图片和图标资源。
参数:
fileKey
:包含节点的Figma文件密钥nodes
:要获取的图像节点数组localPath
:项目中存储图像的目录路径
This server cannot be installed
A Model Context Protocol server that integrates Figma design files with AI coding tools like Cursor, Windsurf, and Cline, allowing AI tools to access and understand Figma design data for generating more accurate code.