Skip to main content
Glama
yhc984
by yhc984

move_node

Reposition a node in Figma by specifying its ID and new X/Y coordinates, enabling precise adjustments to design elements through programmatic commands.

Instructions

Move a node to a new position in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to move
xYesNew X position
yYesNew Y position

Implementation Reference

  • MCP tool registration for 'move_node' including description, input schema using Zod, and handler that forwards the command to Figma plugin via sendCommandToFigma and formats the response.
    server.tool( "move_node", "Move a node to a new position in Figma", { nodeId: z.string().describe("The ID of the node to move"), x: z.number().describe("New X position"), y: z.number().describe("New Y position") }, async ({ nodeId, x, y }) => { try { const result = await sendCommandToFigma('move_node', { nodeId, x, y }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Moved node "${typedResult.name}" to position (${x}, ${y})` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error moving node: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
  • Core handler implementation in Figma plugin that performs the node movement by loading the node via ID and directly setting its x and y coordinates.
    async function moveNode(params) { const { nodeId, x, y } = params || {}; if (!nodeId) { throw new Error("Missing nodeId parameter"); } if (x === undefined || y === undefined) { throw new Error("Missing x or y parameters"); } const node = await figma.getNodeByIdAsync(nodeId); if (!node) { throw new Error(`Node not found with ID: ${nodeId}`); } if (!("x" in node) || !("y" in node)) { throw new Error(`Node does not support position: ${nodeId}`); } node.x = x; node.y = y; return { id: node.id, name: node.name, x: node.x, y: node.y, }; }
  • Dispatch case in the main handleCommand switch statement that routes 'move_node' commands to the moveNode function.
    case "move_node": return await moveNode(params);
  • TypeScript union type FigmaCommand that includes 'move_node' for type safety in sendCommandToFigma calls.
    type FigmaCommand = | 'get_document_info' | 'get_selection' | 'get_node_info' | 'create_rectangle' | 'create_frame' | 'create_text' | 'set_fill_color' | 'set_stroke_color' | 'move_node' | 'resize_node' | 'delete_node' | 'get_styles' | 'get_local_components' | 'get_team_components' | 'create_component_instance' | 'export_node_as_image' | 'execute_code' | 'join' | 'set_corner_radius';
  • Specific call within the MCP handler to forward the move_node parameters to the Figma plugin via WebSocket.
    const result = await sendCommandToFigma('move_node', { nodeId, x, y });

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/yhc984/cursor-talk-to-figma-mcp-main'

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