Skip to main content
Glama
DrBalls

n8n MCP Server

by DrBalls

Update n8n Variable

n8n_update_variable
Idempotent

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
NameRequiredDescriptionDefault
idYesVariable ID to update
keyNoNew variable key
valueNoNew variable value

Implementation Reference

  • 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
      };
  • 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')
  • 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
          }
        },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations cover key behavioral traits: readOnlyHint=false (mutation), idempotentHint=true (safe to retry), destructiveHint=false (non-destructive). The description adds minimal context by specifying 'existing variable', implying it modifies rather than creates. However, it doesn't disclose additional behaviors like authentication needs, rate limits, or what happens if the ID doesn't exist. With annotations providing safety profile, a 3 is appropriate—some value added but limited behavioral detail.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core action ('Update an existing variable'). The Args and Returns sections are structured but somewhat redundant with the schema. Every sentence serves a purpose, though the parameter listings could be trimmed since they're covered in the schema. Overall, it's efficient with minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (mutation with 3 parameters), annotations provide safety context, but there's no output schema. The description covers the basic operation and return statement ('The updated variable'), but lacks details on error conditions, permissions, or system limits. It's minimally adequate but leaves gaps for a mutation tool, especially without output schema to clarify return values.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with each parameter clearly documented in the schema (e.g., 'Variable ID to update', 'New variable key'). The description repeats the parameter names and types but adds no extra semantic meaning beyond the schema. According to guidelines, baseline is 3 when schema coverage is high (>80%), which fits here as the description doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Update') and resource ('existing variable'), making the purpose immediately understandable. It distinguishes from sibling tools like 'n8n_create_variable' by specifying 'existing' and from 'n8n_delete_variable' by the update action. However, it doesn't explicitly contrast with 'n8n_get_variable' or other update tools (e.g., 'n8n_update_workflow'), leaving some sibling differentiation implicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing variable ID), when not to use it (e.g., for creating new variables), or direct alternatives like 'n8n_create_variable' or 'n8n_delete_variable'. The agent must infer usage from the tool name and context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/DrBalls/n8n-mcp-server-v2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server