# How to connect Claude Code to self-hosted n8n over MCP | Nuvits

Source: [https://nuvits.net/en/blog/n8n-mcp-claude-code](https://nuvits.net/en/blog/n8n-mcp-claude-code)

Published 2026-11-30, by Fernando Chagas.

n8n ships with a built-in **MCP (Model Context Protocol)** server. Once it is on, **Claude Code** can see your self-hosted instance: it lists workflows, runs the ones you expose, reads the result of each execution and builds new workflows from a plain-text request. In this tutorial you enable the server, connect Claude Code with OAuth or a token, expose a workflow and learn how to cut access when you need to.

The commands and screen names below were checked on **n8n 2.49.9** (Community edition, no license) with **Claude Code 2.1**. n8n ships releases every week and this area moves fast: the screen used here exists since 2.33.0, according to the [official documentation](https://docs.n8n.io/connect/connect-to-n8n-mcp-server/).

## What you need

- A self-hosted n8n behind a domain with HTTPS, for example `https://n8n.example.com`. If you do not have one yet, follow [How to install n8n with Docker on a VPS](https://nuvits.net/en/blog/install-n8n-docker-vps); the examples here use that setup, with Caddy in front.
- An **owner or admin** account in n8n. Only those two roles can enable MCP.
- [Claude Code](https://code.claude.com/docs/en/overview) installed on your machine.

> **Do not confuse it with the MCP Server Trigger node.** n8n has two things with MCP in the name. The [MCP Server Trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/) is a node: you place it in a workflow and it exposes only that workflow's tools, on its own URL. This tutorial covers the **instance-level MCP**, which gives the client access to the whole n8n through a single URL.

## Step 1: enable MCP on the instance

In n8n, open **Settings > Instance-level MCP** and click **Enable MCP access**.

The page now shows **MCP status: Enabled** and four blocks: **Connect your client**, **Workflows enabled** (starts at 0), **MCP access for new workflows** and **Connected clients**.

The server address is always your domain followed by `/mcp-server/http`:

```text
https://n8n.example.com/mcp-server/http
```

Before you enable it, that address answers `404` with `{"message":"MCP access is disabled"}`. Afterwards it answers `401` to anyone without a credential. You can check from your terminal:

```bash
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://n8n.example.com/mcp-server/http
```

The expected result is `401`.

### The reverse proxy

MCP uses HTTP with streamed responses (`text/event-stream`). The Caddyfile from the install tutorial works unchanged, because Caddy forwards every header and `flush_interval -1` delivers the response without buffering.

If you use another proxy, the n8n documentation asks it to forward the `MCP-Protocol-Version`, `Mcp-Method` and `Mcp-Name` headers and not to buffer the response.

## Step 2: connect Claude Code

Under **Connect your client**, click **Connect**. The **Connect a client** dialog has two tabs, **OAuth (recommended)** and **API key**, and a list of clients. Pick **Claude Code**.

### Option A: OAuth (recommended)

On your machine, run:

```bash
claude mcp add --transport http n8n https://n8n.example.com/mcp-server/http
```

Then open Claude Code, type `/mcp`, choose **n8n** and finish the authorization. The browser opens n8n and asks you to approve the client.

With OAuth no token is copied into any file, and the client shows up under **Connected clients**, where you can remove it.

### Option B: access token

Use the token when there is no browser at hand, such as in an SSH session.

On the **API key** tab of the dialog, copy the **Access token**. n8n generates this token the first time you open the tab and **only shows it in full on that visit**: afterwards you see just the end of it, and the way to get a new one is to rotate it.

Store the token in an environment variable and add the server:

```bash
export N8N_MCP_TOKEN='paste-the-token-here'

claude mcp add --transport http n8n https://n8n.example.com/mcp-server/http \
  --header "Authorization: Bearer $N8N_MCP_TOKEN"
```

> **The token sits in plain text on your computer.** The command above writes the token value into `~/.claude.json`, and `claude mcp get n8n` prints the whole header. Anyone who reads that file can operate your n8n. Do not run the command on a shared machine.

### Check the connection

```bash
claude mcp list
```

The n8n line should end with `✔ Connected`:

```text
n8n: https://n8n.example.com/mcp-server/http (HTTP) - ✔ Connected
```

### Share the configuration with your team

By default the server lives in the `local` scope: only you, only in that folder. For the whole team to use the same configuration, create a `.mcp.json` at the project root, with the token read from each person's environment:

```json .mcp.json
{
  "mcpServers": {
    "n8n": {
      "type": "http",
      "url": "https://n8n.example.com/mcp-server/http",
      "headers": {
        "Authorization": "Bearer ${N8N_MCP_TOKEN}"
      }
    }
  }
}
```

This file can go into Git, because it does not contain the token. Each person sets `N8N_MCP_TOKEN` to their own token and approves the server the first time they open Claude Code in the folder. Until then, `claude mcp list` shows `⏸ Pending approval`, and warns `Missing environment variables: N8N_MCP_TOKEN` if the variable is missing.

## Step 3: expose a workflow

Enabling MCP does not expose any workflow. Each one has to be marked:

1. Open the workflow.
2. In the `...` menu, click **Settings**.
3. Turn on **Available in MCP** and click **Save**.

For Claude Code to run the workflow in production mode, it also has to be **published**. Production mode accepts the Webhook, Chat Trigger, Form Trigger and Schedule Trigger triggers.

There is one detail the screen does not make clear: **the client sees the name of every workflow, exposed or not.** The `search_workflows` tool returns the full list, with an `availableInMCP` field on each item. The block applies to the contents and to execution. When it asks for the details of a workflow that is not exposed, Claude Code gets:

```text
Workflow is not available in MCP. Enable MCP access from the workflow card in the workflows list, or from the workflow settings
```

If a workflow name is sensitive information (a customer name, for example), rename it before you connect an agent.

## Step 4: use it from Claude Code

With a workflow exposed and published, ask in plain text. An example with a workflow called "Order lookup", which receives a webhook with the order number:

```text
List the n8n workflows and run "Order lookup" with order 1042. Show me what it returned.
```

Claude Code chains four of the server's tools:

1. `search_workflows` finds the workflow and its `id`.
2. `get_workflow_details` reads the nodes, to learn which trigger it has and what it expects.
3. `execute_workflow` starts the execution in `production` mode and returns only the `executionId`.
4. `get_workflow_execution` fetches the result, with the output of each node.

An execution through MCP **injects the data straight into the trigger node**. It does not make an HTTP request to the webhook URL. The workflow runs the same way, but this test does not prove that the public URL, the DNS and the proxy are working.

### Build workflows with the agent

The server also builds workflows. A request like this one works:

```text
Create an n8n workflow "Daily notice" with a Schedule Trigger every day at 8 am and an Edit Fields node that returns message = "good morning". Validate it and do not publish it.
```

Claude Code reads the workflow SDK reference, validates with `validate_workflow` and creates with `create_workflow_from_code`. The workflow is created **unpublished**, so nothing runs on its own until you open it, review it and publish it.

Two things to watch in what the agent creates:

- **A workflow created through MCP already has "Available in MCP" turned on**, even with the **MCP access for new workflows** option off. The agent can edit and run it without you exposing it.
- **Check the timezone** of any schedule before you publish. The agent does not set a timezone unless you ask.

## What a connected client can do

The server exposes **71 tools** in version 2.49.9. They go far beyond running a workflow:

| Group             | Example tools                                                        | What they do                                   |
| ----------------- | -------------------------------------------------------------------- | ---------------------------------------------- |
| Read              | `search_workflows`, `get_workflow_details`, `get_workflow_execution` | List and read workflows and executions         |
| Execution         | `execute_workflow`, `test_workflow`                                  | Run exposed workflows                          |
| Building          | `create_workflow_from_code`, `update_workflow`, `validate_workflow`  | Create and change workflows                    |
| Publishing        | `publish_workflow`, `unpublish_workflow`, `archive_workflow`         | Put workflows into production or take them out |
| Data tables       | `create_data_table`, `add_data_table_rows`, `get_data_table_rows`    | Read and write Data Tables                     |
| Credentials       | `list_credentials`, `update_credential_description`                  | List credentials and edit their description    |
| Agents and skills | `create_agent`, `call_agent`, `create_skill`, `delete_skill`         | Manage the instance's agents and skills        |

The token is personal and has no scopes: it is tied to the user who generated it. That leads to three practical rules:

- **Treat the token like your n8n password.** Whoever holds it can do through MCP what your user does on screen.
- **Do not approve write tools blindly.** Claude Code asks for permission before each new tool. Let the read tools through and confirm one by one the ones that publish, archive or write.
- **Remember the time limit.** Executions through MCP have a ceiling, five minutes by default. Workflows with multi-step forms or human approval in the middle are not supported.

## How to revoke access

From the lightest to the most drastic:

**Rotate the token.** Under **Settings > Instance-level MCP > Connect > API key**, generate a new token with the button next to the redacted value. The previous one stops working right away. In Claude Code, `claude mcp list` then shows:

```text
✘ Failed to connect — Server rejected the configured Authorization header (HTTP 401)
```

**Remove an OAuth client.** The **Connected clients** block lists who has access; open **View all** and revoke the client.

**Turn MCP off.** Under **MCP status**, choose **Disable**. The address goes back to answering `404`.

**Remove the module.** To make sure MCP cannot even be turned on from the screen, set the variable on the `n8n` service in `docker-compose.yml`:

```yaml docker-compose.yml
environment:
  - N8N_DISABLED_MODULES=mcp
```

Then recreate the container:

```bash
docker compose up -d n8n
```

The endpoint is gone (it answers `404` again) and, according to the documentation, the MCP screens stop showing.

On your computer, to delete the Claude Code configuration:

```bash
claude mcp remove n8n
```

## Common errors

- **`MCP access is disabled` (404).** MCP was not enabled, or the module is listed in `N8N_DISABLED_MODULES`.
- **`Unauthorized` (401) with a token.** The token was rotated, or the `N8N_MCP_TOKEN` variable was empty when you ran `claude mcp add`. Remove the server and add it again.
- **`Workflow is not available in MCP`.** **Available in MCP** is still off in the workflow settings.
- **The production execution fails.** The workflow is not published, or its trigger is not one of the four accepted ones.
- **OAuth opens the wrong address.** n8n advertises the authorization addresses with the public domain it knows. If the instance announces itself as `localhost:5678`, fix that first, as in [The n8n webhook shows localhost:5678](https://nuvits.net/en/blog/n8n-webhook-localhost-5678).

## Next steps

- Set up [automatic n8n backups](https://nuvits.net/en/blog/n8n-automatic-backup) before you let an agent create and change workflows.
- If the agent will trigger many executions, see [how to configure n8n in queue mode](https://nuvits.net/en/blog/configure-n8n-queue-mode-redis-vps).
- To run deploys from the conversation as well, read [Coolify MCP on a VPS](https://nuvits.net/en/blog/deploy-vps-coolify-mcp-claude-code-cursor).
- Nuvits has its own MCP server to manage your VPS from Claude Code: see the [developers page](https://nuvits.net/en/developers).
- No server yet? See the [VPS for n8n](https://nuvits.net/en/n8n-vps).
