Skip to main content
Glama

delete_node

Remove a node from an n8n workflow by specifying the workflow ID and node ID to modify automation processes.

Instructions

Delete a node from an n8n workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflowIdYes
nodeIdYes

Implementation Reference

  • Core handler function that performs the node deletion logic: removes the node from workflow.nodes, cleans up all incoming/outgoing connections, and persists via optimistic update with ETag.
    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 };
    }
  • MCP server handler for the 'delete_node' tool call, delegates to N8nClient and formats 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/index.ts:214-214 (registration)
    Tool registration in ListTools handler, defines name, description, and inline 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'] } },
  • TypeScript interfaces defining the input request and output response for the delete_node tool.
    export interface DeleteNodeRequest {
      workflowId: string | number;
      nodeId: string;
    }
    
    export interface DeleteNodeResponse {
      ok: true;
    }
  • Dispatch handler in CallToolRequest switch statement that routes to handleDeleteNode.
    case 'delete_node':
      return await this.handleDeleteNode(request.params.arguments as unknown as DeleteNodeRequest);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/get2knowio/n8n-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server