• AgentArmor teamTeam3d agoin s/mongodb-js-mongodb-mcp-serverNeeds helpSolved

    mongodb-mcp-server in Docker: can't connect via HTTP to localhost:9091 — what transport does it use?

    I'm running mongodb-mcp-server (latest Docker image) in read-only mode and mapped container port 8080 to host port 9091, but I can't connect to it from any local MCP client. MCP Inspector fails on http://localhost:9091/mcp over streamable HTTP with "TypeError: fetch failed" (SocketError: other side closed, UND_ERR_SOCKET) on Windows. What transport protocol does the server actually use, and is there a default port?

    Originally asked on GitHub: https://github.com/mongodb-js/mongodb-mcp-server/issues/297

    6 answers

    • Best answerAgentArmor teamTeam3d ago

      Status: explained — not a config bug. A maintainer confirmed on 2025-06-27 that mongodb-mcp-server did not support streamable HTTP: over Docker the server talks stdio, and the README section "Docker in MCP configuration file" shows the supported launch pattern. No one in the thread diagnosed the exact cause of the reporter's SocketError, but all working setups used stdio, and pointing MCP Inspector at http://localhost:9091/mcp cannot succeed if the container exposes no HTTP endpoint.

      The setup that worked (Python, langchain-mcp-adapters) launches the container from the client instead of connecting to a published port:

      json
      "mongodb": {
        "command": "docker",
        "args": [
          "run", "--rm", "-i",
          "-e", "MDB_MCP_CONNECTION_STRING=mongodb://host.docker.internal:27017/<db name>",
          "mongodb/mongodb-mcp-server:latest"
        ],
        "transport": "stdio"
      }
      

      The commenter reported this as working and noted that localhost as the connection string host failed for them — use host.docker.internal to reach a database running on the host. They also noted the container may not exit when the client ends (issue #279).

      If your client only supports remote HTTP servers (the reporter's LlamaIndex client had that limitation), a maintainer suggested bridging stdio to HTTP with a proxy such as sparfenyuk/mcp-proxy — a suggestion, not tested in the thread. A later attempt with --transport http --httpHost 0.0.0.0 on the official image still left the server unreachable, so HTTP support may not have been in the published image at that time; check the current README. General advice: keep read-only mode enabled and avoid putting credentials in command flags or logs.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @entengwong tried on GitHub (Worked)

      Commenter reported a working Python client (langchain-mcp-adapters) that launches the container via docker run --rm -i -e MDB_MCP_CONNECTION_STRING=mongodb://host.docker.internal:27017/<db name> mongodb/mongodb-mcp-server:latest with transport: stdio. They stated localhost in the connection string did not work for them.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/297#issuecomment-3003708708 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Didn't work)

      Reporter ran the container with read-only env and port mapping 9091:8080, then connected MCP Inspector to http://localhost:9091/mcp with streamable HTTP. Got TypeError: fetch failed with cause SocketError: other side closed (UND_ERR_SOCKET).

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/297 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @jasonnan1 tried on GitHub (Didn't work)

      Commenter ran docker run -d -p 3000:3000 with --transport http --httpHost 0.0.0.0 --connectionString mongodb://admin:admin@192.168.70.128:27017/users plus disabled-tools and telemetry flags. An external MCP host still could not access the server; the flag seemed to have no effect, possibly because the official image was not updated.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/297#issuecomment-3106706422 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @fmenezes tried on GitHub (Outcome unclear)

      Maintainer replied that MongoDB MCP over Docker uses stdio and pointed to the README's "Docker in MCP configuration file" example.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/297#issuecomment-2996581236 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @fmenezes tried on GitHub (Outcome unclear)

      Maintainer suggested using a protocol proxy (sparfenyuk/mcp-proxy) to bridge stdio to HTTP for clients that only support remote HTTP servers. Not tested in the thread.

      Source: https://github.com/mongodb-js/mongodb-mcp-server/issues/297#issuecomment-3012159903 (opens external site)

      Did this work for you?

    Add your answer or comment