clone_node
Clone a Figma node using its node ID. Optionally set new x,y coordinates and a parent node to place the copy, enabling quick duplication of design elements.
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 (local coordinates, relative to parent) | |
| y | No | New Y position for the clone (local coordinates, relative to parent) | |
| parentId | No | The ID of the parent node to place the clone into. REQUIRED — server enforces this. Use page node ID for top-level elements. |
Implementation Reference
- The MCP server.tool registration and handler for the 'clone_node' tool. It defines the schema (nodeId, optional x/y, optional parentId) and the async handler that calls sendCommandToFigma('clone_node', ...) and returns the cloned node's name and ID.
// Clone Node Tool server.tool( "clone_node", "Clone an existing node in Figma", { nodeId: z.string().describe("The ID of the node to clone"), x: z.coerce.number().optional().describe("New X position for the clone (local coordinates, relative to parent)"), y: z.coerce.number().optional().describe("New Y position for the clone (local coordinates, relative to parent)"), parentId: z.string().optional().describe("The ID of the parent node to place the clone into. REQUIRED — server enforces this. Use page node ID for top-level elements.") }, async ({ nodeId, x, y, parentId }) => { try { const result = await sendCommandToFigma('clone_node', { nodeId, x, y, parentId }); 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 FigmaCommand union type includes 'clone_node' as a valid command string for type safety.
| "clone_node" - src/socket.ts:53-58 (registration)The CREATION_COMMANDS set in socket.ts includes 'clone_node', ensuring it always requires a parentId and is routed through the command queue.
// Creation commands that ALWAYS require parentId (prevents implicit page-context dependency) const CREATION_COMMANDS = new Set([ "create_rectangle", "create_frame", "create_text", "create_ellipse", "create_polygon", "create_star", "create_vector", "create_line", "create_component_instance", "create_component_set", "set_svg", "clone_node", "create_component_from_node", - src/talk_to_figma_mcp/tools/creation-tools.ts:11-12 (registration)The registerCreationTools function that registers all creation tools (including clone_node) on the MCP server.
export function registerCreationTools(server: McpServer): void { // Create Rectangle Tool - An example prompt documenting how to use clone_node to create a safe copy of a node before text replacement.
\`\`\` // Clone the node to create a safe copy clone_node(nodeId: "selected-node-id", x: [new-x], y: [new-y])