create_rectangle
Generate a rectangle in Figma directly through natural language commands, enabling automated design modifications without manual intervention.
Instructions
Create a new rectangle 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/server.ts:372-401 (handler)The handler function for the create_rectangle MCP tool. It receives parameters, sends a 'create_rectangle' command to the Figma plugin via WebSocket using sendCommandToFigma, and returns a formatted text response with the result or error.async ({ x, y, width, height, name, parentId }) => { try { const result = await sendCommandToFigma("create_rectangle", { x, y, width, height, name: name || "Rectangle", parentId, }); return { content: [ { type: "text", text: `Created rectangle "${JSON.stringify(result)}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating rectangle: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- Zod input schema defining the parameters for the create_rectangle tool: x, y, width, height (required numbers), name and parentId (optional strings).{ x: z.number().describe("X position"), y: z.number().describe("Y position"), width: z.number().describe("Width of the rectangle"), height: z.number().describe("Height of the rectangle"), name: z.string().optional().describe("Optional name for the rectangle"), parentId: z .string() .optional() .describe("Optional parent node ID to append the rectangle to"), },
- src/talk_to_figma_mcp/server.ts:358-402 (registration)MCP server.tool registration for the create_rectangle tool, including name, description, input schema, and handler function.server.tool( "create_rectangle", "Create a new rectangle in Figma", { x: z.number().describe("X position"), y: z.number().describe("Y position"), width: z.number().describe("Width of the rectangle"), height: z.number().describe("Height of the rectangle"), name: z.string().optional().describe("Optional name for the rectangle"), parentId: z .string() .optional() .describe("Optional parent node ID to append the rectangle to"), }, async ({ x, y, width, height, name, parentId }) => { try { const result = await sendCommandToFigma("create_rectangle", { x, y, width, height, name: name || "Rectangle", parentId, }); return { content: [ { type: "text", text: `Created rectangle "${JSON.stringify(result)}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating rectangle: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );