set_text_content
Update the content of an existing text node in Figma programmatically using the Model Context Protocol integration, enabling automated design modifications.
Instructions
Set the text content of an existing text node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/talk_to_figma_mcp/server.ts:905-939 (registration)Registers the MCP tool 'set_text_content' which proxies the command to the Figma plugin via WebSocket, handles the response and formats success/error messages.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-937 (handler)The handler function for the 'set_text_content' tool. It sends the command parameters to the Figma plugin using sendCommandToFigma and returns a formatted response with the updated node name or error.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"), },
- TypeScript type definition for the set_text_content command parameters in the FigmaCommand union.set_text_content: { nodeId: string; text: string; };
- Mention in the design_strategy prompt recommending the use of set_text_content for modifying existing text elements.- use set_text_content() to modify text content.