Skip to content

Using with Open AI Agent Builder #663

@lolz0r

Description

@lolz0r

Summary:
When using the MCP server with HTTP transport behind an Nginx reverse proxy, the Open AI agent builder can detect the server and list available tools. However, tool calls fail most of the time (>90%), returning:

Tool: mcp_mongo.connect
Response: { "code": 32600, "message": "Session terminated" }

Expected behavior:
Tool calls should consistently succeed once the MCP server is reachable.

Observed behavior:
Most requests to /mcp end with a Session terminated error, even though initial handshake and occasional tool calls succeed.

Condensed Server Log:

nginx | "POST /mcp" 200 / 202 responses alternating
mongo-mcp | [INFO] Server started (StreamableHTTPServerTransport)
mongo-mcp | [INFO] Attempting MongoDB connection...
mongo-mcp | [DEBUG] Telemetry: start → stop sequence repeats within seconds
mongo-mcp | [INFO] Server shutdown / "Session terminated"
  • Repeated server restarts and session closures observed within 1–2 seconds.
  • Same behavior across multiple session IDs.
  • Nginx reverse proxy appears to receive valid POST/DELETE cycles but connections terminate immediately after.

I am running the MCP server via docker:
mongo-mcp:
image: mongodb/mongodb-mcp-server:latest
restart: always
env_file:
- .env
environment:
MDB_MCP_CONNECTION_STRING: ${MDB_MCP_CONNECTION_STRING}
MDB_MCP_READ_ONLY: ${MDB_MCP_READ_ONLY:-true}
MDB_MCP_TRANSPORT: ${MDB_MCP_TRANSPORT:-http}
MDB_MCP_HTTP_HOST: ${MDB_MCP_HTTP_HOST:-0.0.0.0}
MDB_MCP_HTTP_PORT: ${MDB_MCP_HTTP_PORT:-8080}
MDB_MCP_API_CLIENT_ID: ${MDB_MCP_API_CLIENT_ID}
MDB_MCP_API_CLIENT_SECRET: ${MDB_MCP_API_CLIENT_SECRET}
MDB_MCP_LOGGERS: "disk,stderr"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions