Skip to main content
Glama
paragdesai1

Cursor Talk to Figma MCP

by paragdesai1

resize_node

Resize Figma design elements by specifying new width and height dimensions to adjust layout proportions.

Instructions

Resize a node in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to resize
widthYesNew width
heightYesNew height

Implementation Reference

  • The core handler function for the resize_node command in the Figma plugin. It retrieves the node by ID, validates it supports resize, calls node.resize(width, height), and returns the updated dimensions.
    async function resizeNode(params) { const { nodeId, width, height } = params || {}; if (!nodeId) { throw new Error("Missing nodeId parameter"); } if (width === undefined || height === undefined) { throw new Error("Missing width or height parameters"); } const node = await figma.getNodeByIdAsync(nodeId); if (!node) { throw new Error(`Node not found with ID: ${nodeId}`); } if (!("resize" in node)) { throw new Error(`Node does not support resizing: ${nodeId}`); } node.resize(width, height); return { id: node.id, name: node.name, width: node.width, height: node.height, }; }
  • Registers the 'resize_node' tool with the MCP server. Defines the input schema using Zod and provides a proxy handler that forwards the command to the Figma plugin via WebSocket using sendCommandToFigma.
    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) }`, }, ], }; } } );
  • Input schema for the resize_node tool, validating nodeId as string and width/height as positive numbers.
    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"), },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paragdesai1/parag-Figma-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server