create_variable
Create a new variable in n8n workflows by providing a unique key and value, enabling dynamic data storage and management for workflow automation.
Instructions
Create a new variable (requires unique key)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | ||
| value | Yes |
Implementation Reference
- src/index.ts:468-471 (handler)MCP tool handler for create_variable: delegates to n8nClient.createVariable and returns JSON responseprivate async handleCreateVariable(args: { key: string; value: string }) { const variable = await this.n8nClient.createVariable(args); return { content: [{ type: 'text', text: JSON.stringify(jsonSuccess(variable), null, 2) }] }; }
- src/index.ts:185-185 (schema)Input schema definition for create_variable tool: requires key (string) and value (string){ name: 'create_variable', description: 'Create a new variable (requires unique key)', inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' } }, required: ['key', 'value'] } },
- src/index.ts:281-282 (registration)Tool dispatch/registration in CallToolRequestHandler switch statementcase 'create_variable': return await this.handleCreateVariable(request.params.arguments as { key: string; value: string });
- src/n8n-client.ts:718-721 (helper)N8nClient helper method: POST /api/v1/variables to create variable via n8n APIasync createVariable(variable: Omit<N8nVariable, 'id'>): Promise<N8nVariable> { const response = await this.api.post<N8nApiResponse<N8nVariable>>('/variables', variable); return response.data.data; }