Skip to main content
Glama
ArchimedesCrypto

Figma MCP Server with Chunking

具有分块功能的 Figma MCP 服务器

铁匠徽章

用于与 Figma API 交互的模型上下文协议 (MCP) 服务器,具有处理大型 Figma 文件的内存高效分块和分页功能。

概述

此 MCP 服务器提供强大的 Figma API 接口,并内置内存管理功能。它旨在通过将操作分解为可管理的块并在必要时实现分页,从而高效处理大型 Figma 文件。

主要特点

  • 具有可配置限制的内存感知处理

  • 大文件的分块数据检索

  • 所有列表操作均支持分页

  • 节点类型过滤

  • 进度追踪

  • 可配置的块大小

  • 恢复中断操作的能力

  • 调试日志记录

  • 配置文件支持

Related MCP server: Figma MCP Server

安装

通过 Smithery 安装

要通过Smithery自动安装 Figma MCP Server 和 Claude Desktop 的 Chunking:

npx -y @smithery/cli install @ArchimedesCrypto/figma-mcp-chunked --client claude

手动安装

# Clone the repository
git clone [repository-url]
cd figma-mcp-chunked

# Install dependencies
npm install

# Build the project
npm run build

配置

环境变量

  • FIGMA_ACCESS_TOKEN :您的 Figma API 访问令牌

配置文件

您可以使用--config标志通过 JSON 文件提供配置:

{
  "mcpServers": {
    "figma": {
      "env": {
        "FIGMA_ACCESS_TOKEN": "your-access-token"
      }
    }
  }
}

用法:

node build/index.js --config=path/to/config.json

工具

get_file_data(新)

使用内存高效的分块和分页检索 Figma 文件数据。

{
  "name": "get_file_data",
  "arguments": {
    "fileKey": "your-file-key",
    "accessToken": "your-access-token",
    "pageSize": 100,          // Optional: nodes per chunk
    "maxMemoryMB": 512,       // Optional: memory limit
    "nodeTypes": ["FRAME", "COMPONENT"],  // Optional: filter by type
    "cursor": "next-page-token",  // Optional: resume from last position
    "depth": 2                // Optional: traversal depth
  }
}

回复:

{
  "nodes": [...],
  "memoryUsage": 256.5,
  "nextCursor": "next-page-token",
  "hasMore": true
}

列表文件

列出支持分页的文件。

{
  "name": "list_files",
  "arguments": {
    "project_id": "optional-project-id",
    "team_id": "optional-team-id"
  }
}

获取文件版本

分块检索版本历史记录。

{
  "name": "get_file_versions",
  "arguments": {
    "file_key": "your-file-key"
  }
}

获取文件评论

检索带有分页的评论。

{
  "name": "get_file_comments",
  "arguments": {
    "file_key": "your-file-key"
  }
}

获取文件信息

使用分块节点遍历检索文件信息。

{
  "name": "get_file_info",
  "arguments": {
    "file_key": "your-file-key",
    "depth": 2,               // Optional: traversal depth
    "node_id": "specific-node-id"  // Optional: start from specific node
  }
}

获取组件

检索具有分块支持的组件。

{
  "name": "get_components",
  "arguments": {
    "file_key": "your-file-key"
  }
}

获取样式

检索具有分块支持的样式。

{
  "name": "get_styles",
  "arguments": {
    "file_key": "your-file-key"
  }
}

获取文件节点

检索具有分块支持的特定节点。

{
  "name": "get_file_nodes",
  "arguments": {
    "file_key": "your-file-key",
    "ids": ["node-id-1", "node-id-2"]
  }
}

内存管理

服务器实施了几种策略来有效地管理内存:

分块策略

  • 通过pageSize配置块大小

  • 内存使用情况监控

  • 根据内存压力自动调整块大小

  • 每个块的进度跟踪

  • 使用游标恢复功能

最佳实践

  1. 从较小的块大小(50-100 个节点)开始,并根据性能进行调整

  2. 通过响应元数据监控内存使用情况

  3. 尽可能使用节点类型过滤来减少数据负载

  4. 为大型数据集实现分页

  5. 对非常大的文件使用恢复功能

配置选项

  • pageSize :每个块的节点数(默认值:100)

  • maxMemoryMB :最大内存使用量(MB)(默认值:512)

  • nodeTypes :过滤特定的节点类型

  • depth :控制嵌套结构的遍历深度

调试日志

该服务器包括全面的调试日志记录:

// Debug log examples
[MCP Debug] Loading config from config.json
[MCP Debug] Access token found xxxxxxxx...
[MCP Debug] Request { tool: 'get_file_data', arguments: {...} }
[MCP Debug] Response size 2.5 MB

错误处理

服务器提供了详细的错误信息和建议:

// Memory limit error
"Response size too large. Try using a smaller depth value or specifying a node_id.""

// Invalid parameters
"Missing required parameters: fileKey and accessToken"

// API errors
"Figma API error: [detailed message]"

故障排除

常见问题

  1. 内存错误

    • 减少块大小

    • 使用节点类型过滤

    • 实现分页

    • 指定较小的深度值

  2. 性能问题

    • 监视内存使用情况

    • 调整块大小

    • 使用适当的节点类型过滤器

    • 对频繁访问的数据实施缓存

  3. API 限制

    • 实施速率限制

    • 使用分页

    • 尽可能缓存响应

调试模式

启用调试日志以获取详细信息:

# Set debug environment variable
export DEBUG=true

贡献

欢迎贡献代码!请阅读我们的贡献指南,并向我们的代码库提交 Pull Request。

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ArchimedesCrypto/figma-mcp-chunked'

If you have feedback or need assistance with the MCP directory API, please join our Discord server