set_text_content
Update text content in Figma by specifying the node ID and new text. Enables programmatic text modification in designs through natural language commands.
Instructions
Set the text content of an existing text node in Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the text node to modify | |
| text | Yes | New text content |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"nodeId": {
"description": "The ID of the text node to modify",
"type": "string"
},
"text": {
"description": "New text content",
"type": "string"
}
},
"required": [
"nodeId",
"text"
],
"type": "object"
}
Implementation Reference
- src/talk_to_figma_mcp/server.ts:898-933 (registration)MCP tool registration for 'set_text_content'. Includes schema definition and handler function that sends the command to the Figma plugin via WebSocket.// Set Text Content Tool 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 }: any) => { 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:906-932 (handler)Handler function for the 'set_text_content' tool. Forwards nodeId and text to Figma plugin command 'set_text_content' and formats success/error response.async ({ nodeId, text }: any) => { 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 validation using Zod for 'set_text_content' tool parameters: 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:2754-2757 (registration)TypeScript type definition for FigmaCommand parameters of 'set_text_content' in CommandParams interface.set_text_content: { nodeId: string; text: string; };