Skip to main content
Glama

get_node_images

Extract all image assets from Figma design nodes to download or analyze visual resources within your design files.

Instructions

获取节点中的所有图片资源

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesFigma文件URL,必须包含node-id参数

Implementation Reference

  • MCP tool handler for 'get_node_images': parses input URL, delegates to elementExtractor.getNodeImages, handles response and errors.
    private async handleGetNodeImages(args: any) {
      const { url } = args;
    
      try {
        console.error(`开始获取节点图片资源: ${url}`);
        
        const images = await this.elementExtractor.getNodeImages(
          this.figmaService.parseUrl(url).fileId,
          this.figmaService.parseUrl(url).nodeId!
        );
    
        console.error(`成功获取 ${images.length} 个图片资源`);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                data: {
                  images,
                  totalCount: images.length,
                },
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : '未知错误';
        console.error(`获取节点图片失败: ${errorMessage}`);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: false,
                error: errorMessage,
                troubleshooting: {
                  commonIssues: [
                    '检查Figma URL是否包含node-id参数',
                    '确认节点中是否包含图片资源',
                    '验证对该文件是否有访问权限',
                  ],
                  urlFormat: 'https://www.figma.com/design/{fileId}/{name}?node-id={nodeId}'
                }
              }, null, 2),
            },
          ],
        };
      }
  • Core logic for extracting image resources from a Figma node: traverses node tree, collects IMAGE fills, fetches URLs, deduplicates.
    async getNodeImages(fileId: string, nodeId: string): Promise<ImageResource[]> {
      try {
        const node = await this.figmaService.getNodeDetails(fileId, nodeId);
        if (!node) {
          throw new Error(`节点 ${nodeId} 不存在`);
        }
    
        const images: ImageResource[] = [];
        
        // 递归收集所有包含图片的节点
        this.figmaService.traverseNodeTree(node, (currentNode) => {
          // 检查填充中的图片
          if (currentNode.fills) {
            for (const fill of currentNode.fills) {
              if (fill.type === 'IMAGE' && fill.imageRef) {
                images.push({
                  id: fill.imageRef,
                  name: currentNode.name || `Image in ${currentNode.id}`,
                  type: 'EMBEDDED',
                  size: currentNode.absoluteBoundingBox ? {
                    width: currentNode.absoluteBoundingBox.width,
                    height: currentNode.absoluteBoundingBox.height
                  } : undefined
                });
              }
            }
          }
    
          // 检查节点类型是否为图片
          if (currentNode.type === 'RECTANGLE' && currentNode.fills?.some(f => f.type === 'IMAGE')) {
            // 已在上面处理
          }
        });
    
        // 获取图片的实际URL
        if (images.length > 0) {
          try {
            const imageRefs = await this.figmaService.getFileImageReferences(fileId);
            for (const image of images) {
              if (imageRefs[image.id]) {
                image.url = imageRefs[image.id];
              }
            }
          } catch (error) {
            console.error('获取图片URL失败:', error);
          }
        }
    
        return this.deduplicateImages(images);
      } catch (error) {
        throw new Error(`获取节点图片失败: ${error instanceof Error ? error.message : '未知错误'}`);
      }
    }
  • src/index.ts:140-153 (registration)
    Tool registration in ListToolsResponse: name, description, and input schema.
    {
      name: 'get_node_images',
      description: '获取节点中的所有图片资源',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'Figma文件URL,必须包含node-id参数',
          },
        },
        required: ['url'],
      },
    },
  • Switch case routing tool calls to the specific handler.
    case 'get_node_images':
      return await this.handleGetNodeImages(args);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It implies a read operation ('get') but doesn't disclose behavioral traits such as authentication needs, rate limits, error handling, or what 'all image resources' entails (e.g., format, size, pagination). This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese, front-loaded with the core purpose. It has no wasted words, though it could benefit from more detail given the lack of annotations and sibling tools.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (1 parameter, no annotations, no output schema, and multiple sibling tools), the description is incomplete. It doesn't clarify the 'node' context, differentiate from siblings, or explain return values, leaving gaps for the agent to understand when and how to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'url' documented as 'Figma文件URL,必须包含node-id参数' (Figma file URL, must include node-id parameter). The description adds no meaning beyond this, as it doesn't explain the 'node' context or provide additional syntax details. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取节点中的所有图片资源' (Get all image resources in a node) states a clear verb ('get') and resource ('image resources in a node'), but it's vague about what 'node' means in context (e.g., Figma node). It doesn't distinguish from siblings like 'get_figma_image' or 'export_multiple_images', leaving ambiguity about scope or output format.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_figma_image' and 'export_multiple_images', the description lacks any context, prerequisites, or exclusions, leaving the agent to infer usage based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Echoxiawan/figma-mcp-full-server'

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