set_text_content
Update text content in Figma text nodes by specifying node ID and new text, enabling programmatic text modifications through MCP integration.
Instructions
Set the text content of an existing text node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the text node to modify | |
| text | Yes | New text content |
Implementation Reference
- src/talk_to_figma_mcp/server.ts:905-939 (registration)Registers the set_text_content MCP tool with name, description, Zod input schema (nodeId, text), and handler function that forwards to Figma plugin.server.tool( "set_text_content", "Set the text content of an existing text node in Figma", { nodeId: z.string().describe("The ID of the text node to modify"), text: z.string().describe("New text content"), }, async ({ nodeId, text }) => { try { const result = await sendCommandToFigma("set_text_content", { nodeId, text, }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Updated text content of node "${typedResult.name}" to "${text}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting text content: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
- src/talk_to_figma_mcp/server.ts:912-938 (handler)Handler function sends 'set_text_content' command with nodeId and text to Figma plugin via sendCommandToFigma, processes response or error, returns MCP-formatted content.async ({ nodeId, text }) => { try { const result = await sendCommandToFigma("set_text_content", { nodeId, text, }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Updated text content of node "${typedResult.name}" to "${text}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting text content: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- Input schema using Zod: nodeId (string, ID of text node), text (string, new content).{ nodeId: z.string().describe("The ID of the text node to modify"), text: z.string().describe("New text content"), },
- Type definition in FigmaCommand union includes "set_text_content".| "scan_text_nodes"
- TypeScript interface CommandParams defines parameters for set_text_content command: nodeId and text.set_text_content: { nodeId: string; text: string; };