Skip to main content
Glama
DrBalls

n8n MCP Server

by DrBalls

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

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