update_workflow
Modify existing n8n workflows by updating workflow name, nodes, connections, activation status, or tags through the n8n API.
Instructions
Update an existing n8n workflow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active | No | ||
| connections | No | ||
| id | Yes | ||
| ifMatch | No | Optional If-Match header value for optimistic concurrency control | |
| name | No | ||
| nodes | No | ||
| tags | No |
Implementation Reference
- src/index.ts:406-411 (handler)Primary MCP tool handler for 'update_workflow': resolves workflow ID alias, calls N8nClient.updateWorkflow, adds numeric ID alias, and formats response.private async handleUpdateWorkflow(args: { id: string | number; ifMatch?: string } & Partial<N8nWorkflow>) { const { id, ifMatch, ...updateData } = args; const resolvedId = this.resolveWorkflowId(id); const workflow = await this.n8nClient.updateWorkflow(resolvedId, updateData, ifMatch); this.withAlias(workflow); return { content: [{ type: 'text', text: JSON.stringify(jsonSuccess(workflow), null, 2) }] };
- src/index.ts:72-72 (registration)Tool registration in ListTools response, defining name, description, and input schema validation.{ name: 'update_workflow', description: 'Update an existing n8n workflow', inputSchema: { type: 'object', properties: { id: { oneOf: [{ type: 'string' }, { type: 'number' }] }, name: { type: 'string' }, nodes: { type: 'array', items: { type: 'object' } }, connections: { type: 'object' }, active: { type: 'boolean' }, tags: { type: 'array', items: { type: 'string' } }, ifMatch: { type: 'string', description: 'Optional If-Match header value for optimistic concurrency control' } }, required: ['id'] } },
- src/n8n-client.ts:196-215 (helper)Core N8nClient method implementing the workflow update: resolves credential aliases, performs PUT /workflows/{id} API call with optional If-Match concurrency control.async updateWorkflow(id: string | number, workflow: Partial<N8nWorkflow>, ifMatch?: string): Promise<N8nWorkflow> { // Resolve credential aliases before updating the workflow await this.resolveCredentialsInWorkflow(workflow); const headers: Record<string, string> = {}; // Allow 'active' to be updated via standard update to support tests and API compatibility if (ifMatch) headers['If-Match'] = ifMatch; try { const response = await this.api.put<N8nApiResponse<N8nWorkflow> | N8nWorkflow>(`/workflows/${id}`, workflow, { headers }); const payload: any = response.data as any; return (payload && typeof payload === 'object' && 'data' in payload) ? payload.data : payload; } catch (error: any) { if (error.response?.status === 412) { throw new Error( 'Precondition failed: The workflow has been modified by another user. Please fetch the latest version and try again.', ); } throw error; } }