用于与Figma API交互的MCP服务器。此服务器通过模型上下文协议提供了完整的Figma API方法集。在处理大型Figma文件时,有时需要指定深度为1来获取文件,当需要更多细节时再增加深度。
此服务器实现了所有Figma API方法作为MCP工具:
figma_get_me - 获取当前用户figma_get_file - 根据键获取Figma文件figma_get_file_nodes - 从Figma文件中获取特定节点figma_get_images - 渲染Figma文件中的图像figma_get_image_fills - 获取Figma文件中的图像填充figma_get_file_versions - 获取Figma文件的版本历史figma_get_comments - 获取Figma文件中的评论figma_post_comment - 向Figma文件添加评论figma_delete_comment - 删除Figma文件中的评论figma_get_comment_reactions - 获取评论的反应figma_post_comment_reaction - 向评论添加反应figma_delete_comment_reaction - 删除评论的反应figma_get_team_projects - 获取团队中的项目figma_get_project_files - 获取项目中的文件figma_get_team_components - 获取团队中的组件figma_get_file_components - 获取文件中的组件figma_get_component - 根据键获取组件figma_get_team_component_sets - 获取团队中的组件集合figma_get_file_component_sets - 获取文件中的组件集合figma_get_component_set - 根据键获取组件集合figma_get_team_styles - 获取团队中的样式figma_get_file_styles - 获取文件中的样式figma_get_style - 根据键获取样式figma_post_webhook - 创建webhookfigma_get_webhook - 根据ID获取webhookfigma_update_webhook - 更新webhookfigma_delete_webhook - 删除webhookfigma_get_team_webhooks - 获取团队中的webhookfigma_get_library_analytics_component_usages - 获取库分析组件使用数据figma_get_library_analytics_style_usages - 获取库分析样式使用数据figma_get_library_analytics_variable_usages - 获取库分析变量使用数据要通过 Smithery 自动安装 mcp-figma for Claude Desktop:
npx @smithery/cli@latest install @thirdstrandstudio/mcp-figma --client claude
# 克隆仓库
git clone https://github.com/thirdstrandstudio/mcp-figma.git
cd mcp-figma
# 安装依赖
npm install
# 构建包
npm run build
要使用此MCP服务器,您需要设置您的Figma API令牌。您可以采用以下三种方式之一进行设置:
在项目根目录创建一个.env文件或直接设置环境变量:
FIGMA_API_KEY=your_figma_api_key
启动服务器时,可以通过命令行参数传递您的Figma API令牌:
# 使用长形式
node dist/index.js --figma-token YOUR_FIGMA_TOKEN
# 或使用短形式
node dist/index.js -ft YOUR_FIGMA_TOKEN
在您的 claude_desktop_config.json 中添加以下内容:
{
"mcpServers": {
"figma": {
"command": "npx",
"args": ["@thirdstrandstudio/mcp-figma", "--figma-token", "your_figma_api_key"]
}
}
}
{
"mcpServers": {
"figma": {
"command": "node",
"args": ["/path/to/mcp-figma/dist/index.js"],
"env": {
"FIGMA_API_KEY": "your_figma_api_key"
}
}
}
}
{
"mcpServers": {
"figma": {
"command": "node",
"args": ["/path/to/mcp-figma/dist/index.js", "--figma-token", "your_figma_api_key"]
}
}
}
请将 /path/to/mcp-figma 替换为您实际的仓库路径。
// 获取 Figma 文件
const result = await callTool("figma_get_file", {
fileKey: "abcXYZ123"
});
// 从文件中获取评论
const comments = await callTool("figma_get_comments", {
fileKey: "abcXYZ123",
as_md: true
});
// 创建 webhook
const webhook = await callTool("figma_post_webhook", {
event_type: "FILE_UPDATE",
team_id: "12345",
endpoint: "https://example.com/webhook",
passcode: "your_passcode_here",
description: "文件更新 webhook"
});
# 安装依赖
npm install
# 在开发模式下启动服务器
npm start
# 构建服务器
npm run build
# 使用 Figma API 令牌运行
npm start -- --figma-token YOUR_FIGMA_TOKEN
此 MCP 服务器根据 MIT 许可证发布。这意味着您可以自由地使用、修改和分发该软件,但需遵守 MIT 许可证的条款和条件。如需更多信息,请参阅项目存储库中的 LICENSE 文件。