set_text_content
Modify text content in Figma design elements by specifying node ID and new text, enabling automated text updates through programmatic communication.
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:912-938 (handler)The handler function for the 'set_text_content' tool. It sends the command to the Figma plugin via sendCommandToFigma and handles the response, returning success or error message.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) }`, }, ], }; } }
- Zod schema defining the input parameters for the 'set_text_content' tool: nodeId (string) and text (string).{ nodeId: z.string().describe("The ID of the text node to modify"), text: z.string().describe("New text content"), },
- src/talk_to_figma_mcp/server.ts:905-939 (registration)MCP server.tool registration for 'set_text_content', including description, input schema, and handler function.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:2571-2571 (registration)The 'set_text_content' command is listed in the FigmaCommand type union.| "set_text_content"
- TypeScript type definition for CommandParams of 'set_text_content' in the sendCommandToFigma function signature.set_text_content: { nodeId: string; text: string; };