create_rectangle
Generate a rectangle in Figma by specifying dimensions, position, and optional attributes like name or parent node, using the MCP server for programmatic design updates.
Instructions
Create a new rectangle in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| height | Yes | Height of the rectangle | |
| name | No | Optional name for the rectangle | |
| parentId | No | Optional parent node ID to append the rectangle to | |
| width | Yes | Width of the rectangle | |
| x | Yes | X position | |
| y | Yes | Y position |
Implementation Reference
- src/talk_to_figma_mcp/server.ts:352-396 (handler)MCP tool registration, schema, and handler implementation for the 'create_rectangle' tool. The handler forwards parameters to the Figma plugin's create_rectangle command via sendCommandToFigma and handles the response, returning a formatted message with the created rectangle details or an error.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 }: any) => { 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) }`, }, ], }; } } );