Claude.ai MCP Connector Failing to connect to my self-hosted n8n

I’m trying to connect Claude.ai to my self-hosted n8n via Instance-level MCP (OAuth). The OAuth flow appears to complete — I get redirected to n8n, I authorize, and n8n shows Claude as a Connected client. But Claude always returns “Authorization with the MCP server failed.”

I also tried creating a separate workflow with an MCP Server Trigger node (no auth) and using that Production URL as a custom connector in Claude. Same error.

My setup

  • n8n version: 2.12.3

  • Database: SQLite (default)

  • n8n EXECUTIONS_PROCESS setting: default

  • Running n8n via: npm (global install, Node.js v22.21.1 via nvm)

  • Operating system: macOS 14.2.1 (Apple Silicon)

n8n runs as a macOS LaunchAgent and is exposed to the internet via Cloudflare Tunnel (cloudflared 2025.11.1) routing n8n.jeffzeb.comhttp://127.0.0.1:5678.

What I’ve tried

  • Confirmed endpoint is reachable: curl -I returns HTTP 401 with Bearer auth as expected

  • Added N8N_PROXY_HOPS=1 and N8N_TRUST_PROXY=true (fixed an ERR_ERL_UNEXPECTED_X_FORWARDED_FOR error in the MCP SDK)

  • Created a Cloudflare Transform Rule to set Origin: https://n8n.jeffzeb.com (known issue with tunnels stripping the scheme)

  • Revoked old Connected clients and re-added the connector fresh

  • Tested in both Safari and Chrome

  • Tested both Instance-level MCP (OAuth) and MCP Server Trigger (no auth) — both fail with the same error

  • Workflows are enabled for MCP access and active

Key observation

OAuth completes on n8n’s side (Connected clients tab confirms it), but Claude doesn’t recognize the connection as successful. This happens with both the instance-level MCP URL and a standalone MCP Server Trigger URL.

Has anyone successfully connected Claude.ai (not Claude Desktop) to a self-hosted n8n behind a Cloudflare Tunnel? Any ideas what could be failing after the OAuth callback? Also possible issue is on the Claude side, so I’ve reached out to their help support as well.

Hi @GeoffS , welcome to the n8n community :tada:

What stands out to me is that both the OAuth connector and the no-auth MCP Server Trigger fail the same way, so I’d be cautious about blaming OAuth itself, to me that points more toward a reverse-proxy / transport issue after the callback, especially since n8n behind a proxy needs the original forwarded host/proto headers and usually a fixed WEBHOOK_URL, plus Cloudflare can sometimes interfere with streaming/compression behavior.

could you please share the response headers and body you get from the MCP endpoint with curl -i, and whether Cloudflare has compression, caching, Access, or any other edge features enabled on that hostname/path?

Cloudflare Tunnel buffers streaming responses by default, which breaks the MCP transport even though the OAuth redirect works fine. Add disableChunkedEncoding: true to your cloudflared config for that ingress rule. Also make sure WebSockets are enabled in the Cloudflare dashboard under Network for your domain.

Thanks everyone for the quick responses! Here’s what I found after working through them:

@pvdyck

disableChunkedEncoding: true Added this to my cloudflared config and restarted the tunnel. This was a good call and may have fixed the streaming issue, but the auth error persists.

@tamy.santos

Here’s what curl -i shows for the instance-level MCP endpoint:

  • GET returns HTTP 200 with the n8n editor HTML (falls through to frontend)

  • POST with MCP initialize payload returns: {"message":"Unauthorized: Authorization header not sent"}— so the endpoint is alive and correctly requiring auth

For the MCP Server Trigger endpoint (no auth), POST with MCP initialize returns a proper response:

event: message
data: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"MCP_Server_Trigger","version":"0.1.0"},"jsonrpc":"2.0","id":1}

Response headers include content-type: text/html; charset=utf-8, access-control-allow-origin: ``https://n8n.xxxxxxxx.com, cache-control: no-cache, no-store, cf-cache-status: DYNAMIC. No compression or caching issues visible.

BenB

As shown above, the MCP Server Trigger returns a valid initialize response with correct tools capability and protocol version. Transport is working fine — the disableChunkedEncoding fix plus WebSockets enabled in Cloudflare means streaming isn’t being buffered.

Both endpoints work correctly at the transport level when tested with curl. The OAuth flow also completes — n8n shows Claude as a Connected client after I authorize. But Claude.ai still returns “Authorization with the MCP server failed” every time.

Even the no-auth MCP Server Trigger fails with the same error, which suggests Claude.ai’s custom connector is attempting OAuth regardless and something in that exchange isn’t completing on Claude’s side.

I also fixed an ERR_ERL_UNEXPECTED_X_FORWARDED_FOR error earlier by adding N8N_TRUST_PROXY=true — the error log is clean now.

Has anyone gotten Claude.ai (not Claude Desktop) working with a self-hosted n8n behind Cloudflare Tunnel specifically? Starting to wonder if this is a Claude-side issue with the OAuth callback.

Also, @tamy.santos here’s what you asked for.

curl -i against the instance-level MCP endpoint (POST):

HTTP/2 401
content-type: application/json; charset=utf-8
content-length: 57
access-control-allow-credentials: true
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, push-ref, browser-id, anonymousid, authorization, x-authorization
access-control-allow-methods: GET, POST, OPTIONS, PUT, PATCH, DELETE
access-control-allow-origin: https://n8n.xxxxxxx.com
etag: W/"39-2hSNeRgbNg6crq17Q/2hLPX4gMU"
vary: Accept-Encoding
www-authenticate: Bearer realm="n8n MCP Server"
cf-cache-status: DYNAMIC

{"message":"Unauthorized: Authorization header not sent"}

curl -i against the MCP Server Trigger endpoint (no auth, POST):

HTTP/2 200
content-type: text/event-stream
content-length: 178
access-control-allow-methods: OPTIONS, DELETE, GET, POST
access-control-allow-origin: https://n8n.xxxxxxx.com
cache-control: no-cache
mcp-session-id: 9bcea911-251c-4dd2-ab03-d8c28c93fc9a
vary: Accept-Encoding
cf-cache-status: DYNAMIC

event: message
data: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"MCP_Server_Trigger","version":"0.1.0"},"jsonrpc":"2.0","id":1}

Cloudflare edge features:

  • No custom caching, compression, or Access policies on this hostname

  • WebSockets enabled

  • One active rule: Modify Request Header setting Origin: https://n8n.xxxxxxx.com

  • Tunnel config has disableChunkedEncoding: true per @pvdyck’s suggestion

@GeoffS 如果你願意使用 Claude Desktop 或 Claude Code CLI,而不是 Claude.ai 網頁版,有一種方法可以完全避免 OAuth 問題。我建立了一個 Python MCP 伺服器,使用 stdio 連接並直接呼叫 n8n REST API;沒有 Cloudflare 隧道的複雜問題,也沒有 OAuth 握手。值得試試看:https://github.com/DerJams/n8n-mcp-server-python

感謝您提供的資訊 @GeoffS

那麼,遺憾地告訴您,問題似乎在於 Claude Desktop 和 Claude AI 之間的差異。文件中提到的 MCP 觸發器僅針對 Claude Desktop 而言,我沒有找到任何有關 Claude.ai 自訂連接器的資訊,而且無認證端點以相同錯誤失敗這一事實表明,它可能正在套用自己的授權流程或不接受這類型的端點。實務上的解決方案是使用 Claude Desktop 或其他受支援/已記錄的 MCP 來測試。如果必須使用 Claude.ai,我會暫時在 Claude.ai 和 n8n 之間使用代理/適配器。

以下是支持文件
MCP 連接器 - Claude API 文件
MCP Server Trigger 節點文件 | n8n 文件
設定並使用 n8n MCP 伺服器 | n8n 文件

感謝 @tamy.santos。我有一陣子沒有進行這個專案,但我會根據你的文件重新檢視。不幸的是,我也沒有在 Claude Desktop 上取得任何進展。

唉呀 :frowning:
真遺憾。

更新:成功了。

OAuth 連接流程仍然無法運作 — 這似乎是 Claude 端的錯誤,它完成了 OAuth 握手,但從未將 Bearer token 附加到後續的 MCP 請求。我已向 Anthropic 支援回報,他們確認這是一個已知的問題。

有效的方法: 使用 Claude Desktop 的設定檔直接繞過 OAuth,改用 Bearer token。

  1. 從 n8n Settings → Instance-level MCP → Connection details → Access Token 標籤取得你的 Access Token

  2. 編輯 ~/Library/Application Support/Claude/claude_desktop_config.json

  3. 新增一個 mcpServers 區塊:

{
  "mcpServers": {
    "n8n": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://your-n8n-domain.com/mcp-server/http",
        "--header",
        "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE"
      ]
    }
  }
}

  1. 重新啟動 Claude Desktop

這使用 mcp-remote 將 Claude Desktop 的 stdio 傳輸橋接到 n8n 的 HTTP 端點,並直接傳遞 token。無需 OAuth 流程。

注意: 這只在 Claude Desktop 中有效,在瀏覽器中的 claude.ai 無法使用。token 也可能過期,所以你可能需要定期重新整理。

沿途所需的其他修正 (如果你的 n8n 在 Cloudflare Tunnel 後面):

  • cloudflared 設定中的 disableChunkedEncoding: true (防止 SSE 緩衝)

  • N8N_TRUST_PROXY=true 環境變數 (修正 MCP SDK 中的 ERR_ERL_UNEXPECTED_X_FORWARDED_FOR 錯誤)

  • Cloudflare Transform Rule 設定 Origin: https://your-domain.com (修正 scheme 移除問題)

  • 在 Cloudflare Network 設定中啟用 WebSockets

感謝 @tamy.santos、BenB、pvdyck、unstableentity 和 @syed_noor 協助我們縮小問題範圍。

很棒的討論串!有一點值得注意:

MCP 伺服器在本機 Claude Desktop 設置中最適合使用 stdio 傳輸,

在遠端/伺服器部署中則適合使用 SSE。

我一直在運行一個自訂的 Flowmatic MCP

伺服器,將 Claude 連接到即時市場數據

和投資組合管理 — 如果有用的話,很樂意分享

架構。