I'm having trouble connecting n8n, which is installed on Docker, to claude n8n mcp

Describe the problem/error/question

I’m having trouble connecting n8n, which is installed on Docker, to claude n8n mcp.For a Docker-based n8n system to successfully communicate with Claude Desktop, the first step is overcoming network barriers. Many users can access the n8n interface via a browser using http://localhost:5678, and the same address can be entered into the Claude security file. However, when Claude starts an MCP server (e.g., n8n-mcp), if that server is started as a Docker container, the localhost address will be used within that new container and will not reach the n8n on another machine. In short, I couldn’t connect mcp to the n8n installed on locale. I’m waiting for anyone with knowledge on this subject to share their insights below.

What is the error message (if any)?

Please share your workflow


Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Correct. You should use Docker Compose with all services (n8n, mcp, and others).
Then they will be accessible to each other
Networking | Docker Docs

1 Like

Yes, but I don’t know how to install mcp inside Docker. I couldn’t find any documentation.

Hey @uzox Welcome !

The reason you’re hitting a wall is that localhost inside a Docker container is like a private room that can’t see the rest of the house.

To fix this, you just need to point the MCP server to the “gate” leading back to your machine. If you’re on Windows or Mac, swap localhost for host.docker.internal in your Claude config file. If you’re on Linux, you’ll usually use the bridge IP 172.17.0.1. This tells the MCP container to look outside itself and talk to the n8n instance running on your actual system. Alternatively, just run the MCP server via npx instead of Docker , that way it’s already on your host machine and can “see” localhost without any extra networking.

Let me know if you need more help debugging this issue, but keep in mind as never use localhost:XXXX for connecting anything as it wouldnt work.

2 Likes

Hi @uzox , Welcome to the n8n community!
I believe this documentation will be able to help you
What is the Model Context Protocol (MCP)? - Model Context Protocol

1 Like

I tried to solve the problem with Docker, but I failed again; I probably did something wrong. The issue was resolved by installing with npm instead of Docker. Thank you for your suggestion.

I solved the problem. I’ve included the Docker Compose installation and Claude config settings below. The Python part is optional; I installed it because I needed it for work.

docker_compose

version: "3.9"

services:

  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: n8n
    ports:
      - "5678:5678"
    environment:
      - TZ=Europe/Istanbul
      - GENERIC_TIMEZONE=Europe/Istanbul
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_RUNNERS_ENABLED=true
      - NODES_EXCLUDE=[]
    volumes:
      - n8n_data:/home/node/.n8n
    networks:
      - n8nnet

  python:
    image: python:3.11
    container_name: python-runtime
    command: tail -f /dev/null
    volumes:
      - ./scripts:/scripts
    networks:
      - n8nnet

networks:
  n8nnet:

volumes:
  n8n_data:

claude_desktop_config

  "mcpServers": {
    "n8n-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--init",
        "-e",
        "MCP_MODE=stdio",
        "-e",
        "LOG_LEVEL=error",
        "-e",
        "N8N_API_URL=http://host.docker.internal:5678",
        "-e",
        "N8N_API_KEY=YOUR_API_KEY",
        "-e",
        "WEBHOOK_SECURITY_MODE=moderate",
        "ghcr.io/czlonkowski/n8n-mcp:latest"
      ]
    }
  }
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.