Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/transports/streamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()];
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/transports/streamableHttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
});
});
}

Expand Down
Loading