update_node
Modify existing nodes within n8n workflows by updating parameters, credentials, names, or type versions to adapt workflow functionality as needed.
Instructions
Update an existing node in an n8n workflow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| credentials | No | ||
| name | No | ||
| nodeId | Yes | ||
| params | No | ||
| typeVersion | No | ||
| workflowId | Yes |
Implementation Reference
- src/n8n-client.ts:426-439 (handler)Primary handler function that implements the core logic for updating a node: locates the node by ID in the workflow, merges new params/credentials/name/typeVersion, and performs an atomic workflow update with ETag concurrency control.async updateNode(request: UpdateNodeRequest): Promise<UpdateNodeResponse> { 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 node = workflow.nodes[nodeIndex]; if (request.params !== undefined) node.parameters = { ...node.parameters, ...request.params }; if (request.credentials !== undefined) node.credentials = { ...node.credentials, ...request.credentials }; if (request.name !== undefined) node.name = request.name; if (request.typeVersion !== undefined) node.typeVersion = request.typeVersion; }); return { nodeId: request.nodeId }; }
- src/index.ts:212-212 (registration)Tool registration in the ListTools response, defining name, description, and input schema.{ name: 'update_node', description: 'Update an existing node in an n8n workflow', inputSchema: { type: 'object', properties: { workflowId: { oneOf: [{ type: 'string' }, { type: 'number' }] }, nodeId: { type: 'string' }, params: { type: 'object' }, credentials: { type: 'object' }, name: { type: 'string' }, typeVersion: { type: 'number' } }, required: ['workflowId', 'nodeId'] } },
- src/types.ts:201-208 (schema)TypeScript interface defining the input parameters for the update_node tool.export interface UpdateNodeRequest { workflowId: string | number; nodeId: string; params?: Record<string, any>; credentials?: Record<string, string>; name?: string; typeVersion?: number; }
- src/index.ts:553-562 (handler)MCP server handler method that receives tool calls for 'update_node' and delegates to N8nClient.updateNode, formatting the success response.private async handleUpdateNode(args: UpdateNodeRequest) { const result = await this.n8nClient.updateNode(args); return { content: [ { type: 'text', text: JSON.stringify(jsonSuccess(result), null, 2), }, ], };
- src/n8n-client.ts:384-406 (helper)Helper method used by updateNode for atomic workflow updates with ETag-based optimistic concurrency and exponential backoff retries on conflicts.private async performWorkflowUpdate( workflowId: string | number, operation: (workflow: N8nWorkflow) => void, maxRetries: number = 3, ): Promise<void> { let retries = 0; while (retries < maxRetries) { try { const { workflow, etag } = await this.getWorkflowWithETag(workflowId); operation(workflow); await this.updateWorkflow(workflowId, workflow, etag || undefined); return; } catch (error: any) { const message = error?.message || ''; if (message.includes('Precondition failed') && retries < maxRetries - 1) { retries++; await new Promise((resolve) => setTimeout(resolve, Math.pow(2, retries) * 100)); continue; } throw error; } } }