update_variable
Modify existing variable values in n8n workflows to adapt workflow behavior and maintain data consistency across automated 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)MCP tool handler for 'update_variable'. Parses arguments, calls N8nClient.updateVariable, formats JSON success 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:186-186 (registration)Registers the 'update_variable' tool in the MCP server's listTools response, including name, description, and input schema.{ name: 'update_variable', description: 'Update an existing variable value', inputSchema: { type: 'object', properties: { id: { type: 'string' }, value: { type: 'string' } }, required: ['id', 'value'] } },
- src/index.ts:186-186 (schema)Input schema definition for 'update_variable' tool: requires 'id' (string) and 'value' (string).{ 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-726 (helper)N8nClient helper method that performs the HTTP PUT request to update a variable via n8n API.async updateVariable(id: string, variable: Partial<N8nVariable>): Promise<N8nVariable> { const response = await this.api.put<N8nApiResponse<N8nVariable>>(`/variables/${id}`, variable); return response.data.data; }