delete_node
Remove a specific element from Figma designs by providing its node ID to clean up or modify layouts.
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 Figma plugin handler function that implements node deletion by fetching the node by ID and calling node.remove()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 server.tool registration for 'delete_node' tool, including schema, description, and proxy handler that calls the Figma pluginserver.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)}` } ] }; } } );
- src/cursor_mcp_plugin/code.js:87-88 (handler)Dispatch handler in Figma plugin's handleCommand switch statement that routes 'delete_node' command to deleteNode functioncase "delete_node": return await deleteNode(params);
- Zod input schema for delete_node MCP tool requiring nodeId string{ nodeId: z.string().describe("The ID of the node to delete") },
- Call to sendCommandToFigma helper function that forwards the delete_node command to the Figma WebSocket serverawait sendCommandToFigma('delete_node', { nodeId });