How coleam00/n8n-nodes-mcp works
Project type and purpose
• This is an n8n community-node package written in TypeScript/JavaScript.
• Purpose: provide an MCP Client node for n8n workflows, allowing users to connect to Model Context Protocol (MCP) servers via STDIO or Server-Sent Events (SSE), list tools/prompts/resources, and execute tools.
File structure
• Top level: configuration files (.eslintrc, tsconfig.json, gulpfile.js), CI/CD workflows (.github/workflows), tests (__tests__), credentials definitions (credentials/*.credentials.ts), the published entry point (index.js), and the main node implementation under nodes/McpClient/.
• Build pipeline: gulpfile.js orchestrates TypeScript compilation and bundling.
• Testing: Jest config in jest.config.js and tests in __tests__ folder.
• Packaging: package.json, .npmignore, and lockfiles for npm/pnpm.
README for additional insights
• Describes two transport mechanisms—STDIO (spawning MCP server processes) and SSE (long-lived HTTP connections).
• Outlines credential schemes, environment variable usage, and example workflows (Brave Search, multi-server, local SSE).
• Emphasizes use inside n8n’s plugin/AI Agent ecosystem.
a. Main components
• n8n Core Platform – hosts workflows and community nodes
• MCP Client Node – plugin loaded by n8n, implements node logic & UI
• Credentials Store – where n8n saves command/arguments, SSE URLs, headers, env-vars
• Transport Layer
– STDIO Transport: spawns MCP server process (child_process)
– SSE Transport: opens EventSource connection + HTTP POST endpoint
• MCP Server(s) – external services (e.g., Brave Search, OpenAI, Serper, Weather)
• Build & CI/CD Pipeline – gulp build, Jest tests, GitHub Actions, publishing to npm
b. Relationships & interactions
1. Developer commits code → GitHub CI runs lint/test/build → package published
2. At runtime, n8n loads community-nodes folder → registers MCP Client node
3. User drags MCP Client node into workflow → selects transport & credentials
4. Node executes:
• STDIO: spawn MCP server with configured command, arguments, env-vars → communicate via stdin/stdout JSON messages
• SSE: open EventSource to SSE URL, send operations via HTTP POST → listen for server-sent events
5. MCP Server processes requests → returns tool lists, prompts, resource data, or executes tools → responses flow back to node → n8n displays outputs
c. Architectural patterns & design principles
• Plugin/extension pattern: node implements n8n’s NodeInterface and credential types
• Strategy pattern for transports: abstract common operations behind STDIO or SSE modules
• Separation of concerns: UI/credentials definitions, core node logic, transport implementations, and tests
• Event-driven I/O for SSE transport; process spawning for STDIO transport
d. Key technologies & libraries
• TypeScript/JavaScript, Node.js
• n8n Node API (Node Interface, Credential Interface)
• child_process for STDIO transport
• EventSource or fetch for SSE transport
• Gulp for build tasks; Jest for testing
• GitHub Actions for CI/CD
Detail
• File/folder names where relevant (e.g., build script gulpfile.js, test suite __tests__).
• Both STDIO and SSE transport modules and their unique communication channels.
• External dependency list (Brave Search server, OpenAI server, etc.) as MCP servers.