Skip to main content
Glama

init-n8n

Establish connection to an n8n automation platform instance using URL and API key credentials to enable workflow management and execution.

Instructions

Initialize connection to n8n instance. Use this tool whenever an n8n URL and API key are shared to establish the connection. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
apiKeyYes

Implementation Reference

  • The handler for the 'init-n8n' tool. It creates an N8nClient instance using the provided URL and API key, tests the connection by calling listWorkflows(), generates a unique clientId from the URL, stores the client in the global 'clients' Map, and returns a success message with the clientId or an error.
    case "init-n8n": {
      const { url, apiKey } = args as { url: string; apiKey: string };
      try {
        const client = new N8nClient(url, apiKey);
        
        // Test connection by listing workflows
        await client.listWorkflows();
        
        // Generate a unique client ID
        const clientId = Buffer.from(url).toString('base64');
        clients.set(clientId, client);
    
        return {
          content: [{
            type: "text",
            text: `Successfully connected to n8n at ${url}. Use this client ID for future operations: ${clientId}`,
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: error instanceof Error ? error.message : "Unknown error occurred",
          }],
          isError: true
        };
      }
    }
  • The tool schema definition including name, description, and inputSchema specifying required 'url' and 'apiKey' string properties.
    {
      name: "init-n8n",
      description: "Initialize connection to n8n instance. Use this tool whenever an n8n URL and API key are shared to establish the connection. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
      inputSchema: {
        type: "object",
        properties: {
          url: { type: "string" },
          apiKey: { type: "string" }
        },
        required: ["url", "apiKey"]
      }
    },
  • src/index.ts:397-851 (registration)
    The ListToolsRequestSchema handler registers all tools, including 'init-n8n' as the first entry in the tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "init-n8n",
            description: "Initialize connection to n8n instance. Use this tool whenever an n8n URL and API key are shared to establish the connection. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                url: { type: "string" },
                apiKey: { type: "string" }
              },
              required: ["url", "apiKey"]
            }
          },
          {
            name: "list-workflows",
            description: "List all workflows from n8n. Use after init-n8n to see available workflows. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" }
              },
              required: ["clientId"]
            }
          },
          {
            name: "get-workflow",
            description: "Retrieve a workflow by ID. Use after list-workflows to get detailed information about a specific workflow. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "create-workflow",
            description: "Create a new workflow in n8n. Use to set up a new workflow with optional nodes and connections. IMPORTANT: 1) Arguments must be provided as compact, single-line JSON without whitespace or newlines. 2) Must provide full workflow structure including nodes and connections arrays, even if empty. The 'active' property should not be included as it is read-only.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                name: { type: "string" },
                nodes: { type: "array" },
                connections: { type: "object" }
              },
              required: ["clientId", "name"]
            }
          },
          {
            name: "update-workflow",
            description: "Update an existing workflow in n8n. Use after get-workflow to modify a workflow's properties, nodes, or connections. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" },
                workflow: {
                  type: "object",
                  properties: {
                    name: { type: "string" },
                    active: { type: "boolean" },
                    nodes: { type: "array" },
                    connections: { type: "object" },
                    settings: { type: "object" }
                  }
                }
              },
              required: ["clientId", "id", "workflow"]
            }
          },
          {
            name: "delete-workflow",
            description: "Delete a workflow by ID. This action cannot be undone. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "activate-workflow",
            description: "Activate a workflow by ID. This will enable the workflow to run. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "deactivate-workflow",
            description: "Deactivate a workflow by ID. This will prevent the workflow from running. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "list-projects",
            description: "List all projects from n8n. NOTE: Requires n8n Enterprise license with project management features enabled. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" }
              },
              required: ["clientId"]
            }
          },
          {
            name: "create-project",
            description: "Create a new project in n8n. NOTE: Requires n8n Enterprise license with project management features enabled. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                name: { type: "string" }
              },
              required: ["clientId", "name"]
            }
          },
          {
            name: "delete-project",
            description: "Delete a project by ID. NOTE: Requires n8n Enterprise license with project management features enabled. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                projectId: { type: "string" }
              },
              required: ["clientId", "projectId"]
            }
          },
          {
            name: "update-project",
            description: "Update a project's name. NOTE: Requires n8n Enterprise license with project management features enabled. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                projectId: { type: "string" },
                name: { type: "string" }
              },
              required: ["clientId", "projectId", "name"]
            }
          },
          {
            name: "list-users",
            description: "Retrieve all users from your instance. Only available for the instance owner.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" }
              },
              required: ["clientId"]
            }
          },
          {
            name: "create-users",
            description: "Create one or more users in your instance.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                users: {
                  type: "array",
                  items: {
                    type: "object",
                    properties: {
                      email: { type: "string" },
                      role: { 
                        type: "string",
                        enum: ["global:admin", "global:member"]
                      }
                    },
                    required: ["email"]
                  }
                }
              },
              required: ["clientId", "users"]
            }
          },
          {
            name: "get-user",
            description: "Get user by ID or email address.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                idOrEmail: { type: "string" }
              },
              required: ["clientId", "idOrEmail"]
            }
          },
          {
            name: "delete-user",
            description: "Delete a user from your instance.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                idOrEmail: { type: "string" }
              },
              required: ["clientId", "idOrEmail"]
            }
          },
          {
            name: "list-variables",
            description: "List all variables from n8n. NOTE: Requires n8n Enterprise license with variable management features enabled. Use after init-n8n to see available variables. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" }
              },
              required: ["clientId"]
            }
          },
          {
            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"]
            }
          },
          {
            name: "delete-variable",
            description: "Delete a variable by ID. NOTE: Requires n8n Enterprise license with variable management features enabled. Use after list-variables to get the ID of the variable to delete. This action cannot be undone. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "create-credential",
            description: "Create a credential that can be used by nodes of the specified type. The credential type name can be found in the n8n UI when creating credentials (e.g., 'cloudflareApi', 'githubApi', 'slackOAuth2Api'). Use get-credential-schema first to see what fields are required for the credential type you want to create.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                name: { type: "string" },
                type: { type: "string" },
                data: { type: "object" }
              },
              required: ["clientId", "name", "type", "data"]
            }
          },
          {
            name: "delete-credential",
            description: "Delete a credential by ID. You must be the owner of the credentials.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "get-credential-schema",
            description: "Show credential data schema for a specific credential type. The credential type name can be found in the n8n UI when creating credentials (e.g., 'cloudflareApi', 'githubApi', 'slackOAuth2Api'). This will show you what fields are required for creating credentials of this type.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                credentialTypeName: { type: "string" }
              },
              required: ["clientId", "credentialTypeName"]
            }
          },
          // Execution Management Tools
          {
            name: "list-executions",
            description: "Retrieve all executions from your instance with optional filtering.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                includeData: { type: "boolean" },
                status: { 
                  type: "string",
                  enum: ["error", "success", "waiting"]
                },
                workflowId: { type: "string" },
                limit: { type: "number" }
              },
              required: ["clientId"]
            }
          },
          {
            name: "get-execution",
            description: "Retrieve a specific execution by ID.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "number" },
                includeData: { type: "boolean" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "delete-execution",
            description: "Delete a specific execution by ID.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "number" }
              },
              required: ["clientId", "id"]
            }
          },
          // Tag Management Tools
          {
            name: "create-tag",
            description: "Create a new tag in your instance.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                name: { type: "string" }
              },
              required: ["clientId", "name"]
            }
          },
          {
            name: "list-tags",
            description: "Retrieve all tags from your instance.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                limit: { type: "number" }
              },
              required: ["clientId"]
            }
          },
          {
            name: "get-tag",
            description: "Retrieve a specific tag by ID.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "update-tag",
            description: "Update a tag's name.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" },
                name: { type: "string" }
              },
              required: ["clientId", "id", "name"]
            }
          },
          {
            name: "delete-tag",
            description: "Delete a tag by ID.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                id: { type: "string" }
              },
              required: ["clientId", "id"]
            }
          },
          {
            name: "get-workflow-tags",
            description: "Get tags associated with a workflow.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                workflowId: { type: "string" }
              },
              required: ["clientId", "workflowId"]
            }
          },
          {
            name: "update-workflow-tags",
            description: "Update tags associated with a workflow.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                workflowId: { type: "string" },
                tagIds: {
                  type: "array",
                  items: {
                    type: "object",
                    properties: {
                      id: { type: "string" }
                    },
                    required: ["id"]
                  }
                }
              },
              required: ["clientId", "workflowId", "tagIds"]
            }
          },
          // Security Audit Tool
          {
            name: "generate-audit",
            description: "Generate a security audit for your n8n instance.",
            inputSchema: {
              type: "object",
              properties: {
                clientId: { type: "string" },
                daysAbandonedWorkflow: { type: "number" },
                categories: {
                  type: "array",
                  items: {
                    type: "string",
                    enum: ["credentials", "database", "nodes", "filesystem", "instance"]
                  }
                }
              },
              required: ["clientId"]
            }
          }
        ]
      };
    });
  • Global Map to store N8nClient instances keyed by clientId, used by init-n8n and all other tools.
    const clients = new Map<string, N8nClient>();
  • N8nClient class constructor used by init-n8n to instantiate the API client.
    class N8nClient {
      constructor(
        private baseUrl: string,
        private apiKey: string
      ) {
        // Remove trailing slash if present
        this.baseUrl = baseUrl.replace(/\/$/, '');
      }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool establishes a connection, which implies a stateful setup operation, but doesn't mention behavioral traits like authentication requirements (though implied by API key), error handling, or persistence of the connection. The IMPORTANT note about JSON formatting adds useful operational context, but overall disclosure is basic.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by usage guidance and a critical formatting note. Every sentence earns its place: the first defines the tool, the second specifies when to use it, and the third provides essential input instructions. It's appropriately sized with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a setup operation with 2 parameters), no annotations, and no output schema, the description is minimally adequate. It covers the purpose, usage trigger, and input format, but lacks details on what the connection enables, error scenarios, or output expectations. For a foundational tool, more context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 2 parameters with 0% description coverage, so the description must compensate. It implicitly explains the parameters by stating 'n8n URL and API key are shared,' which maps to 'url' and 'apiKey.' This adds meaning beyond the bare schema types. However, it doesn't detail format expectations (e.g., URL structure, API key format), keeping it from a perfect score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Initialize connection to n8n instance.' It specifies the verb ('Initialize') and resource ('connection to n8n instance'), making it distinct from sibling tools that perform CRUD operations on workflows, users, tags, etc. However, it doesn't explicitly differentiate from potential alternative connection methods, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: 'whenever an n8n URL and API key are shared to establish the connection.' This gives a specific trigger (URL and API key availability) and implies it's a prerequisite for other operations. It doesn't explicitly state when not to use it or name alternatives, but the context is sufficiently clear for a setup tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.