Skip to main content
Glama

create-variable

Generate and manage variables in n8n workflows to store and share data. Requires n8n Enterprise license with variable management enabled. Input data must be in compact JSON format.

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

  • The main handler for the 'create-variable' tool within the CallToolRequestSchema switch statement. It retrieves the N8nClient by clientId, calls the client's createVariable method, and returns success or error response.
    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
        };
      }
    }
  • The input schema definition for the 'create-variable' tool, registered in the listTools response.
      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"]
      }
    },
  • The N8nClient helper method that performs the actual API call to create a variable in n8n by POSTing to /variables endpoint.
    async createVariable(key: string, value: string): Promise<void> {
      return this.makeRequest<void>('/variables', {
        method: 'POST',
        body: JSON.stringify({ key, value }),
      });
    }
Behavior3/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 covers licensing requirements and input format constraints ('Arguments must be provided as compact, single-line JSON'), which are valuable behavioral traits. However, it doesn't describe what happens on success/failure, whether the operation is idempotent, or any rate limits - leaving gaps for a mutation tool.

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 efficiently structured with three sentences that each serve distinct purposes: tool purpose, prerequisites/context, and technical requirements. It's front-loaded with the core functionality and avoids unnecessary verbiage, though the technical note about JSON formatting could be slightly more integrated.

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?

For a mutation tool with 3 parameters, 0% schema coverage, and no output schema, the description does reasonably well by covering prerequisites and format requirements. However, it lacks details about return values, error conditions, and parameter meanings - leaving the agent with incomplete operational understanding despite the clear purpose.

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, the description doesn't explain any of the 3 parameters (clientId, key, value). The baseline would be lower, but the description compensates somewhat by specifying the JSON format requirement for all arguments. However, it doesn't clarify what each parameter represents or their relationships.

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 ('Create a new variable') and resource ('in n8n'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list-variables' or 'delete-variable' beyond the obvious action difference, so it doesn't reach the highest score.

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 for when to use this tool ('Variables can be used across workflows to store and share data') and includes important prerequisites ('Requires n8n Enterprise license with variable management features enabled'). It doesn't explicitly state when NOT to use it or name alternatives like 'update-variable' (which doesn't exist in siblings), but the context is well-defined.

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

Related 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/fellipesaraiva88/n8n-mcp-server'

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