delete_node
Remove a node from an n8n workflow by specifying the workflow ID and node ID to modify workflow structure.
Instructions
Delete a node from an n8n workflow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | ||
| workflowId | Yes |
Implementation Reference
- src/index.ts:214-214 (registration)Registration of the 'delete_node' tool in the ListTools response, defining name, description, and input schema.{ name: 'delete_node', description: 'Delete a node from an n8n workflow', inputSchema: { type: 'object', properties: { workflowId: { oneOf: [{ type: 'string' }, { type: 'number' }] }, nodeId: { type: 'string' } }, required: ['workflowId', 'nodeId'] } },
- src/index.ts:321-322 (handler)Dispatch from CallToolRequest handler switch to specific delete_node handler method.case 'delete_node': return await this.handleDeleteNode(request.params.arguments as unknown as DeleteNodeRequest);
- src/index.ts:601-610 (handler)MCP server wrapper handler: delegates to n8nClient.deleteNode and returns JSON response.private async handleDeleteNode(args: DeleteNodeRequest) { const result = await this.n8nClient.deleteNode(args); return { content: [ { type: 'text', text: JSON.stringify(jsonSuccess(result), null, 2), }, ], };
- src/n8n-client.ts:461-479 (handler)Core tool logic: atomically removes node from workflow.nodes array and cleans up all related connections (outgoing and incoming from other nodes) using optimistic concurrency control.async deleteNode(request: DeleteNodeRequest): Promise<DeleteNodeResponse> { await this.performWorkflowUpdate(request.workflowId, (workflow) => { const nodeIndex = workflow.nodes.findIndex((node) => node.id === request.nodeId); if (nodeIndex === -1) { throw new Error(`Node with id ${request.nodeId} not found in workflow ${request.workflowId}`); } const nodeName = workflow.nodes[nodeIndex].name; workflow.nodes.splice(nodeIndex, 1); const connections: any = workflow.connections as any; delete connections[nodeName]; Object.keys(connections).forEach((sourceNodeName) => { Object.keys(connections[sourceNodeName]).forEach((outputType) => { connections[sourceNodeName][outputType] = connections[sourceNodeName][outputType].map((outputArray: any[]) => outputArray.filter((conn: any) => conn.node !== nodeName), ); }); }); }); return { ok: true };
- src/types.ts:230-237 (schema)TypeScript interfaces defining input parameters (workflowId, nodeId) and response for the delete_node tool.export interface DeleteNodeRequest { workflowId: string | number; nodeId: string; } export interface DeleteNodeResponse { ok: true; }