Skip to main content
Glama

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
NameRequiredDescriptionDefault
keyYes
valueYes

Implementation Reference

  • 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) }] }; }
  • 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 });
  • 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'] } },

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/get2knowio/n8n-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server