delete_node
Remove a specific node from Figma designs by providing its ID, enabling precise editing and management of design elements programmatically.
Instructions
Delete a node from Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the node to delete |
Implementation Reference
- src/cursor_mcp_plugin/code.js:551-573 (handler)Core implementation of delete_node tool: fetches Figma node by ID, removes it with node.remove(), returns deleted node info.async function deleteNode(params) { const { nodeId } = params || {}; if (!nodeId) { throw new Error("Missing nodeId parameter"); } const node = await figma.getNodeByIdAsync(nodeId); if (!node) { throw new Error(`Node not found with ID: ${nodeId}`); } // Save node info before deleting const nodeInfo = { id: node.id, name: node.name, type: node.type, }; node.remove(); return nodeInfo; }
- src/talk_to_figma_mcp/server.ts:413-441 (registration)MCP tool registration for 'delete_node', defines schema (nodeId: string), thin handler forwarding to Figma plugin via WebSocket.server.tool( "delete_node", "Delete a node from Figma", { nodeId: z.string().describe("The ID of the node to delete") }, async ({ nodeId }) => { try { await sendCommandToFigma('delete_node', { nodeId }); return { content: [ { type: "text", text: `Deleted node with ID: ${nodeId}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error deleting node: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- Zod schema definition for delete_node tool input: requires nodeId string.nodeId: z.string().describe("The ID of the node to delete")
- src/cursor_mcp_plugin/code.js:87-88 (helper)Dispatch in handleCommand switch that routes 'delete_node' command to deleteNode handler.case "delete_node": return await deleteNode(params);