update_variable
Modify existing variable values in n8n workflows to adjust workflow behavior and data flow during automation processes.
Instructions
Update an existing variable value
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| value | Yes |
Implementation Reference
- src/index.ts:473-475 (handler)The main tool handler method that processes the update_variable tool call, extracts arguments, calls the N8nClient method, and formats the response.private async handleUpdateVariable(args: { id: string; value: string }) { const variable = await this.n8nClient.updateVariable(args.id, { value: args.value }); return { content: [{ type: 'text', text: JSON.stringify(jsonSuccess(variable), null, 2) }] };
- src/index.ts:283-284 (registration)The switch case registration that routes 'update_variable' tool calls to the handler method.case 'update_variable': return await this.handleUpdateVariable(request.params.arguments as { id: string; value: string });
- src/index.ts:186-186 (schema)The tool definition including name, description, and input schema for update_variable, returned by list_tools.{ name: 'update_variable', description: 'Update an existing variable value', inputSchema: { type: 'object', properties: { id: { type: 'string' }, value: { type: 'string' } }, required: ['id', 'value'] } },
- src/n8n-client.ts:723-725 (helper)The N8nClient helper method that performs the actual API PUT request to update a variable in n8n.async updateVariable(id: string, variable: Partial<N8nVariable>): Promise<N8nVariable> { const response = await this.api.put<N8nApiResponse<N8nVariable>>(`/variables/${id}`, variable); return response.data.data;