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
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Variable key (alphanumeric + underscore, must start with letter or underscore) | |
| value | Yes | Variable value |
Implementation Reference
- src/tools/variables.ts:126-133 (handler)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 }; } - src/schemas/index.ts:222-227 (schema)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(); - src/tools/variables.ts:104-125 (registration)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 } },