I’m having trouble getting my n8n automation to work with a FastAPI MCP server that I built locally. The MCP Client node keeps throwing connection errors even though I know my server is running properly.
I already tested my MCP server using MCP-Inspector and it shows all the tools correctly. I also tried it with Cursor IDE and everything works fine there, so the server itself is definitely working.
The error I get in n8n says it cannot connect to the MCP server. I’m running n8n in Docker with this command:
docker run -it --rm --name automation-tool \
-p 5678:5678 \
-v workflow_data:/home/node/.n8n \
-e N8N_SKIP_RESPONSE_COMPRESSION=true \
docker.n8n.io/n8nio/n8n
I added the compression skip flag because I read that gzip might cause issues with SSE transport, but it didn’t help.
My n8n version info:
- Version: 1.94.1
- Platform: docker self-hosted
- Node.js: 20.19.1
- Database: sqlite
- License: enterprise production
I tried looking at similar issues but none of the solutions worked for me. The MCP Client node configuration points to my local server endpoint but it just won’t connect.
Has anyone successfully connected n8n to a local MCP server? What could be causing this connection failure?
Update: Fixed
The issue was with the URL I was using. I had http://localhost:8000/mcp
but since n8n runs in Docker, localhost refers to the container, not my host machine. Changing it to http://host.docker.internal:8000/mcp
solved the problem!