set_text_content
Update the text content of a selected text node in Figma using direct commands, enabling AI-assisted design adjustments within the platform.
Instructions
Set the text content of an existing text node in Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/talk_to_figma_mcp/tools/text-tools.ts:12-45 (registration)Primary registration of the 'set_text_content' MCP tool, including input schema (nodeId, text), description, and inline handler that proxies the command to the Figma plugin via sendCommandToFigma and formats the response.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)}`, }, ], }; } } );
- The handler function implementing the core logic of the set_text_content tool: sends websocket command to Figma and returns 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 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/tools/index.ts:17-17 (registration)Calls registerTextTools within the main registerTools function, which includes the set_text_content tool.registerTextTools(server);
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Initializes the MCP server and calls registerTools, which transitively registers the set_text_content tool.registerTools(server);
- Includes 'set_text_content' in the FigmaCommand type union used by sendCommandToFigma.| "set_text_content"