create_variable
Create new variables with unique keys to store and manage data within n8n workflows, enabling dynamic workflow configuration and data persistence.
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'. Receives {key, value}, delegates to N8nClient.createVariable, and returns JSON-formatted success response.private 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/n8n-client.ts:718-721 (helper)Core helper method in N8nClient that sends POST request to n8n API /variables endpoint to create the variable.async createVariable(variable: Omit<N8nVariable, 'id'>): Promise<N8nVariable> { const response = await this.api.post<N8nApiResponse<N8nVariable>>('/variables', variable); return response.data.data; }
- src/index.ts:281-282 (registration)Dispatch/registration in CallToolRequestSchema switch statement that routes 'create_variable' calls to the handler method.case 'create_variable': return await this.handleCreateVariable(request.params.arguments as { key: string; value: string });
- src/index.ts:185-185 (schema)Tool registration entry in list_tools response defining name, description, and input schema for create_variable.{ name: 'create_variable', description: 'Create a new variable (requires unique key)', inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' } }, required: ['key', 'value'] } },