Skip to main content
Glama

create-variable

Create variables in n8n to store and share data across workflows, requiring an Enterprise license with variable management enabled.

Instructions

Create a new variable in n8n. NOTE: Requires n8n Enterprise license with variable management features enabled. Variables can be used across workflows to store and share data. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientIdYes
keyYes
valueYes

Implementation Reference

  • src/index.ts:627-638 (registration)
    Registration of the 'create-variable' tool in the listTools response, including name, description, and input schema.
      name: "create-variable",
      description: "Create a new variable in n8n. NOTE: Requires n8n Enterprise license with variable management features enabled. Variables can be used across workflows to store and share data. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
      inputSchema: {
        type: "object",
        properties: {
          clientId: { type: "string" },
          key: { type: "string" },
          value: { type: "string" }
        },
        required: ["clientId", "key", "value"]
      }
    },
  • Input schema definition for the 'create-variable' tool.
      name: "create-variable",
      description: "Create a new variable in n8n. NOTE: Requires n8n Enterprise license with variable management features enabled. Variables can be used across workflows to store and share data. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
      inputSchema: {
        type: "object",
        properties: {
          clientId: { type: "string" },
          key: { type: "string" },
          value: { type: "string" }
        },
        required: ["clientId", "key", "value"]
      }
    },
  • Main handler for executing the 'create-variable' tool: validates clientId, retrieves N8nClient instance, calls createVariable method, handles success/error responses.
    case "create-variable": {
      const { clientId, key, value } = args as { clientId: string; key: string; value: string };
      const client = clients.get(clientId);
      if (!client) {
        return {
          content: [{
            type: "text",
            text: "Client not initialized. Please run init-n8n first.",
          }],
          isError: true
        };
      }
    
      try {
        await client.createVariable(key, value);
        return {
          content: [{
            type: "text",
            text: `Successfully created variable with key: ${key}`,
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: error instanceof Error ? error.message : "Unknown error occurred",
          }],
          isError: true
        };
      }
    }
  • N8nClient helper method that performs the actual API POST request to create a variable in n8n.
    async createVariable(key: string, value: string): Promise<void> {
      return this.makeRequest<void>('/variables', {
        method: 'POST',
        body: JSON.stringify({ key, value }),
      });
    }
  • Type definition for N8nVariable used in variable management.
    interface N8nVariable {
      id: string;
      key: string;
      value: string;
      type?: string;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates key behavioral traits: the licensing requirement (access control), the purpose of variables ('used across workflows to store and share data'), and a critical implementation detail about argument formatting ('compact, single-line JSON without whitespace or newlines'). This provides substantial value beyond basic function description.

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 efficiently structured with three sentences that each serve distinct purposes: stating the core function, providing licensing requirements and variable purpose, and giving critical formatting instructions. There's no wasted language, and important information is front-loaded appropriately.

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 no annotations and no output schema, the description does well by covering licensing requirements, variable purpose, and critical formatting constraints. However, it doesn't explain what happens on success/failure, whether the operation is idempotent, or provide examples of the compact JSON format. Given the complexity of a creation operation, there are some gaps in completeness.

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?

With 0% schema description coverage for 3 required parameters, the description doesn't explain what 'clientId', 'key', or 'value' represent or how they should be formatted beyond the JSON requirement. While it mentions arguments must be compact JSON, it doesn't add semantic meaning to the individual parameters. The baseline is appropriate given the schema's lack of descriptions.

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 variable'), target resource ('in n8n'), and distinguishes it from siblings like 'list-variables' and 'delete-variable' by focusing on creation rather than retrieval or removal. It provides a clear verb+resource combination with contextual differentiation.

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 explicitly states when to use this tool ('Create a new variable in n8n') and includes important prerequisites ('Requires n8n Enterprise license with variable management features enabled'). However, it doesn't explicitly mention when NOT to use it or name specific alternatives among siblings, though the context implies it's for creation rather than listing or deleting 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/illuminaresolutions/n8n-mcp-server'

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