Skip to main content
Glama

export_multiple_images

Export multiple Figma design elements as images in various formats. Specify file ID, node IDs, format (PNG, JPG, SVG, PDF), and scale to batch download design assets.

Instructions

批量导出多个节点的图片

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileIdYesFigma文件ID
formatNo图片格式,默认为pngpng
nodeIdsYes节点ID列表
scaleNo图片缩放比例,默认为1

Implementation Reference

  • The handler function that executes the tool logic: parses input arguments, invokes the image extractor for multiple images, and returns a formatted JSON response.
    private async handleExportMultipleImages(args: any) { const { fileId, nodeIds, format = 'png', scale = 1 } = args; const options: ImageExportOptions = { format, scale }; const results = await this.imageExtractor.getMultipleImages(fileId, nodeIds, options); return { content: [ { type: 'text', text: JSON.stringify({ success: true, data: { images: results, totalCount: results.length, }, }, null, 2), }, ], }; }
  • Core helper method in FigmaImageExtractor that fetches node information, exports images via Figma API, and constructs ImageResult objects for multiple nodes.
    async getMultipleImages( fileId: string, nodeIds: string[], options: ImageExportOptions = {} ): Promise<ImageResult[]> { try { if (nodeIds.length === 0) { return []; } // 获取所有节点信息 const nodeInfoPromises = nodeIds.map(nodeId => this.figmaService.getNode(fileId, nodeId) ); const nodeInfos = await Promise.all(nodeInfoPromises); // 导出所有图片 const images = await this.figmaService.exportImage(fileId, nodeIds, options); const results: ImageResult[] = []; for (let i = 0; i < nodeIds.length; i++) { const nodeId = nodeIds[i]; const nodeInfo = nodeInfos[i]; const imageUrl = images[nodeId]; if (imageUrl && nodeInfo) { results.push({ url: imageUrl, nodeId, nodeName: nodeInfo.name, format: options.format || 'png', scale: options.scale || 1, }); } } return results; } catch (error) { throw new Error(`批量获取图片失败: ${error instanceof Error ? error.message : '未知错误'}`); } }
  • Input schema defining the parameters for the export_multiple_images tool: fileId, nodeIds (required), format, and scale.
    inputSchema: { type: 'object', properties: { fileId: { type: 'string', description: 'Figma文件ID', }, nodeIds: { type: 'array', items: { type: 'string' }, description: '节点ID列表', }, format: { type: 'string', enum: ['png', 'jpg', 'svg', 'pdf'], description: '图片格式,默认为png', default: 'png', }, scale: { type: 'number', description: '图片缩放比例,默认为1', default: 1, minimum: 0.01, maximum: 4, }, }, required: ['fileId', 'nodeIds'], },
  • src/index.ts:94-125 (registration)
    Registration of the export_multiple_images tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: 'export_multiple_images', description: '批量导出多个节点的图片', inputSchema: { type: 'object', properties: { fileId: { type: 'string', description: 'Figma文件ID', }, nodeIds: { type: 'array', items: { type: 'string' }, description: '节点ID列表', }, format: { type: 'string', enum: ['png', 'jpg', 'svg', 'pdf'], description: '图片格式,默认为png', default: 'png', }, scale: { type: 'number', description: '图片缩放比例,默认为1', default: 1, minimum: 0.01, maximum: 4, }, }, required: ['fileId', 'nodeIds'], }, },
  • Type definition for the ImageResult returned by the image export functions, used in the tool's output.
    export interface ImageResult { url: string; nodeId: string; nodeName: string; format: string; scale: number; }

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