How n8n Uses MCP
n8n's AI Agent node can be equipped with an MCP Client Tool sub-node. The MCP Client Tool connects to an MCP server over stdio (subprocess) or SSE (HTTP). Agent MCP Studio's bridge.js acts as the stdio server, relaying requests to your browser tab via the cloud relay.
Prerequisites
- n8n self-hosted (v1.31+) or n8n Cloud — n8n.io
- Node.js 18+ on the machine running n8n (for bridge.js)
- Agent MCP Studio open at agentmcp.studio
Step-by-Step Setup
-
Get your relay URL and run bridge.js
Open the studio → Settings → MCP Relay Bridge. Copy your session URL, click Connect, then download and start bridge.js on the same machine as n8n:
curl -O https://agentmcp.studio/bridge.js npm install ws # Keep this running in a terminal: node bridge.js wss://agentmcp.studio/api/relay/YOUR-UUID
You'll see [bridge] Browser tab connected once the studio connects. Leave this terminal open.
-
Build an AI Agent workflow in n8n
In n8n, create a new workflow and add an AI Agent node. Configure it with your preferred LLM (OpenAI, Claude, etc.) via the Chat Model input.
-
Add an MCP Client Tool node
Click the + button on the AI Agent's Tools input. Search for MCP Client Tool and add it. Configure:
- Connection Type: stdio
- Command:
node - Arguments:
/absolute/path/to/bridge.js wss://agentmcp.studio/api/relay/YOUR-UUID
Alternatively — keep bridge running separatelyInstead of n8n launching bridge.js, you can keep bridge.js running as a standalone process and connect n8n to it via a wrapper. This is useful for shared team setups where multiple n8n workflows use the same bridge instance.
-
Test the workflow
Trigger the AI Agent node with a prompt that would use one of your tools. For example, if you registered a
query_databasetool: "Query the orders table and return the top 5 customers by revenue."The agent will call your browser-based DuckDB tool and return structured results.
Use Case Ideas for n8n + Agent MCP Studio
- Data pipeline agent — trigger n8n on a schedule, agent queries your DuckDB tool, transforms results, and posts to Slack
- Web scraping workflow — agent calls your
fetch_webpagePyodide tool to scrape URLs, n8n routes the data to a spreadsheet - API integration agent — agent uses your custom API caller tool to hit internal APIs that n8n's built-in nodes don't support
Frequently Asked Questions
Yes — n8n has a built-in "MCP Client Tool" node in its AI Agent nodes section. Add it to your workflow, point it at your relay URL, and n8n's AI Agent can call all your Agent MCP Studio tools during automation runs.
The MCP Client Tool node in n8n allows an AI Agent node to call tools from any MCP server. It handles the MCP protocol automatically — you just provide the server transport type (stdio or SSE) and connection details.
Yes — since Agent MCP Studio's relay bridge uses an outbound WebSocket connection (no inbound ports needed), it works with n8n Cloud, self-hosted n8n, and n8n Desktop without any firewall configuration.
Yes — connect the MCP Client Tool node as a tool provider to n8n's AI Agent node. The agent can then call your Python functions, SQL queries, and API tools from Agent MCP Studio during workflow execution.
n8n runs bridge.js as a subprocess (stdio transport). bridge.js connects outbound to your relay URL via WebSocket. When n8n's agent needs a tool, it sends a JSON-RPC call through bridge.js → relay → your browser tab → Pyodide/DuckDB executes it.