Skip to main content
Glama
DrBalls

n8n MCP Server

by DrBalls

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
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
          }
        },

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