clone_node
Duplicate Figma design elements by cloning nodes to new positions, enabling rapid iteration and layout adjustments within your projects.
Instructions
Clone an existing node in Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the node to clone | |
| x | No | New X position for the clone | |
| y | No | New Y position for the clone |
Implementation Reference
- src/talk_to_figma_mcp/tools/creation-tools.ts:505-536 (registration)The registration of the 'clone_node' MCP tool, including input schema using Zod and the handler function that forwards the clone_node command to the Figma plugin via sendCommandToFigma websocket utility.
server.tool( "clone_node", "Clone an existing node in Figma", { nodeId: z.string().describe("The ID of the node to clone"), x: z.number().optional().describe("New X position for the clone"), y: z.number().optional().describe("New Y position for the clone") }, async ({ nodeId, x, y }) => { try { const result = await sendCommandToFigma('clone_node', { nodeId, x, y }); const typedResult = result as { name: string, id: string }; return { content: [ { type: "text", text: `Cloned node "${typedResult.name}" with new ID: ${typedResult.id}${x !== undefined && y !== undefined ? ` at position (${x}, ${y})` : ''}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error cloning node: ${error instanceof Error ? error.message : String(error)}` } ] }; } } ); - The handler function for the clone_node tool that executes the logic by calling sendCommandToFigma and formatting the response.
try { const result = await sendCommandToFigma('clone_node', { nodeId, x, y }); const typedResult = result as { name: string, id: string }; return { content: [ { type: "text", text: `Cloned node "${typedResult.name}" with new ID: ${typedResult.id}${x !== undefined && y !== undefined ? ` at position (${x}, ${y})` : ''}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error cloning node: ${error instanceof Error ? error.message : String(error)}` } ] }; } } - Zod schema defining the input parameters for the clone_node tool.
{ nodeId: z.string().describe("The ID of the node to clone"), x: z.number().optional().describe("New X position for the clone"), y: z.number().optional().describe("New Y position for the clone") }, - The 'clone_node' command is listed in the FigmaCommand type union, used for type safety in sendCommandToFigma calls.
| "clone_node"