# illuminaresolutions/n8n-mcp-server architecture

> Architecture diagram of the GitHub repository illuminaresolutions/n8n-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/illuminaresolutions/n8n-mcp-server
- Repository: https://github.com/illuminaresolutions/n8n-mcp-server

## Overview

##### Project type and purpose
- This is a lightweight, open-source CLI/server tool (written in Node.js/TypeScript) that implements the Model Context Protocol (MCP) to expose an n8n instance’s capabilities (workflows, credentials, executions, etc.) to large language model (LLM) tools (e.g., Claude Desktop, Cline, upcoming Sage integration).
- Its primary role is to act as an adapter/facade: it listens for MCP requests from LLM-driven clients, translates them into n8n REST API calls, and returns structured responses.

##### File structure
- Top-level files:
- package.json / package-lock.json: npm package metadata, scripts (“build”, “start”), dependencies.
- tsconfig.json: TypeScript compiler configuration.
- smithery.yml and N8N_API.yml: metadata for Smithery.ai marketplace and OpenAPI spec for the n8n REST API.
- src/index.ts: single entry point. Builds the MCP server, parses environment variables (N8N_HOST, N8N_API_KEY), loads the OpenAPI spec, registers MCP operations.
- DEVELOP­MENT.md / LLM_GUIDE.md / TYPEKIT_MCP_SDK.md: docs for developers, LLM integration, and SDK guidance.
- There is no separate “frontend” folder; this is purely a backend/adapter service.

##### README for additional insights
- Describes installation (npm vs. source), configuration for each LLM client, core vs. enterprise features.
- Calls out the MCP handshake: commands → MCP server CLI → environment variables → HTTP requests to n8n host.
- Mentions future distribution channels (Smithery.ai marketplace).

a. Main components:
- LLM Client(s): Claude Desktop, Cline extension, (future) Sage/Smithery marketplace.
- n8n MCP Server: Node.js process exposing MCP endpoints over STDIO or local socket.
- Configuration store: environment variables (N8N_HOST, N8N_API_KEY).
- n8n Instance: REST API–driven backend (self-hosted or cloud).
- OpenAPI Spec: N8N_API.yml driving dynamic client code.
b. Relationships & data flow:
1. LLM Client issues MCP command (e.g., “List my n8n workflows”).
2. Command is forwarded to the n8n MCP Server process.
3. Server reads env vars, loads OpenAPI spec, constructs REST API call to n8n instance.
4. n8n instance authenticates, executes the request (list workflows), returns JSON.
5. MCP server transforms JSON into MCP response protocol, streams it back to the LLM client.
c. Architectural patterns & design principles:
- Adapter/Facade pattern: abstracts n8n REST API behind MCP interface.
- Single process, pluggable commands via a registry (index.ts).
- Configuration by environment (12-factor app style).
- Separation of concerns: protocol handling (MCP) vs. API client vs. core logic.
d. Key technologies/frameworks:
- Node.js + TypeScript, built via npm.
- OpenAPI-driven HTTP client integration (N8N_API.yml).
- MCP SDK conventions (per LLM_GUIDE.md / TYPEKIT_MCP_SDK.md).
- Packaging for CLI consumption (global npm install, “n8n-mcp-server” binary).

##### Final recommendation
- Be thorough: capture every logical component (protocol handler, API client, config loader).
- Keep it high-level enough to fit on one page but detailed enough to guide future enhancements (e.g., enterprise features, new client integrations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Side"
        direction TB
        Clients["LLM Clients\n(Claude Desktop, Cline Extension,\nFuture Sage/Smithery)"]:::external
    end

    subgraph "Server Side"
        direction TB
        MCP["n8n MCP Server\n(protocol handler, command registry)"]:::server
        Config["Configuration Store\n(env vars: N8N_HOST, N8N_API_KEY)"]:::config
        Spec["OpenAPI Spec\n(N8N_API.yml)"]:::config
        API["n8n REST API\n(n8n Instance)"]:::api
    end

    subgraph "Project Files & Docs"
        direction TB
        pkg["package.json\n(npm packaging & CLI scripts)"]:::config
        ts["tsconfig.json\n(TypeScript compiler config)"]:::config
        smith["smithery.yml\n(Smithery.ai metadata)"]:::config
        readme["README.md\n(Overview & install)"]:::config
        dev["DEVELOPMENT.md\n(Core dev guidelines)"]:::config
        llmguide["LLM_GUIDE.md\n(LLM integration guide)"]:::config
        sdk["TYPEKIT_MCP_SDK.md\n(MCP SDK conventions)"]:::config
    end

    Clients -->|"MCP JSON"| MCP
    MCP -->|reads env vars| Config
    MCP -->|loads spec| Spec
    MCP -->|"HTTP GET /workflows, etc."| API
    API -->|"JSON response"| MCP
    MCP -->|"MCP JSON"| Clients

    pkg --> MCP
    ts --> MCP
    smith --> MCP
    readme --> MCP
    dev --> MCP
    llmguide --> MCP
    sdk --> MCP

    click MCP "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/src/index.ts"
    click Spec "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/N8N_API.yml"
    click Config "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/src/index.ts"
    click smith "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/smithery.yml"
    click pkg "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/package.json"
    click ts "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/tsconfig.json"
    click dev "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/DEVELOPMENT.md"
    click llmguide "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/LLM_GUIDE.md"
    click sdk "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/TYPEKIT_MCP_SDK.md"
    click readme "https://github.com/illuminaresolutions/n8n-mcp-server/blob/main/README.md"

    classDef external fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1;
    classDef server fill:#C8E6C9,stroke:#43A047,color:#1B5E20;
    classDef api fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef config fill:#E0E0E0,stroke:#9E9E9E,color:#424242;
```
