create_text
Add text elements to Figma designs by specifying position, content, font size, weight, and color for AI-assisted design workflows.
Instructions
Create a new text element in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X position | |
| y | Yes | Y position | |
| text | Yes | Text content | |
| fontSize | No | Font size (default: 14) | |
| fontWeight | No | Font weight (e.g., 400 for Regular, 700 for Bold) | |
| fontColor | No | Font color in RGBA format | |
| name | No | Optional name for the text node by default following text | |
| parentId | No | Optional parent node ID to append the text to |
Implementation Reference
- The handler function that implements the core logic for the 'create_text' tool. It constructs the parameters, sends the 'create_text' command to Figma via sendCommandToFigma, handles the response, and returns formatted success or error messages.async ({ x, y, text, fontSize, fontWeight, fontColor, name, parentId }) => { try { const result = await sendCommandToFigma("create_text", { x, y, text, fontSize: fontSize || 14, fontWeight: fontWeight || 400, fontColor: fontColor || { r: 0, g: 0, b: 0, a: 1 }, name: name || "Text", parentId, }); const typedResult = result as { name: string; id: string }; return { content: [ { type: "text", text: `Created text "${typedResult.name}" with ID: ${typedResult.id}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating text: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- Zod input schema defining the parameters for the create_text tool: position (x,y), text content, optional font styling (size, weight, color), name, and parentId.{ x: z.number().describe("X position"), y: z.number().describe("Y position"), text: z.string().describe("Text content"), fontSize: z.number().optional().describe("Font size (default: 14)"), fontWeight: z .number() .optional() .describe("Font weight (e.g., 400 for Regular, 700 for Bold)"), fontColor: z .object({ r: z.number().min(0).max(1).describe("Red component (0-1)"), g: z.number().min(0).max(1).describe("Green component (0-1)"), b: z.number().min(0).max(1).describe("Blue component (0-1)"), a: z .number() .min(0) .max(1) .optional() .describe("Alpha component (0-1)"), }) .optional() .describe("Font color in RGBA format"), name: z .string() .optional() .describe("Optional name for the text node by default following text"), parentId: z .string() .optional() .describe("Optional parent node ID to append the text to"), },
- src/talk_to_figma_mcp/tools/creation-tools.ts:147-148 (registration)The server.tool() call that registers the 'create_text' tool with its description. The full registration spans lines 147-214 including schema and handler.server.tool( "create_text",
- src/talk_to_figma_mcp/tools/index.ts:15-15 (registration)Intermediate registration call to registerCreationTools within registerTools function.registerCreationTools(server);
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Top-level call to registerTools in the main server initialization, which chains to the create_text tool registration.registerTools(server);