create_rectangle
Add rectangular shapes to Figma designs by specifying position, dimensions, and optional parent elements for precise layout control.
Instructions
Create a new rectangle in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X position | |
| y | Yes | Y position | |
| width | Yes | Width of the rectangle | |
| height | Yes | Height of the rectangle | |
| name | No | Optional name for the rectangle | |
| parentId | No | Optional parent node ID to append the rectangle to |
Implementation Reference
- The async handler function that executes the 'create_rectangle' tool logic. It forwards the parameters to Figma via sendCommandToFigma and returns a textual 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 parameters for the create_rectangle tool: x, y, width, height, optional name, and parentId.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/tools/creation-tools.ts:13-55 (registration)Direct registration of the 'create_rectangle' MCP tool via server.tool(), specifying name, description, input schema, and handler."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)}`, }, ], }; } } );
- src/talk_to_figma_mcp/tools/index.ts:14-14 (registration)Higher-level registration call to registerCreationTools(server), which includes the create_rectangle tool, as part of all tools registration.registerCreationTools(server);
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Top-level call to registerTools(server) in the main server initialization, which chains to registering the create_rectangle tool.registerTools(server);