view_node
Retrieve a thumbnail of a specific node within a Figma file by specifying the file key and node ID using the Figma MCP Server tool.
Instructions
Get a thumbnail for a specific node in a Figma file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_key | Yes | The key of the Figma file | |
| node_id | Yes | The ID of the node to view. Node ids have the format `<number>:<number>` |
Implementation Reference
- index.ts:195-215 (handler)The main handler function that executes the view_node tool: fetches thumbnails for the node using getThumbnails, converts to base64, and returns an image in the tool result.async function doViewNode(fileKey: string, nodeId: string): Promise<CallToolResult> { const thumbnails = await getThumbnails(fileKey, [nodeId]); const nodeThumb = thumbnails[nodeId]; if (!nodeThumb) { throw new Error(`Could not get thumbnail for node ${nodeId}`); } const b64 = await imageUrlToBase64(nodeThumb); return { content: [ { type: "text", text: `Thumbnail for node ${nodeId}:`, }, { type: "image", data: b64, mimeType: "image/png", }, ], }; }
- index.ts:49-66 (schema)The Tool schema definition for view_node, specifying input parameters file_key and node_id.const VIEW_NODE: Tool = { name: "view_node", description: "Get a thumbnail for a specific node in a Figma file", inputSchema: { type: "object", properties: { file_key: { type: "string", description: "The key of the Figma file", }, node_id: { type: "string", description: "The ID of the node to view. Node ids have the format `<number>:<number>`", }, }, required: ["file_key", "node_id"], }, };
- index.ts:138-140 (registration)Registration of the view_node tool (via VIEW_NODE constant) in the MCP server's list of tools.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ADD_FIGMA_FILE, VIEW_NODE, READ_COMMENTS, POST_COMMENT, REPLY_TO_COMMENT], }));
- index.ts:323-327 (helper)Helper utility to convert the thumbnail image URL to base64 format, called within the doViewNode handler.async function imageUrlToBase64(url: string) { const response = await fetch(url); const arrayBuffer = await response.arrayBuffer(); return Buffer.from(arrayBuffer).toString("base64"); }
- index.ts:270-273 (registration)Dispatch logic in the CallToolRequest handler that routes 'view_node' calls to the doViewNode function.if (request.params.name === "view_node") { const input = request.params.arguments as { file_key: string; node_id: string }; return doViewNode(input.file_key, input.node_id); }