create_rectangle
Use this tool to generate a rectangle in Figma instantly. Integrates with AI-powered platforms like Claude Desktop to execute natural language commands for design tasks.
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
- The handler function that executes the create_rectangle tool. It sends a 'create_rectangle' command to Figma via sendCommandToFigma with the provided parameters (x, y, width, height, name, parentId) and returns a textual response with the result or error message.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 schema defining the input parameters for the create_rectangle tool: required x, y, width, height (numbers); optional name (string), parentId (string).{ 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:12-55 (registration)The MCP server.tool() registration for 'create_rectangle', including tool name, description, input schema, and handler implementation.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)}`, }, ], }; } } );
- src/talk_to_figma_mcp/tools/index.ts:15-15 (registration)Higher-level registration call to registerCreationTools(server), which registers the create_rectangle tool among others.registerCreationTools(server);
- The 'create_rectangle' command is included in the FigmaCommand type union, used for typing the commands sent to Figma.| "create_rectangle"