Skip to content

Conversation

@ashwin-ranade
Copy link

@ashwin-ranade ashwin-ranade commented Nov 3, 2025

Summary

Adds a simple /health endpoint that returns HTTP 200 for Kubernetes/Docker health checks.

Motivation

Container orchestration platforms need a basic HTTP endpoint for readiness probes. The existing /mcp endpoint expects MCP protocol requests and authentication, making it unsuitable for standard health checks.

Changes

  • Added GET /health endpoint returning {"status": "healthy", "service": "mongodb-mcp"}
  • Placed before authentication middleware to work with all configurations
  • Added test coverage in existing streamableHttp test suite

Testing

All existing tests pass (13/13 in streamableHttp test suite), including new health endpoint tests with and without custom headers configured.

Manual verification:

Run mongodb-mcp-server via Node:

mongodb-mcp-server % npm start

Verify health endpoint works by curl-ing it in a different terminal:

ashwin.ranade@SGMDXFQXMK4K3 ~ % curl http://localhost:3000/health
{"status":"healthy","service":"mongodb-mcp"}%

@ashwin-ranade ashwin-ranade requested a review from a team as a code owner November 3, 2025 22:17
Copilot AI review requested due to automatic review settings November 3, 2025 22:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a health check endpoint to the MCP server's HTTP transport layer to support container orchestration and monitoring systems. The endpoint is designed to be accessible without authentication.

Key changes:

  • Added a /health GET endpoint that returns a JSON response with status and service information
  • Positioned the health endpoint before authentication middleware to ensure it's always accessible

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/transports/streamableHttp.ts Implements the /health endpoint before authentication middleware
tests/integration/transports/streamableHttp.test.ts Adds integration test verifying the health endpoint works without authentication

@ashwin-ranade ashwin-ranade changed the title add health check endpoint to mcp server [feat]: add health check endpoint to mcp server Nov 3, 2025
@nirinchev
Copy link
Collaborator

Hey, thank you so much for this contribution! The code looks good to me, but we would need you to sign the MongoDB Contributor Agreement before we can merge it.

@fmenezes
Copy link
Collaborator

fmenezes commented Nov 4, 2025

it looks good to me 🎉

@ashwin-ranade ashwin-ranade changed the title [feat]: add health check endpoint to mcp server feat: add health check endpoint to mcp server Nov 5, 2025
@fmenezes
Copy link
Collaborator

fmenezes commented Nov 5, 2025

@ashwin-ranade let us know when you've signed https://www.mongodb.com/legal/contributor-agreement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants