Skip to main content
Glama

update_workflow

Modify existing n8n workflows by updating nodes, connections, activation status, or tags using the n8n API.

Instructions

Update an existing n8n workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
nameNo
nodesNo
connectionsNo
activeNo
tagsNo
ifMatchNoOptional If-Match header value for optimistic concurrency control

Implementation Reference

  • MCP tool handler that resolves workflow ID alias, calls n8nClient.updateWorkflow, adds numeric alias to response, and formats JSON success 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) }] };
  • Tool registration entry defining name, description, and input schema for update_workflow.
    { 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/index.ts:232-233 (registration)
    Switch statement case that routes 'update_workflow' tool calls to the specific handler method.
    case 'update_workflow': return await this.handleUpdateWorkflow(request.params.arguments as { id: string | number; ifMatch?: string } & Partial<N8nWorkflow>);
  • Core N8nClient.updateWorkflow method: resolves credential aliases, sends PUT /workflows/{id} with optional If-Match for concurrency, handles 412 precondition errors.
    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; } }

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