create_text
Add new text elements to Figma designs by specifying content, position, font size, weight, and color through structured input via cursor AI integration.
Instructions
Create a new text element in Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fontColor | No | Font color in RGBA format | |
| fontSize | No | Font size (default: 14) | |
| fontWeight | No | Font weight (e.g., 400 for Regular, 700 for Bold) | |
| name | No | Optional name for the text node by default following text | |
| parentId | No | Optional parent node ID to append the text to | |
| text | Yes | Text content | |
| x | Yes | X position | |
| y | Yes | Y position |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"fontColor": {
"additionalProperties": false,
"description": "Font color in RGBA format",
"properties": {
"a": {
"description": "Alpha component (0-1)",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"b": {
"description": "Blue component (0-1)",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"g": {
"description": "Green component (0-1)",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"r": {
"description": "Red component (0-1)",
"maximum": 1,
"minimum": 0,
"type": "number"
}
},
"required": [
"r",
"g",
"b"
],
"type": "object"
},
"fontSize": {
"description": "Font size (default: 14)",
"type": "number"
},
"fontWeight": {
"description": "Font weight (e.g., 400 for Regular, 700 for Bold)",
"type": "number"
},
"name": {
"description": "Optional name for the text node by default following text",
"type": "string"
},
"parentId": {
"description": "Optional parent node ID to append the text to",
"type": "string"
},
"text": {
"description": "Text content",
"type": "string"
},
"x": {
"description": "X position",
"type": "number"
},
"y": {
"description": "Y position",
"type": "number"
}
},
"required": [
"x",
"y",
"text"
],
"type": "object"
}
Implementation Reference
- src/talk_to_figma_mcp/server.ts:528-596 (registration)Registration of the 'create_text' MCP tool using server.tool(), including schema and handler.server.tool( "create_text", "Create a new text element in Figma", { 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("Semantic layer name for the text node"), parentId: z .string() .optional() .describe("Optional parent node ID to append the text to"), }, async ({ x, y, text, fontSize, fontWeight, fontColor, name, parentId }: any) => { 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) }`, }, ], }; } } );
- src/talk_to_figma_mcp/server.ts:563-595 (handler)The handler function that executes the create_text tool logic by calling sendCommandToFigma('create_text') with provided parameters and handling the response.async ({ x, y, text, fontSize, fontWeight, fontColor, name, parentId }: any) => { 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 schema defining the input parameters for the create_text tool.{ 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("Semantic layer name for the text node"), parentId: z .string() .optional() .describe("Optional parent node ID to append the text to"), },