fix: use dynamic database lookup for search index check#1095
fix: use dynamic database lookup for search index check#1095
Conversation
…check Use listDatabases() to find an accessible non-system database instead of hardcoded '#mongodb-mcp' which may not exist or be accessible when the connection string restricts database access.
There was a problem hiding this comment.
Pull request overview
This PR updates Atlas Search capability detection to avoid relying on a single hardcoded probe database, improving compatibility with users whose connection string/roles restrict database access (Issue #1022).
Changes:
- Update
ConnectionStateConnected.isSearchSupported()to probe multiple candidate databases (initial DB +listDatabases()results + fallback) and treatSearchNotEnabledas the definitive “not supported” signal. - Add logging for the search capability probe and thread a logger through
Session.isSearchSupported(). - Expand unit/integration test coverage, including spinning up auth-enabled MongoDB test clusters with multiple users and restricted privileges.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/common/connectionManager.ts |
Implements the new multi-database probe logic and caches the probe result. |
src/common/session.ts |
Passes the session logger into the connected state’s isSearchSupported() call. |
src/common/logging/loggingDefinitions.ts |
Adds a new log ID for probe-related debug logging. |
tests/unit/common/session.test.ts |
Updates mocks and assertions for the new probe behavior and error handling. |
tests/integration/common/connectionManager.test.ts |
Adds integration coverage for probe candidate selection, failure modes, and caching. |
tests/integration/tools/mongodb/mongodbHelpers.ts |
Adds a helper to build per-user connection strings for restricted-user scenarios. |
tests/integration/tools/mongodb/mongodbClusterProcess.ts |
Adds support for creating multiple users on mongo-runner clusters and generating per-user URIs. |
api-extractor/reports/web.public.api.md |
Updates public API report for the new isSearchSupported(logger) signature. |
api-extractor/reports/mongodb-mcp-server.public.api.md |
Updates public API report for the new isSearchSupported(logger) signature. |
Coverage Report for CI Build 24860576670Warning No base build found for commit Coverage: 81.942%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
|
I opened #1097 as a small compatibility patch on top of this branch. It keeps |
Based on #1091 - uses a dynamic list of databases to check for search index support instead of the hardcoded
#mongodb-mcpwhich may not be accessible for the db user.Fixes #1022