update-workflow
Modify existing workflows in n8n by updating properties, nodes, or connections. Requires compact JSON input for efficient workflow management via the MCP server.
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)The primary handler for the 'update-workflow' tool within the CallToolRequestSchema request handler. It validates the client exists, calls the N8nClient.updateWorkflow method, 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:452-469 (schema)The input schema definition for the 'update-workflow' tool, specifying required parameters: clientId, id, and workflow object with optional properties like name, active, nodes, connections, settings.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:450-470 (registration)The registration of the 'update-workflow' tool in the list of tools returned by the ListToolsRequestSchema handler.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)The N8nClient helper method that makes the actual PUT API request to update the workflow in the n8n instance.async updateWorkflow(id: string, workflow: Partial<N8nWorkflow>): Promise<N8nWorkflow> { return this.makeRequest<N8nWorkflow>(`/workflows/${id}`, { method: 'PUT', body: JSON.stringify(workflow), }); }