n8n_create_variable
Create environment variables in n8n to store configuration values for workflows, supporting string, number, boolean, and JSON data types.
Instructions
Create a new environment variable
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Variable key | |
| value | Yes | Variable value | |
| type | No | Variable type (string, number, boolean, json) |
Implementation Reference
- src/n8n-client.ts:166-169 (handler)The core API call implementation for creating an n8n variable.
async createVariable(data: { key: string; value: string; type?: string }): Promise<any> { const response = await this.client.post('/variables', data); return response.data; } - src/index.ts:225-233 (handler)The request handler for the n8n_create_variable tool, which processes arguments and calls the n8n client.
case 'n8n_create_variable': { if (!args?.key || !args?.value) { throw new Error('key and value are required'); } const result = await n8nClient.createVariable(args as any); return { content: [{ type: 'text', text: formatResponse(result) }], }; } - src/index.ts:670-681 (registration)The tool definition and schema registration for n8n_create_variable.
name: 'n8n_create_variable', description: 'Create a new environment variable', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Variable key' }, value: { type: 'string', description: 'Variable value' }, type: { type: 'string', description: 'Variable type (string, number, boolean, json)' }, }, required: ['key', 'value'], }, },