dockersnowflake-cloud-data-platformfastapin8nmodel-context-protocol

Connecting n8n with local MCP server failed - Error in sub-node 'MCP Client' Could not connect to your MCP server


I'm trying to set up an n8n workflow that can use tools from an MCP server that I wrote with FastAPI MCP and n8n can't seem to connect to my MCP server no matter what I do.

I have already confirmed with MCP-Inspector that my MCP server is correctly created and tested with cursor against my MCP server so I know it works. Here's a screenshot from MCP inspector and Cursor demonstrating the working MCP server: MCP Inspector Screenshot - Tools are Found and Available

Screenshot from Cursor using my local MCP server

Here's the error message I got from n8n:

Could not connect to MCP server

This is the command I run to run my local n8n instance:

docker run -it --rm --name n8n \   
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_SKIP_RESPONSE_COMPRESSION=true \
  docker.n8n.io/n8nio/n8n

Note that I used the documentation from the n8n website to create the original volume being used with n8n https://docs.n8n.io/hosting/installation/docker/#starting-n8n

I added the N8N_SKIP_RESPONSE_COMPRESSION environment variable to try to address other stackoverflow threads that mentioned that gzip compression might be causing issues with the SSE transport but maybe this didn't work. Not sure.

Here's a couple other threads I tried to follow:

Also here's a rough view of my n8n workflow (you can ignore most of it -- the important thing is the MCP Client module linked as a tool that can't connect): n8n workflow screenshot n8n MCP Client config pointing to SSE MCP Server endpoint

Here's the debug info for my self-hosted n8n version:

Debug info

core

storage

pruning

client

Generated at: 2025-05-27T18:45:23.237Z


Solution

  • Your n8n docker can't connect because you are telling it to connect to localhost port 8000 inside that docker .. but there is no service - so it doesn't see your host port8000

    Try to either replace it with docker internal

    host.docker.internal

    or to find virtual ip that is loopbacked on your host.