diff --git a/README.md b/README.md index e45d1ebaf..97831d29d 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,47 @@ npx -y mongodb-mcp-server@latest --transport http --httpHost=0.0.0.0 --httpPort= > **Note:** The default transport is `stdio`, which is suitable for integration with most MCP clients. Use `http` transport if you need to interact with the server over HTTP. +##### Monitoring server health checks + +When running with `--transport http`, you can optionally start a **separate** monitoring HTTP server that exposes a health-check endpoint and, optionally, a metrics endpoint. It listens on its own host and port, independent of the main MCP HTTP server, so you can keep it on an internal-only interface. + +The monitoring server is only started when **both** `--monitoringServerHost` and `--monitoringServerPort` are set (setting only one of them is rejected at startup). It is disabled by default. + +```shell +npx -y mongodb-mcp-server@latest --transport http \ + --httpHost=0.0.0.0 --httpPort=3000 \ + --monitoringServerHost=127.0.0.1 --monitoringServerPort=8080 +``` + +It exposes the following routes: + +| Route | Enabled by | Response | +| ---------- | -------------------------------- | ----------------------------------------------------------- | +| `/health` | `health-check` feature (default) | `200` with `{"status":"ok"}` | +| `/metrics` | `metrics` feature | `200` with `text/plain` metrics for scraping by a collector | + +Check the health endpoint: + +```shell +curl http://127.0.0.1:8080/health +# {"status":"ok"} +``` + +Use `--monitoringServerFeatures` (or `MDB_MCP_MONITORING_SERVER_FEATURES`) to control which routes are exposed. It accepts a comma-separated list and defaults to `health-check`. To expose both the health check and metrics: + +```shell +npx -y mongodb-mcp-server@latest --transport http \ + --httpHost=0.0.0.0 --httpPort=3000 \ + --monitoringServerHost=127.0.0.1 --monitoringServerPort=8080 \ + --monitoringServerFeatures=health-check,metrics +``` + +- `--monitoringServerHost` (default: ``): Host to bind the monitoring server to. +- `--monitoringServerPort` (default: ``): Port for the monitoring server. +- `--monitoringServerFeatures` (default: `health-check`): Comma-separated features to expose (`health-check`, `metrics`). + +> **Note:** The `--healthCheckHost` and `--healthCheckPort` options are deprecated aliases for `--monitoringServerHost` and `--monitoringServerPort`; prefer the `monitoringServer*` options. + #### Option 6: Copilot CLI You can use the Copilot CLI to interactively add the MCP server: