📁 last Posts

n8n MCP Server: Connect Your AI Agent to Any Tool

🔌 In 2026, the Model Context Protocol (MCP) changed how AI agents interact with the world. Instead of writing custom code for every integration, MCP provides a universal language for AI agents to discover and call external tools. And n8n is now one of the best platforms to build an MCP server.

The Direct Answer

Build an MCP server in n8n by adding an MCP Server Trigger node and connecting it directly to one or more Tool nodes (such as the Custom n8n Workflow Tool, HTTP Request Tool, or sub‑workflow tools). The MCP Server Trigger does not run like a normal trigger — it only exposes the tools attached to it, and any MCP client (Claude Desktop, Cursor, ChatGPT, etc.) can list and call them through a standard protocol. For exposing many workflows at once, use a small set of helper tools (search, list, add, remove, execute) backed by a lightweight memory store like Redis. As of April 2026, n8n also ships a first‑party instance‑level MCP server that needs no custom workflow at all — see Section 9. Total setup time: 30–90 minutes.

In this guide, I'll walk you through the entire process – from understanding what MCP is, to building the server workflow, connecting it to Claude Desktop, and securing it for production. You'll also get a complete, downloadable JSON workflow that you can import and run immediately.

Why this guide is different: Most articles stop at the basic "here's a workflow" stage. I'll show you how to deploy this in production, handle errors, scale to dozens of workflows, and secure your server against unauthorised access. These are the exact patterns I use in my own n8n deployments for enterprise clients.

AI agent connecting to n8n MCP Server over the MCP protocol
Figure 1: MCP provides a standardised layer between AI agents and external tools – n8n is the perfect MCP server.

1. What is MCP and Why Does It Matter?

The Model Context Protocol (MCP) is an open standard that allows AI agents to interact with external tools and data sources through a unified interface. Think of it as a USB‑C port for AI – instead of building a custom adapter for every tool, you build one MCP server that exposes all your tools through a consistent API.

In the context of n8n, MCP enables:

  • Tool discovery – AI agents can ask "what can you do?" and get a list of available workflows with their input schemas.
  • Parameter validation – The agent knows exactly what input each workflow expects, including required fields, data types, and descriptions.
  • Execution management – The agent can run workflows and get structured results back, including success/failure status and execution details.
  • Persistent connections – Using Server‑Sent Events (SSE) for real‑time communication and long‑running workflows.

Why is this a game‑changer? Before MCP, integrating an AI agent with n8n meant building custom webhook endpoints for every workflow, hard‑coding authentication and parameter formats, writing custom error handling, and having no standard way for the agent to discover what workflows exist. MCP solves all of these problems in one protocol.

MCP vs. Webhooks: Key Differences

FeatureWebhooksMCP
DirectionOne‑way (push only)Bidirectional (discover + execute)
Tool discoveryNone – you must know the URLAgent asks "what can you do?"
Parameter validationManual – you must validate inside the workflowSchema‑driven – the agent knows exactly what to send
Error handlingHTTP status codes onlyStructured error responses with context
Connection typeStateless (HTTP request/response)Persistent (SSE) or stateless
"MCP is the protocol that makes AI agents truly useful in production. Instead of hard‑coding every possible action, you expose a set of capabilities and let the agent decide which ones to use. This is the pattern that scales." — From a production deployment serving 100+ AI agents across 15+ n8n instances
Real‑world example: I built an MCP server for a client that exposed 25 workflows – from CRM lookups to email sending. The AI agent could discover all of them, understand their input requirements, and execute them without any custom integration code. The agent handled 500+ tool calls per day with zero failures from integration issues.

2. MCP Server Architecture in n8n

The n8n MCP Server pattern is built around one rule that trips up almost everyone the first time: the MCP Server Trigger node does not behave like a normal trigger. A normal trigger starts a workflow and passes data forward through "main" connections. The MCP Server Trigger only connects to Tool nodes — it does not run a linear chain of nodes itself. Whatever tools you attach to it are exactly the tools an AI agent will see and be able to call. Let's break down the five core components of a production‑ready setup:

🔌 MCP Server Trigger
    ├── 🧰 Custom n8n Workflow Tool (executes a tagged workflow)
    ├── 🔍 Search/List "available" workflows tool (n8n node + Redis)
    └── ➕➖ Add/Remove "available" workflow tools (Redis)

2.1 The MCP Server Trigger

The MCP Server Trigger node is the entry point for all MCP traffic. It exposes a test URL and a production URL that MCP clients connect to, handles the MCP protocol handshake, and lets a connected client list and call whatever Tool nodes you've attached to it. This node is available from n8n v1.88.0 onward and supports both Server‑Sent Events (SSE) and streamable HTTP — it does not support stdio transport.

2.2 Exposing a Single Workflow as a Tool

The simplest pattern: attach a Custom n8n Workflow Tool node directly to the MCP Server Trigger. This node calls a specific workflow (which must start with a Subworkflow / Execute Workflow Trigger and have its Input Schema defined) and returns the result. This is enough if you only want to expose one or two workflows.

2.3 Exposing Many Workflows ("Available Workflows" Pattern)

If you want to expose dozens of workflows without hard‑coding a Tool node for each one, use n8n's official multi‑tool pattern: tag every workflow you want to expose (e.g., "mcp"), then attach four or five small helper tools to the MCP Server Trigger — search workflows, list available workflows, add to available, remove from available, and execute. The search/list tools internally use the built‑in n8n node (Core Nodes → n8n, Resource: Workflow) to query your instance for tagged workflows, while the add/remove/list tools use a Redis node as lightweight, fast memory for which workflows the agent has currently marked "available." The agent decides for itself which workflows to activate before using them — you are not manually wiring a Redis step into a single linear chain.

2.4 The Tool Execution Layer

Execution happens through a Subworkflow trigger with passthrough parameters: whatever the agent sends as input is forwarded to the target workflow, run, and the result is returned to the MCP client. Input validation comes from the Subworkflow trigger's Input Schema — this is what the agent reads to know exactly what parameters a tool expects.

2.5 The MCP Client (Optional, Reverse Direction)

n8n can also act as an MCP client inside an AI Agent node, consuming tools from external MCP servers via the MCP Client Tool node. This lets one workflow orchestrate tools from several MCP servers at once, creating a federated tool ecosystem.

Common misconception: Many older tutorials show the MCP Server Trigger connected through a single "main" chain (Trigger → n8n node → Redis → Execute Workflow), as if it were a normal trigger. That is not how the node works. The MCP Server Trigger only fires the specific Tool node the agent decides to call — there is no single linear path that always executes in order.
n8n MCP Server workflow architecture diagram showing the five components
Figure 2: The MCP Server workflow – MCP Server Trigger, n8n discovery, Redis memory, and Execute Workflow.

3. Prerequisites & Setup

Before you build anything, make sure you have the following in place. Skipping these is the single biggest cause of failed first attempts.

  • n8n v1.88.0 or higher for the per‑workflow MCP Server Trigger, or v2.18.4+ if you want the newer instance‑level MCP server covered in Section 9. Check your version under Settings → About.
  • An n8n API key (Settings → API → Create API Key) if you plan to use the "search/list available workflows" tools, since they query your instance via the n8n node.
  • A Redis instance (self‑hosted, Redis Cloud, or Upstash) only if you're using the multi‑workflow "available pool" pattern from Section 2.3. A single‑workflow setup with one Custom n8n Workflow Tool node doesn't need Redis at all.
  • An MCP client to test with — Claude Desktop, Cursor, Windsurf, or ChatGPT with MCP support.
  • HTTPS on your production n8n URL. MCP clients connecting over SSE/streamable HTTP will refuse plain HTTP in most setups.
Decide your pattern first: if you only want to expose 1–3 workflows, skip straight to a Custom n8n Workflow Tool per workflow — it's faster and needs no Redis. Use the "available pool" pattern from Section 2.3 only once you're exposing a larger, changing set of workflows.

4. Step‑by‑Step Build Guide

Now let's build the MCP server workflow. I'll walk you through each step with exact node configurations and code examples.

1

Tag Your Workflows

In n8n, go to each workflow you want to expose as an MCP tool. Click the workflow name, then click the Tags section and add the tag "mcp" (or any tag you prefer). This is how the MCP server discovers them – it will query n8n for all workflows with this tag.

For testing, start with 2–3 simple workflows (e.g., a "Hello World" workflow, a "Get Current Time" workflow, or a "Send Email" workflow).

2

Add Subworkflow Triggers to Each Exposed Workflow

In each workflow you want to expose, add a Subworkflow trigger node at the very beginning. This allows the MCP server to call the workflow with parameters.

Important: Configure the Subworkflow trigger's Input Schema. This defines what parameters the workflow expects, and the agent will see these as the tool's input schema. For example, if your workflow expects a email and a message, define those in the schema with their types.
3

Create the MCP Server Workflow

Create a new workflow in n8n. Add an MCP Server Trigger node. This node exposes a test URL and a production URL that MCP clients will connect to — but remember, it only fires the Tool nodes you connect to it, it does not run a "main" chain.

MCP Server Trigger configuration
Path: /mcp (auto-generated, can be customised)
Authentication: Bearer token (recommended for production)
Transport: SSE / Streamable HTTP (stdio is not supported)

After publishing, copy the Production URL from the node panel.
It will look like: https://your-n8n-instance.com/mcp/your-path
4

Add a "Search Workflows" Tool

Add an n8n node (Core Nodes → n8n) and connect it to the MCP Server Trigger as a tool (not a main connection). Configure it to query your instance for workflows tagged "mcp":

  • Resource: Workflow
  • Operation: Get Many
  • Return All: True
  • Filters: Tags: mcp

Give the node a clear name and description (e.g., "Search workflows tagged mcp") — the agent reads this description to decide when to call it. Add your n8n API key as a credential (created in the Prerequisites section).

5

Add Redis Tools for the "Available" Pool (Optional)

If you're exposing more than a handful of workflows, add three small Redis tool nodes — add to available, remove from available, and list available — and connect each one to the MCP Server Trigger as a tool. These let the agent build its own short list of workflows it currently intends to use, without restarting the server.

Redis "add to available" tool
// Operation: SET
// Key: available_workflows:{{ $json.sessionId }}
// Value: {{ $json.workflowId }}  (appended to a Redis list)
// Expire: 3600  (1 hour – adjust as needed)

// Credentials: your Redis connection
// Host: your-redis-host.com
// Port: 6379
// Password: YOUR_REDIS_PASSWORD (if applicable)

If you'd rather avoid Redis entirely, replace it with a Code node holding workflow‑scoped static data, or skip the "available pool" concept altogether and let the search tool return everything.

6

Add the Execution Tool

Add a Custom n8n Workflow Tool node (or one per workflow you expose) and connect it to the MCP Server Trigger as a tool. Point it at a target workflow that starts with a Subworkflow trigger with its Input Schema defined — that schema is exactly what the agent will see as the tool's parameters.

  • Source: Database / By ID, pointing at the workflow tagged "mcp"
  • Workflow Inputs: mapped from the Subworkflow trigger's Input Schema
  • Wait for completion: True (so the agent gets the result back)
Node connection: Every tool (search, list, add, remove, execute) connects to the MCP Server Trigger's tool input — not its main output. There is no single ordered chain; the agent decides which tool to call and when.
7

Activate and Test

Save the workflow and activate it (green toggle). Copy the Production URL from the MCP Server Trigger node. This is the URL your MCP client will connect to.

To test, use any MCP client (Claude Desktop, Cursor, or a simple HTTP client) to connect to the endpoint. The first request should return the list of available tools – the workflows tagged with "mcp".

Your MCP server is now live!

Any MCP‑compatible client can now connect, discover your workflows, and execute them. The agent will automatically see the tag‑based tool list and can add or remove workflows from the available pool.

5. Connect an MCP Client (Claude Desktop)

Once your MCP Server is running, you can connect any MCP client to it. Here's how to configure Claude Desktop – the most popular MCP client in 2026.

Claude Desktop Configuration

Edit your Claude Desktop configuration file. On macOS, it's located at:

~/Library/Application Support/Claude/claude_desktop_config.json

Add the n8n MCP server configuration:

claude_desktop_config.json
{
  "mcpServers": {
    "n8n-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e", "MCP_MODE=stdio",
        "-e", "LOG_LEVEL=error",
        "-e", "DISABLE_CONSOLE_OUTPUT=true",
        "-e", "N8N_API_URL=https://your-n8n-instance.com",
        "-e", "N8N_API_KEY=your-api-key-here",
        "ghcr.io/czlonkowski/n8n-mcp:latest"
      ]
    }
  }
}

If you prefer not to use Docker, you can connect directly to the n8n MCP Server URL (SSE endpoint) using the MCP Client Tool node inside n8n itself. This allows you to orchestrate multiple MCP servers in a single workflow.

Note: The N8N_API_URL and N8N_API_KEY are optional in the Docker image. Without them, you get documentation and validation tools only – useful for local development and testing.

6. Security & Best Practices

Exposing your n8n instance to AI agents introduces significant security considerations. Here's how to protect your MCP server.

6.1 Authentication

MCP supports Bearer tokens, custom headers, and OAuth2. Always enable authentication on your MCP Server. The n8n MCP Server Trigger node can be configured with authentication requirements – add a Bearer token that clients must provide.

6.2 Tag‑Based Access Control

Only expose workflows tagged with a specific label (e.g., "mcp"). This prevents the agent from accidentally discovering and executing sensitive workflows like credential management or data deletion. Never expose workflows that handle passwords, API keys, or personal data.

6.3 Input Validation

Ensure every exposed workflow validates its input parameters. The Subworkflow trigger's input schema is the first line of defence. Add additional validation inside the workflow using Code nodes or IF nodes – check that email addresses are valid, that numbers are within range, and that required fields are provided.

6.4 Audit Logging

Enable n8n's execution history to track every time an agent executes a workflow. This gives you visibility into what the agent is doing, which tools it's using, and which parameters it's sending. You can also log to Google Sheets or a database for long‑term auditing.

6.5 Production Deployment Checklist

  • Use HTTPS – Never expose MCP over HTTP in production.
  • Use a reverse proxy – Nginx or Caddy should handle SSL termination.
  • Rate limiting – Implement rate limiting on your MCP endpoint to prevent abuse.
  • Monitor usage – Track which workflows are executed and by which agents.
  • Regular audits – Review exposed workflows monthly and remove unused ones.
Critical: Never expose workflows that handle sensitive data (passwords, API keys, personal information) to MCP unless you have strict authentication and input validation in place. Start with read‑only workflows and gradually expand as you gain confidence in your security controls.

7. Common Errors & Fixes

After deploying this on multiple production environments, I've seen the same errors repeatedly. Here are the exact fixes:

"Redis connection failed"

Your Redis instance is not reachable. Check that the host, port, and password are correct. If using Redis Cloud, ensure your IP is whitelisted. For local Redis, verify the container is running (docker ps | grep redis).

"n8n API authentication error"

Your n8n API key is invalid or expired. Regenerate the key in n8n Settings → API and update it in the n8n node's credentials. Also check that the API is enabled in your n8n instance.

"Schema validation failed"

The agent sent parameters that don't match the Subworkflow trigger's input schema. Review the schema in the Subworkflow trigger node and ensure it accurately describes the expected parameters. Add a Code node before the Subworkflow to validate and transform incoming parameters.

"Timeout on long‑running workflows"

The workflow execution exceeds the MCP server's timeout. Increase the execution timeout in the n8n workflow settings (Settings → Execution Timeout). For very long workflows, consider using the Wait for Webhook pattern with the MCP Server Trigger.

"SSE connection closed unexpectedly"

The persistent connection was interrupted. Check your network configuration, proxy settings, and ensure your n8n instance is stable. For self‑hosted instances, increase the connection timeout in your reverse proxy (e.g., Nginx's proxy_read_timeout).

"Workflow not found"

The agent is trying to execute a workflow that no longer exists or isn't tagged with "mcp". Check that the workflow ID is correct and that the workflow is still tagged. If you've renamed or moved the workflow, the agent's reference may be stale.

8. Scaling & Optimization

As you add more workflows to your MCP server, performance can degrade. Here's how to scale:

8.1 Caching Strategies

The n8n discovery node queries your entire n8n instance for tagged workflows. For large instances (50+ workflows), this query can become slow. Use Redis to cache the discovery results – set a TTL of 60 seconds so the cache refreshes periodically without overloading the n8n API.

8.2 Batch Discovery

If you're using the MCP client to discover workflows, batch the discovery requests. Instead of querying one workflow at a time, the agent should discover all available workflows in a single request.

8.3 Redis Memory Management

Redis stores the entire list of available workflows. For large lists (100+ workflows), consider compressing the data or using a more efficient serialization format like MessagePack instead of JSON.

Real‑world scalability: I've seen MCP servers with 80+ workflows serving 20+ AI agents simultaneously. The key to scaling is caching and asynchronous execution. Use Redis for caching, and consider using message queues (like RabbitMQ) for heavy workflows.

9. 2026 Update: The New Instance‑Level MCP Server

In April 2026, n8n shipped something that changes this whole picture: a first‑party, instance‑level MCP server built directly into n8n (Cloud, Enterprise, and self‑hosted Community Edition, v2.18.4+). This is different from everything covered in Sections 2–8, and it's worth understanding before you commit to a workflow‑based setup.

FeatureMCP Server Trigger nodeInstance‑level MCP server
ScopeOne workflow at a timeWhole n8n instance, one connection
SetupYou build the trigger + tools yourselfToggle on in Settings, enable workflows individually
What's exposedExactly what you wire to the triggerRun, search, create, and edit workflows (from v2.13)
Best forA specific, curated set of tools/workflowsLetting an agent browse and operate your whole instance
AuthenticationPer‑workflow Bearer/header/OAuth2Centralised, instance‑wide

To use it: an instance owner or admin enables MCP access in Settings, then toggles Available in MCP on each workflow you want exposed (individually, or in bulk per project/folder). Any connected MCP client — Claude Desktop, ChatGPT, Cursor — can then call search_workflows, get_workflow, execute_workflow, and related tools across every enabled workflow, without you building a single custom node.

Visibility caveat: the instance‑level server isn't scoped per MCP client — every client you connect (Claude Desktop and ChatGPT, for example) sees the same set of MCP‑enabled workflows. You can't restrict specific workflows to one client only; you can only restrict by user permission.

Which should you use? If you want an AI agent to browse and run a growing library of workflows with minimal setup, the instance‑level server is faster to stand up and is now n8n's recommended default. If you need a tightly curated, single‑purpose set of tools — or you're on an n8n version below 2.18.4 — the MCP Server Trigger pattern from Sections 2–8 still applies and gives you finer control over exactly what's exposed.

10. Complete Workflow JSON

Below is the full MCP Server workflow JSON. Import it into n8n (Workflows → Import from File). Replace the placeholders for your n8n API key, Redis connection, and production URL.

n8n-mcp-server.json
{
  "name": "n8n MCP Server – Expose Workflows as Tools",
  "nodes": [
    {
      "parameters": {
        "path": "mcp",
        "authentication": "bearerAuth",
        "options": {}
      },
      "id": "mcp-trigger",
      "name": "MCP Server Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "typeVersion": 1,
      "position": [400, 300]
    },
    {
      "parameters": {
        "resource": "workflow",
        "operation": "getAll",
        "returnAll": true,
        "filters": { "tags": ["mcp"] },
        "descriptionType": "manual",
        "toolDescription": "Search for workflows tagged 'mcp' that are available to use as tools."
      },
      "id": "search-tool",
      "name": "Search Workflows (Tool)",
      "type": "n8n-nodes-base.n8nTool",
      "typeVersion": 1,
      "position": [250, 500],
      "credentials": { "n8nApi": { "id": "YOUR_N8N_API_CREDENTIAL_ID" } }
    },
    {
      "parameters": {
        "operation": "set",
        "key": "=available_workflows:{{ $json.sessionId }}",
        "value": "={{ $json.workflowId }}",
        "expire": 3600,
        "descriptionType": "manual",
        "toolDescription": "Add a workflow ID to this session's list of available tools."
      },
      "id": "add-available-tool",
      "name": "Add to Available (Tool)",
      "type": "n8n-nodes-base.redisTool",
      "typeVersion": 1,
      "position": [450, 500],
      "credentials": { "redis": { "id": "YOUR_REDIS_CREDENTIAL_ID" } }
    },
    {
      "parameters": {
        "source": "database",
        "workflowId": "={{ $json.selectedWorkflowId }}",
        "waitForSubWorkflow": true
      },
      "id": "execute-tool",
      "name": "Execute Workflow (Tool)",
      "type": "n8n-nodes-base.executeWorkflowTool",
      "typeVersion": 1,
      "position": [650, 500]
    }
  ],
  "connections": {
    "MCP Server Trigger": {
      "ai_tool": [
        [
          { "node": "Search Workflows (Tool)", "type": "ai_tool", "index": 0 },
          { "node": "Add to Available (Tool)", "type": "ai_tool", "index": 0 },
          { "node": "Execute Workflow (Tool)", "type": "ai_tool", "index": 0 }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "executionTimeout": 120
  }
}
Before importing: Replace these placeholders, and double‑check the exact type strings against your own n8n version (they can shift between releases):
  • YOUR_N8N_API_CREDENTIAL_ID – the credential ID for your n8n API key
  • YOUR_REDIS_CREDENTIAL_ID – the credential ID for your Redis connection
  • Update the filters.tags array if you're using a different tag name

Fastest way to get the exact type strings for your version: build the nodes manually in the UI as shown in Section 4, then use Download from the workflow menu to export a real JSON file and compare it against this template.

11. Frequently Asked Questions

What version of n8n do I need for MCP?

v1.88.0 or higher for the MCP Server Trigger and MCP Client Tool nodes. If you want the newer instance‑level MCP server (Section 9), you'll need v2.18.4 or higher. Check your version in Settings → About.

Should I use the MCP Server Trigger node or the instance‑level MCP server?

Use the instance‑level server if you want the fastest setup and are comfortable exposing a growing set of enabled workflows to any connected client. Use the MCP Server Trigger node if you need a tightly curated set of tools, finer per‑workflow control, or you're on an older n8n version. See the comparison table in Section 9.

Can I use MCP with n8n Cloud?

Yes. The MCP Server Trigger and MCP Client Tool nodes are available in n8n Cloud, Enterprise, and the free self‑hosted Community Edition. However, self‑hosting gives you more control over the MCP server configuration and Redis integration.

How is MCP different from webhooks?

Webhooks are one‑way triggers – they start a workflow when an event occurs. MCP is bidirectional: the agent discovers tools, inspects their parameters, executes them, and gets structured results – all in a standard protocol. MCP also supports persistent connections (SSE) for real‑time communication.

Is MCP secure? How do I protect my server?

Yes, MCP supports Bearer tokens, custom headers, and OAuth2. Always secure your MCP server with authentication, limit which workflows are exposed (tag‑based filtering), and use HTTPS for all connections. Also enable audit logging to track agent activity.

Can I build my own MCP server without Redis?

Redis is used for lightweight memory storage of the "available" workflows list. You can replace Redis with a Code node that stores data in a variable, or use a different database like SQLite. However, Redis is the simplest and most reliable option for this pattern.

What MCP clients can I use with n8n?

n8n's MCP Server works with any MCP‑compatible client – Claude Desktop, Cursor, ChatGPT (with MCP support), and custom agents built with the MCP SDK. You can also use n8n itself as an MCP client via the MCP Client Tool node.

Does MCP work with self‑hosted n8n behind a reverse proxy?

Yes, but SSE/streamable HTTP needs special handling. For Nginx, disable proxy buffering, gzip compression, and chunked transfer encoding on the MCP location block, and clear the Connection header so it isn't inherited from elsewhere in your config. Also raise proxy_read_timeout (e.g., 300s) for long‑running workflows.

Continue your n8n journey with these guides:
AI Automation Build an AI Content Factory with n8n, DeepSeek & Gemini Fixed Error Fix "Workflow Execution Failed" Error in n8n AI Automation How to Build an AI Agent with n8n (Step‑by‑Step) Small Business Automate Invoice Processing & Unpaid Reminders
Ahmed Ayari — TriggerWorkflow I've built MCP servers in n8n for enterprise clients, government agencies, and startups – exposing everything from CRM systems to internal databases. This guide is the distilled result of those projects, including the exact security patterns, error handling strategies, and scaling techniques that work in production.
The MCP server JSON above runs on my own infrastructure and serves over 200 workflow executions per day across 15 AI agents.
See more automation guides by Mr.Ayari
Comments