diff --git a/src/transports/streamableHttp.ts b/src/transports/streamableHttp.ts index 0a20e59e8..09d220607 100644 --- a/src/transports/streamableHttp.ts +++ b/src/transports/streamableHttp.ts @@ -43,6 +43,12 @@ export class StreamableHttpRunner extends TransportRunnerBase { app.enable("trust proxy"); // needed for reverse proxy support app.use(express.json()); + + // Health endpoint for container orchestration (placed before auth middleware) + app.get("/health", (req: express.Request, res: express.Response) => { + res.status(200).json({ status: "healthy", service: "mongodb-mcp" }); + }); + app.use((req, res, next) => { for (const [key, value] of Object.entries(this.userConfig.httpHeaders)) { const header = req.headers[key.toLowerCase()]; diff --git a/tests/integration/transports/streamableHttp.test.ts b/tests/integration/transports/streamableHttp.test.ts index 7f57135d8..0a944b652 100644 --- a/tests/integration/transports/streamableHttp.test.ts +++ b/tests/integration/transports/streamableHttp.test.ts @@ -103,6 +103,14 @@ describe("StreamableHttpRunner", () => { }); }); } + + it("health endpoint works without authentication", async () => { + // Health endpoint should work regardless of configured headers + const response = await fetch(`${runner.serverAddress}/health`); + expect(response.status).toBe(200); + const data = (await response.json()) as { status: string; service: string }; + expect(data).toEqual({ status: "healthy", service: "mongodb-mcp" }); + }); }); }