figma_get_images
Extract images from Figma nodes by specifying file key, node IDs, format, scale, and other parameters. Supports formats like PNG, JPG, SVG, and PDF for efficient design asset retrieval.
Instructions
Get images of Figma nodes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileKey | Yes | Unique identifier of the Figma file | |
| format | No | Image format, e.g., png, jpg, svg | |
| ids | Yes | Node IDs to get images for, comma separated | |
| personalToken | No | Your Figma personal access token | |
| scale | No | Image scale factor | |
| svg_include_id | No | Whether SVG includes ID | |
| svg_simplify_stroke | No | Whether to simplify SVG strokes | |
| use_absolute_bounds | No | Whether to use absolute bounds | |
| version | No | Specify the version to return |
Implementation Reference
- src/server/figma/tools/figma.ts:56-68 (handler)Handler function that executes the tool logic by calling api.images(o) and formatting the response as text content or error.async (o): Promise<CallToolResult> => { try { const data = await api.images(o) return { content: [{type: 'text', text: JSON.stringify(data)}], } } catch (error: any) { return { content: [{type: 'text', text: `Error: ${error.message}`}], } } },
- src/server/figma/tools/figma.ts:40-69 (registration)Registration of the figma_get_images tool on the MCP server, specifying name, description, input schema, and handler function.'figma_get_images', 'Get images of Figma nodes', { fileKey: z.string().describe('Unique identifier of the Figma file'), ids: z.string().describe('Node IDs to get images for, comma separated'), format: z.enum(['jpg', 'png', 'svg', 'pdf']).optional().describe('Image format, e.g., png, jpg, svg'), scale: z.number().optional().describe('Image scale factor'), svg_include_id: z.boolean().optional().describe('Whether SVG includes ID'), svg_simplify_stroke: z.boolean().optional().describe('Whether to simplify SVG strokes'), use_absolute_bounds: z.boolean().optional().describe('Whether to use absolute bounds'), version: z.string().optional().describe('Specify the version to return'), personalToken: z .string() .optional() .describe('Your Figma personal access token, The parameters are not required when the tool is called.'), }, async (o): Promise<CallToolResult> => { try { const data = await api.images(o) return { content: [{type: 'text', text: JSON.stringify(data)}], } } catch (error: any) { return { content: [{type: 'text', text: `Error: ${error.message}`}], } } }, )
- Zod input validation schema for the tool parameters.{ fileKey: z.string().describe('Unique identifier of the Figma file'), ids: z.string().describe('Node IDs to get images for, comma separated'), format: z.enum(['jpg', 'png', 'svg', 'pdf']).optional().describe('Image format, e.g., png, jpg, svg'), scale: z.number().optional().describe('Image scale factor'), svg_include_id: z.boolean().optional().describe('Whether SVG includes ID'), svg_simplify_stroke: z.boolean().optional().describe('Whether to simplify SVG strokes'), use_absolute_bounds: z.boolean().optional().describe('Whether to use absolute bounds'), version: z.string().optional().describe('Specify the version to return'), personalToken: z .string() .optional() .describe('Your Figma personal access token, The parameters are not required when the tool is called.'), },
- src/server/figma/apis/figma.ts:19-22 (helper)Helper function implementing the Figma API call for retrieving images by constructing the endpoint URL and fetching the data.async images(o: GetImagesParams) { const url = this.opToUrl(`${this.figmaHost}/images/${o.fileKey}`, o) return this.fetch(url) }
- TypeScript type definition for input parameters matching the tool schema.export interface GetImagesParams { fileKey: string ids: string scale?: number format?: 'jpg' | 'png' | 'svg' | 'pdf' svg_include_id?: boolean svg_simplify_stroke?: boolean use_absolute_bounds?: boolean version?: string personalToken?: string }