Skip to main content
Glama

create-variable

Generate and store new variables in n8n workflows using a compact JSON input. Enables data sharing across workflows, requires an Enterprise license with variable management.

Instructions

Create a new variable in n8n. NOTE: Requires n8n Enterprise license with variable management features enabled. Variables can be used across workflows to store and share data. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientIdYes
keyYes
valueYes

Implementation Reference

  • The primary handler for the 'create-variable' tool. It retrieves the N8nClient instance using the provided clientId, validates it exists, and calls the client's createVariable method with the key and value. Returns success message or error.
    case "create-variable": { const { clientId, key, value } = args as { clientId: string; key: string; value: string }; const client = clients.get(clientId); if (!client) { return { content: [{ type: "text", text: "Client not initialized. Please run init-n8n first.", }], isError: true }; } try { await client.createVariable(key, value); return { content: [{ type: "text", text: `Successfully created variable with key: ${key}`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }], isError: true }; } }
  • src/index.ts:627-638 (registration)
    The tool registration entry in the ListTools response, including name, description, and input schema.
    name: "create-variable", description: "Create a new variable in n8n. NOTE: Requires n8n Enterprise license with variable management features enabled. Variables can be used across workflows to store and share data. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.", inputSchema: { type: "object", properties: { clientId: { type: "string" }, key: { type: "string" }, value: { type: "string" } }, required: ["clientId", "key", "value"] } },
  • The N8nClient helper method that makes the POST request to the n8n API endpoint '/variables' to create a new variable.
    async createVariable(key: string, value: string): Promise<void> { return this.makeRequest<void>('/variables', { method: 'POST', body: JSON.stringify({ key, value }), }); }
  • The input schema definition specifying required parameters: clientId, key, value.
    inputSchema: { type: "object", properties: { clientId: { type: "string" }, key: { type: "string" }, value: { type: "string" } }, required: ["clientId", "key", "value"] }
  • Type definition for n8n variables used in API responses.
    interface N8nVariable { id: string; key: string; value: string; type?: string; }

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

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