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(/\/$/, ''); }

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