resize_node
Adjust the dimensions of a Figma design element programmatically using the Model Context Protocol integration for precise resizing and layout updates.
Instructions
Resize a node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/talk_to_figma_mcp/server.ts:766-793 (handler)The async handler function that implements the core logic of the 'resize_node' MCP tool. It forwards the resize parameters (nodeId, width, height) to the Figma plugin via sendCommandToFigma and handles success/error responses with appropriate content blocks.async ({ nodeId, width, height }) => { try { const result = await sendCommandToFigma("resize_node", { nodeId, width, height, }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Resized node "${typedResult.name}" to width ${width} and height ${height}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error resizing node: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- Zod schema defining the input parameters for the resize_node tool: nodeId (string), width (positive number), height (positive number). Used for input validation.{ nodeId: z.string().describe("The ID of the node to resize"), width: z.number().positive().describe("New width"), height: z.number().positive().describe("New height"), },
- src/talk_to_figma_mcp/server.ts:758-794 (registration)Registration of the 'resize_node' tool on the MCP server using server.tool(). Includes tool name, description, input schema, and handler function reference.server.tool( "resize_node", "Resize a node in Figma", { nodeId: z.string().describe("The ID of the node to resize"), width: z.number().positive().describe("New width"), height: z.number().positive().describe("New height"), }, async ({ nodeId, width, height }) => { try { const result = await sendCommandToFigma("resize_node", { nodeId, width, height, }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Resized node "${typedResult.name}" to width ${width} and height ${height}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error resizing node: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );