Skip to main content
Glama
DrBalls

n8n MCP Server

by DrBalls

Create n8n Variable

n8n_create_variable

Create environment variables for n8n workflows to store reusable values accessed via $vars.variableName syntax.

Instructions

Create a new environment variable.

Variables can be used in workflows with $vars.variableName syntax.

Args:

  • key (string): Variable key (alphanumeric + underscore, must start with letter or underscore)

  • value (string): Variable value

Returns: The created variable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesVariable key (alphanumeric + underscore, must start with letter or underscore)
valueYesVariable value

Implementation Reference

  • The handler function that executes the n8n_create_variable tool, performing a POST request to create a variable.
    async (params: z.infer<typeof CreateVariableSchema>) => {
      const variable = await post<N8nVariable>('/variables', params);
      
      return {
        content: [{ type: 'text', text: `✅ Variable created!\n\n${formatVariable(variable)}\n\nUse in workflows: \`$vars.${variable.key}\`` }],
        structuredContent: variable
      };
    }
  • Zod schema defining the input parameters for the Create Variable tool.
    export const CreateVariableSchema = z.object({
      key: z.string().min(1).max(50).regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/)
        .describe('Variable key (alphanumeric + underscore, must start with letter or underscore)'),
      value: z.string()
        .describe('Variable value')
    }).strict();
  • Registration of the n8n_create_variable tool with the MCP server.
      server.registerTool(
        'n8n_create_variable',
        {
          title: 'Create n8n Variable',
          description: `Create a new environment variable.
    
    Variables can be used in workflows with $vars.variableName syntax.
    
    Args:
      - key (string): Variable key (alphanumeric + underscore, must start with letter or underscore)
      - value (string): Variable value
    
    Returns:
      The created variable.`,
          inputSchema: CreateVariableSchema,
          annotations: {
            readOnlyHint: false,
            destructiveHint: false,
            idempotentHint: false,
            openWorldHint: false
          }
        },
Behavior3/5

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

Annotations already declare this is a write operation (readOnlyHint=false) and non-destructive (destructiveHint=false). The description adds useful context about how variables are used in workflows ($vars.variableName syntax), which isn't covered by annotations. However, it doesn't mention potential side effects, permissions needed, or rate limits.

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

Conciseness5/5

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

The description is perfectly structured and front-loaded: purpose statement first, then usage context, followed by parameter details. Every sentence earns its place, with zero wasted words. The three-part structure (purpose, usage, parameters) is efficient and logical.

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

Completeness4/5

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

For a creation tool with good annotations and full schema coverage, the description provides adequate context. It explains the purpose, usage syntax, and parameters. The main gap is the lack of output schema, but the description does mention 'Returns: The created variable,' which partially compensates. A complete output description would make it a 5.

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 both parameters (key and value) fully documented in the schema. The description's 'Args' section repeats the schema information without adding additional semantic meaning. The baseline of 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Create a new environment variable') and the resource ('environment variable'), distinguishing it from sibling tools like n8n_update_variable or n8n_delete_variable. It provides immediate clarity about what this tool does.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('Variables can be used in workflows with $vars.variableName syntax'), giving practical application guidance. However, it doesn't explicitly state when NOT to use it or mention alternatives like n8n_update_variable for modifying existing variables.

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