scan_text_nodes
Extract all text content from selected Figma design elements to analyze, edit, or export text data for AI-assisted design workflows.
Instructions
Scan all text nodes in the selected Figma node
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | ID of the node to scan |
Implementation Reference
- Full registration and handler implementation for the 'scan_text_nodes' MCP tool. The handler proxies the request to the Figma plugin's scan_text_nodes command with chunking enabled, processes the response, and returns formatted content including progress status and results.server.tool( "scan_text_nodes", "Scan all text nodes in the selected Figma node", { nodeId: z.string().describe("ID of the node to scan"), }, async ({ nodeId }) => { try { // Initial response to indicate we're starting the process const initialStatus = { type: "text" as const, text: "Starting text node scanning. This may take a moment for large designs...", }; // Use the plugin's scan_text_nodes function with chunking flag const result = await sendCommandToFigma("scan_text_nodes", { nodeId, useChunking: true, // Enable chunking on the plugin side chunkSize: 10 // Process 10 nodes at a time }); // If the result indicates chunking was used, format the response accordingly if (result && typeof result === 'object' && 'chunks' in result) { const typedResult = result as { success: boolean, totalNodes: number, processedNodes: number, chunks: number, textNodes: Array<any> }; const summaryText = ` Scan completed: - Found ${typedResult.totalNodes} text nodes - Processed in ${typedResult.chunks} chunks `; return { content: [ initialStatus, { type: "text" as const, text: summaryText }, { type: "text" as const, text: JSON.stringify(typedResult.textNodes, null, 2) } ], }; } // If chunking wasn't used or wasn't reported in the result format, return the result as is return { content: [ initialStatus, { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error scanning text nodes: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
- Input schema for the scan_text_nodes tool using Zod validation for nodeId parameter.{ nodeId: z.string().describe("ID of the node to scan"), },
- src/talk_to_figma_mcp/tools/index.ts:12-19 (registration)Higher-level tool registration that calls registerDocumentTools(server), which includes scan_text_nodes.export function registerTools(server: McpServer): void { // Register all tool categories registerDocumentTools(server); registerCreationTools(server); registerModificationTools(server); registerTextTools(server); registerComponentTools(server); }
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Main server setup calls registerTools, indirectly registering scan_text_nodes tool.registerTools(server);
- Type definition including 'scan_text_nodes' as a valid FigmaCommand used by the websocket communication.| "scan_text_nodes"