Skip to main content
Glama

init-n8n

Establish a connection to an n8n instance by providing the URL and API key in a compact JSON format. Automates the initialization process for seamless integration.

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
apiKeyYes
urlYes

Implementation Reference

  • Handler function that implements the core logic of the 'init-n8n' tool: parses arguments, instantiates N8nClient, tests the API connection by listing workflows, generates a unique clientId from the URL, stores the client in a global 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
        };
      }
    }
  • Input schema defining the parameters required for the 'init-n8n' tool: n8n instance URL and API key.
    inputSchema: {
      type: "object",
      properties: {
        url: { type: "string" },
        apiKey: { type: "string" }
      },
      required: ["url", "apiKey"]
    }
  • src/index.ts:400-411 (registration)
    Tool registration in the ListTools response, specifying name, description, and input schema for 'init-n8n'.
    {
      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"]
      }
    },
  • Global Map used to store N8nClient instances, keyed by base64-encoded URL generated during init-n8n.
    const clients = new Map<string, N8nClient>();
  • N8nClient class constructor, initialized with baseUrl and apiKey in the init-n8n handler, provides methods like listWorkflows used for connection testing.
    class N8nClient {
      constructor(
        private baseUrl: string,
        private apiKey: string
      ) {
        // Remove trailing slash if present
        this.baseUrl = baseUrl.replace(/\/$/, '');
      }
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.

Install Server

Other Tools

Related Tools

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

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