set_text_content
Modify text content in Figma design files by updating existing text nodes with new text values using node IDs.
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
- The async handler that implements the core logic of the set_text_content tool by sending the command to Figma via websocket and formatting the response.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/tools/text-tools.ts:12-45 (registration)Registers the set_text_content MCP tool, including name, description, input schema, and references the 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)}`, }, ], }; } } );
- Zod schema defining input parameters for the 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/tools/index.ts:17-17 (registration)Calls registerTextTools to include text tools (including set_text_content) in the overall tool registration.registerTextTools(server);
- Type definition including set_text_content in FigmaCommand union type.| "set_text_content"