n8n_update_variable
Modify existing workflow variables by updating their key or value to maintain automation integrity and adapt to changing requirements.
Instructions
Update an existing variable.
Args:
id (string): Variable ID to update
key (string, optional): New variable key
value (string, optional): New variable value
Returns: The updated variable.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Variable ID to update | |
| key | No | New variable key | |
| value | No | New variable value |
Implementation Reference
- src/tools/variables.ts:158-165 (handler)The tool handler function for 'n8n_update_variable' that processes input parameters and updates the variable using a PUT request.
async (params: z.infer<typeof UpdateVariableSchema>) => { const { id, ...updateData } = params; const variable = await put<N8nVariable>(`/variables/${id}`, updateData); return { content: [{ type: 'text', text: `✅ Variable updated!\n\n${formatVariable(variable)}` }], structuredContent: variable }; - src/schemas/index.ts:229-235 (schema)Zod schema definition for input validation of 'n8n_update_variable'.
export const UpdateVariableSchema = z.object({ id: z.string().min(1) .describe('Variable ID to update'), key: z.string().min(1).max(50).regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/).optional() .describe('New variable key'), value: z.string().optional() .describe('New variable value') - src/tools/variables.ts:137-157 (registration)Registration of the 'n8n_update_variable' tool with the MCP server.
server.registerTool( 'n8n_update_variable', { title: 'Update n8n Variable', description: `Update an existing variable. Args: - id (string): Variable ID to update - key (string, optional): New variable key - value (string, optional): New variable value Returns: The updated variable.`, inputSchema: UpdateVariableSchema, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false } },