Skip to main content
Glama
grab
by grab

export_node_as_image

Convert Figma design nodes into images in PNG, JPG, SVG, or PDF formats. Specify the node ID and scale to export precise design elements for use in documents or presentations.

Instructions

Export a node as an image from Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoExport format
nodeIdYesThe ID of the node to export
scaleNoExport scale

Implementation Reference

  • Registration of the 'export_node_as_image' tool including its input schema (nodeId, optional format and scale), description, and handler function. The handler sends the export command to the underlying Figma plugin via WebSocket (sendCommandToFigma), receives the base64 image data, and returns it as an MCP image content block.
    // Export Node as Image Tool server.tool( "export_node_as_image", "Export a node as an image from Figma", { nodeId: z.string().describe("The ID of the node to export"), format: z .enum(["PNG", "JPG", "SVG", "PDF"]) .optional() .describe("Export format"), scale: z.number().positive().optional().describe("Export scale"), }, async ({ nodeId, format, scale }: any) => { try { const result = await sendCommandToFigma("export_node_as_image", { nodeId, format: format || "PNG", scale: scale || 1, }); const typedResult = result as { imageData: string; mimeType: string }; return { content: [ { type: "image", data: typedResult.imageData, mimeType: typedResult.mimeType || "image/png", }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error exporting node as image: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • Zod input schema for the 'export_node_as_image' tool defining parameters: nodeId (required string), format (optional enum PNG/JPG/SVG/PDF), scale (optional positive number).
    { nodeId: z.string().describe("The ID of the node to export"), format: z .enum(["PNG", "JPG", "SVG", "PDF"]) .optional() .describe("Export format"), scale: z.number().positive().optional().describe("Export scale"),
  • Handler function that executes the tool: proxies parameters to Figma plugin command 'export_node_as_image', handles the response (imageData base64 and mimeType), returns MCP image content or error text.
    async ({ nodeId, format, scale }: any) => { try { const result = await sendCommandToFigma("export_node_as_image", { nodeId, format: format || "PNG", scale: scale || 1, }); const typedResult = result as { imageData: string; mimeType: string }; return { content: [ { type: "image", data: typedResult.imageData, mimeType: typedResult.mimeType || "image/png", }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error exporting node as image: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } }
  • TypeScript type definition for CommandParams of 'export_node_as_image' matching the Zod schema, used in sendCommandToFigma.
    export_node_as_image: { nodeId: string; format?: "PNG" | "JPG" | "SVG" | "PDF"; 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/grab/cursor-talk-to-figma-mcp'

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