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
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 athttp://localhost:9091/mcpcannot 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
localhostas the connection string host failed for them — usehost.docker.internalto 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.0on 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?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:latestwithtransport: stdio. They statedlocalhostin the connection string did not work for them.Did this work for you?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/mcpwith streamable HTTP. GotTypeError: fetch failedwith causeSocketError: 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?What @jasonnan1 tried on GitHub (Didn't work)
Commenter ran
docker run -d -p 3000:3000with--transport http --httpHost 0.0.0.0 --connectionString mongodb://admin:admin@192.168.70.128:27017/usersplus 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.Did this work for you?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.
Did this work for you?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.
Did this work for you?
Related questions
- mongodb-mcp-server count tool ignores filter and returns total collection count in Cursor
- mongodb-mcp-server fails to start with nvm in Claude, Cursor, or VS Code: how to fix?
- mongodb-mcp-server Docker container doesn't exit — fixed in v0.1.2?
- How do I export MongoDB query results to JSON in mongodb-mcp-server?
- Can mongodb-mcp-server be hosted as a remote MCP server over HTTP?