update-workflow
Modify and update an n8n workflow by altering its properties, nodes, or connections. Provide arguments as compact JSON to ensure precise adjustments.
Instructions
Update an existing workflow in n8n. Use after get-workflow to modify a workflow's properties, nodes, or connections. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientId | Yes | ||
| id | Yes | ||
| workflow | Yes |
Implementation Reference
- src/index.ts:960-995 (handler)Handler for the 'update-workflow' tool in the CallToolRequestSchema switch statement. Validates client existence, calls N8nClient.updateWorkflow, and returns success or error response.case "update-workflow": { const { clientId, id, workflow } = args as { clientId: string; id: string; workflow: Partial<N8nWorkflow>; }; const client = clients.get(clientId); if (!client) { return { content: [{ type: "text", text: "Client not initialized. Please run init-n8n first.", }], isError: true }; } try { const updatedWorkflow = await client.updateWorkflow(id, workflow); return { content: [{ type: "text", text: `Successfully updated workflow:\n${JSON.stringify(updatedWorkflow, null, 2)}`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }], isError: true }; } }
- src/index.ts:450-470 (registration)Registration of the 'update-workflow' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.name: "update-workflow", description: "Update an existing workflow in n8n. Use after get-workflow to modify a workflow's properties, nodes, or connections. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.", inputSchema: { type: "object", properties: { clientId: { type: "string" }, id: { type: "string" }, workflow: { type: "object", properties: { name: { type: "string" }, active: { type: "boolean" }, nodes: { type: "array" }, connections: { type: "object" }, settings: { type: "object" } } } }, required: ["clientId", "id", "workflow"] } },
- src/index.ts:179-184 (helper)Core helper method in N8nClient class that performs the HTTP PUT request to update a workflow via the n8n API.async updateWorkflow(id: string, workflow: Partial<N8nWorkflow>): Promise<N8nWorkflow> { return this.makeRequest<N8nWorkflow>(`/workflows/${id}`, { method: 'PUT', body: JSON.stringify(workflow), }); }
- src/index.ts:24-31 (schema)TypeScript interface defining the structure of an n8n workflow object, used in update-workflow operations.interface N8nWorkflow { id: number; name: string; active: boolean; createdAt: string; updatedAt: string; tags: string[]; }