From 7dc352f8e392530060f8dceb997eff482f846dff Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Wed, 14 Oct 2026 16:22:54 +0200 Subject: [PATCH 01/23] chore(deps): migrate Database Tools to mongodb-mcp-server v3 mongodb-mcp-server v3 is binary-only; library embedding moved to the scoped @mongodb-js/mcp-* packages. Compass used the v1 library API directly (in-memory runner, session-scoped config, session-scoped connection manager), none of which exists in v3. Build the in-memory server composition by hand instead of via TransportRunnerBase, expose Compass's active connection through a ConnectionRegistry, and inject the tool connection handle at invocation time rather than exposing it to the model. MCP telemetry is now a no-op and the webpack aliases that only existed for the v1 package are gone. --- package-lock.json | 1763 ++--------------- .../src/compass-assistant-provider.spec.tsx | 5 - .../src/compass-assistant-provider.tsx | 5 - .../compass-assistant/test/tool-calls.eval.ts | 2 - packages/compass-generative-ai/package.json | 4 +- .../compass-generative-ai/src/provider.tsx | 2 - .../src/tools-connection-error-handler.ts | 2 +- .../src/tools-connection-manager.spec.ts | 70 +- .../src/tools-connection-manager.ts | 105 +- .../src/tools-controller.spec.ts | 116 +- .../src/tools-controller.ts | 259 ++- .../compass-generative-ai/src/tools-logger.ts | 12 +- packages/compass-web/package.json | 1 - .../polyfills/diagnostics_channel/index.ts | 47 - packages/compass-web/webpack.config.js | 22 +- packages/compass/webpack.config.js | 5 - 16 files changed, 583 insertions(+), 1837 deletions(-) delete mode 100644 packages/compass-web/polyfills/diagnostics_channel/index.ts diff --git a/package-lock.json b/package-lock.json index 6f6f89e7c1e..3dc68403420 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7140,380 +7140,6 @@ "node": ">=6.9.0" } }, - "node_modules/@inquirer/ansi": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.5.tgz", - "integrity": "sha512-doc2sWgJpbFQ64UflSVd17ibMGDuxO1yKgOgLMwavzESnXjFWJqUeG8saYosqKpHp4kWiM5x1nXvEjbpx90gzw==", - "license": "MIT", - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - } - }, - "node_modules/@inquirer/checkbox": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-5.1.3.tgz", - "integrity": "sha512-+G7I8CT+EHv/hasNfUl3P37DVoMoZfpA+2FXmM54dA8MxYle1YqucxbacxHalw1iAFSdKNEDTGNV7F+j1Ldqcg==", - "license": "MIT", - "dependencies": { - "@inquirer/ansi": "^2.0.5", - "@inquirer/core": "^11.1.8", - "@inquirer/figures": "^2.0.5", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/confirm": { - "version": "6.0.11", - "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.0.11.tgz", - "integrity": "sha512-pTpHjg0iEIRMYV/7oCZUMf27/383E6Wyhfc/MY+AVQGEoUobffIYWOK9YLP2XFRGz/9i6WlTQh1CkFVIo2Y7XA==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/core": { - "version": "11.1.8", - "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-11.1.8.tgz", - "integrity": "sha512-/u+yJk2pOKNDOh1ZgdUH2RQaRx6OOH4I0uwL95qPvTFTIL38YBsuSC4r1yXBB3Q6JvNqFFc202gk0Ew79rrcjA==", - "license": "MIT", - "dependencies": { - "@inquirer/ansi": "^2.0.5", - "@inquirer/figures": "^2.0.5", - "@inquirer/type": "^4.0.5", - "cli-width": "^4.1.0", - "fast-wrap-ansi": "^0.2.0", - "mute-stream": "^3.0.0", - "signal-exit": "^4.1.0" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/core/node_modules/cli-width": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", - "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", - "license": "ISC", - "engines": { - "node": ">= 12" - } - }, - "node_modules/@inquirer/core/node_modules/mute-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz", - "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==", - "license": "ISC", - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, - "node_modules/@inquirer/core/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@inquirer/editor": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-5.1.0.tgz", - "integrity": "sha512-6wlkYl65Qfayy48gPCfU4D7li6KCAGN79mLXa/tYHZH99OfZ820yY+HA+DgE88r8YwwgeuY6PQgNqMeK6LuMmw==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/external-editor": "^3.0.0", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/expand": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-5.0.12.tgz", - "integrity": "sha512-vOfrB33b7YIZfDauXS8vNNz2Z86FozTZLIt7e+7/dCaPJ1RXZsHCuI9TlcERzEUq57vkM+UdnBgxP0rFd23JYQ==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/external-editor": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-3.0.0.tgz", - "integrity": "sha512-lDSwMgg+M5rq6JKBYaJwSX6T9e/HK2qqZ1oxmOwn4AQoJE5D+7TumsxLGC02PWS//rkIVqbZv3XA3ejsc9FYvg==", - "license": "MIT", - "dependencies": { - "chardet": "^2.1.1", - "iconv-lite": "^0.7.2" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/external-editor/node_modules/iconv-lite": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", - "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/@inquirer/figures": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.5.tgz", - "integrity": "sha512-NsSs4kzfm12lNetHwAn3GEuH317IzpwrMCbOuMIVytpjnJ90YYHNwdRgYGuKmVxwuIqSgqk3M5qqQt1cDk0tGQ==", - "license": "MIT", - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - } - }, - "node_modules/@inquirer/input": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-5.0.11.tgz", - "integrity": "sha512-twUWidn4ocPO8qi6fRM7tNWt7W1FOnOZqQ+/+PsfLUacMR5rFLDPK9ql0nBPwxi0oELbo8T5NhRs8B2+qQEqFQ==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/number": { - "version": "4.0.11", - "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-4.0.11.tgz", - "integrity": "sha512-Vscmim9TCksQsfjPtka/JwPUcbLhqWYrgfPf1cHrCm24X/F2joFwnageD50yMKsaX14oNGOyKf/RNXAFkNjWpA==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/password": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-5.0.11.tgz", - "integrity": "sha512-9KZFeRaNHIcejtPb0wN4ddFc7EvobVoAFa049eS3LrDZFxI8O7xUXiITEOinBzkZFAIwY5V4yzQae/QfO9cbbg==", - "license": "MIT", - "dependencies": { - "@inquirer/ansi": "^2.0.5", - "@inquirer/core": "^11.1.8", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/prompts": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-8.4.1.tgz", - "integrity": "sha512-AH5xPQ997K7e0F0vulPlteIHke2awMkFi8F0dBemrDfmvtPmHJo82mdHbONC4F/t8d1NHwrbI5cGVI+RbLWdoQ==", - "license": "MIT", - "dependencies": { - "@inquirer/checkbox": "^5.1.3", - "@inquirer/confirm": "^6.0.11", - "@inquirer/editor": "^5.1.0", - "@inquirer/expand": "^5.0.12", - "@inquirer/input": "^5.0.11", - "@inquirer/number": "^4.0.11", - "@inquirer/password": "^5.0.11", - "@inquirer/rawlist": "^5.2.7", - "@inquirer/search": "^4.1.7", - "@inquirer/select": "^5.1.3" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/rawlist": { - "version": "5.2.7", - "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-5.2.7.tgz", - "integrity": "sha512-AqRMiD9+uE1lskDPrdqHwrV/EUmxKEBLX44SR7uxK3vD2413AmVfE5EQaPeNzYf5Pq5SitHJDYUFVF0poIr09w==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/search": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-4.1.7.tgz", - "integrity": "sha512-1y7+0N65AWk5RdlXH/Kn13txf3IjIQ7OEfhCEkDTU+h5wKMLq8DUF3P6z+/kLSxDGDtQT1dRBWEUC3o/VvImsQ==", - "license": "MIT", - "dependencies": { - "@inquirer/core": "^11.1.8", - "@inquirer/figures": "^2.0.5", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/select": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-5.1.3.tgz", - "integrity": "sha512-zYyqWgGQi3NhBcNq4Isc5rB3oEdQEh1Q/EcAnOW0FK4MpnXWkvSBYgA4cYrTM4A9UB573omouZbnL9JJ74Mq3A==", - "license": "MIT", - "dependencies": { - "@inquirer/ansi": "^2.0.5", - "@inquirer/core": "^11.1.8", - "@inquirer/figures": "^2.0.5", - "@inquirer/type": "^4.0.5" - }, - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, - "node_modules/@inquirer/type": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.0.5.tgz", - "integrity": "sha512-aetVUNeKNc/VriqXlw1NRSW0zhMBB0W4bNbWRJgzRl/3d0QNDQFfk0GO5SDdtjMZVg6o8ZKEiadd7SCCzoOn5Q==", - "license": "MIT", - "engines": { - "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" - }, - "peerDependencies": { - "@types/node": ">=18" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - } - } - }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -9329,16 +8955,6 @@ "integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", "license": "MIT" }, - "node_modules/@mcp-ui/server": { - "version": "5.16.3", - "resolved": "https://registry.npmjs.org/@mcp-ui/server/-/server-5.16.3.tgz", - "integrity": "sha512-MZttML9tQC1B8f4SPgoT1BORfCDXqs4Ywb/mQ0wSwIYS9AuIWFLj1KXmvqC/zrG0SlNMlyvMSxEX/eVYsIoZaA==", - "license": "Apache-2.0", - "dependencies": { - "@modelcontextprotocol/ext-apps": "^0.2.2", - "@modelcontextprotocol/sdk": "^1.25.1" - } - }, "node_modules/@microsoft/api-extractor": { "version": "7.59.4", "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.59.4.tgz", @@ -9502,64 +9118,25 @@ "dev": true, "license": "MIT" }, - "node_modules/@modelcontextprotocol/ext-apps": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/ext-apps/-/ext-apps-0.2.2.tgz", - "integrity": "sha512-h8sN3QIBLqMsRXjKL76M5VmBQf3N0I1G1DiDiSYAgtdynYQctHqCs79WEo1d5wClyZVYBWXdRcxgiR/WBfSOqw==", - "hasInstallScript": true, - "license": "MIT", - "workspaces": [ - "examples/*" - ], + "node_modules/@modelcontextprotocol/core": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.3.1.tgz", + "integrity": "sha512-laVmIhPGpWi7rG9q+0UigblRN0Hws/Yjlb6qLFtVqryXVLkc4h+yN8z731POD2LnAGQlFe7/tXhUm7Bi0YB91g==", + "license": "Apache-2.0", "dependencies": { - "prettier": "^3.6.2" + "zod": "^4.2.0" }, - "optionalDependencies": { - "@oven/bun-darwin-aarch64": "^1.2.21", - "@oven/bun-darwin-x64": "^1.2.21", - "@oven/bun-darwin-x64-baseline": "^1.2.21", - "@oven/bun-linux-aarch64": "^1.2.21", - "@oven/bun-linux-aarch64-musl": "^1.2.21", - "@oven/bun-linux-x64": "^1.2.21", - "@oven/bun-linux-x64-baseline": "^1.2.21", - "@oven/bun-linux-x64-musl": "^1.2.21", - "@oven/bun-linux-x64-musl-baseline": "^1.2.21", - "@oven/bun-windows-x64": "^1.2.21", - "@oven/bun-windows-x64-baseline": "^1.2.21", - "@rollup/rollup-darwin-arm64": "^4.53.3", - "@rollup/rollup-darwin-x64": "^4.53.3", - "@rollup/rollup-linux-arm64-gnu": "^4.53.3", - "@rollup/rollup-linux-x64-gnu": "^4.53.3", - "@rollup/rollup-win32-x64-msvc": "^4.53.3" - }, - "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.24.0", - "react": "^17.0.0 || ^18.0.0 || ^19.0.0", - "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", - "zod": "^3.25.0 || ^4.0.0" - }, - "peerDependenciesMeta": { - "react": { - "optional": true - }, - "react-dom": { - "optional": true - } + "engines": { + "node": ">=20" } }, - "node_modules/@modelcontextprotocol/ext-apps/node_modules/prettier": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", - "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", + "node_modules/@modelcontextprotocol/core/node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" + "url": "https://github.com/sponsors/colinhacks" } }, "node_modules/@modelcontextprotocol/sdk": { @@ -9945,106 +9522,31 @@ "node": ">= 0.6" } }, - "node_modules/@mongodb-js/atlas-admin-api": { - "resolved": "packages/atlas-admin-api", - "link": true - }, - "node_modules/@mongodb-js/atlas-local": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local/-/atlas-local-1.3.0.tgz", - "integrity": "sha512-NYcXgw3/P+mEe9dUMEJbEpSCxEKvqTfoHu/doGKaCaSSKjxTDUnybJDPyE3NksjmSK5XU++IoYudIuAFfYdzow==", + "node_modules/@modelcontextprotocol/server": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.3.1.tgz", + "integrity": "sha512-e59MfWuSssj6DoQ96JCTqdW1AXT5/XtnTl0WWd6MU1Ka434fFUGGosCLJbGNySDhHGvxQWoRWK137FXYFkYNWw==", "license": "Apache-2.0", - "optional": true, - "engines": { - "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" + "dependencies": { + "@modelcontextprotocol/core": "2.3.1", + "zod": "^4.2.0" }, - "optionalDependencies": { - "@mongodb-js/atlas-local-darwin-arm64": "1.3.0", - "@mongodb-js/atlas-local-darwin-x64": "1.3.0", - "@mongodb-js/atlas-local-linux-arm64-gnu": "1.3.0", - "@mongodb-js/atlas-local-linux-x64-gnu": "1.3.0", - "@mongodb-js/atlas-local-win32-x64-msvc": "1.3.0" - } - }, - "node_modules/@mongodb-js/atlas-local-darwin-arm64": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-darwin-arm64/-/atlas-local-darwin-arm64-1.3.0.tgz", - "integrity": "sha512-+g4So8Fz9TNdDsWGWUUf9F4bsVvGaqwebMq/mHmHpHp+HVD71GDYlmCTsfm/YzDkmVLPKkHSC7pAqXgpO3DROw==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], "engines": { - "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" - } - }, - "node_modules/@mongodb-js/atlas-local-darwin-x64": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-darwin-x64/-/atlas-local-darwin-x64-1.3.0.tgz", - "integrity": "sha512-/ENeKGv9HXtsm4OiFS1tnIxmp6JV9/wWpOQum4MhXR9px9+rfyWhY/BFxXAVSB/i7YvntbP2Z0U91Am9Hw8n9g==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" - } - }, - "node_modules/@mongodb-js/atlas-local-linux-arm64-gnu": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-linux-arm64-gnu/-/atlas-local-linux-arm64-gnu-1.3.0.tgz", - "integrity": "sha512-FsNqduceCFWm6/llp7Y3GlARBGew7nPNWFbNHsWghGeP/jW1J5pc8zdj9NGN+lbX5INdSg8Rz6WVPNDiYTnJyQ==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" + "node": ">=20" } }, - "node_modules/@mongodb-js/atlas-local-linux-x64-gnu": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-linux-x64-gnu/-/atlas-local-linux-x64-gnu-1.3.0.tgz", - "integrity": "sha512-I+gCqMXTC5SG1GLUxhPprWb0MyiIhzsAKxi9/FsrB0XL9qrrDurY2W2PGBIFan5eloo8tti9uIMeZUQ4ov/X5w==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" + "node_modules/@modelcontextprotocol/server/node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" } }, - "node_modules/@mongodb-js/atlas-local-win32-x64-msvc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-win32-x64-msvc/-/atlas-local-win32-x64-msvc-1.3.0.tgz", - "integrity": "sha512-nGHHd3MlhQQixjguuMGwgG5OnMBxHOJY+wqGVDE72vGoY7YBbGwAucqhGU/UMCbppweMqZmykVnTWjmqVW9Yww==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" - } + "node_modules/@mongodb-js/atlas-admin-api": { + "resolved": "packages/atlas-admin-api", + "link": true }, "node_modules/@mongodb-js/atlas-service": { "resolved": "packages/atlas-service", @@ -10502,6 +10004,152 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/@mongodb-js/mcp-atlas-api-client": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-atlas-api-client/-/mcp-atlas-api-client-3.0.5.tgz", + "integrity": "sha512-Dbt5NpG4fdYPnu9LWZKZMPEzILA9ZLjBrfO6Xv1uKDvfD1ETVduQpicm4kIPnQBtHpm7tA2DZ9G2Ov3QxHKOtg==", + "dependencies": { + "@mongodb-js/mcp-core": "3.0.5", + "@mongodb-js/mcp-types": "3.0.5", + "oauth4webapi": "^3.8.5", + "openapi-fetch": "^0.17.0" + } + }, + "node_modules/@mongodb-js/mcp-atlas-telemetry": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-atlas-telemetry/-/mcp-atlas-telemetry-3.0.5.tgz", + "integrity": "sha512-Lsjbn3LNfEcAE5qac+inzW8VbTb0UzJWW/IcSovk9u81/MJJm3xS8loGIUrqEoZBPGwxAFRcvv7begH8nQw6tQ==", + "dependencies": { + "@mongodb-js/mcp-atlas-api-client": "3.0.5", + "@mongodb-js/mcp-core": "3.0.5", + "@mongodb-js/mcp-types": "3.0.5", + "lru-cache": "^11.2.6" + } + }, + "node_modules/@mongodb-js/mcp-atlas-telemetry/node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@mongodb-js/mcp-core": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-core/-/mcp-core-3.0.5.tgz", + "integrity": "sha512-Hg/vnSr4dWj/abpoEhhhDBrWn1HiVYHDrNCjA7LhcZanEg3/qUMGU128EvE9aVZz6561NNqoBUFRdQQm1rHQ7g==", + "license": "Apache-2.0", + "dependencies": { + "@mcp-ui/server": "^6.1.0", + "@modelcontextprotocol/server": "^2.0.0", + "bson": "^7.2.0", + "mongodb-redact": "^1.1.6", + "zod": "^4.4.2" + } + }, + "node_modules/@mongodb-js/mcp-core/node_modules/@mcp-ui/server": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@mcp-ui/server/-/server-6.1.0.tgz", + "integrity": "sha512-uxv9JrzEzHfdGo/V/KTFKp5WeCOsaiAoQZ3V88jw1dSXUofONEw4rMwEvVP3612aj/unS2TIeM0o1I0asfIxtw==", + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/ext-apps": "^0.3.1", + "@modelcontextprotocol/sdk": "^1.25.1" + } + }, + "node_modules/@mongodb-js/mcp-core/node_modules/@modelcontextprotocol/ext-apps": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/ext-apps/-/ext-apps-0.3.1.tgz", + "integrity": "sha512-Iivz2KwWK8xlRbiWwFB/C4NXqE8VJBoRCbBkJCN98ST2UbQvA6kfyebcLsypiqylJS467XOOaBcI9DeQ3t+zqA==", + "hasInstallScript": true, + "license": "MIT", + "workspaces": [ + "examples/*" + ], + "optionalDependencies": { + "@oven/bun-darwin-aarch64": "^1.2.21", + "@oven/bun-darwin-x64": "^1.2.21", + "@oven/bun-darwin-x64-baseline": "^1.2.21", + "@oven/bun-linux-aarch64": "^1.2.21", + "@oven/bun-linux-aarch64-musl": "^1.2.21", + "@oven/bun-linux-x64": "^1.2.21", + "@oven/bun-linux-x64-baseline": "^1.2.21", + "@oven/bun-linux-x64-musl": "^1.2.21", + "@oven/bun-linux-x64-musl-baseline": "^1.2.21", + "@oven/bun-windows-x64": "^1.2.21", + "@oven/bun-windows-x64-baseline": "^1.2.21", + "@rollup/rollup-darwin-arm64": "^4.53.3", + "@rollup/rollup-darwin-x64": "^4.53.3", + "@rollup/rollup-linux-arm64-gnu": "^4.53.3", + "@rollup/rollup-linux-x64-gnu": "^4.53.3", + "@rollup/rollup-win32-arm64-msvc": "^4.53.3", + "@rollup/rollup-win32-x64-msvc": "^4.53.3" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": "^1.24.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/@mongodb-js/mcp-core/node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/@mongodb-js/mcp-tools-mongodb": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-tools-mongodb/-/mcp-tools-mongodb-3.0.5.tgz", + "integrity": "sha512-syZkiRZvtLiYsIh0ybKX4eTIw7i3QxWT0b93P0Ud6oj6t0Ig/X4oAtwHqi60KOP5fAM5HOpxAnAL9YRj4WjJ0Q==", + "dependencies": { + "@mongodb-js/device-id": "^0.4.18", + "@mongodb-js/mcp-atlas-telemetry": "3.0.5", + "@mongodb-js/mcp-core": "3.0.5", + "@mongodb-js/mcp-types": "3.0.5", + "@mongosh/arg-parser": "^5.0.2", + "@mongosh/service-provider-node-driver": "^5.0.2", + "bson": "^7.2.0", + "hadron-document": "^8.11.5", + "mongodb": "^7.1.1", + "mongodb-build-info": "^1.9.7", + "mongodb-connection-string-url": "^7.0.1", + "mongodb-schema": "^12.7.0", + "node-machine-id": "1.1.12", + "zod": "^4.4.2" + } + }, + "node_modules/@mongodb-js/mcp-tools-mongodb/node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/@mongodb-js/mcp-types": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-types/-/mcp-types-3.0.5.tgz", + "integrity": "sha512-BWna6eo0bOZqdRWWjA+NfhxqWgsOicFcWL+HWLmLzVPLNJeoJiKU1LTkRxv7zUUbevdY2So00BDKdIVqBKo2vw==", + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/server": "^2.0.0", + "mongodb-redact": "^1.4.6" + } + }, "node_modules/@mongodb-js/mdb-experiment-js": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@mongodb-js/mdb-experiment-js/-/mdb-experiment-js-1.9.0.tgz", @@ -15936,6 +15584,19 @@ "linux" ] }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.64.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.64.6.tgz", + "integrity": "sha512-KlfpmF1AAIdAWxt8QQNClbpLFlAUfYOzqIuJ7IXEStMHpFRuH78RG6FjqPb3Rqhh0K89F5npvG+/i3Fjl6IveQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rollup/rollup-win32-x64-msvc": { "version": "4.55.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz", @@ -18085,13 +17746,6 @@ "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==" }, - "node_modules/@types/http-errors": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", - "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", - "license": "MIT", - "peer": true - }, "node_modules/@types/http-proxy": { "version": "1.17.9", "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.9.tgz", @@ -18462,16 +18116,6 @@ "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", "dev": true }, - "node_modules/@types/send": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", - "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/@types/serve-index/-/serve-index-1.9.1.tgz", @@ -21665,12 +21309,6 @@ "file-uri-to-path": "1.0.0" } }, - "node_modules/bintrees": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.2.tgz", - "integrity": "sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==", - "license": "MIT" - }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -22728,6 +22366,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-2.2.0.tgz", "integrity": "sha512-rddelWYNPRrXq6PtNEN2S3f6t9ILzvqaN5pVgi4kqt9jHQaXIial9PznB5iSPVlQSLNaaH22ItWz3EJtQ10+OA==", + "dev": true, "license": "MIT" }, "node_modules/check-error": { @@ -28007,21 +27646,6 @@ "resolved": "https://registry.npmjs.org/fast-memoize/-/fast-memoize-2.5.2.tgz", "integrity": "sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw==" }, - "node_modules/fast-string-truncated-width": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz", - "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==", - "license": "MIT" - }, - "node_modules/fast-string-width": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz", - "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", - "license": "MIT", - "dependencies": { - "fast-string-truncated-width": "^3.0.2" - } - }, "node_modules/fast-uri": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz", @@ -28038,15 +27662,6 @@ ], "license": "BSD-3-Clause" }, - "node_modules/fast-wrap-ansi": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/fast-wrap-ansi/-/fast-wrap-ansi-0.2.0.tgz", - "integrity": "sha512-rLV8JHxTyhVmFYhBJuMujcrHqOT2cnO5Zxj37qROj23CP39GXubJRBUFF0z8KFK77Uc0SukZUf7JZhsVEQ6n8w==", - "license": "MIT", - "dependencies": { - "fast-string-width": "^3.0.2" - } - }, "node_modules/fast-xml-builder": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", @@ -44296,19 +43911,6 @@ "node": ">=0.4.0" } }, - "node_modules/prom-client": { - "version": "15.1.3", - "resolved": "https://registry.npmjs.org/prom-client/-/prom-client-15.1.3.tgz", - "integrity": "sha512-6ZiOBfCywsD4k1BN9IX0uZhF+tJkV8q8llP64G5Hajs4JOeVLPCwpPVcpXy3BwYiUGgyJzsJJQeOIv7+hDSq8g==", - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/api": "^1.4.0", - "tdigest": "^0.1.1" - }, - "engines": { - "node": "^16 || ^18 || >=20" - } - }, "node_modules/promise-all-reject-late": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz", @@ -48232,15 +47834,6 @@ "node": ">=8" } }, - "node_modules/tdigest": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.2.tgz", - "integrity": "sha512-+G0LLgjjo9BZX2MfdvPfH+MKLCrxlXSYec5DaPYP1fe6Iyhf0/fSmJ0bFiZ1F8BT6cGXl2LpltQptzjXKWEkKA==", - "license": "MIT", - "dependencies": { - "bintrees": "1.0.2" - } - }, "node_modules/temp": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", @@ -48750,12 +48343,6 @@ "typescript": ">=4.8.4" } }, - "node_modules/ts-levenshtein": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/ts-levenshtein/-/ts-levenshtein-1.0.7.tgz", - "integrity": "sha512-wautEf7gl2ITJuRTTYxnlrLjzUUcwFSdg46bcu4RlzoE/zQM++TJjBFRf2Xhil49GiHqKCqmpjf1lBkWnAHj0A==", - "license": "MIT" - }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -54473,6 +54060,9 @@ "@mongodb-js/compass-logging": "^1.18.2", "@mongodb-js/compass-telemetry": "^1.35.1", "@mongodb-js/compass-utils": "^0.10.6", + "@mongodb-js/mcp-core": "^3.0.5", + "@mongodb-js/mcp-tools-mongodb": "^3.0.5", + "@mongodb-js/mcp-types": "^3.0.5", "@mongodb-js/mongodb-schema": "^12.7.2", "@mongodb-js/shell-bson-parser": "^1.6.3", "@mongosh/service-provider-core": "^5.2.0", @@ -54484,7 +54074,6 @@ "mongodb": "^7.5.0", "mongodb-build-info": "^1.8.1", "mongodb-connection-string-url": "^7.0.2", - "mongodb-mcp-server": "^1.10.0", "react": "^18.3.1", "react-redux": "^8.1.3", "redux": "^4.2.1", @@ -54518,131 +54107,6 @@ "xvfb-maybe": "^0.2.1" } }, - "packages/compass-generative-ai/node_modules/@types/express": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", - "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", - "license": "MIT", - "peer": true, - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^5.0.0", - "@types/serve-static": "^2" - } - }, - "packages/compass-generative-ai/node_modules/@types/express-serve-static-core": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.1.1.tgz", - "integrity": "sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A==", - "license": "MIT", - "peer": true, - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*", - "@types/send": "*" - } - }, - "packages/compass-generative-ai/node_modules/@types/serve-static": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz", - "integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "@types/http-errors": "*", - "@types/node": "*" - } - }, - "packages/compass-generative-ai/node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "packages/compass-generative-ai/node_modules/body-parser": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", - "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^1.0.5", - "debug": "^4.4.3", - "http-errors": "^2.0.0", - "iconv-lite": "^0.7.0", - "on-finished": "^2.4.1", - "qs": "^6.14.1", - "raw-body": "^3.0.1", - "type-is": "^2.0.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-generative-ai/node_modules/chalk": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", - "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "packages/compass-generative-ai/node_modules/content-disposition": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", - "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-generative-ai/node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "packages/compass-generative-ai/node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "packages/compass-generative-ai/node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "packages/compass-generative-ai/node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -54652,110 +54116,12 @@ "node": ">=0.3.1" } }, - "packages/compass-generative-ai/node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "packages/compass-generative-ai/node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", "dev": true }, - "packages/compass-generative-ai/node_modules/express": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", - "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.2.1", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "depd": "^2.0.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.0.1", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-generative-ai/node_modules/finalhandler": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", - "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-generative-ai/node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-generative-ai/node_modules/iconv-lite": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", - "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "packages/compass-generative-ai/node_modules/ipaddr.js": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.5.0.tgz", @@ -54765,67 +54131,6 @@ "node": ">= 10" } }, - "packages/compass-generative-ai/node_modules/jsonc-parser": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", - "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", - "license": "MIT" - }, - "packages/compass-generative-ai/node_modules/lru-cache": { - "version": "11.3.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.3.5.tgz", - "integrity": "sha512-NxVFwLAnrd9i7KUBxC4DrUhmgjzOs+1Qm50D3oF1/oL+r1NpZ4gA7xvG0/zJ8evR7zIKn4vLf7qTNduWFtCrRw==", - "license": "BlueOak-1.0.0", - "engines": { - "node": "20 || >=22" - } - }, - "packages/compass-generative-ai/node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-generative-ai/node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "packages/compass-generative-ai/node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "packages/compass-generative-ai/node_modules/mime-types": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", - "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "packages/compass-generative-ai/node_modules/mongodb-connection-string-url": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.2.tgz", @@ -54839,90 +54144,6 @@ "node": ">=20.19.0" } }, - "packages/compass-generative-ai/node_modules/mongodb-mcp-server": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/mongodb-mcp-server/-/mongodb-mcp-server-1.10.0.tgz", - "integrity": "sha512-ai4605IiaA6BMiVY2danIthgfZaQkyiRW9tNW+866iPcWtZfGHKxhiQoDw1lUDGa28wUoZf616ug8ChlW5e8Tg==", - "license": "Apache-2.0", - "dependencies": { - "@inquirer/prompts": "^8.0.2", - "@inquirer/select": "^5.1.3", - "@mcp-ui/server": "^5.13.1", - "@modelcontextprotocol/sdk": "^1.29.0", - "@mongodb-js/device-id": "^0.4.6", - "@mongodb-js/devtools-proxy-support": "^0.7.8", - "@mongosh/arg-parser": "^5.0.2", - "@mongosh/service-provider-node-driver": "^5.0.2", - "bson": "^7.2.0", - "chalk": "^5.6.2", - "express": "^5.2.1", - "jsonc-parser": "^3.3.1", - "lru-cache": "^11.2.6", - "mongodb-build-info": "^1.9.7", - "mongodb-connection-string-url": "^7.0.1", - "mongodb-log-writer": "^2.5.7", - "mongodb-redact": "^1.4.6", - "mongodb-schema": "^12.7.0", - "node-fetch": "^3.3.2", - "node-machine-id": "1.1.12", - "oauth4webapi": "^3.8.5", - "openapi-fetch": "^0.17.0", - "prom-client": "^15.1.3", - "semver": "^7.7.2", - "ts-levenshtein": "^1.0.7", - "yaml": "^2.8.1", - "zod": "^4.0.0" - }, - "bin": { - "mongodb-mcp-server": "dist/esm/index.js" - }, - "engines": { - "node": "^20.19.0 || ^22.12.0 || >= 24.0.0" - }, - "optionalDependencies": { - "@mongodb-js/atlas-local": "^1.3.0", - "kerberos": "^7.0.0" - }, - "peerDependencies": { - "@types/express": "^5.0.3" - } - }, - "packages/compass-generative-ai/node_modules/mongodb-mcp-server/node_modules/zod": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", - "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, - "packages/compass-generative-ai/node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "packages/compass-generative-ai/node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "license": "MIT", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, "packages/compass-generative-ai/node_modules/p-queue": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-7.4.1.tgz", @@ -54951,66 +54172,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/compass-generative-ai/node_modules/raw-body": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", - "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "http-errors": "~2.0.1", - "iconv-lite": "~0.7.0", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.10" - } - }, - "packages/compass-generative-ai/node_modules/send": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", - "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.1", - "mime-types": "^3.0.2", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-generative-ai/node_modules/serve-static": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", - "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "packages/compass-generative-ai/node_modules/sinon": { "version": "9.2.4", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", @@ -55029,29 +54190,6 @@ "url": "https://opencollective.com/sinon" } }, - "packages/compass-generative-ai/node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-generative-ai/node_modules/type-is": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", - "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", - "license": "MIT", - "dependencies": { - "content-type": "^1.0.5", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "packages/compass-generative-ai/node_modules/whatwg-url": { "version": "14.2.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", @@ -55065,21 +54203,6 @@ "node": ">=18" } }, - "packages/compass-generative-ai/node_modules/yaml": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", - "integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==", - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - }, - "funding": { - "url": "https://github.com/sponsors/eemeli" - } - }, "packages/compass-global-writes": { "name": "@mongodb-js/compass-global-writes", "version": "2.6.0", @@ -56636,7 +55759,6 @@ "mongodb": "^7.5.0", "mongodb-data-service": "^22.41.3", "mongodb-log-writer": "^2.4.4", - "mongodb-mcp-server": "^1.10.0", "mongodb-ns": "^3.2.0", "nyc": "^15.1.0", "os-browserify": "^0.3.0", @@ -56693,84 +55815,6 @@ "type-detect": "4.0.8" } }, - "packages/compass-web/node_modules/@types/express": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", - "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^5.0.0", - "@types/serve-static": "^2" - } - }, - "packages/compass-web/node_modules/@types/express-serve-static-core": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.1.1.tgz", - "integrity": "sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*", - "@types/send": "*" - } - }, - "packages/compass-web/node_modules/@types/serve-static": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz", - "integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@types/http-errors": "*", - "@types/node": "*" - } - }, - "packages/compass-web/node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "dev": true, - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "packages/compass-web/node_modules/body-parser": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", - "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", - "dev": true, - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^1.0.5", - "debug": "^4.4.3", - "http-errors": "^2.0.0", - "iconv-lite": "^0.7.0", - "on-finished": "^2.4.1", - "qs": "^6.14.1", - "raw-body": "^3.0.1", - "type-is": "^2.0.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "packages/compass-web/node_modules/buffer": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", @@ -56795,73 +55839,6 @@ "ieee754": "^1.2.1" } }, - "packages/compass-web/node_modules/chalk": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", - "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "packages/compass-web/node_modules/content-disposition": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", - "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-web/node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "packages/compass-web/node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "packages/compass-web/node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-web/node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "packages/compass-web/node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -56871,225 +55848,6 @@ "node": ">=0.8.x" } }, - "packages/compass-web/node_modules/express": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", - "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.2.1", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "depd": "^2.0.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.0.1", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-web/node_modules/finalhandler": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", - "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-web/node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-web/node_modules/iconv-lite": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", - "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", - "dev": true, - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-web/node_modules/jsonc-parser": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", - "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", - "dev": true, - "license": "MIT" - }, - "packages/compass-web/node_modules/lru-cache": { - "version": "11.3.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.3.5.tgz", - "integrity": "sha512-NxVFwLAnrd9i7KUBxC4DrUhmgjzOs+1Qm50D3oF1/oL+r1NpZ4gA7xvG0/zJ8evR7zIKn4vLf7qTNduWFtCrRw==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": "20 || >=22" - } - }, - "packages/compass-web/node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-web/node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "packages/compass-web/node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "packages/compass-web/node_modules/mime-types": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", - "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-web/node_modules/mongodb-mcp-server": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/mongodb-mcp-server/-/mongodb-mcp-server-1.10.0.tgz", - "integrity": "sha512-ai4605IiaA6BMiVY2danIthgfZaQkyiRW9tNW+866iPcWtZfGHKxhiQoDw1lUDGa28wUoZf616ug8ChlW5e8Tg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@inquirer/prompts": "^8.0.2", - "@inquirer/select": "^5.1.3", - "@mcp-ui/server": "^5.13.1", - "@modelcontextprotocol/sdk": "^1.29.0", - "@mongodb-js/device-id": "^0.4.6", - "@mongodb-js/devtools-proxy-support": "^0.7.8", - "@mongosh/arg-parser": "^5.0.2", - "@mongosh/service-provider-node-driver": "^5.0.2", - "bson": "^7.2.0", - "chalk": "^5.6.2", - "express": "^5.2.1", - "jsonc-parser": "^3.3.1", - "lru-cache": "^11.2.6", - "mongodb-build-info": "^1.9.7", - "mongodb-connection-string-url": "^7.0.1", - "mongodb-log-writer": "^2.5.7", - "mongodb-redact": "^1.4.6", - "mongodb-schema": "^12.7.0", - "node-fetch": "^3.3.2", - "node-machine-id": "1.1.12", - "oauth4webapi": "^3.8.5", - "openapi-fetch": "^0.17.0", - "prom-client": "^15.1.3", - "semver": "^7.7.2", - "ts-levenshtein": "^1.0.7", - "yaml": "^2.8.1", - "zod": "^4.0.0" - }, - "bin": { - "mongodb-mcp-server": "dist/esm/index.js" - }, - "engines": { - "node": "^20.19.0 || ^22.12.0 || >= 24.0.0" - }, - "optionalDependencies": { - "@mongodb-js/atlas-local": "^1.3.0", - "kerberos": "^7.0.0" - }, - "peerDependencies": { - "@types/express": "^5.0.3" - } - }, - "packages/compass-web/node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, "packages/compass-web/node_modules/nise": { "version": "5.1.5", "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.5.tgz", @@ -57130,41 +55888,6 @@ "type-detect": "4.0.8" } }, - "packages/compass-web/node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "dev": true, - "license": "MIT", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, - "packages/compass-web/node_modules/raw-body": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", - "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", - "dev": true, - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "http-errors": "~2.0.1", - "iconv-lite": "~0.7.0", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.10" - } - }, "packages/compass-web/node_modules/readable-stream": { "version": "4.5.1", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.1.tgz", @@ -57181,53 +55904,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "packages/compass-web/node_modules/send": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", - "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.1", - "mime-types": "^3.0.2", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "packages/compass-web/node_modules/serve-static": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", - "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", - "dev": true, - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "packages/compass-web/node_modules/sinon": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", @@ -57246,31 +55922,6 @@ "url": "https://opencollective.com/sinon" } }, - "packages/compass-web/node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "packages/compass-web/node_modules/type-is": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", - "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", - "dev": true, - "license": "MIT", - "dependencies": { - "content-type": "^1.0.5", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "packages/compass-web/node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", @@ -57284,32 +55935,6 @@ "which-typed-array": "^1.1.2" } }, - "packages/compass-web/node_modules/yaml": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", - "integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==", - "dev": true, - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - }, - "funding": { - "url": "https://github.com/sponsors/eemeli" - } - }, - "packages/compass-web/node_modules/zod": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", - "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "packages/compass-welcome": { "name": "@mongodb-js/compass-welcome", "version": "1.6.0", diff --git a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx index 61d86b5bd51..bfc7d9fd40a 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx @@ -684,7 +684,6 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ - enableMCPTelemetry: true, maxTimeMS: undefined, connections: [], query, @@ -751,7 +750,6 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ - enableMCPTelemetry: true, maxTimeMS: undefined, connections: [], query, @@ -826,7 +824,6 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ - enableMCPTelemetry: true, maxTimeMS: undefined, connections: [], query, @@ -912,7 +909,6 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ - enableMCPTelemetry: true, maxTimeMS: undefined, connections: [ { @@ -971,7 +967,6 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ - enableMCPTelemetry: true, maxTimeMS: 5000, connections: [], query: undefined, diff --git a/packages/compass-assistant/src/compass-assistant-provider.tsx b/packages/compass-assistant/src/compass-assistant-provider.tsx index fab3302dc40..ecb38784751 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.tsx @@ -485,7 +485,6 @@ export function ensureOptInAndSendThunk( ? activeCollectionSubTab || activeWorkspace.type : null; setToolsContext(toolsController, { - enableMCPTelemetry: prefs.trackUsageStatistics, maxTimeMS: prefs.maxTimeMS, activeConnection, connections: activeConnections, @@ -1010,7 +1009,6 @@ export function createDefaultChat({ export function setToolsContext( toolsController: ToolsController, { - enableMCPTelemetry, maxTimeMS, activeConnection, connections, @@ -1020,7 +1018,6 @@ export function setToolsContext( enableGenAIToolCalling, activeTab, }: { - enableMCPTelemetry: boolean; maxTimeMS?: number; activeConnection: ActiveConnectionInfo | null; connections: ActiveConnectionInfo[]; @@ -1046,7 +1043,6 @@ export function setToolsContext( } toolsController.setActiveTools(toolGroups); toolsController.setContext({ - enableMCPTelemetry, maxTimeMS, connections: connections.map((connection) => { if (!connection.connectOptions) { @@ -1066,7 +1062,6 @@ export function setToolsContext( } else { toolsController.setActiveTools(new Set([])); toolsController.setContext({ - enableMCPTelemetry, maxTimeMS, connections: [], query: undefined, diff --git a/packages/compass-assistant/test/tool-calls.eval.ts b/packages/compass-assistant/test/tool-calls.eval.ts index 3100cef3ed0..9f25ba0be75 100644 --- a/packages/compass-assistant/test/tool-calls.eval.ts +++ b/packages/compass-assistant/test/tool-calls.eval.ts @@ -68,7 +68,6 @@ const toolsController = new ToolsController({ logger, getTelemetryAnonymousId: () => 'eval-anonymous-id', track: createNoopTrack(), - enableMCPTelemetry: false, preferences: defaultPreferencesInstance, atlasAdminApi: {} as AtlasAdminApiService, }); @@ -110,7 +109,6 @@ function getToolsForCase({ toolsController.setActiveTools(toolGroups); toolsController.setContext({ - enableMCPTelemetry: false, connections: [connectionConfig], query: input.currentQuery ? JSON.stringify(input.currentQuery) : undefined, pipeline: input.currentPipeline diff --git a/packages/compass-generative-ai/package.json b/packages/compass-generative-ai/package.json index 463f615e621..a4e1d36a211 100644 --- a/packages/compass-generative-ai/package.json +++ b/packages/compass-generative-ai/package.json @@ -62,6 +62,9 @@ "@mongodb-js/compass-logging": "^1.18.2", "@mongodb-js/compass-telemetry": "^1.35.1", "@mongodb-js/compass-utils": "^0.10.6", + "@mongodb-js/mcp-core": "^3.0.5", + "@mongodb-js/mcp-tools-mongodb": "^3.0.5", + "@mongodb-js/mcp-types": "^3.0.5", "@mongodb-js/mongodb-schema": "^12.7.2", "@mongodb-js/shell-bson-parser": "^1.6.3", "@mongosh/service-provider-core": "^5.2.0", @@ -73,7 +76,6 @@ "mongodb": "^7.5.0", "mongodb-build-info": "^1.8.1", "mongodb-connection-string-url": "^7.0.2", - "mongodb-mcp-server": "^1.10.0", "react": "^18.3.1", "react-redux": "^8.1.3", "redux": "^4.2.1", diff --git a/packages/compass-generative-ai/src/provider.tsx b/packages/compass-generative-ai/src/provider.tsx index cabaea9145c..91da9624ec3 100644 --- a/packages/compass-generative-ai/src/provider.tsx +++ b/packages/compass-generative-ai/src/provider.tsx @@ -74,8 +74,6 @@ export const ToolsControllerProvider: React.FC<{ logger, getTelemetryAnonymousId: () => telemetryAnonymousId ?? '', track, - // we will set this later through setContext() - enableMCPTelemetry: false, preferences, atlasAdminApi, }); diff --git a/packages/compass-generative-ai/src/tools-connection-error-handler.ts b/packages/compass-generative-ai/src/tools-connection-error-handler.ts index fbfb74dcb99..aa95f85828f 100644 --- a/packages/compass-generative-ai/src/tools-connection-error-handler.ts +++ b/packages/compass-generative-ai/src/tools-connection-error-handler.ts @@ -1,7 +1,7 @@ import type { ConnectionErrorUnhandled, ConnectionErrorHandler, -} from 'mongodb-mcp-server'; +} from '@mongodb-js/mcp-tools-mongodb'; /** * Creates a connection error handler for mongodb-mcp-server in Compass. diff --git a/packages/compass-generative-ai/src/tools-connection-manager.spec.ts b/packages/compass-generative-ai/src/tools-connection-manager.spec.ts index 36656cd2d29..461434fe16a 100644 --- a/packages/compass-generative-ai/src/tools-connection-manager.spec.ts +++ b/packages/compass-generative-ai/src/tools-connection-manager.spec.ts @@ -3,8 +3,9 @@ import { expect } from 'chai'; import { ToolsConnectionManager } from './tools-connection-manager'; import type { ToolsConnectParams } from './tools-connection-manager'; import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; -import { ConnectionStateConnected } from 'mongodb-mcp-server'; -import type { LoggerBase } from 'mongodb-mcp-server'; +import { ConnectionStateConnected } from '@mongodb-js/mcp-tools-mongodb'; +import type { LoggerBase } from '@mongodb-js/mcp-core'; +import { MongoServerError } from 'mongodb'; import { mongoLogId } from '@mongodb-js/compass-logging/provider'; describe('ToolsConnectionManager', function () { @@ -233,11 +234,19 @@ describe('ToolsConnectionManager', function () { }); describe('isSearchSupported on ConnectionStateConnected', function () { + const createSearchProbeProvider = ( + getSearchIndexes: sinon.SinonStub + ) => ({ + close: sandbox.stub().resolves(), + initialDb: 'test', + listDatabases: sandbox.stub().resolves({ databases: [] }), + getSearchIndexes, + }); + it('returns true when getSearchIndexes resolves', async function () { - const mockProvider = { - close: sandbox.stub().resolves(), - getSearchIndexes: sandbox.stub().resolves([]), - }; + const mockProvider = createSearchProbeProvider( + sandbox.stub().resolves([]) + ); connectStub.resolves(mockProvider as any); await connectionManager.connectToCompassConnection( @@ -248,17 +257,19 @@ describe('ToolsConnectionManager', function () { expect(state).to.be.instanceOf(ConnectionStateConnected); const result = await ( state as ConnectionStateConnected - ).isSearchSupported(); + ).isSearchSupported(logger); expect(result).to.be.true; }); - it('returns false when getSearchIndexes rejects', async function () { - const mockProvider = { - close: sandbox.stub().resolves(), - getSearchIndexes: sandbox - .stub() - .rejects(new Error('search not available')), - }; + it('returns false when the cluster reports search as not enabled', async function () { + const mockProvider = createSearchProbeProvider( + sandbox.stub().rejects( + new MongoServerError({ + message: 'search not enabled', + code: 31082, + }) + ) + ); connectStub.resolves(mockProvider as any); await connectionManager.connectToCompassConnection( @@ -269,15 +280,32 @@ describe('ToolsConnectionManager', function () { expect(state).to.be.instanceOf(ConnectionStateConnected); const result = await ( state as ConnectionStateConnected - ).isSearchSupported(); + ).isSearchSupported(logger); expect(result).to.be.false; }); + it('returns true when the probe fails inconclusively', async function () { + const mockProvider = createSearchProbeProvider( + sandbox.stub().rejects(new Error('search not available')) + ); + connectStub.resolves(mockProvider as any); + + await connectionManager.connectToCompassConnection( + mockConnectionParams + ); + + const state = connectionManager.currentConnectionState; + expect(state).to.be.instanceOf(ConnectionStateConnected); + const result = await ( + state as ConnectionStateConnected + ).isSearchSupported(logger); + expect(result).to.be.true; + }); + it('caches the result and only calls getSearchIndexes once', async function () { - const mockProvider = { - close: sandbox.stub().resolves(), - getSearchIndexes: sandbox.stub().resolves([]), - }; + const mockProvider = createSearchProbeProvider( + sandbox.stub().resolves([]) + ); connectStub.resolves(mockProvider as any); await connectionManager.connectToCompassConnection( @@ -286,8 +314,8 @@ describe('ToolsConnectionManager', function () { const state = connectionManager.currentConnectionState as ConnectionStateConnected; - await state.isSearchSupported(); - await state.isSearchSupported(); + await state.isSearchSupported(logger); + await state.isSearchSupported(logger); expect(mockProvider.getSearchIndexes.callCount).to.equal(1); }); diff --git a/packages/compass-generative-ai/src/tools-connection-manager.ts b/packages/compass-generative-ai/src/tools-connection-manager.ts index 6719b8a1ded..66092ecb708 100644 --- a/packages/compass-generative-ai/src/tools-connection-manager.ts +++ b/packages/compass-generative-ai/src/tools-connection-manager.ts @@ -1,9 +1,14 @@ import { ConnectionManager, + ConnectionEntry, ConnectionStateConnected, + ErrorCodes, + MongoDBError, + type ConnectionRegistry, + type ConnectionSettings, type ConnectionStateDisconnected, - type LoggerBase, -} from 'mongodb-mcp-server'; +} from '@mongodb-js/mcp-tools-mongodb'; +import type { Keychain, LoggerBase } from '@mongodb-js/mcp-core'; import { NodeDriverServiceProvider, type DevtoolsConnectOptions, @@ -22,6 +27,13 @@ export interface ToolsConnectParams { export const DATABASE_TOOLS_TELEMETRY_APP_NAME = 'Database Tools'; const DEFAULT_TELEMETRY_APP_NAME = 'MongoDB Compass'; +/** + * The single connection handle Compass Database Tools expose to the MCP tools. + * Compass drives the connection itself (see {@link ToolsConnectionManager}), so + * the tools only ever need one opaque id to address it by. + */ +export const COMPASS_CONNECTION_ID = 'compass'; + type ToolsConnectionManagerConfig = { logger: LoggerBase; getTelemetryAnonymousId: () => string; @@ -44,7 +56,7 @@ export class ToolsConnectionManager extends ConnectionManager { this.getTelemetryAnonymousId = getTelemetryAnonymousId; } - override connect(): Promise { + override connect(_settings?: ConnectionSettings): Promise { // It shouldn't be possible for a user to get here because the connect tool // is not included. We also only include the database tools when there is a // relevant connection. @@ -125,7 +137,7 @@ To connect, choose a connection from Compass's connection sidebar - https://www. }; return void this.changeState( 'connection-success', - new ConnectionStateConnected(serviceProvider) + new ConnectionStateConnected({ serviceProvider }) ); } catch (error) { this.logger.error({ @@ -179,3 +191,88 @@ To connect, choose a connection from Compass's connection sidebar - https://www. }; } } + +/** + * A {@link ConnectionRegistry} view over the single Compass connection. + * + * mongodb-mcp-server v3 resolves every MongoDB tool call through a connection + * registry keyed by an opaque `connectionId`, but Compass owns its connection + * lifecycle (the user's sidebar connection) and only ever has one live at a + * time. This adapter exposes that connection under + * {@link COMPASS_CONNECTION_ID} so the tools can resolve it without Compass + * having to run the library's connection store. + */ +export class ToolsConnectionRegistry implements ConnectionRegistry { + private readonly entry: ConnectionEntry; + + constructor(connectionManager: ToolsConnectionManager, keychain: Keychain) { + this.entry = new ConnectionEntry({ + connectionId: COMPASS_CONNECTION_ID, + name: COMPASS_CONNECTION_ID, + source: 'explicit', + manager: connectionManager, + keychain, + }); + } + + createEntry(): Promise { + return Promise.reject( + new Error( + 'Database Tools in MongoDB Compass manage connections through the Compass connection sidebar' + ) + ); + } + + connect(): Promise { + return Promise.reject( + new Error( + 'Database Tools in MongoDB Compass manage connections through the Compass connection sidebar' + ) + ); + } + + get(connectionId: string): Promise { + return Promise.resolve( + connectionId === COMPASS_CONNECTION_ID ? this.entry : undefined + ); + } + + peek(connectionId: string): Promise { + return this.get(connectionId); + } + + find( + predicate?: (entry: ConnectionEntry) => boolean + ): Promise { + return Promise.resolve( + predicate === undefined || predicate(this.entry) ? [this.entry] : [] + ); + } + + async resolve(connectionId: string): Promise { + const entry = await this.get(connectionId); + if (!entry) { + throw new MongoDBError( + ErrorCodes.UnknownConnectionId, + `Connection "${connectionId}" does not exist or has expired.` + ); + } + return entry.getServiceProvider(); + } + + async disconnect(connectionId: string): Promise { + const entry = await this.get(connectionId); + if (!entry) { + throw new MongoDBError( + ErrorCodes.UnknownConnectionId, + `Connection "${connectionId}" does not exist or has expired.` + ); + } + await entry.close(); + } + + close(): Promise { + // The connection is owned by Compass, not by this registry. + return Promise.resolve(); + } +} diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 7edff1ac4f8..dff81002bbb 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -12,6 +12,7 @@ import { type PreferencesAccess, } from 'compass-preferences-model'; import type { AtlasAdminApiService } from '@mongodb-js/atlas-admin-api/provider'; +import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; describe('ToolsController', function () { let sandbox: sinon.SinonSandbox; @@ -31,7 +32,6 @@ describe('ToolsController', function () { atlasAdminApi = {} as AtlasAdminApiService; toolsController = new ToolsController({ - enableMCPTelemetry: false, logger, getTelemetryAnonymousId, track: createNoopTrack(), @@ -152,7 +152,6 @@ describe('ToolsController', function () { it('get-current-query returns context query', async function () { const testQuery = '{ name: "test" }'; toolsController.setContext({ - enableMCPTelemetry: false, query: testQuery, connections: [], }); @@ -168,7 +167,6 @@ describe('ToolsController', function () { it('get-current-query returns undefined when no query in context', async function () { toolsController.setContext({ - enableMCPTelemetry: false, connections: [], }); @@ -207,7 +205,6 @@ describe('ToolsController', function () { it('get-current-pipeline returns context pipeline', async function () { const testPipeline = '[{ $match: { status: "active" } }]'; toolsController.setContext({ - enableMCPTelemetry: false, pipeline: testPipeline, connections: [], }); @@ -223,7 +220,6 @@ describe('ToolsController', function () { it('get-current-pipeline returns undefined when no pipeline in context', async function () { toolsController.setContext({ - enableMCPTelemetry: false, connections: [], }); @@ -245,7 +241,6 @@ describe('ToolsController', function () { it('ignores db tools if the server is not started', function () { const newController = new ToolsController({ - enableMCPTelemetry: false, logger, getTelemetryAnonymousId, track: createNoopTrack(), @@ -284,13 +279,6 @@ describe('ToolsController', function () { expect(toolsController.server).to.not.be.undefined; expect(toolsController.server?.tools).to.not.be.undefined; - if ( - toolsController.server && - toolsController.server.tools.length === 0 - ) { - toolsController.server.registerTools(); - } - const serverTools = toolsController.server?.tools ?? []; const serverToolNames = serverTools.map((tool) => tool.name); @@ -363,7 +351,6 @@ describe('ToolsController', function () { it('sets context with query', async function () { const query = '{ status: "active" }'; toolsController.setContext({ - enableMCPTelemetry: false, query, connections: [], }); @@ -378,7 +365,6 @@ describe('ToolsController', function () { it('sets context with pipeline', async function () { const pipeline = '[{ $match: { age: { $gte: 18 } } }]'; toolsController.setContext({ - enableMCPTelemetry: false, pipeline, connections: [], }); @@ -403,14 +389,12 @@ describe('ToolsController', function () { ]; toolsController.setContext({ - enableMCPTelemetry: false, connections, }); // Context is set internally, verify through tool execution expect(() => toolsController.setContext({ - enableMCPTelemetry: false, connections, }) ).to.not.throw(); @@ -418,13 +402,11 @@ describe('ToolsController', function () { it('updates existing context', async function () { toolsController.setContext({ - enableMCPTelemetry: false, query: 'old query', connections: [], }); toolsController.setContext({ - enableMCPTelemetry: false, query: 'new query', connections: [], }); @@ -436,42 +418,31 @@ describe('ToolsController', function () { expect(result.query).to.equal('new query'); }); - it('syncs telemetry setting with runner userConfig', function () { + it('syncs maxTimeMS setting with the tools config', async function () { + await toolsController.startServer(); + toolsController.setContext({ - enableMCPTelemetry: true, + maxTimeMS: 5000, connections: [], }); - expect((toolsController as any).runner.userConfig.telemetry).to.equal( - 'enabled' - ); + expect(toolsController.server?.config.maxTimeMS).to.equal(5000); toolsController.setContext({ - enableMCPTelemetry: false, + maxTimeMS: undefined, connections: [], }); - expect((toolsController as any).runner.userConfig.telemetry).to.equal( - 'disabled' - ); + expect(toolsController.server?.config.maxTimeMS).to.equal(undefined); }); - it('syncs maxTimeMS setting with runner userConfig', function () { + it('applies maxTimeMS set before the server starts', async function () { toolsController.setContext({ - enableMCPTelemetry: false, maxTimeMS: 5000, connections: [], }); - expect((toolsController as any).runner.userConfig.maxTimeMS).to.equal( - 5000 - ); - toolsController.setContext({ - enableMCPTelemetry: false, - maxTimeMS: undefined, - connections: [], - }); - expect((toolsController as any).runner.userConfig.maxTimeMS).to.equal( - undefined - ); + await toolsController.startServer(); + + expect(toolsController.server?.config.maxTimeMS).to.equal(5000); }); }); @@ -547,7 +518,6 @@ describe('ToolsController', function () { it('handles errors during server startup gracefully', async function () { const errorController = new ToolsController({ - enableMCPTelemetry: false, logger, getTelemetryAnonymousId: () => { throw new Error('Telemetry error'); @@ -653,7 +623,6 @@ describe('ToolsController', function () { it('context persists across tool group changes', async function () { const query = '{ test: 1 }'; toolsController.setContext({ - enableMCPTelemetry: false, query, connections: [], }); @@ -669,6 +638,66 @@ describe('ToolsController', function () { }); }); + describe('db-read tool execution', function () { + beforeEach(async function () { + sandbox.stub(NodeDriverServiceProvider, 'connect').resolves({ + close: sandbox.stub().resolves(), + initialDb: 'test', + listDatabases: sandbox.stub().resolves({ + databases: [{ name: 'admin', sizeOnDisk: 1024 }], + }), + } as any); + + await toolsController.startServer(); + toolsController.setActiveTools(new Set(['db-read'])); + toolsController.setConnectionIdForToolCall({ + toolCallId: 'call-1', + connectionId: 'conn-1', + }); + toolsController.setContext({ + connections: [ + { + connectionId: 'conn-1', + connectionString: 'mongodb://localhost:27017', + connectOptions: {} as any, + }, + ], + }); + }); + + it('invokes the MCP tool against the Compass connection', async function () { + const tools = toolsController.getActiveTools(); + const result: any = await tools['list-databases'].execute?.({}, { + toolCallId: 'call-1', + } as any); + + expect(result.isError).to.not.equal(true); + expect(JSON.stringify(result.content)).to.include('admin'); + }); + + it('does not expose the connection handle to the model', function () { + const tools = toolsController.getActiveTools(); + const shape = (tools['list-databases'] as any).inputSchema.shape; + + expect(shape).to.not.have.property('connectionId'); + }); + + it('exposes schemas the model arguments can be validated against', function () { + const tools = toolsController.getActiveTools(); + const schema = (tools['find'] as any).inputSchema; + + expect( + schema.safeParse({ + database: 'db', + collection: 'coll', + filter: { status: 'active' }, + limit: 5, + }).success + ).to.equal(true); + expect(schema.safeParse({ database: 'db' }).success).to.equal(false); + }); + }); + describe('error handling in db-read tools', function () { beforeEach(async function () { await toolsController.startServer(); @@ -696,7 +725,6 @@ describe('ToolsController', function () { }); toolsController.setContext({ - enableMCPTelemetry: false, connections: [], }); diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index bbedc251b2f..2447649d020 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -3,20 +3,31 @@ import type { ToolSet } from 'ai'; import type { Logger } from '@mongodb-js/compass-logging'; import z from 'zod/v4'; import { + CompositeLogger, + Elicitation, Keychain, - TransportRunnerBase, - UserConfigSchema, -} from 'mongodb-mcp-server'; + McpServer, + NoopMetrics, + NoopTelemetry, + type AnyToolBase, +} from '@mongodb-js/mcp-core'; +import { + AGG_COUNT_MAX_TIME_MS_CAP, + MongoDBTools, + QUERY_COUNT_MAX_TIME_MS_CAP, + type MongoDBToolServer, +} from '@mongodb-js/mcp-tools-mongodb'; import type { - DefaultMetrics, - Metrics, - Server, - TransportRunnerConfig, - UserConfig, -} from 'mongodb-mcp-server'; + ServerMetadata, + ToolExecutionContext, +} from '@mongodb-js/mcp-types'; import { createConnectionErrorHandler } from './tools-connection-error-handler'; import { ToolsLogger } from './tools-logger'; -import { ToolsConnectionManager } from './tools-connection-manager'; +import { + COMPASS_CONNECTION_ID, + ToolsConnectionManager, + ToolsConnectionRegistry, +} from './tools-connection-manager'; import type { ToolsConnectParams } from './tools-connection-manager'; import { removeZodTransforms } from './remove-zod-transforms'; import { READ_ONLY_DATABASE_TOOLS } from './available-tools'; @@ -32,7 +43,6 @@ import { export type ToolGroup = 'querybar' | 'aggregation-builder' | 'db-read'; type CompassContext = { - enableMCPTelemetry: boolean; maxTimeMS?: number; query?: string; pipeline?: string; @@ -42,50 +52,28 @@ type ToolsContext = CompassContext & { connections: ToolsConnectParams[]; }; -class NoopDefaultMetrics { - observe(): void { - // no-op - } -} - -class NoopMetrics implements Metrics { - constructor() {} - get(_key: K): DefaultMetrics[K] { - return new NoopDefaultMetrics() as unknown as DefaultMetrics[K]; - } - getMetrics(): Promise { - return Promise.resolve(''); - } -} - /** - * In-memory MCP runner that doesn't bind to any external transport. - * The server is kept in memory for direct programmatic access. + * Compass reports the MCP server name/version to the client and the driver + * `appName`; the latter is always overridden by {@link ToolsConnectionManager}, + * so only the name matters here. */ -class InMemoryRunner extends TransportRunnerBase { - public server?: Server; - public readonly userConfig: UserConfig; - - constructor(config: TransportRunnerConfig) { - super(config); - this.userConfig = config.userConfig; - } +const serverMetadata: ServerMetadata = { + mcpServerName: 'mongodb-compass', + version: '0.0.0', +}; - async start(): Promise { - this.server = await this.setupServer(); - } +/** The in-memory server composition the tools read their services from. */ +type CompassToolServer = MongoDBToolServer & { tools: AnyToolBase[] }; - async closeTransport(): Promise { - await this.server?.close(); - } -} +const READ_ONLY_DATABASE_TOOL_NAMES = new Set( + READ_ONLY_DATABASE_TOOLS.map((tool) => tool.name) +); type ToolsControllerConfig = { logger: Logger; preferences: PreferencesAccess; getTelemetryAnonymousId: () => string; track: TrackFunction; - enableMCPTelemetry: boolean; maxTimeMS?: number; atlasAdminApi: AtlasAdminApiService; }; @@ -95,7 +83,9 @@ export class ToolsController { private preferences: PreferencesAccess; private toolGroups: Set = new Set(); private context: ToolsContext = Object.create(null); - private readonly runner: InMemoryRunner; + private toolServer?: CompassToolServer; + private readonly keychain = new Keychain(); + private readonly serverLogger: CompositeLogger; private connectionManager: ToolsConnectionManager; private connectionIdByToolCallId: Record = Object.create(null); @@ -106,7 +96,6 @@ export class ToolsController { logger, getTelemetryAnonymousId, track, - enableMCPTelemetry, maxTimeMS, atlasAdminApi, preferences, @@ -115,29 +104,13 @@ export class ToolsController { this.atlasAdminApi = atlasAdminApi; this.preferences = preferences; this.track = track; - const mcpConfig = UserConfigSchema.parse({ - disabledTools: ['connect'], - loggers: ['mcp'], - readOnly: true, - // NOTE: the preferences could change at runtime. As a best-effort way of - // keeping them in sync we'll change them every time we set the tools' context - telemetry: enableMCPTelemetry ? 'enabled' : 'disabled', - maxTimeMS, - }); - - this.runner = new InMemoryRunner({ - userConfig: mcpConfig, - createConnectionManager: () => Promise.resolve(this.connectionManager), - connectionErrorHandler: createConnectionErrorHandler(), - additionalLoggers: [new ToolsLogger(Keychain.root, this.logger)], - telemetryProperties: { - hosting_mode: 'compass', - }, - metrics: new NoopMetrics(), + this.context = { ...this.context, maxTimeMS }; + this.serverLogger = new CompositeLogger({ + loggers: [new ToolsLogger(this.keychain, logger)], }); this.connectionManager = new ToolsConnectionManager({ - logger: this.runner.logger, + logger: this.serverLogger, getTelemetryAnonymousId, }); @@ -156,6 +129,79 @@ export class ToolsController { }); } + private createServer(): CompassToolServer { + const mcpServer = new McpServer({ + name: serverMetadata.mcpServerName, + version: serverMetadata.version, + }); + const tools: AnyToolBase[] = []; + + const server: CompassToolServer = { + // Defaults mirror `UserConfigSchema`; Compass only exposes read-only + // database tools, so the write- and Atlas-specific options are unused. + config: { + transport: 'stdio', + httpResponseType: 'sse', + readOnly: true, + disabledTools: ['connect'], + confirmationRequiredTools: [], + previewFeatures: [], + connectionString: undefined, + indexCheck: false, + disableServerSideJs: true, + maxTimeMS: this.context.maxTimeMS, + maxDocumentsPerQuery: 100, + maxBytesPerQuery: 16_777_216, + httpHost: '127.0.0.1', + queryCountMaxTimeMsCap: QUERY_COUNT_MAX_TIME_MS_CAP, + aggregationCountMaxTimeMsCap: AGG_COUNT_MAX_TIME_MS_CAP, + }, + logger: this.serverLogger, + keychain: this.keychain, + connectionRegistry: new ToolsConnectionRegistry( + this.connectionManager, + this.keychain + ), + // `MongoDBToolServices` types the handler's return as + // `{ errorHandled, result }` even though `result` is only read when + // `errorHandled` is true. Compass never handles connection errors, so the + // narrower `ConnectionErrorUnhandled` is safe here. + connectionErrorHandler: + createConnectionErrorHandler() as MongoDBToolServer['connectionErrorHandler'], + // Only the `export` tool reads the exports manager, and Compass does not + // register it. + exportsManager: { + createJSONExport: () => { + return Promise.reject( + new Error( + 'Exporting data is not supported in Compass Database Tools' + ) + ); + }, + }, + telemetry: new NoopTelemetry(), + elicitation: new Elicitation({ server: mcpServer.server }), + metrics: new NoopMetrics(), + mcpServer, + tools, + isToolCategoryAvailable: (category) => { + return tools.some((tool) => tool.category === category); + }, + }; + + for (const ToolConstructor of MongoDBTools) { + if (!READ_ONLY_DATABASE_TOOL_NAMES.has(ToolConstructor.toolName)) { + continue; + } + const toolInstance = new ToolConstructor({ server }); + if (toolInstance.register()) { + tools.push(toolInstance); + } + } + + return server; + } + setActiveTools(toolGroups: Set): void { this.toolGroups = toolGroups; } @@ -201,30 +247,23 @@ export class ToolsController { }; } - if (this.toolGroups.has('db-read') && this.runner.server) { - const readonlyDatabaseToolNames = READ_ONLY_DATABASE_TOOLS.map( - (tool) => tool.name - ); - if (this.runner.server.tools.length === 0) { - this.runner.server.registerTools(); - } - - const availableTools = this.runner.server.tools ?? []; - for (const toolBase of availableTools) { - if (!readonlyDatabaseToolNames.includes(toolBase.name)) { - continue; - } - + if (this.toolGroups.has('db-read') && this.toolServer) { + for (const toolBase of this.toolServer.tools) { tools[toolBase.name] = tool({ description: getCustomToolDescription(toolBase), inputSchema: z.object( Object.fromEntries( - Object.entries(toolBase.argsShape).map(([key, value]) => { - // TODO: MCP server applies transformations like toEJSON. - // We should come up with a better solution for this but for now we recursively remove the transforms. - // AI SDK applies transformations defined in the schema *before* sending the request to the model. - return [key, removeZodTransforms(value)]; - }) + Object.entries(toolBase.argsShape()) + // Compass always runs against the user's active connection, so + // the connection handle is never something the model should + // pick; it is injected in `execute` below. + .filter(([key]) => key !== 'connectionId') + .map(([key, value]) => { + // TODO: MCP server applies transformations like toEJSON. + // We should come up with a better solution for this but for now we recursively remove the transforms. + // AI SDK applies transformations defined in the schema *before* sending the request to the model. + return [key, removeZodTransforms(value)]; + }) ) ), needsApproval: true, @@ -278,9 +317,15 @@ export class ToolsController { let result: Awaited>; try { - result = await toolBase.invoke(args, { - signal: options.abortSignal ?? new AbortSignal(), - }); + const context: ToolExecutionContext = { + request: { + signal: options.abortSignal ?? new AbortController().signal, + }, + }; + result = await toolBase.invoke( + { ...args, connectionId: COMPASS_CONNECTION_ID }, + context + ); } finally { // disconnect await this.connectionManager.disconnect(); @@ -336,10 +381,9 @@ export class ToolsController { setContext(context: ToolsContext): void { // make sure these properties are always in sync with the tools' config - this.runner.userConfig.telemetry = context.enableMCPTelemetry - ? 'enabled' - : 'disabled'; - this.runner.userConfig.maxTimeMS = context.maxTimeMS; + if (this.toolServer) { + this.toolServer.config.maxTimeMS = context.maxTimeMS; + } this.context = context; } @@ -353,29 +397,26 @@ export class ToolsController { this.connectionIdByToolCallId[toolCallId] = connectionId; } - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents - get server(): Server | undefined { - return this.runner?.server; + get server(): CompassToolServer | undefined { + return this.toolServer; } - public async startServer(): Promise { - if (this.runner.server) { - return; + public startServer(): Promise { + if (this.toolServer) { + return Promise.resolve(); } try { this.logger.log.info( this.logger.mongoLogId(1_001_000_402), 'ToolsController', - 'Starting in-memory MCP server with config', + 'Starting in-memory MCP server', { - ...this.runner.userConfig, - apiClientId: '', - apiClientSecret: '', + maxTimeMS: this.context.maxTimeMS, } ); - await this.runner.start(); + this.toolServer = this.createServer(); this.logger.log.info( this.logger.mongoLogId(1_001_000_403), @@ -392,11 +433,13 @@ export class ToolsController { { error: error.message } ); } + + return Promise.resolve(); } public async stopServer(): Promise { try { - if (!this.runner.server) { + if (!this.toolServer) { this.logger.log.info( this.logger.mongoLogId(1_001_000_406), 'ToolsController', @@ -404,7 +447,9 @@ export class ToolsController { ); return; } - await this.runner.server.close(); + const server = this.toolServer; + this.toolServer = undefined; + await server.mcpServer.close(); this.logger.log.info( this.logger.mongoLogId(1_001_000_407), 'ToolsController', diff --git a/packages/compass-generative-ai/src/tools-logger.ts b/packages/compass-generative-ai/src/tools-logger.ts index dbe0ebb895d..5ef16ab179a 100644 --- a/packages/compass-generative-ai/src/tools-logger.ts +++ b/packages/compass-generative-ai/src/tools-logger.ts @@ -1,14 +1,14 @@ import type { Logger } from '@mongodb-js/compass-logging'; -import type { LoggerType, LogLevel, LogPayload } from 'mongodb-mcp-server'; -import { LoggerBase } from 'mongodb-mcp-server'; -import type { Keychain } from 'mongodb-mcp-server'; +import type { Keychain } from '@mongodb-js/mcp-core'; +import { RedactingLoggerBase } from '@mongodb-js/mcp-core'; +import type { LoggerType, LogLevel, LogPayload } from '@mongodb-js/mcp-types'; -export class ToolsLogger extends LoggerBase { +export class ToolsLogger extends RedactingLoggerBase { private readonly _logger: Logger; - protected type: LoggerType = 'console'; + protected readonly type: LoggerType = 'console'; constructor(keychain: Keychain, logger: Logger) { - super(keychain); + super({ keychain }); this._logger = logger; } diff --git a/packages/compass-web/package.json b/packages/compass-web/package.json index ddf1732e4b7..4c1c1a58849 100644 --- a/packages/compass-web/package.json +++ b/packages/compass-web/package.json @@ -141,7 +141,6 @@ "mongodb": "^7.5.0", "mongodb-data-service": "^22.41.3", "mongodb-log-writer": "^2.4.4", - "mongodb-mcp-server": "^1.10.0", "mongodb-ns": "^3.2.0", "nyc": "^15.1.0", "os-browserify": "^0.3.0", diff --git a/packages/compass-web/polyfills/diagnostics_channel/index.ts b/packages/compass-web/polyfills/diagnostics_channel/index.ts deleted file mode 100644 index b05aad4d8df..00000000000 --- a/packages/compass-web/polyfills/diagnostics_channel/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -const noopChannel = { - hasSubscribers: false, - publish() {}, - subscribe() {}, - unsubscribe() {}, -}; - -const noopTracingChannel = { - hasSubscribers: false, - tracePromise(fn: () => Promise) { - return fn(); - }, - traceSync(fn: () => unknown) { - return fn(); - }, - traceCallback(fn: (...args: unknown[]) => unknown, ...args: unknown[]) { - return fn(...args); - }, - start: noopChannel, - end: noopChannel, - asyncStart: noopChannel, - asyncEnd: noopChannel, - error: noopChannel, -}; - -export function channel(_name: string) { - return noopChannel; -} - -export function tracingChannel(_name: string) { - return noopTracingChannel; -} - -export function hasSubscribers(_name: string) { - return false; -} - -export function subscribe() {} -export function unsubscribe() {} - -export default { - channel, - tracingChannel, - hasSubscribers, - subscribe, - unsubscribe, -}; diff --git a/packages/compass-web/webpack.config.js b/packages/compass-web/webpack.config.js index c2bae9a4278..aa27fbd8cc2 100644 --- a/packages/compass-web/webpack.config.js +++ b/packages/compass-web/webpack.config.js @@ -186,23 +186,11 @@ module.exports = (env, args) => { 'mongodb-client-encryption/package.json': localPolyfill('throwError'), 'mongodb-client-encryption': localPolyfill('throwError'), - 'prom-client': false, - // lru-cache (bundled inside mongodb-mcp-server) calls channel() and - // tracingChannel() from diagnostics_channel - diagnostics_channel: localPolyfill('diagnostics_channel'), - // We want to use the cjs dist instead of esm to make sure that no dynamic - // import code from mcp-server ends up in compass bundle. - // Otherwise, this breaks COMPILE_CLIENT_BAZEL task on mms side. - 'mongodb-mcp-server': require.resolve('mongodb-mcp-server'), - - // mongodb-mcp-server polyfills - // This is only used by StreamableHttpTransport which we do not use. - express: false, - http2: false, - // Only used by Atlas Local tools which we do not currently use. - '@mongodb-js/atlas-local': localPolyfill('throwError'), - // Only used by Atlas tools which we do not currently use. - 'node-fetch': false, + // @mongodb-js/mcp-tools-mongodb dynamically imports node-machine-id to + // compute a device id. Compass doesn't use that path, and leaving it + // resolvable emits a dynamic-import chunk that breaks the MMS + // COMPILE_CLIENT_BAZEL task. + 'node-machine-id': localPolyfill('throwError'), }, }, externalsType: 'window', diff --git a/packages/compass/webpack.config.js b/packages/compass/webpack.config.js index c5dc9cc5d26..6cf44153edd 100644 --- a/packages/compass/webpack.config.js +++ b/packages/compass/webpack.config.js @@ -229,11 +229,6 @@ module.exports = (_env, args) => { // amount of dependencies is massive and can benefit from them more optimization, externals, - resolve: { - alias: { - '@mongodb-js/atlas-local': false, - }, - }, plugins: [ new webpack.EnvironmentPlugin(hadronEnvConfig), ...compileOnlyPlugins, From 13e0ef629964dea0179e46f112397d961a57651f Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Thu, 15 Oct 2026 13:45:07 +0200 Subject: [PATCH 02/23] test(compass-generative-ai): exercise MCP server startup failure path The startup-error test only made getTelemetryAnonymousId throw, which startServer() no longer calls, so the catch block was never entered. --- .../src/tools-controller.spec.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index dff81002bbb..b4694c457da 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -519,16 +519,31 @@ describe('ToolsController', function () { it('handles errors during server startup gracefully', async function () { const errorController = new ToolsController({ logger, - getTelemetryAnonymousId: () => { - throw new Error('Telemetry error'); - }, + getTelemetryAnonymousId, track: createNoopTrack(), preferences, atlasAdminApi, }); + sandbox + .stub(errorController as any, 'createServer') + .throws(new Error('Server creation error')); + const logStub = sandbox.stub(logger.log, 'error'); // Should not throw even if there's an error await errorController.startServer(); + + expect(errorController.server).to.be.undefined; + for (const args of logStub.args) { + (args[0] as any) = args[0].__value; + } + expect( + logStub.calledWith( + sinon.match.number, + 'ToolsController', + 'Error when attempting to start MCP server' + ) + ).to.be.true; + // don't hang await errorController.stopServer(); }); From bdbbf0dbaadb98eab36b107a2a5f4696c94f6bcd Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Thu, 15 Oct 2026 23:49:34 +0200 Subject: [PATCH 03/23] fix(compass-generative-ai): restore MCP telemetry for Database Tools The v3 migration replaced the MCP telemetry pipeline with a no-op and dropped enableMCPTelemetry, so the events the v1 integration reported stopped being sent. v1 was inconsistent about it (it only scheduled its send timer when the server happened to start with the preference already on, otherwise it just flushed a batch of cached events on shutdown), but it did report. Wire AtlasTelemetry back up behind an unauthenticated Atlas API client, keep the hosting_mode: 'compass' property, and read trackUsageStatistics live so toggling the preference takes effect without restarting the server. --- package-lock.json | 8 +- .../src/compass-assistant-provider.spec.tsx | 5 ++ .../src/compass-assistant-provider.tsx | 5 ++ .../compass-assistant/test/tool-calls.eval.ts | 2 + packages/compass-generative-ai/package.json | 8 +- .../compass-generative-ai/src/provider.tsx | 2 + .../src/tools-controller.spec.ts | 69 ++++++++++++++++ .../src/tools-controller.ts | 80 +++++++++++++++++-- .../src/tools-telemetry.ts | 49 ++++++++++++ 9 files changed, 214 insertions(+), 14 deletions(-) create mode 100644 packages/compass-generative-ai/src/tools-telemetry.ts diff --git a/package-lock.json b/package-lock.json index 1962667974d..d2406fd3406 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54086,9 +54086,11 @@ "@mongodb-js/compass-logging": "^1.18.2", "@mongodb-js/compass-telemetry": "^1.35.1", "@mongodb-js/compass-utils": "^0.10.6", - "@mongodb-js/mcp-core": "^3.0.5", - "@mongodb-js/mcp-tools-mongodb": "^3.0.5", - "@mongodb-js/mcp-types": "^3.0.5", + "@mongodb-js/mcp-atlas-api-client": "^3.1.0", + "@mongodb-js/mcp-atlas-telemetry": "^3.1.0", + "@mongodb-js/mcp-core": "^3.1.0", + "@mongodb-js/mcp-tools-mongodb": "^3.1.0", + "@mongodb-js/mcp-types": "^3.1.0", "@mongodb-js/mongodb-schema": "^12.7.2", "@mongodb-js/shell-bson-parser": "^1.6.3", "@mongosh/service-provider-core": "^5.2.0", diff --git a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx index bfc7d9fd40a..61d86b5bd51 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx @@ -684,6 +684,7 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ + enableMCPTelemetry: true, maxTimeMS: undefined, connections: [], query, @@ -750,6 +751,7 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ + enableMCPTelemetry: true, maxTimeMS: undefined, connections: [], query, @@ -824,6 +826,7 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ + enableMCPTelemetry: true, maxTimeMS: undefined, connections: [], query, @@ -909,6 +912,7 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ + enableMCPTelemetry: true, maxTimeMS: undefined, connections: [ { @@ -967,6 +971,7 @@ describe('CompassAssistantProvider', function () { expect(mockToolsController.setContext.callCount).to.equal(1); expect(mockToolsController.setContext.firstCall.args[0]).to.deep.equal({ + enableMCPTelemetry: true, maxTimeMS: 5000, connections: [], query: undefined, diff --git a/packages/compass-assistant/src/compass-assistant-provider.tsx b/packages/compass-assistant/src/compass-assistant-provider.tsx index ecb38784751..fab3302dc40 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.tsx @@ -485,6 +485,7 @@ export function ensureOptInAndSendThunk( ? activeCollectionSubTab || activeWorkspace.type : null; setToolsContext(toolsController, { + enableMCPTelemetry: prefs.trackUsageStatistics, maxTimeMS: prefs.maxTimeMS, activeConnection, connections: activeConnections, @@ -1009,6 +1010,7 @@ export function createDefaultChat({ export function setToolsContext( toolsController: ToolsController, { + enableMCPTelemetry, maxTimeMS, activeConnection, connections, @@ -1018,6 +1020,7 @@ export function setToolsContext( enableGenAIToolCalling, activeTab, }: { + enableMCPTelemetry: boolean; maxTimeMS?: number; activeConnection: ActiveConnectionInfo | null; connections: ActiveConnectionInfo[]; @@ -1043,6 +1046,7 @@ export function setToolsContext( } toolsController.setActiveTools(toolGroups); toolsController.setContext({ + enableMCPTelemetry, maxTimeMS, connections: connections.map((connection) => { if (!connection.connectOptions) { @@ -1062,6 +1066,7 @@ export function setToolsContext( } else { toolsController.setActiveTools(new Set([])); toolsController.setContext({ + enableMCPTelemetry, maxTimeMS, connections: [], query: undefined, diff --git a/packages/compass-assistant/test/tool-calls.eval.ts b/packages/compass-assistant/test/tool-calls.eval.ts index 9f25ba0be75..3100cef3ed0 100644 --- a/packages/compass-assistant/test/tool-calls.eval.ts +++ b/packages/compass-assistant/test/tool-calls.eval.ts @@ -68,6 +68,7 @@ const toolsController = new ToolsController({ logger, getTelemetryAnonymousId: () => 'eval-anonymous-id', track: createNoopTrack(), + enableMCPTelemetry: false, preferences: defaultPreferencesInstance, atlasAdminApi: {} as AtlasAdminApiService, }); @@ -109,6 +110,7 @@ function getToolsForCase({ toolsController.setActiveTools(toolGroups); toolsController.setContext({ + enableMCPTelemetry: false, connections: [connectionConfig], query: input.currentQuery ? JSON.stringify(input.currentQuery) : undefined, pipeline: input.currentPipeline diff --git a/packages/compass-generative-ai/package.json b/packages/compass-generative-ai/package.json index a4e1d36a211..9578c240991 100644 --- a/packages/compass-generative-ai/package.json +++ b/packages/compass-generative-ai/package.json @@ -62,9 +62,11 @@ "@mongodb-js/compass-logging": "^1.18.2", "@mongodb-js/compass-telemetry": "^1.35.1", "@mongodb-js/compass-utils": "^0.10.6", - "@mongodb-js/mcp-core": "^3.0.5", - "@mongodb-js/mcp-tools-mongodb": "^3.0.5", - "@mongodb-js/mcp-types": "^3.0.5", + "@mongodb-js/mcp-atlas-api-client": "^3.1.0", + "@mongodb-js/mcp-atlas-telemetry": "^3.1.0", + "@mongodb-js/mcp-core": "^3.1.0", + "@mongodb-js/mcp-tools-mongodb": "^3.1.0", + "@mongodb-js/mcp-types": "^3.1.0", "@mongodb-js/mongodb-schema": "^12.7.2", "@mongodb-js/shell-bson-parser": "^1.6.3", "@mongosh/service-provider-core": "^5.2.0", diff --git a/packages/compass-generative-ai/src/provider.tsx b/packages/compass-generative-ai/src/provider.tsx index 91da9624ec3..cabaea9145c 100644 --- a/packages/compass-generative-ai/src/provider.tsx +++ b/packages/compass-generative-ai/src/provider.tsx @@ -74,6 +74,8 @@ export const ToolsControllerProvider: React.FC<{ logger, getTelemetryAnonymousId: () => telemetryAnonymousId ?? '', track, + // we will set this later through setContext() + enableMCPTelemetry: false, preferences, atlasAdminApi, }); diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index b4694c457da..4375e3b4439 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -13,6 +13,7 @@ import { } from 'compass-preferences-model'; import type { AtlasAdminApiService } from '@mongodb-js/atlas-admin-api/provider'; import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; +import type { CompassMcpTelemetry } from './tools-telemetry'; describe('ToolsController', function () { let sandbox: sinon.SinonSandbox; @@ -32,6 +33,7 @@ describe('ToolsController', function () { atlasAdminApi = {} as AtlasAdminApiService; toolsController = new ToolsController({ + enableMCPTelemetry: false, logger, getTelemetryAnonymousId, track: createNoopTrack(), @@ -152,6 +154,7 @@ describe('ToolsController', function () { it('get-current-query returns context query', async function () { const testQuery = '{ name: "test" }'; toolsController.setContext({ + enableMCPTelemetry: false, query: testQuery, connections: [], }); @@ -167,6 +170,7 @@ describe('ToolsController', function () { it('get-current-query returns undefined when no query in context', async function () { toolsController.setContext({ + enableMCPTelemetry: false, connections: [], }); @@ -205,6 +209,7 @@ describe('ToolsController', function () { it('get-current-pipeline returns context pipeline', async function () { const testPipeline = '[{ $match: { status: "active" } }]'; toolsController.setContext({ + enableMCPTelemetry: false, pipeline: testPipeline, connections: [], }); @@ -220,6 +225,7 @@ describe('ToolsController', function () { it('get-current-pipeline returns undefined when no pipeline in context', async function () { toolsController.setContext({ + enableMCPTelemetry: false, connections: [], }); @@ -241,6 +247,7 @@ describe('ToolsController', function () { it('ignores db tools if the server is not started', function () { const newController = new ToolsController({ + enableMCPTelemetry: false, logger, getTelemetryAnonymousId, track: createNoopTrack(), @@ -351,6 +358,7 @@ describe('ToolsController', function () { it('sets context with query', async function () { const query = '{ status: "active" }'; toolsController.setContext({ + enableMCPTelemetry: false, query, connections: [], }); @@ -365,6 +373,7 @@ describe('ToolsController', function () { it('sets context with pipeline', async function () { const pipeline = '[{ $match: { age: { $gte: 18 } } }]'; toolsController.setContext({ + enableMCPTelemetry: false, pipeline, connections: [], }); @@ -389,12 +398,14 @@ describe('ToolsController', function () { ]; toolsController.setContext({ + enableMCPTelemetry: false, connections, }); // Context is set internally, verify through tool execution expect(() => toolsController.setContext({ + enableMCPTelemetry: false, connections, }) ).to.not.throw(); @@ -402,11 +413,13 @@ describe('ToolsController', function () { it('updates existing context', async function () { toolsController.setContext({ + enableMCPTelemetry: false, query: 'old query', connections: [], }); toolsController.setContext({ + enableMCPTelemetry: false, query: 'new query', connections: [], }); @@ -422,12 +435,14 @@ describe('ToolsController', function () { await toolsController.startServer(); toolsController.setContext({ + enableMCPTelemetry: false, maxTimeMS: 5000, connections: [], }); expect(toolsController.server?.config.maxTimeMS).to.equal(5000); toolsController.setContext({ + enableMCPTelemetry: false, maxTimeMS: undefined, connections: [], }); @@ -436,6 +451,7 @@ describe('ToolsController', function () { it('applies maxTimeMS set before the server starts', async function () { toolsController.setContext({ + enableMCPTelemetry: false, maxTimeMS: 5000, connections: [], }); @@ -446,6 +462,55 @@ describe('ToolsController', function () { }); }); + describe('MCP telemetry', function () { + it('starts disabled until the context enables it', async function () { + await toolsController.startServer(); + + expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( + false + ); + + toolsController.setContext({ + enableMCPTelemetry: true, + connections: [], + }); + + expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( + true + ); + }); + + it('stops collecting when the preference is turned back off', async function () { + await toolsController.startServer(); + toolsController.setContext({ + enableMCPTelemetry: true, + connections: [], + }); + expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( + true + ); + + toolsController.setContext({ + enableMCPTelemetry: false, + connections: [], + }); + expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( + false + ); + }); + + it('stamps the Compass hosting mode on every event', async function () { + await toolsController.startServer(); + const telemetry = toolsController.server + ?.telemetry as unknown as CompassMcpTelemetry; + + expect(telemetry.getCommonProperties()).to.have.property( + 'hosting_mode', + 'compass' + ); + }); + }); + describe('setConnectionIdForToolCall', function () { it('sets connection ID for a tool call', function () { toolsController.setConnectionIdForToolCall({ @@ -518,6 +583,7 @@ describe('ToolsController', function () { it('handles errors during server startup gracefully', async function () { const errorController = new ToolsController({ + enableMCPTelemetry: false, logger, getTelemetryAnonymousId, track: createNoopTrack(), @@ -638,6 +704,7 @@ describe('ToolsController', function () { it('context persists across tool group changes', async function () { const query = '{ test: 1 }'; toolsController.setContext({ + enableMCPTelemetry: false, query, connections: [], }); @@ -670,6 +737,7 @@ describe('ToolsController', function () { connectionId: 'conn-1', }); toolsController.setContext({ + enableMCPTelemetry: false, connections: [ { connectionId: 'conn-1', @@ -740,6 +808,7 @@ describe('ToolsController', function () { }); toolsController.setContext({ + enableMCPTelemetry: false, connections: [], }); diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index 2447649d020..f0f4603a251 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -8,15 +8,24 @@ import { Keychain, McpServer, NoopMetrics, - NoopTelemetry, type AnyToolBase, } from '@mongodb-js/mcp-core'; +import { + ApiClient, + userAgentFromServerMetadata, + type HttpClient, +} from '@mongodb-js/mcp-atlas-api-client'; import { AGG_COUNT_MAX_TIME_MS_CAP, + DeviceId, MongoDBTools, QUERY_COUNT_MAX_TIME_MS_CAP, type MongoDBToolServer, } from '@mongodb-js/mcp-tools-mongodb'; +import { + createCompassMcpTelemetry, + type CompassMcpTelemetry, +} from './tools-telemetry'; import type { ServerMetadata, ToolExecutionContext, @@ -43,6 +52,7 @@ import { export type ToolGroup = 'querybar' | 'aggregation-builder' | 'db-read'; type CompassContext = { + enableMCPTelemetry: boolean; maxTimeMS?: number; query?: string; pipeline?: string; @@ -62,6 +72,18 @@ const serverMetadata: ServerMetadata = { version: '0.0.0', }; +/** The Atlas endpoint MCP telemetry events are sent to (matching the v1 default). */ +const ATLAS_API_BASE_URL = 'https://cloud.mongodb.com/'; + +/** + * The MCP server only ever runs inside a browser or the Electron renderer, so + * the platform `fetch`/`Request` pair is used directly. + */ +const httpClient: HttpClient = { + fetch: (...args) => globalThis.fetch(...args), + Request: globalThis.Request, +}; + /** The in-memory server composition the tools read their services from. */ type CompassToolServer = MongoDBToolServer & { tools: AnyToolBase[] }; @@ -74,6 +96,7 @@ type ToolsControllerConfig = { preferences: PreferencesAccess; getTelemetryAnonymousId: () => string; track: TrackFunction; + enableMCPTelemetry: boolean; maxTimeMS?: number; atlasAdminApi: AtlasAdminApiService; }; @@ -86,6 +109,9 @@ export class ToolsController { private toolServer?: CompassToolServer; private readonly keychain = new Keychain(); private readonly serverLogger: CompositeLogger; + private telemetry?: CompassMcpTelemetry; + private deviceId?: DeviceId; + private apiClient?: ApiClient; private connectionManager: ToolsConnectionManager; private connectionIdByToolCallId: Record = Object.create(null); @@ -96,6 +122,7 @@ export class ToolsController { logger, getTelemetryAnonymousId, track, + enableMCPTelemetry, maxTimeMS, atlasAdminApi, preferences, @@ -104,7 +131,7 @@ export class ToolsController { this.atlasAdminApi = atlasAdminApi; this.preferences = preferences; this.track = track; - this.context = { ...this.context, maxTimeMS }; + this.context = { ...this.context, enableMCPTelemetry, maxTimeMS }; this.serverLogger = new CompositeLogger({ loggers: [new ToolsLogger(this.keychain, logger)], }); @@ -129,6 +156,16 @@ export class ToolsController { }); } + /** Flushes and releases the telemetry pipeline and its API client. */ + private async closeTelemetry(): Promise { + await this.telemetry?.close(); + await this.apiClient?.close(); + this.deviceId?.close(); + this.telemetry = undefined; + this.apiClient = undefined; + this.deviceId = undefined; + } + private createServer(): CompassToolServer { const mcpServer = new McpServer({ name: serverMetadata.mcpServerName, @@ -136,6 +173,32 @@ export class ToolsController { }); const tools: AnyToolBase[] = []; + const apiClient = new ApiClient({ + options: { + baseUrl: ATLAS_API_BASE_URL, + userAgent: userAgentFromServerMetadata(serverMetadata), + httpClient, + }, + logger: this.serverLogger, + }); + const deviceId = DeviceId.create(this.serverLogger); + const telemetry = createCompassMcpTelemetry( + { + logger: this.serverLogger, + deviceId, + apiClient, + keychain: this.keychain, + // Constructed enabled so the pipeline is set up and ready either way; + // the callback below is the live gate. + enabled: true, + serverMetadata, + }, + () => this.context.enableMCPTelemetry + ); + this.apiClient = apiClient; + this.deviceId = deviceId; + this.telemetry = telemetry; + const server: CompassToolServer = { // Defaults mirror `UserConfigSchema`; Compass only exposes read-only // database tools, so the write- and Atlas-specific options are unused. @@ -179,7 +242,7 @@ export class ToolsController { ); }, }, - telemetry: new NoopTelemetry(), + telemetry, elicitation: new Elicitation({ server: mcpServer.server }), metrics: new NoopMetrics(), mcpServer, @@ -401,9 +464,9 @@ export class ToolsController { return this.toolServer; } - public startServer(): Promise { + public async startServer(): Promise { if (this.toolServer) { - return Promise.resolve(); + return; } try { @@ -425,7 +488,9 @@ export class ToolsController { ); } catch (error: any) { // In case of errors we don't want Compass to crash so we - // silence MCP start errors and instead log them for debugging. + // silence MCP start errors and instead log them for debugging. Anything + // createServer() managed to build before throwing is released here. + await this.closeTelemetry(); this.logger.log.error( this.logger.mongoLogId(1_001_000_404), 'ToolsController', @@ -433,8 +498,6 @@ export class ToolsController { { error: error.message } ); } - - return Promise.resolve(); } public async stopServer(): Promise { @@ -450,6 +513,7 @@ export class ToolsController { const server = this.toolServer; this.toolServer = undefined; await server.mcpServer.close(); + await this.closeTelemetry(); this.logger.log.info( this.logger.mongoLogId(1_001_000_407), 'ToolsController', diff --git a/packages/compass-generative-ai/src/tools-telemetry.ts b/packages/compass-generative-ai/src/tools-telemetry.ts new file mode 100644 index 00000000000..fd5e5d8ac10 --- /dev/null +++ b/packages/compass-generative-ai/src/tools-telemetry.ts @@ -0,0 +1,49 @@ +import { AtlasTelemetry } from '@mongodb-js/mcp-atlas-telemetry'; +import type { TelemetryConfig } from '@mongodb-js/mcp-atlas-telemetry'; +import type { TelemetryCommonProperties } from '@mongodb-js/mcp-types'; + +/** + * The MCP telemetry pipeline for Compass's in-memory Database Tools server. + * + * Two Compass-specific behaviours on top of {@link AtlasTelemetry}: + * - every event carries `hosting_mode: 'compass'`, which the v1 integration + * passed as `telemetryProperties`; + * - whether events are collected is read live from the caller, so toggling + * "usage statistics" takes effect without restarting the server. + */ +export class CompassMcpTelemetry extends AtlasTelemetry { + private readonly isEnabled: () => boolean; + + constructor(config: TelemetryConfig, isEnabled: () => boolean) { + super(config); + this.isEnabled = isEnabled; + } + + public override isTelemetryEnabled(): boolean { + return this.isEnabled() && super.isTelemetryEnabled(); + } + + public override getCommonProperties(): TelemetryCommonProperties { + return { + ...super.getCommonProperties(), + hosting_mode: 'compass', + }; + } +} + +/** + * Builds and starts the Compass MCP telemetry pipeline. + * + * The pipeline is always constructed enabled so that turning the preference on + * mid-session starts collection; `isEnabled` is the live gate. (The v1 wiring + * only scheduled its send timer when telemetry happened to be enabled at server + * start, so flipping the preference on later collected nothing.) + */ +export function createCompassMcpTelemetry( + config: TelemetryConfig, + isEnabled: () => boolean +): CompassMcpTelemetry { + const instance = new CompassMcpTelemetry(config, isEnabled); + void instance.setup(); + return instance; +} From 0127c817e7f477aa303371108a21b8b2974fd9fa Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Thu, 15 Oct 2026 23:56:34 +0200 Subject: [PATCH 04/23] fix(compass-generative-ai): keep MCP telemetry inert while disabled The pipeline was constructed enabled so that turning the preference on mid-session would start collection, which also meant the machine id lookup, container probe and 30s send timer ran even when Compass telemetry was off. Start the pipeline lazily instead: nothing is set up until the first event the preference actually allows through, and the machine id is resolved on first use rather than at construction. --- .../src/tools-controller.spec.ts | 41 ++++++++ .../src/tools-controller.ts | 10 -- .../src/tools-telemetry.ts | 94 ++++++++++++++++--- 3 files changed, 121 insertions(+), 24 deletions(-) diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 4375e3b4439..7786f878fb1 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -13,6 +13,8 @@ import { } from 'compass-preferences-model'; import type { AtlasAdminApiService } from '@mongodb-js/atlas-admin-api/provider'; import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; +import { DeviceId } from '@mongodb-js/mcp-tools-mongodb'; +import type { ITelemetry } from '@mongodb-js/mcp-types'; import type { CompassMcpTelemetry } from './tools-telemetry'; describe('ToolsController', function () { @@ -463,6 +465,25 @@ describe('ToolsController', function () { }); describe('MCP telemetry', function () { + let createDeviceId: sinon.SinonStub; + + beforeEach(function () { + createDeviceId = sandbox.stub(DeviceId, 'create').returns({ + get: sandbox.stub().resolves('test-device-id'), + close: sandbox.stub(), + } as any); + }); + + const emitEvent = (telemetry: ITelemetry | undefined) => { + telemetry?.emitEvents([ + { + timestamp: new Date().toISOString(), + source: 'mdbmcp', + properties: {}, + } as any, + ]); + }; + it('starts disabled until the context enables it', async function () { await toolsController.startServer(); @@ -499,6 +520,26 @@ describe('ToolsController', function () { ); }); + it('resolves no device id while telemetry is disabled', async function () { + await toolsController.startServer(); + + emitEvent(toolsController.server?.telemetry); + + expect(createDeviceId.called).to.equal(false); + }); + + it('starts the pipeline on the first event once enabled', async function () { + await toolsController.startServer(); + toolsController.setContext({ + enableMCPTelemetry: true, + connections: [], + }); + + emitEvent(toolsController.server?.telemetry); + + expect(createDeviceId.calledOnce).to.equal(true); + }); + it('stamps the Compass hosting mode on every event', async function () { await toolsController.startServer(); const telemetry = toolsController.server diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index f0f4603a251..74874b1086c 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -17,7 +17,6 @@ import { } from '@mongodb-js/mcp-atlas-api-client'; import { AGG_COUNT_MAX_TIME_MS_CAP, - DeviceId, MongoDBTools, QUERY_COUNT_MAX_TIME_MS_CAP, type MongoDBToolServer, @@ -110,7 +109,6 @@ export class ToolsController { private readonly keychain = new Keychain(); private readonly serverLogger: CompositeLogger; private telemetry?: CompassMcpTelemetry; - private deviceId?: DeviceId; private apiClient?: ApiClient; private connectionManager: ToolsConnectionManager; private connectionIdByToolCallId: Record = @@ -160,10 +158,8 @@ export class ToolsController { private async closeTelemetry(): Promise { await this.telemetry?.close(); await this.apiClient?.close(); - this.deviceId?.close(); this.telemetry = undefined; this.apiClient = undefined; - this.deviceId = undefined; } private createServer(): CompassToolServer { @@ -181,22 +177,16 @@ export class ToolsController { }, logger: this.serverLogger, }); - const deviceId = DeviceId.create(this.serverLogger); const telemetry = createCompassMcpTelemetry( { logger: this.serverLogger, - deviceId, apiClient, keychain: this.keychain, - // Constructed enabled so the pipeline is set up and ready either way; - // the callback below is the live gate. - enabled: true, serverMetadata, }, () => this.context.enableMCPTelemetry ); this.apiClient = apiClient; - this.deviceId = deviceId; this.telemetry = telemetry; const server: CompassToolServer = { diff --git a/packages/compass-generative-ai/src/tools-telemetry.ts b/packages/compass-generative-ai/src/tools-telemetry.ts index fd5e5d8ac10..0110b9e99ce 100644 --- a/packages/compass-generative-ai/src/tools-telemetry.ts +++ b/packages/compass-generative-ai/src/tools-telemetry.ts @@ -1,6 +1,43 @@ import { AtlasTelemetry } from '@mongodb-js/mcp-atlas-telemetry'; import type { TelemetryConfig } from '@mongodb-js/mcp-atlas-telemetry'; -import type { TelemetryCommonProperties } from '@mongodb-js/mcp-types'; +import type { ApiClient } from '@mongodb-js/mcp-atlas-api-client'; +import { DeviceId } from '@mongodb-js/mcp-tools-mongodb'; +import type { LoggerBase } from '@mongodb-js/mcp-core'; +import type { + IDeviceId, + IKeychain, + ServerMetadata, + TelemetryCommonProperties, +} from '@mongodb-js/mcp-types'; + +export type CompassMcpTelemetryConfig = { + logger: LoggerBase; + apiClient: ApiClient; + keychain: IKeychain; + serverMetadata: ServerMetadata; +}; + +/** + * Resolves the machine id only when it is first asked for, so a disabled + * telemetry preference never reads the machine id. + */ +class LazyDeviceId implements IDeviceId { + private readonly logger: LoggerBase; + private resolved?: DeviceId; + + constructor(logger: LoggerBase) { + this.logger = logger; + } + + get(): Promise { + this.resolved ??= DeviceId.create(this.logger); + return this.resolved.get(); + } + + close(): void { + this.resolved?.close(); + } +} /** * The MCP telemetry pipeline for Compass's in-memory Database Tools server. @@ -10,12 +47,23 @@ import type { TelemetryCommonProperties } from '@mongodb-js/mcp-types'; * passed as `telemetryProperties`; * - whether events are collected is read live from the caller, so toggling * "usage statistics" takes effect without restarting the server. + * + * The pipeline is not started until the first event that is actually allowed + * through, so a disabled preference costs nothing: no machine id lookup, no + * container probe and no send timer. */ export class CompassMcpTelemetry extends AtlasTelemetry { private readonly isEnabled: () => boolean; + private readonly lazyDeviceId: LazyDeviceId; + private setupStarted = false; - constructor(config: TelemetryConfig, isEnabled: () => boolean) { + constructor( + config: TelemetryConfig, + lazyDeviceId: LazyDeviceId, + isEnabled: () => boolean + ) { super(config); + this.lazyDeviceId = lazyDeviceId; this.isEnabled = isEnabled; } @@ -23,6 +71,23 @@ export class CompassMcpTelemetry extends AtlasTelemetry { return this.isEnabled() && super.isTelemetryEnabled(); } + public override emitEvents( + events: Parameters[0] + ): void { + // `ToolBase` checks `isTelemetryEnabled()` before emitting, so this starts + // the pipeline on the first event that the preference actually allows. + if (this.isTelemetryEnabled() && !this.setupStarted) { + this.setupStarted = true; + void this.setup(); + } + super.emitEvents(events); + } + + public override async close(): Promise { + await super.close(); + this.lazyDeviceId.close(); + } + public override getCommonProperties(): TelemetryCommonProperties { return { ...super.getCommonProperties(), @@ -31,19 +96,20 @@ export class CompassMcpTelemetry extends AtlasTelemetry { } } -/** - * Builds and starts the Compass MCP telemetry pipeline. - * - * The pipeline is always constructed enabled so that turning the preference on - * mid-session starts collection; `isEnabled` is the live gate. (The v1 wiring - * only scheduled its send timer when telemetry happened to be enabled at server - * start, so flipping the preference on later collected nothing.) - */ export function createCompassMcpTelemetry( - config: TelemetryConfig, + config: CompassMcpTelemetryConfig, isEnabled: () => boolean ): CompassMcpTelemetry { - const instance = new CompassMcpTelemetry(config, isEnabled); - void instance.setup(); - return instance; + const deviceId = new LazyDeviceId(config.logger); + return new CompassMcpTelemetry( + { + ...config, + // Always true so that the live preference is the only gate; nothing is + // set up until `emitEvents` sees it enabled. + enabled: true, + deviceId, + }, + deviceId, + isEnabled + ); } From 707d48e25c488e244d25142b4a89b3c96925bdc4 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 00:12:09 +0200 Subject: [PATCH 05/23] refactor(compass-generative-ai): split MCP telemetry into its own modules Move CompassMcpTelemetry and its factory into compass-mcp-telemetry.ts and LazyDeviceId into lazy-device-id.ts, and trim the comments added alongside them. --- .../src/compass-mcp-telemetry.ts | 82 +++++++++++++ .../src/lazy-device-id.ts | 22 ++++ .../src/tools-controller.spec.ts | 2 +- .../src/tools-controller.ts | 37 ++---- .../src/tools-telemetry.ts | 115 ------------------ packages/compass-web/webpack.config.js | 6 +- 6 files changed, 118 insertions(+), 146 deletions(-) create mode 100644 packages/compass-generative-ai/src/compass-mcp-telemetry.ts create mode 100644 packages/compass-generative-ai/src/lazy-device-id.ts delete mode 100644 packages/compass-generative-ai/src/tools-telemetry.ts diff --git a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts new file mode 100644 index 00000000000..e27eeb21c1a --- /dev/null +++ b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts @@ -0,0 +1,82 @@ +import { AtlasTelemetry } from '@mongodb-js/mcp-atlas-telemetry'; +import type { + TelemetryBaseEvent, + TelemetryConfig, +} from '@mongodb-js/mcp-atlas-telemetry'; +import type { ApiClient } from '@mongodb-js/mcp-atlas-api-client'; +import type { LoggerBase } from '@mongodb-js/mcp-core'; +import type { + IDeviceId, + IKeychain, + ServerMetadata, + TelemetryCommonProperties, +} from '@mongodb-js/mcp-types'; +import { LazyDeviceId } from './lazy-device-id'; + +export type CompassMcpTelemetryConfig = { + logger: LoggerBase; + apiClient: ApiClient; + keychain: IKeychain; + serverMetadata: ServerMetadata; +}; + +/** + * MCP telemetry for Compass's in-memory Database Tools server. + * + * Adds the `hosting_mode` property the v1 integration set, and reads the usage + * statistics preference live so toggling it needs no restart. Nothing is set up + * — no machine id, no container probe, no send timer — until the first event + * the preference allows through. + */ +export class CompassMcpTelemetry extends AtlasTelemetry { + private readonly isEnabled: () => boolean; + private readonly deviceIdRef: IDeviceId; + private setupStarted = false; + + constructor(config: TelemetryConfig, isEnabled: () => boolean) { + super(config); + this.deviceIdRef = config.deviceId; + this.isEnabled = isEnabled; + } + + public override isTelemetryEnabled(): boolean { + return this.isEnabled() && super.isTelemetryEnabled(); + } + + public override emitEvents(events: TelemetryBaseEvent[]): void { + // ToolBase checks isTelemetryEnabled() before emitting, so setup only runs + // for events the preference actually allows. + if (this.isTelemetryEnabled() && !this.setupStarted) { + this.setupStarted = true; + void this.setup(); + } + super.emitEvents(events); + } + + public override async close(): Promise { + await super.close(); + this.deviceIdRef.close(); + } + + public override getCommonProperties(): TelemetryCommonProperties { + return { + ...super.getCommonProperties(), + hosting_mode: 'compass', + }; + } +} + +export function createCompassMcpTelemetry( + config: CompassMcpTelemetryConfig, + isEnabled: () => boolean +): CompassMcpTelemetry { + return new CompassMcpTelemetry( + { + ...config, + // Always true so the live preference is the only gate. + enabled: true, + deviceId: new LazyDeviceId(config.logger), + }, + isEnabled + ); +} diff --git a/packages/compass-generative-ai/src/lazy-device-id.ts b/packages/compass-generative-ai/src/lazy-device-id.ts new file mode 100644 index 00000000000..240cbab8173 --- /dev/null +++ b/packages/compass-generative-ai/src/lazy-device-id.ts @@ -0,0 +1,22 @@ +import { DeviceId } from '@mongodb-js/mcp-tools-mongodb'; +import type { LoggerBase } from '@mongodb-js/mcp-core'; +import type { IDeviceId } from '@mongodb-js/mcp-types'; + +/** Resolves the machine id on first use so it is never read while telemetry is off. */ +export class LazyDeviceId implements IDeviceId { + private readonly logger: LoggerBase; + private resolved?: DeviceId; + + constructor(logger: LoggerBase) { + this.logger = logger; + } + + get(): Promise { + this.resolved ??= DeviceId.create(this.logger); + return this.resolved.get(); + } + + close(): void { + this.resolved?.close(); + } +} diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 7786f878fb1..85435af17a9 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -15,7 +15,7 @@ import type { AtlasAdminApiService } from '@mongodb-js/atlas-admin-api/provider' import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; import { DeviceId } from '@mongodb-js/mcp-tools-mongodb'; import type { ITelemetry } from '@mongodb-js/mcp-types'; -import type { CompassMcpTelemetry } from './tools-telemetry'; +import type { CompassMcpTelemetry } from './compass-mcp-telemetry'; describe('ToolsController', function () { let sandbox: sinon.SinonSandbox; diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index 74874b1086c..c25451969a8 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -24,7 +24,7 @@ import { import { createCompassMcpTelemetry, type CompassMcpTelemetry, -} from './tools-telemetry'; +} from './compass-mcp-telemetry'; import type { ServerMetadata, ToolExecutionContext, @@ -61,29 +61,21 @@ type ToolsContext = CompassContext & { connections: ToolsConnectParams[]; }; -/** - * Compass reports the MCP server name/version to the client and the driver - * `appName`; the latter is always overridden by {@link ToolsConnectionManager}, - * so only the name matters here. - */ +// Version is unused: telemetry is the only consumer and ToolsConnectionManager +// always overrides the driver appName. const serverMetadata: ServerMetadata = { mcpServerName: 'mongodb-compass', version: '0.0.0', }; -/** The Atlas endpoint MCP telemetry events are sent to (matching the v1 default). */ const ATLAS_API_BASE_URL = 'https://cloud.mongodb.com/'; -/** - * The MCP server only ever runs inside a browser or the Electron renderer, so - * the platform `fetch`/`Request` pair is used directly. - */ +// Compass only ever runs this in a browser or the Electron renderer. const httpClient: HttpClient = { fetch: (...args) => globalThis.fetch(...args), Request: globalThis.Request, }; -/** The in-memory server composition the tools read their services from. */ type CompassToolServer = MongoDBToolServer & { tools: AnyToolBase[] }; const READ_ONLY_DATABASE_TOOL_NAMES = new Set( @@ -154,7 +146,6 @@ export class ToolsController { }); } - /** Flushes and releases the telemetry pipeline and its API client. */ private async closeTelemetry(): Promise { await this.telemetry?.close(); await this.apiClient?.close(); @@ -190,8 +181,8 @@ export class ToolsController { this.telemetry = telemetry; const server: CompassToolServer = { - // Defaults mirror `UserConfigSchema`; Compass only exposes read-only - // database tools, so the write- and Atlas-specific options are unused. + // Defaults mirror `UserConfigSchema`; Compass only exposes read-only tools, + // so the write- and Atlas-specific options are unused. config: { transport: 'stdio', httpResponseType: 'sse', @@ -215,14 +206,11 @@ export class ToolsController { this.connectionManager, this.keychain ), - // `MongoDBToolServices` types the handler's return as - // `{ errorHandled, result }` even though `result` is only read when - // `errorHandled` is true. Compass never handles connection errors, so the - // narrower `ConnectionErrorUnhandled` is safe here. + // `MongoDBToolServices` requires a `result` that is only read when + // `errorHandled` is true; Compass never handles connection errors. connectionErrorHandler: createConnectionErrorHandler() as MongoDBToolServer['connectionErrorHandler'], - // Only the `export` tool reads the exports manager, and Compass does not - // register it. + // Only the unregistered `export` tool reads this. exportsManager: { createJSONExport: () => { return Promise.reject( @@ -307,9 +295,7 @@ export class ToolsController { inputSchema: z.object( Object.fromEntries( Object.entries(toolBase.argsShape()) - // Compass always runs against the user's active connection, so - // the connection handle is never something the model should - // pick; it is injected in `execute` below. + // Injected in `execute`; the model never picks a connection. .filter(([key]) => key !== 'connectionId') .map(([key, value]) => { // TODO: MCP server applies transformations like toEJSON. @@ -478,8 +464,7 @@ export class ToolsController { ); } catch (error: any) { // In case of errors we don't want Compass to crash so we - // silence MCP start errors and instead log them for debugging. Anything - // createServer() managed to build before throwing is released here. + // silence MCP start errors and instead log them for debugging. await this.closeTelemetry(); this.logger.log.error( this.logger.mongoLogId(1_001_000_404), diff --git a/packages/compass-generative-ai/src/tools-telemetry.ts b/packages/compass-generative-ai/src/tools-telemetry.ts deleted file mode 100644 index 0110b9e99ce..00000000000 --- a/packages/compass-generative-ai/src/tools-telemetry.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { AtlasTelemetry } from '@mongodb-js/mcp-atlas-telemetry'; -import type { TelemetryConfig } from '@mongodb-js/mcp-atlas-telemetry'; -import type { ApiClient } from '@mongodb-js/mcp-atlas-api-client'; -import { DeviceId } from '@mongodb-js/mcp-tools-mongodb'; -import type { LoggerBase } from '@mongodb-js/mcp-core'; -import type { - IDeviceId, - IKeychain, - ServerMetadata, - TelemetryCommonProperties, -} from '@mongodb-js/mcp-types'; - -export type CompassMcpTelemetryConfig = { - logger: LoggerBase; - apiClient: ApiClient; - keychain: IKeychain; - serverMetadata: ServerMetadata; -}; - -/** - * Resolves the machine id only when it is first asked for, so a disabled - * telemetry preference never reads the machine id. - */ -class LazyDeviceId implements IDeviceId { - private readonly logger: LoggerBase; - private resolved?: DeviceId; - - constructor(logger: LoggerBase) { - this.logger = logger; - } - - get(): Promise { - this.resolved ??= DeviceId.create(this.logger); - return this.resolved.get(); - } - - close(): void { - this.resolved?.close(); - } -} - -/** - * The MCP telemetry pipeline for Compass's in-memory Database Tools server. - * - * Two Compass-specific behaviours on top of {@link AtlasTelemetry}: - * - every event carries `hosting_mode: 'compass'`, which the v1 integration - * passed as `telemetryProperties`; - * - whether events are collected is read live from the caller, so toggling - * "usage statistics" takes effect without restarting the server. - * - * The pipeline is not started until the first event that is actually allowed - * through, so a disabled preference costs nothing: no machine id lookup, no - * container probe and no send timer. - */ -export class CompassMcpTelemetry extends AtlasTelemetry { - private readonly isEnabled: () => boolean; - private readonly lazyDeviceId: LazyDeviceId; - private setupStarted = false; - - constructor( - config: TelemetryConfig, - lazyDeviceId: LazyDeviceId, - isEnabled: () => boolean - ) { - super(config); - this.lazyDeviceId = lazyDeviceId; - this.isEnabled = isEnabled; - } - - public override isTelemetryEnabled(): boolean { - return this.isEnabled() && super.isTelemetryEnabled(); - } - - public override emitEvents( - events: Parameters[0] - ): void { - // `ToolBase` checks `isTelemetryEnabled()` before emitting, so this starts - // the pipeline on the first event that the preference actually allows. - if (this.isTelemetryEnabled() && !this.setupStarted) { - this.setupStarted = true; - void this.setup(); - } - super.emitEvents(events); - } - - public override async close(): Promise { - await super.close(); - this.lazyDeviceId.close(); - } - - public override getCommonProperties(): TelemetryCommonProperties { - return { - ...super.getCommonProperties(), - hosting_mode: 'compass', - }; - } -} - -export function createCompassMcpTelemetry( - config: CompassMcpTelemetryConfig, - isEnabled: () => boolean -): CompassMcpTelemetry { - const deviceId = new LazyDeviceId(config.logger); - return new CompassMcpTelemetry( - { - ...config, - // Always true so that the live preference is the only gate; nothing is - // set up until `emitEvents` sees it enabled. - enabled: true, - deviceId, - }, - deviceId, - isEnabled - ); -} diff --git a/packages/compass-web/webpack.config.js b/packages/compass-web/webpack.config.js index aa27fbd8cc2..307996beed0 100644 --- a/packages/compass-web/webpack.config.js +++ b/packages/compass-web/webpack.config.js @@ -186,10 +186,8 @@ module.exports = (env, args) => { 'mongodb-client-encryption/package.json': localPolyfill('throwError'), 'mongodb-client-encryption': localPolyfill('throwError'), - // @mongodb-js/mcp-tools-mongodb dynamically imports node-machine-id to - // compute a device id. Compass doesn't use that path, and leaving it - // resolvable emits a dynamic-import chunk that breaks the MMS - // COMPILE_CLIENT_BAZEL task. + // Left resolvable, the device-id dynamic import emits a chunk that + // breaks the MMS COMPILE_CLIENT_BAZEL task. 'node-machine-id': localPolyfill('throwError'), }, }, From f2fdf74a6318ca38c973a5c889b479f5785c188c Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 00:21:42 +0200 Subject: [PATCH 06/23] refactor(compass-generative-ai): let CompassMcpTelemetry own its teardown The telemetry module now builds the Atlas API client it sends through, so closing the pipeline releases everything it uses and ToolsController no longer has to know about the client at all. Also abort the machine id lookup before the flush rather than after: the base close() waits for setup, which waits on that lookup, so aborting afterwards never shortened shutdown. --- .../src/compass-mcp-telemetry.ts | 33 +++++++++++++++++-- .../src/tools-controller.ts | 26 --------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts index e27eeb21c1a..7faeb5c4bdf 100644 --- a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts +++ b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts @@ -3,7 +3,11 @@ import type { TelemetryBaseEvent, TelemetryConfig, } from '@mongodb-js/mcp-atlas-telemetry'; -import type { ApiClient } from '@mongodb-js/mcp-atlas-api-client'; +import { + ApiClient, + userAgentFromServerMetadata, + type HttpClient, +} from '@mongodb-js/mcp-atlas-api-client'; import type { LoggerBase } from '@mongodb-js/mcp-core'; import type { IDeviceId, @@ -13,9 +17,16 @@ import type { } from '@mongodb-js/mcp-types'; import { LazyDeviceId } from './lazy-device-id'; +const ATLAS_API_BASE_URL = 'https://cloud.mongodb.com/'; + +// Compass only ever runs this in a browser or the Electron renderer. +const httpClient: HttpClient = { + fetch: (...args) => globalThis.fetch(...args), + Request: globalThis.Request, +}; + export type CompassMcpTelemetryConfig = { logger: LoggerBase; - apiClient: ApiClient; keychain: IKeychain; serverMetadata: ServerMetadata; }; @@ -30,11 +41,15 @@ export type CompassMcpTelemetryConfig = { */ export class CompassMcpTelemetry extends AtlasTelemetry { private readonly isEnabled: () => boolean; + // Held separately from the base class' private fields so `close` can release + // them; the pipeline itself only ever flushes. + private readonly apiClientRef: ApiClient; private readonly deviceIdRef: IDeviceId; private setupStarted = false; constructor(config: TelemetryConfig, isEnabled: () => boolean) { super(config); + this.apiClientRef = config.apiClient; this.deviceIdRef = config.deviceId; this.isEnabled = isEnabled; } @@ -54,8 +69,12 @@ export class CompassMcpTelemetry extends AtlasTelemetry { } public override async close(): Promise { - await super.close(); + // Abort first: `super.close()` waits for setup, which waits on the machine + // id, so aborting afterwards would be too late to shorten shutdown. this.deviceIdRef.close(); + // Flush before releasing the client the drain sends through. + await super.close(); + await this.apiClientRef.close(); } public override getCommonProperties(): TelemetryCommonProperties { @@ -76,6 +95,14 @@ export function createCompassMcpTelemetry( // Always true so the live preference is the only gate. enabled: true, deviceId: new LazyDeviceId(config.logger), + apiClient: new ApiClient({ + options: { + baseUrl: ATLAS_API_BASE_URL, + userAgent: userAgentFromServerMetadata(config.serverMetadata), + httpClient, + }, + logger: config.logger, + }), }, isEnabled ); diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index c25451969a8..ca8dd156155 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -10,11 +10,6 @@ import { NoopMetrics, type AnyToolBase, } from '@mongodb-js/mcp-core'; -import { - ApiClient, - userAgentFromServerMetadata, - type HttpClient, -} from '@mongodb-js/mcp-atlas-api-client'; import { AGG_COUNT_MAX_TIME_MS_CAP, MongoDBTools, @@ -68,14 +63,6 @@ const serverMetadata: ServerMetadata = { version: '0.0.0', }; -const ATLAS_API_BASE_URL = 'https://cloud.mongodb.com/'; - -// Compass only ever runs this in a browser or the Electron renderer. -const httpClient: HttpClient = { - fetch: (...args) => globalThis.fetch(...args), - Request: globalThis.Request, -}; - type CompassToolServer = MongoDBToolServer & { tools: AnyToolBase[] }; const READ_ONLY_DATABASE_TOOL_NAMES = new Set( @@ -101,7 +88,6 @@ export class ToolsController { private readonly keychain = new Keychain(); private readonly serverLogger: CompositeLogger; private telemetry?: CompassMcpTelemetry; - private apiClient?: ApiClient; private connectionManager: ToolsConnectionManager; private connectionIdByToolCallId: Record = Object.create(null); @@ -148,9 +134,7 @@ export class ToolsController { private async closeTelemetry(): Promise { await this.telemetry?.close(); - await this.apiClient?.close(); this.telemetry = undefined; - this.apiClient = undefined; } private createServer(): CompassToolServer { @@ -160,24 +144,14 @@ export class ToolsController { }); const tools: AnyToolBase[] = []; - const apiClient = new ApiClient({ - options: { - baseUrl: ATLAS_API_BASE_URL, - userAgent: userAgentFromServerMetadata(serverMetadata), - httpClient, - }, - logger: this.serverLogger, - }); const telemetry = createCompassMcpTelemetry( { logger: this.serverLogger, - apiClient, keychain: this.keychain, serverMetadata, }, () => this.context.enableMCPTelemetry ); - this.apiClient = apiClient; this.telemetry = telemetry; const server: CompassToolServer = { From 082acf62a12c7e206299830dd41a2a69e0bd9f56 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 09:50:24 +0200 Subject: [PATCH 07/23] docs(compass-generative-ai): point the telemetry field shadows at the upstream fix --- packages/compass-generative-ai/src/compass-mcp-telemetry.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts index 7faeb5c4bdf..373d649e2d3 100644 --- a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts +++ b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts @@ -41,8 +41,8 @@ export type CompassMcpTelemetryConfig = { */ export class CompassMcpTelemetry extends AtlasTelemetry { private readonly isEnabled: () => boolean; - // Held separately from the base class' private fields so `close` can release - // them; the pipeline itself only ever flushes. + // Shadow the base class' private fields so `close` can release them. + // TODO(mongodb-mcp-server#1620): drop these once the fields are protected. private readonly apiClientRef: ApiClient; private readonly deviceIdRef: IDeviceId; private setupStarted = false; From 22420cd6f6415dd25aa24ccd880aa6beb8bb5cf6 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 09:56:17 +0200 Subject: [PATCH 08/23] test(compass-generative-ai): cover the telemetry preference set before server start --- .../src/tools-controller.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 85435af17a9..830407de92c 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -520,6 +520,19 @@ describe('ToolsController', function () { ); }); + it('honours the preference set before the server starts', async function () { + toolsController.setContext({ + enableMCPTelemetry: true, + connections: [], + }); + + await toolsController.startServer(); + + expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( + true + ); + }); + it('resolves no device id while telemetry is disabled', async function () { await toolsController.startServer(); From 04443e8b95e6616316d01866289c9a33c054e214 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 09:59:21 +0200 Subject: [PATCH 09/23] docs(compass-generative-ai): point the MCP service workarounds at their upstream fixes --- packages/compass-generative-ai/src/tools-controller.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index ca8dd156155..52b12caee1f 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -182,9 +182,11 @@ export class ToolsController { ), // `MongoDBToolServices` requires a `result` that is only read when // `errorHandled` is true; Compass never handles connection errors. + // TODO(mongodb-mcp-server#1621): drop this cast once released. connectionErrorHandler: createConnectionErrorHandler() as MongoDBToolServer['connectionErrorHandler'], // Only the unregistered `export` tool reads this. + // TODO(mongodb-mcp-server#1621): use NoopExportsManager once released. exportsManager: { createJSONExport: () => { return Promise.reject( From 66a83f979141ed72d28d43521a44e44dfad92269 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 10:12:13 +0200 Subject: [PATCH 10/23] test: restore the telemetry sync test and cover the disabled paths 'syncs telemetry setting with runner userConfig' asserted on the v1 runner's config, which the migration removed, so it came back as 'syncs telemetry setting with the tools config' asserting the pipeline's own gate. Also cover the other ways telemetry ends up off: DO_NOT_TRACK, and the trackUsageStatistics preference reaching the tools context from the provider. --- .../src/compass-assistant-provider.spec.tsx | 40 +++++++++++++++++++ .../src/tools-controller.spec.ts | 37 +++++++++++------ 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx index 61d86b5bd51..44ac1c5d259 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx @@ -346,6 +346,7 @@ describe('CompassAssistantProvider', function () { enableToolCalling = true, enableGenAIToolCallingAtlasProject = true, enableGenAIToolCalling = true, + trackUsageStatistics, maxTimeMS, query, pipeline, @@ -361,6 +362,7 @@ describe('CompassAssistantProvider', function () { enableToolCalling?: boolean; enableGenAIToolCallingAtlasProject?: boolean; enableGenAIToolCalling?: boolean; + trackUsageStatistics?: boolean; maxTimeMS?: number; query?: string; pipeline?: string; @@ -391,6 +393,9 @@ describe('CompassAssistantProvider', function () { enableToolCalling, enableGenAIToolCallingAtlasProject, enableGenAIToolCalling, + ...(trackUsageStatistics !== undefined + ? { trackUsageStatistics } + : {}), maxTimeMS, }, } @@ -692,6 +697,41 @@ describe('CompassAssistantProvider', function () { }); }); + it('disables MCP telemetry when usage statistics are off', async function () { + const mockChat = new Chat({ messages: [] }); + const sendMessageSpy = sinon.spy(mockChat, 'sendMessage'); + const mockToolsController = { + setActiveTools: sinon.stub(), + getActiveTools: sinon.stub(), + setContext: sinon.stub(), + startServer: sinon.stub().resolves(), + stopServer: sinon.stub().resolves(), + setConnectionIdForToolCall: sinon.stub(), + }; + + await renderOpenAssistantDrawer({ + chat: mockChat, + toolsController: mockToolsController, + enableToolCalling: true, + trackUsageStatistics: false, + }); + + userEvent.type( + screen.getByPlaceholderText('Ask a question'), + 'Hello assistant' + ); + userEvent.click(screen.getByLabelText('Send message')); + + await waitFor(() => { + expect(sendMessageSpy.calledOnce).to.be.true; + }); + + expect(mockToolsController.setContext.callCount).to.equal(1); + expect(mockToolsController.setContext.firstCall.args[0]).to.deep.include({ + enableMCPTelemetry: false, + }); + }); + it('disables tools if enableToolCalling and enableGenAIToolCallingAtlasProject are enabled but enableGenAIToolCalling setting is disabled', async function () { const mockChat = new Chat({ messages: [ diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 830407de92c..096fa2c9ef4 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -484,25 +484,13 @@ describe('ToolsController', function () { ]); }; - it('starts disabled until the context enables it', async function () { + it('syncs telemetry setting with the tools config', async function () { await toolsController.startServer(); expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( false ); - toolsController.setContext({ - enableMCPTelemetry: true, - connections: [], - }); - - expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( - true - ); - }); - - it('stops collecting when the preference is turned back off', async function () { - await toolsController.startServer(); toolsController.setContext({ enableMCPTelemetry: true, connections: [], @@ -520,6 +508,29 @@ describe('ToolsController', function () { ); }); + it('stays disabled when DO_NOT_TRACK is set', async function () { + const hadDoNotTrack = 'DO_NOT_TRACK' in process.env; + process.env.DO_NOT_TRACK = '1'; + try { + await toolsController.startServer(); + toolsController.setContext({ + enableMCPTelemetry: true, + connections: [], + }); + + expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( + false + ); + + emitEvent(toolsController.server?.telemetry); + expect(createDeviceId.called).to.equal(false); + } finally { + if (!hadDoNotTrack) { + delete process.env.DO_NOT_TRACK; + } + } + }); + it('honours the preference set before the server starts', async function () { toolsController.setContext({ enableMCPTelemetry: true, From a6f75ce5e8e8011c3cb1d8bd9112df3374d35698 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 10:16:11 +0200 Subject: [PATCH 11/23] test(compass-generative-ai): drop the DO_NOT_TRACK case Compass never reads DO_NOT_TRACK, so the test only pinned inherited upstream behaviour rather than anything Compass controls. --- .../src/tools-controller.spec.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 096fa2c9ef4..0fd4567410d 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -508,29 +508,6 @@ describe('ToolsController', function () { ); }); - it('stays disabled when DO_NOT_TRACK is set', async function () { - const hadDoNotTrack = 'DO_NOT_TRACK' in process.env; - process.env.DO_NOT_TRACK = '1'; - try { - await toolsController.startServer(); - toolsController.setContext({ - enableMCPTelemetry: true, - connections: [], - }); - - expect(toolsController.server?.telemetry.isTelemetryEnabled()).to.equal( - false - ); - - emitEvent(toolsController.server?.telemetry); - expect(createDeviceId.called).to.equal(false); - } finally { - if (!hadDoNotTrack) { - delete process.env.DO_NOT_TRACK; - } - } - }); - it('honours the preference set before the server starts', async function () { toolsController.setContext({ enableMCPTelemetry: true, From c76e3523f84c8cc4b75987dddd6475400408dd44 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 16 Oct 2026 10:25:22 +0200 Subject: [PATCH 12/23] docs(compass-generative-ai): point the MCP workaround TODOs at the combined upstream PR --- packages/compass-generative-ai/src/tools-controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index 52b12caee1f..ed84c4d0b0e 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -182,11 +182,11 @@ export class ToolsController { ), // `MongoDBToolServices` requires a `result` that is only read when // `errorHandled` is true; Compass never handles connection errors. - // TODO(mongodb-mcp-server#1621): drop this cast once released. + // TODO(mongodb-mcp-server#1620): drop this cast once released. connectionErrorHandler: createConnectionErrorHandler() as MongoDBToolServer['connectionErrorHandler'], // Only the unregistered `export` tool reads this. - // TODO(mongodb-mcp-server#1621): use NoopExportsManager once released. + // TODO(mongodb-mcp-server#1620): use NoopExportsManager once released. exportsManager: { createJSONExport: () => { return Promise.reject( From 84c948b5534b032ff491fce4e3676cd58916b517 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Tue, 27 Oct 2026 10:21:26 +0100 Subject: [PATCH 13/23] test(compass-generative-ai): assert MCP telemetry actually reaches the API client The existing telemetry tests only asserted the enable/disable gate, so a broken pipeline or a dropped hosting_mode property would still have passed. Run a real tool call and assert the event handed to the Atlas API client carries the tool name and Compass properties, plus the counterpart that nothing is sent while telemetry is off. --- .../src/tools-controller.spec.ts | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 0fd4567410d..1f6d5a13bff 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -14,6 +14,7 @@ import { import type { AtlasAdminApiService } from '@mongodb-js/atlas-admin-api/provider'; import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; import { DeviceId } from '@mongodb-js/mcp-tools-mongodb'; +import { ApiClient } from '@mongodb-js/mcp-atlas-api-client'; import type { ITelemetry } from '@mongodb-js/mcp-types'; import type { CompassMcpTelemetry } from './compass-mcp-telemetry'; @@ -551,6 +552,85 @@ describe('ToolsController', function () { 'compass' ); }); + + describe('when a database tool runs', function () { + let sendEvents: sinon.SinonStub; + + beforeEach(async function () { + sendEvents = sandbox.stub(ApiClient.prototype, 'sendEvents').resolves(); + sandbox.stub(NodeDriverServiceProvider, 'connect').resolves({ + close: sandbox.stub().resolves(), + initialDb: 'test', + listDatabases: sandbox.stub().resolves({ + databases: [{ name: 'admin', sizeOnDisk: 1024 }], + }), + } as any); + + await toolsController.startServer(); + toolsController.setActiveTools(new Set(['db-read'])); + toolsController.setConnectionIdForToolCall({ + toolCallId: 'call-1', + connectionId: 'conn-1', + }); + }); + + const setTelemetryEnabled = (enableMCPTelemetry: boolean) => { + toolsController.setContext({ + enableMCPTelemetry, + connections: [ + { + connectionId: 'conn-1', + connectionString: 'mongodb://localhost:27017', + connectOptions: {} as any, + }, + ], + }); + }; + + const runListDatabases = async () => { + const tools = toolsController.getActiveTools(); + await tools['list-databases'].execute?.({}, { + toolCallId: 'call-1', + } as any); + }; + + // Tool telemetry is fire-and-forget, and the pipeline only drains on + // close or on its timer, so give the event time to reach the client. + const waitForSend = async () => { + const deadline = Date.now() + 2000; + while (!sendEvents.called && Date.now() < deadline) { + await new Promise((resolve) => setTimeout(resolve, 5)); + } + }; + + it('reports the tool call to the Atlas API client', async function () { + setTelemetryEnabled(true); + await runListDatabases(); + await toolsController.stopServer(); + await waitForSend(); + + expect(sendEvents.called).to.equal(true); + const [events] = sendEvents.firstCall.args; + expect(events[0].properties).to.include({ + command: 'list-databases', + component: 'tool', + category: 'mongodb', + result: 'success', + hosting_mode: 'compass', + }); + }); + + it('reports nothing while telemetry is disabled', async function () { + setTelemetryEnabled(false); + await runListDatabases(); + await toolsController.stopServer(); + + // Long enough for the fire-and-forget tool telemetry and the drain. + await new Promise((resolve) => setTimeout(resolve, 100)); + + expect(sendEvents.called).to.equal(false); + }); + }); }); describe('setConnectionIdForToolCall', function () { From 8a671e5acfec41b3fafab5cf0764002a9ad60b83 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 6 Nov 2026 13:59:27 +0100 Subject: [PATCH 14/23] fix(compass-utilities): keep the ai-assistant utility entry free of exports The entry module has to stay export-free: compass-web bundles it as an ESM worker chunk and webpack's ModuleLibraryPlugin crashes on an unused export of a chunk entry module. `main` still has to be importable for the utility spec, so the implementation now lives in `main.mts` and the entry only calls it. --- .../src/ai-assistant/index.mts | 57 +------------------ .../src/ai-assistant/index.spec.mts | 2 +- .../src/ai-assistant/main.mts | 55 ++++++++++++++++++ 3 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 packages/compass-utilities/src/ai-assistant/main.mts diff --git a/packages/compass-utilities/src/ai-assistant/index.mts b/packages/compass-utilities/src/ai-assistant/index.mts index 92933444327..bf5985a19af 100644 --- a/packages/compass-utilities/src/ai-assistant/index.mts +++ b/packages/compass-utilities/src/ai-assistant/index.mts @@ -1,58 +1,5 @@ -import process from 'node:process'; - -import { listen } from '@mongodb-js/compass-utils'; -import { ToolsHost } from '@mongodb-js/compass-generative-ai/utility'; -import { createUtilityLogger } from '../logging.mts'; -import type { UtilityParentPort } from '../ipc.mts'; -import { currentParentPort, onPort } from '../ipc.mts'; - -const name = 'ai-assistant'; - -function main(parentPort: UtilityParentPort): Disposable { - using ds = new DisposableStack(); - - ds.use( - listen(process, 'unhandledRejection', (reason) => { - throw reason; - }) - ); - - const logger = createUtilityLogger(parentPort, name); - - const hosts = new Set(); - ds.defer(() => { - for (const host of hosts) { - void host.stop(); - } - }); - - ds.use( - onPort(parentPort, (port) => { - const host = new ToolsHost(port, { logger }); - hosts.add(host); - listen( - port, - 'close', - () => { - hosts.delete(host); - void host.stop().catch((error) => { - logger.log.error( - logger.mongoLogId(1_001_000_454), - 'ai-assistant', - 'Error when stopping the tools host', - { - error: error instanceof Error ? error.message : String(error), - } - ); - }); - }, - { once: true } - ); - }) - ); - - return ds.move(); -} +import { currentParentPort } from '../ipc.mts'; +import { main } from './main.mts'; const parentPort = currentParentPort(); if (parentPort) { diff --git a/packages/compass-utilities/src/ai-assistant/index.spec.mts b/packages/compass-utilities/src/ai-assistant/index.spec.mts index 3e72634e390..1493a0baac5 100644 --- a/packages/compass-utilities/src/ai-assistant/index.spec.mts +++ b/packages/compass-utilities/src/ai-assistant/index.spec.mts @@ -2,7 +2,7 @@ import process from 'node:process'; import { EventEmitter } from 'node:events'; import { expect } from 'chai'; import type { MessagePortMain, ParentPort } from 'electron'; -import { main } from './index.mts'; +import { main } from './main.mts'; function createFakePort(): MessagePortMain & { sent: unknown[] } { const sent: unknown[] = []; diff --git a/packages/compass-utilities/src/ai-assistant/main.mts b/packages/compass-utilities/src/ai-assistant/main.mts new file mode 100644 index 00000000000..68cc3cf7abe --- /dev/null +++ b/packages/compass-utilities/src/ai-assistant/main.mts @@ -0,0 +1,55 @@ +import process from 'node:process'; + +import { listen } from '@mongodb-js/compass-utils'; +import { ToolsHost } from '@mongodb-js/compass-generative-ai/utility'; +import { createUtilityLogger } from '../logging.mts'; +import type { UtilityParentPort } from '../ipc.mts'; +import { onPort } from '../ipc.mts'; + +export const name = 'ai-assistant'; + +export function main(parentPort: UtilityParentPort): Disposable { + using ds = new DisposableStack(); + + ds.use( + listen(process, 'unhandledRejection', (reason) => { + throw reason; + }) + ); + + const logger = createUtilityLogger(parentPort, name); + + const hosts = new Set(); + ds.defer(() => { + for (const host of hosts) { + void host.stop(); + } + }); + + ds.use( + onPort(parentPort, (port) => { + const host = new ToolsHost(port, { logger }); + hosts.add(host); + listen( + port, + 'close', + () => { + hosts.delete(host); + void host.stop().catch((error) => { + logger.log.error( + logger.mongoLogId(1_001_000_454), + 'ai-assistant', + 'Error when stopping the tools host', + { + error: error instanceof Error ? error.message : String(error), + } + ); + }); + }, + { once: true } + ); + }) + ); + + return ds.move(); +} From b4988c8dacc584a27994a0ac0911030556ce9d39 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 6 Nov 2026 14:36:21 +0100 Subject: [PATCH 15/23] chore(compass-generative-ai): upgrade @mongodb-js/mcp-* to 3.2.2 Drops the mongodb-mcp-server#1620 workarounds now that the upstream fields are protected, the connection error handler type matches, and NoopExportsManager is exported. The upgrade also removes the per-operation `maxTimeMS`, so the Compass preference is applied as the connection's driver `timeoutMS`, and the count caps are renamed to `queryCountTimeoutMs`/`aggregationCountTimeoutMs`. --- package-lock.json | 498 +++++++++--------- packages/compass-generative-ai/package.json | 10 +- .../src/compass-mcp-telemetry.ts | 11 +- .../src/tools-connection-manager.spec.ts | 17 + .../src/tools-connection-manager.ts | 9 +- .../src/tools-controller.spec.ts | 10 +- .../tools/infrastructure/tools-host.spec.ts | 2 +- .../src/tools/infrastructure/tools-host.ts | 28 +- 8 files changed, 281 insertions(+), 304 deletions(-) diff --git a/package-lock.json b/package-lock.json index b09151182c1..2f39c086e76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6737,9 +6737,9 @@ } }, "node_modules/@hono/node-server": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.5.tgz", - "integrity": "sha512-MgP/I06GdvsilDspMk/qmRzpk8LOUStP6jFAbSRi40W09DhoyUn+Mj7eyKICPqeYKybOjVFLVIAQzvu1bfIa7Q==", + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.6.tgz", + "integrity": "sha512-p/KH9MnfNcsm3sR6x4lNgm5j+QN4Et8srKredl9DZfXiyZ1UQ3aQ2YVpFLbqktYN5JI+DB+VZFKM2PqE5hLKjQ==", "license": "MIT", "engines": { "node": ">=20" @@ -8603,6 +8603,16 @@ "integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", "license": "MIT" }, + "node_modules/@mcp-ui/server": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@mcp-ui/server/-/server-6.1.0.tgz", + "integrity": "sha512-uxv9JrzEzHfdGo/V/KTFKp5WeCOsaiAoQZ3V88jw1dSXUofONEw4rMwEvVP3612aj/unS2TIeM0o1I0asfIxtw==", + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/ext-apps": "^0.3.1", + "@modelcontextprotocol/sdk": "^1.25.1" + } + }, "node_modules/@microsoft/api-extractor": { "version": "7.59.4", "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.59.4.tgz", @@ -8778,19 +8788,53 @@ "node": ">=20" } }, - "node_modules/@modelcontextprotocol/core/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "node_modules/@modelcontextprotocol/ext-apps": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/ext-apps/-/ext-apps-0.3.1.tgz", + "integrity": "sha512-Iivz2KwWK8xlRbiWwFB/C4NXqE8VJBoRCbBkJCN98ST2UbQvA6kfyebcLsypiqylJS467XOOaBcI9DeQ3t+zqA==", + "hasInstallScript": true, "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" + "workspaces": [ + "examples/*" + ], + "optionalDependencies": { + "@oven/bun-darwin-aarch64": "^1.2.21", + "@oven/bun-darwin-x64": "^1.2.21", + "@oven/bun-darwin-x64-baseline": "^1.2.21", + "@oven/bun-linux-aarch64": "^1.2.21", + "@oven/bun-linux-aarch64-musl": "^1.2.21", + "@oven/bun-linux-x64": "^1.2.21", + "@oven/bun-linux-x64-baseline": "^1.2.21", + "@oven/bun-linux-x64-musl": "^1.2.21", + "@oven/bun-linux-x64-musl-baseline": "^1.2.21", + "@oven/bun-windows-x64": "^1.2.21", + "@oven/bun-windows-x64-baseline": "^1.2.21", + "@rollup/rollup-darwin-arm64": "^4.53.3", + "@rollup/rollup-darwin-x64": "^4.53.3", + "@rollup/rollup-linux-arm64-gnu": "^4.53.3", + "@rollup/rollup-linux-x64-gnu": "^4.53.3", + "@rollup/rollup-win32-arm64-msvc": "^4.53.3", + "@rollup/rollup-win32-x64-msvc": "^4.53.3" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": "^1.24.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } } }, "node_modules/@modelcontextprotocol/sdk": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.1.tgz", - "integrity": "sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw==", + "version": "1.32.2", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.2.tgz", + "integrity": "sha512-SWsVtH/0vULSQStoZ6xxH2K09Li8fXYTMC64ZeogCdpZ3XSi1eCPOByV1OpuJxuI3OcmHhosDWYyii07tpPsLw==", "license": "MIT", "dependencies": { "@hono/node-server": "^1.19.9 || ^2.0.5", @@ -8841,9 +8885,9 @@ } }, "node_modules/@modelcontextprotocol/sdk/node_modules/ajv": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", - "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", @@ -8894,9 +8938,9 @@ } }, "node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", - "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-2.0.1.tgz", + "integrity": "sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==", "license": "MIT", "engines": { "node": ">=18" @@ -8925,24 +8969,28 @@ } }, "node_modules/@modelcontextprotocol/sdk/node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz", + "integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==", "license": "MIT", "engines": { "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/@modelcontextprotocol/sdk/node_modules/express": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", - "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.3.0.tgz", + "integrity": "sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==", "license": "MIT", "dependencies": { "accepts": "^2.0.0", - "body-parser": "^2.2.1", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", + "body-parser": "^2.3.0", + "content-disposition": "^2.0.1", + "content-type": "^2.0.0", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", @@ -8958,14 +9006,14 @@ "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", + "proxy-addr": "^2.0.8", + "qs": "^6.16.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", - "type-is": "^2.0.1", + "type-is": "^2.1.0", "vary": "^1.1.2" }, "engines": { @@ -8976,6 +9024,19 @@ "url": "https://opencollective.com/express" } }, + "node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/@modelcontextprotocol/sdk/node_modules/finalhandler": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", @@ -9029,12 +9090,16 @@ "license": "MIT" }, "node_modules/@modelcontextprotocol/sdk/node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", "license": "MIT", "engines": { "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/@modelcontextprotocol/sdk/node_modules/merge-descriptors": { @@ -9075,12 +9140,32 @@ } }, "node_modules/@modelcontextprotocol/sdk/node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, "engines": { - "node": ">= 0.6" + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/@modelcontextprotocol/sdk/node_modules/raw-body": { @@ -9196,15 +9281,6 @@ "node": ">=20" } }, - "node_modules/@modelcontextprotocol/server/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@mongodb-js/atlas-admin-api": { "resolved": "packages/atlas-admin-api", "link": true @@ -9720,24 +9796,24 @@ "link": true }, "node_modules/@mongodb-js/mcp-atlas-api-client": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-atlas-api-client/-/mcp-atlas-api-client-3.1.0.tgz", - "integrity": "sha512-lirxkg7q1F+ExbCSDfJcIbbQfYDGcogFuRF2g/FcYPLNjfZSUJviIqg4a8ZXMag8+xuguwnL/hUG6Nun3GyAJA==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-atlas-api-client/-/mcp-atlas-api-client-3.2.2.tgz", + "integrity": "sha512-PjVAolb5pNfsV4CLGMkFtZQBCZNTkIK/i/YYxhjiBC7TmWpCeUUPGo1IAPsiouRPjq7kKcpIu1hY0WBkJzy1GQ==", "dependencies": { - "@mongodb-js/mcp-core": "3.1.0", - "@mongodb-js/mcp-types": "3.1.0", + "@mongodb-js/mcp-core": "3.2.2", + "@mongodb-js/mcp-types": "3.2.2", "oauth4webapi": "^3.8.5", "openapi-fetch": "^0.17.0" } }, "node_modules/@mongodb-js/mcp-atlas-telemetry": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-atlas-telemetry/-/mcp-atlas-telemetry-3.1.0.tgz", - "integrity": "sha512-hwYrKHgQz9LG7zFKdiX8eWiMmVgOxxFHsDC+jZiZ5Xac8NvVxsHgcuGLFyzC+0OyrihC3reWmeIFSh20WwF8rA==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-atlas-telemetry/-/mcp-atlas-telemetry-3.2.2.tgz", + "integrity": "sha512-tsZT/r00rpOMCMs3tqUrFgsfCfGCMgKYmS4GczJ4vyx8W24aSDADaEIgYrDnk/JYgz1/YX+rqXCIbxR4cYmAPw==", "dependencies": { - "@mongodb-js/mcp-atlas-api-client": "3.1.0", - "@mongodb-js/mcp-core": "3.1.0", - "@mongodb-js/mcp-types": "3.1.0", + "@mongodb-js/mcp-atlas-api-client": "3.2.2", + "@mongodb-js/mcp-core": "3.2.2", + "@mongodb-js/mcp-types": "3.2.2", "lru-cache": "^11.5.3" } }, @@ -9751,89 +9827,28 @@ } }, "node_modules/@mongodb-js/mcp-core": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-core/-/mcp-core-3.1.0.tgz", - "integrity": "sha512-M5kwnBwNDr47I2uzfl+Z7B39yb+zxAhXQ26gLRlsGlXMESq6FZ1A43W1+T3YF9wkLIIkGhlFWk3+Q8AoOuchEQ==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-core/-/mcp-core-3.2.2.tgz", + "integrity": "sha512-zhOQuw7jtNRqMKediVW4bZLFbgjrlAuIHjyzqc5EMn89OzX0VihMOhv4jADW0MYDeF1mk4Yf9mfp2mx42K9I7w==", "license": "Apache-2.0", "dependencies": { "@mcp-ui/server": "^6.1.0", "@modelcontextprotocol/server": "^2.3.1", + "@mongodb-js/mcp-types": "3.2.2", "bson": "^7.2.0", "mongodb-redact": "^1.1.6", "zod": "^4.4.2" } }, - "node_modules/@mongodb-js/mcp-core/node_modules/@mcp-ui/server": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@mcp-ui/server/-/server-6.1.0.tgz", - "integrity": "sha512-uxv9JrzEzHfdGo/V/KTFKp5WeCOsaiAoQZ3V88jw1dSXUofONEw4rMwEvVP3612aj/unS2TIeM0o1I0asfIxtw==", - "license": "Apache-2.0", - "dependencies": { - "@modelcontextprotocol/ext-apps": "^0.3.1", - "@modelcontextprotocol/sdk": "^1.25.1" - } - }, - "node_modules/@mongodb-js/mcp-core/node_modules/@modelcontextprotocol/ext-apps": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/ext-apps/-/ext-apps-0.3.1.tgz", - "integrity": "sha512-Iivz2KwWK8xlRbiWwFB/C4NXqE8VJBoRCbBkJCN98ST2UbQvA6kfyebcLsypiqylJS467XOOaBcI9DeQ3t+zqA==", - "hasInstallScript": true, - "license": "MIT", - "workspaces": [ - "examples/*" - ], - "optionalDependencies": { - "@oven/bun-darwin-aarch64": "^1.2.21", - "@oven/bun-darwin-x64": "^1.2.21", - "@oven/bun-darwin-x64-baseline": "^1.2.21", - "@oven/bun-linux-aarch64": "^1.2.21", - "@oven/bun-linux-aarch64-musl": "^1.2.21", - "@oven/bun-linux-x64": "^1.2.21", - "@oven/bun-linux-x64-baseline": "^1.2.21", - "@oven/bun-linux-x64-musl": "^1.2.21", - "@oven/bun-linux-x64-musl-baseline": "^1.2.21", - "@oven/bun-windows-x64": "^1.2.21", - "@oven/bun-windows-x64-baseline": "^1.2.21", - "@rollup/rollup-darwin-arm64": "^4.53.3", - "@rollup/rollup-darwin-x64": "^4.53.3", - "@rollup/rollup-linux-arm64-gnu": "^4.53.3", - "@rollup/rollup-linux-x64-gnu": "^4.53.3", - "@rollup/rollup-win32-arm64-msvc": "^4.53.3", - "@rollup/rollup-win32-x64-msvc": "^4.53.3" - }, - "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.24.0", - "react": "^17.0.0 || ^18.0.0 || ^19.0.0", - "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", - "zod": "^3.25.0 || ^4.0.0" - }, - "peerDependenciesMeta": { - "react": { - "optional": true - }, - "react-dom": { - "optional": true - } - } - }, - "node_modules/@mongodb-js/mcp-core/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@mongodb-js/mcp-tools-mongodb": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-tools-mongodb/-/mcp-tools-mongodb-3.1.0.tgz", - "integrity": "sha512-zU7KPR5bUynPtD1H319eOM0TdghND2a/vihWCWehxZr2Wh44qp2ePwcdjFRa5dZXZsyUzjofrVn4fBeg2qT/IQ==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-tools-mongodb/-/mcp-tools-mongodb-3.2.2.tgz", + "integrity": "sha512-Prn0E6QLndjbP7viBujftsuevlj7xbfr+N9Rk4ZV5kIbhlQojKA22oQszOhbpGmjy461tOxqFm34gj4o638Ttw==", "dependencies": { "@mongodb-js/device-id": "^0.4.18", - "@mongodb-js/mcp-atlas-telemetry": "3.1.0", - "@mongodb-js/mcp-core": "3.1.0", - "@mongodb-js/mcp-types": "3.1.0", + "@mongodb-js/mcp-atlas-telemetry": "3.2.2", + "@mongodb-js/mcp-core": "3.2.2", + "@mongodb-js/mcp-types": "3.2.2", "@mongosh/arg-parser": "^5.0.2", "@mongosh/service-provider-node-driver": "^5.0.2", "bson": "^7.2.0", @@ -9872,19 +9887,10 @@ "node": ">=18" } }, - "node_modules/@mongodb-js/mcp-tools-mongodb/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@mongodb-js/mcp-types": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-types/-/mcp-types-3.1.0.tgz", - "integrity": "sha512-yYSFTXIeuiM3LFuNqfCYdptwzL0I1SasAU94es6X+4OwU1ONXZkG82LXEILyeslWrA2cyxAVgV/tP/wkdLcbUg==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/mcp-types/-/mcp-types-3.2.2.tgz", + "integrity": "sha512-GY6LCCIUpATchlB4OcqG9U9/EF+TNDa8ToRDaPuR7v5dKLiW9uI+NXedMhSqD+yxWiCApUXqtIAggGCLla0pXg==", "license": "Apache-2.0", "dependencies": { "@modelcontextprotocol/server": "^2.3.1", @@ -12424,16 +12430,6 @@ "node": ">=14.15.1" } }, - "node_modules/@mongosh/arg-parser/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@mongosh/async-rewriter2": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/@mongosh/async-rewriter2/-/async-rewriter2-2.6.0.tgz", @@ -14712,9 +14708,9 @@ } }, "node_modules/@oven/bun-darwin-aarch64": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.3.6.tgz", - "integrity": "sha512-27rypIapNkYboOSylkf1tD9UW9Ado2I+P1NBL46Qz29KmOjTL6WuJ7mHDC5O66CYxlOkF5r93NPDAC3lFHYBXw==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.4.4.tgz", + "integrity": "sha512-zW/hxwc8sJAILGwB5eTC4i48ouGXf0V4lrxmEOk3JIE6JkYVW1TZh1E2pIempqsezgW1sckTIIDudFON8bJ2Mw==", "cpu": [ "arm64" ], @@ -14725,9 +14721,9 @@ ] }, "node_modules/@oven/bun-darwin-x64": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.3.6.tgz", - "integrity": "sha512-I82xGzPkBxzBKgbl8DsA0RfMQCWTWjNmLjIEkW1ECiv3qK02kHGQ5FGUr/29L/SuvnGsULW4tBTRNZiMzL37nA==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.4.4.tgz", + "integrity": "sha512-oKGcxLsvh4oHjAo28nPm8c/xN0o/OmGyj1IHYc94vprkWsW2hNg2keEZt5f40cI5Hvu4jDlSRTR0UNpv1UIAxw==", "cpu": [ "x64" ], @@ -14738,9 +14734,9 @@ ] }, "node_modules/@oven/bun-darwin-x64-baseline": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.3.6.tgz", - "integrity": "sha512-nqtr+pTsHqusYpG2OZc6s+AmpWDB/FmBvstrK0y5zkti4OqnCuu7Ev2xNjS7uyb47NrAFF40pWqkpaio5XEd7w==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.4.4.tgz", + "integrity": "sha512-uzSXckTnNNS7Un1ihiM31R7P5iKndZ65t6Zj3iI72SrfoV2uI97MKM8z1qer2oRHyqXHLUIJTIhj+qT5UeEjrw==", "cpu": [ "x64" ], @@ -14751,12 +14747,15 @@ ] }, "node_modules/@oven/bun-linux-aarch64": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.3.6.tgz", - "integrity": "sha512-YaQEAYjBanoOOtpqk/c5GGcfZIyxIIkQ2m1TbHjedRmJNwxzWBhGinSARFkrRIc3F8pRIGAopXKvJ/2rjN1LzQ==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.4.4.tgz", + "integrity": "sha512-ZTVtpf9zmHSBVPX1sBwe5agGb/rN34yPGg/Hby8e2Ax2uCUA2URZKlZH7qLntK7qaFJCMXh9v0GWNYN2zINz1w==", "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -14764,12 +14763,15 @@ ] }, "node_modules/@oven/bun-linux-aarch64-musl": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.3.6.tgz", - "integrity": "sha512-FR+iJt17rfFgYgpxL3M67AUwujOgjw52ZJzB9vElI5jQXNjTyOKf8eH4meSk4vjlYF3h/AjKYd6pmN0OIUlVKQ==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.4.4.tgz", + "integrity": "sha512-QFd0P+mHJxbZFbUla4MgiE5OwxysHaUIYxL2pPNkpWtaI7v4ShOpr8OhBmsuyB0xn5rv/ZJnPsj2y8+bB9+g/A==", "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -14777,12 +14779,15 @@ ] }, "node_modules/@oven/bun-linux-x64": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.3.6.tgz", - "integrity": "sha512-egfngj0dfJ868cf30E7B+ye9KUWSebYxOG4l9YP5eWeMXCtenpenx0zdKtAn9qxJgEJym5AN6trtlk+J6x8Lig==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.4.4.tgz", + "integrity": "sha512-CHbbkmHVM28T1GFq+6GL4Ao4ujwwYwj1CxFFwEFzLanPfNsId9AhbIP0Q4reWuWBkGimUkoQygrK7Rgjtj3vog==", "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -14790,12 +14795,15 @@ ] }, "node_modules/@oven/bun-linux-x64-baseline": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.3.6.tgz", - "integrity": "sha512-jRmnX18ak8WzqLrex3siw0PoVKyIeI5AiCv4wJLgSs7VKfOqrPycfHIWfIX2jdn7ngqbHFPzI09VBKANZ4Pckg==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.4.4.tgz", + "integrity": "sha512-FBU6T21NT+i+rESbi0Z8A8G5xN51c+WZ0v6pIjI6szSzOlqVNv64nf7FPnwNIyxKD1M7Wg5cEobLC/QbzCeLtA==", "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -14803,12 +14811,15 @@ ] }, "node_modules/@oven/bun-linux-x64-musl": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.3.6.tgz", - "integrity": "sha512-YeXcJ9K6vJAt1zSkeA21J6pTe7PgDMLTHKGI3nQBiMYnYf7Ob3K+b/ChSCznrJG7No5PCPiQPg4zTgA+BOTmSA==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.4.4.tgz", + "integrity": "sha512-lEEjNOJJrbGZu2NVcPI4uXdILcpspezWkA8R/Jr0RCGhM6zQd0Y7JBIIKNAmbX59EeWpeEz7Q78iLbpcAUypUA==", "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -14816,12 +14827,15 @@ ] }, "node_modules/@oven/bun-linux-x64-musl-baseline": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.3.6.tgz", - "integrity": "sha512-7FjVnxnRTp/AgWqSQRT/Vt9TYmvnZ+4M+d9QOKh/Lf++wIFXFGSeAgD6bV1X/yr2UPVmZDk+xdhr2XkU7l2v3w==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.4.4.tgz", + "integrity": "sha512-hlAPq5jIndGITsca7kUL/jB53hPSq5wEOEHSe36Z7GnUAiCTJn3aS5JBzmYXO1lLK7gt1vRxUF2Bk6WhelIfxw==", "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -14829,9 +14843,9 @@ ] }, "node_modules/@oven/bun-windows-x64": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.3.6.tgz", - "integrity": "sha512-Sr1KwUcbB0SEpnSPO22tNJppku2khjFluEst+mTGhxHzAGQTQncNeJxDnt3F15n+p9Q+mlcorxehd68n1siikQ==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.4.4.tgz", + "integrity": "sha512-a3LNctBVO8PjePsFZfwDleF2JXYf2BfQ1u/PLRnBDLnC2Riml+4+LgJpKj4xRGhB92KweGyQI5PXaTkP9qypMQ==", "cpu": [ "x64" ], @@ -14842,9 +14856,9 @@ ] }, "node_modules/@oven/bun-windows-x64-baseline": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.3.6.tgz", - "integrity": "sha512-PFUa7JL4lGoyyppeS4zqfuoXXih+gSE0XxhDMrCPVEUev0yhGNd/tbWBvcdpYnUth80owENoGjc8s5Knopv9wA==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.4.4.tgz", + "integrity": "sha512-c+169V+ole29sk5GpFuh6Q4uNwRDqu9tXZAVUYIsdfGZeiJeduQ030BkxHi3PmNpj7w/ec2+oO2okRFVFC9i1g==", "cpu": [ "x64" ], @@ -15441,9 +15455,9 @@ } }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.55.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.55.1.tgz", - "integrity": "sha512-p3grE2PHcQm2e8PSGZdzIhCKbMCw/xi9XvMPErPhwO17vxtvCN5FEA2mSLgmKlCjHGMQTP6phuQTYWUnKewwGg==", + "version": "4.67.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.67.5.tgz", + "integrity": "sha512-SNamgdrY69oPdBrQV9fKGo6PSmKcVhyn0D0jnDmcqgRJvrxQGGBhtekOHTUJ7TCgkW0nE8XMH9v2CwXmjNIzVA==", "cpu": [ "arm64" ], @@ -15454,9 +15468,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.55.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.55.1.tgz", - "integrity": "sha512-rDUjG25C9qoTm+e02Esi+aqTKSBYwVTaoS1wxcN47/Luqef57Vgp96xNANwt5npq9GDxsH7kXxNkJVEsWEOEaQ==", + "version": "4.67.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.67.5.tgz", + "integrity": "sha512-HNdl34thiJtHDSglogjmAlQ296L8cc8zA7ODH65nnmY7E+jPP55WEbh8J5583rWFLMjxyYywxZuwPOwRvEi5tA==", "cpu": [ "x64" ], @@ -15467,12 +15481,15 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.55.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.55.1.tgz", - "integrity": "sha512-a59mwd1k6x8tXKcUxSyISiquLwB5pX+fJW9TkWU46lCqD/GRDe9uDN31jrMmVP3feI3mhAdvcCClhV8V5MhJFQ==", + "version": "4.67.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.67.5.tgz", + "integrity": "sha512-+jtCiQnrEFHWAUAcUpP7wppb1p6HKOgBP3mXx75cEYpDF2Y5MEqBky2HNz+osFuVx5uX44gnMTmbe5RJauzn6A==", "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -15480,12 +15497,15 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.55.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.55.1.tgz", - "integrity": "sha512-a8G4wiQxQG2BAvo+gU6XrReRRqj+pLS2NGXKm8io19goR+K8lw269eTrPkSdDTALwMmJp4th2Uh0D8J9bEV1vg==", + "version": "4.67.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.67.5.tgz", + "integrity": "sha512-HmEfNh5Cdd/NHxgqwMzKnjlvicQQA+D+w+vQXDJSV0x/aHiQSjVwh1Th5RoA7QsMieIaxibt/5iJq68BraTSUg==", "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -15493,9 +15513,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.65.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.65.1.tgz", - "integrity": "sha512-x9VSsDmsMsEWy4cr/mFeaEsXnVJ6Kc4NCAU/lCnwml3s7LQbZoa9+/qwc9etWHbuuDT5mYxdyyKUwo76njtjZw==", + "version": "4.67.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.67.5.tgz", + "integrity": "sha512-nJKiMKDO140DUCEcQZl+f4HiGPMBxrW2webjuWJ2E3qPeoruHf2zByml4TP52lA1zDi6L4I92D/5stxeA/6pig==", "cpu": [ "arm64" ], @@ -15506,9 +15526,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.55.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz", - "integrity": "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw==", + "version": "4.67.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.67.5.tgz", + "integrity": "sha512-Khj/vrKCpdbiAWYbJAeSy4D5iep+qwW/86lNoKvdleJYGxgbRE7h87+5d5T9D7gt8NcqhNFpreRgIg8T4bLzKQ==", "cpu": [ "x64" ], @@ -27791,12 +27811,13 @@ } }, "node_modules/express-rate-limit": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.2.1.tgz", - "integrity": "sha512-PCZEIEIxqwhzw4KF0n7QF4QqruVTcF73O5kFKUnGOyjbCCgizBBiFaYpd/fnBLUMPw/BWw9OsiN7GgrNYr7j6g==", + "version": "8.7.3", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.3.tgz", + "integrity": "sha512-zPLqDI2f0gV2WmGnacLf9XSSqn4VldRyP5LCzOwx0BKH40mO6+2PCFkoSsRO2jePx87/Kf6NUF6P2QOTKXHbQA==", "license": "MIT", "dependencies": { - "ip-address": "10.0.1" + "debug": "^4.4.3", + "ip-address": "^10.2.0" }, "engines": { "node": ">= 16" @@ -27808,15 +27829,6 @@ "express": ">= 4.11" } }, - "node_modules/express-rate-limit/node_modules/ip-address": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.0.1.tgz", - "integrity": "sha512-NWv9YLW4PoW2B7xtzaS3NCot75m6nK7Icdv0o3lfMceJVRfSoQwqD4wEH5rLwoKJwUiZ/rfpiVBhnaF0FK4HoA==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, "node_modules/express/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -30353,9 +30365,9 @@ } }, "node_modules/hono": { - "version": "4.13.13", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.13.tgz", - "integrity": "sha512-CQ46U0ZkAGmbT/4UxdzzGJpacP2IeKgY4a5/tOI9AABbpOMfK739wfDXmv1usCk+3RkKj1hQy4/fjhiwa2xlrA==", + "version": "4.13.16", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.16.tgz", + "integrity": "sha512-AOLOEhvrV+iH92xXCnFr/5+3KjPKcI3xP63XJtX5spAnkznPdHijlIsUTpi7/9EhWqrTCekw5c5zh1K+YsVw7A==", "license": "MIT", "engines": { "node": ">=16.9.0" @@ -51419,9 +51431,9 @@ } }, "node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" @@ -52213,15 +52225,6 @@ "node": ">=12" } }, - "packages/compass-assistant/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "packages/compass-collection": { "name": "@mongodb-js/compass-collection", "version": "5.9.0", @@ -53476,11 +53479,11 @@ "@mongodb-js/compass-preferences-model": "^3.9.0", "@mongodb-js/compass-telemetry": "^1.37.1", "@mongodb-js/compass-utils": "^0.11.0", - "@mongodb-js/mcp-atlas-api-client": "^3.1.0", - "@mongodb-js/mcp-atlas-telemetry": "^3.1.0", - "@mongodb-js/mcp-core": "^3.1.0", - "@mongodb-js/mcp-tools-mongodb": "^3.1.0", - "@mongodb-js/mcp-types": "^3.1.0", + "@mongodb-js/mcp-atlas-api-client": "^3.2.2", + "@mongodb-js/mcp-atlas-telemetry": "^3.2.2", + "@mongodb-js/mcp-core": "^3.2.2", + "@mongodb-js/mcp-tools-mongodb": "^3.2.2", + "@mongodb-js/mcp-types": "^3.2.2", "@mongodb-js/mock-data-generator": "^1.2.1", "@mongodb-js/mongodb-build-info": "^1.9.19", "@mongodb-js/mongodb-schema": "^12.8.11", @@ -53670,15 +53673,6 @@ "node": ">=18" } }, - "packages/compass-generative-ai/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "packages/compass-global-writes": { "name": "@mongodb-js/compass-global-writes", "version": "2.9.0", @@ -54576,15 +54570,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "packages/compass-user-data/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "packages/compass-utilities": { "name": "@mongodb-js/compass-utilities", "version": "1.2.0", @@ -56274,15 +56259,6 @@ "typescript": "^6.0.3" } }, - "packages/mock-data-generator/node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "packages/mongodb-explain-compat": { "version": "3.3.43", "license": "SSPL", diff --git a/packages/compass-generative-ai/package.json b/packages/compass-generative-ai/package.json index 0b815ee28c3..19b1c53cc87 100644 --- a/packages/compass-generative-ai/package.json +++ b/packages/compass-generative-ai/package.json @@ -66,11 +66,11 @@ "@mongodb-js/compass-preferences-model": "^3.9.0", "@mongodb-js/compass-telemetry": "^1.37.1", "@mongodb-js/compass-utils": "^0.11.0", - "@mongodb-js/mcp-atlas-api-client": "^3.1.0", - "@mongodb-js/mcp-atlas-telemetry": "^3.1.0", - "@mongodb-js/mcp-core": "^3.1.0", - "@mongodb-js/mcp-tools-mongodb": "^3.1.0", - "@mongodb-js/mcp-types": "^3.1.0", + "@mongodb-js/mcp-atlas-api-client": "^3.2.2", + "@mongodb-js/mcp-atlas-telemetry": "^3.2.2", + "@mongodb-js/mcp-core": "^3.2.2", + "@mongodb-js/mcp-tools-mongodb": "^3.2.2", + "@mongodb-js/mcp-types": "^3.2.2", "@mongodb-js/mock-data-generator": "^1.2.1", "@mongodb-js/mongodb-build-info": "^1.9.19", "@mongodb-js/mongodb-schema": "^12.8.11", diff --git a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts index 373d649e2d3..5ab0b13c382 100644 --- a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts +++ b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts @@ -10,7 +10,6 @@ import { } from '@mongodb-js/mcp-atlas-api-client'; import type { LoggerBase } from '@mongodb-js/mcp-core'; import type { - IDeviceId, IKeychain, ServerMetadata, TelemetryCommonProperties, @@ -41,16 +40,10 @@ export type CompassMcpTelemetryConfig = { */ export class CompassMcpTelemetry extends AtlasTelemetry { private readonly isEnabled: () => boolean; - // Shadow the base class' private fields so `close` can release them. - // TODO(mongodb-mcp-server#1620): drop these once the fields are protected. - private readonly apiClientRef: ApiClient; - private readonly deviceIdRef: IDeviceId; private setupStarted = false; constructor(config: TelemetryConfig, isEnabled: () => boolean) { super(config); - this.apiClientRef = config.apiClient; - this.deviceIdRef = config.deviceId; this.isEnabled = isEnabled; } @@ -71,10 +64,10 @@ export class CompassMcpTelemetry extends AtlasTelemetry { public override async close(): Promise { // Abort first: `super.close()` waits for setup, which waits on the machine // id, so aborting afterwards would be too late to shorten shutdown. - this.deviceIdRef.close(); + this.deviceId.close(); // Flush before releasing the client the drain sends through. await super.close(); - await this.apiClientRef.close(); + await this.apiClient.close(); } public override getCommonProperties(): TelemetryCommonProperties { diff --git a/packages/compass-generative-ai/src/tools-connection-manager.spec.ts b/packages/compass-generative-ai/src/tools-connection-manager.spec.ts index eadce45f50c..4ba782170f3 100644 --- a/packages/compass-generative-ai/src/tools-connection-manager.spec.ts +++ b/packages/compass-generative-ai/src/tools-connection-manager.spec.ts @@ -12,6 +12,7 @@ describe('ToolsConnectionManager', function () { let sandbox: Sinon.SinonSandbox; let logger: LoggerBase; let getTelemetryAnonymousId: Sinon.SinonStub; + let getMaxTimeMS: Sinon.SinonStub; let connectionManager: ToolsConnectionManager; const mockConnectionParams: ToolsConnectParams = { @@ -32,10 +33,12 @@ describe('ToolsConnectionManager', function () { debug: sandbox.stub(), } as unknown as LoggerBase; getTelemetryAnonymousId = sandbox.stub().returns('test-anonymous-id'); + getMaxTimeMS = sandbox.stub().returns(undefined); connectionManager = new ToolsConnectionManager({ logger, getTelemetryAnonymousId, + getMaxTimeMS, mongoLogId: (id) => ({ __value: id }), }); }); @@ -160,6 +163,20 @@ describe('ToolsConnectionManager', function () { ); }); + it('applies the configured maxTimeMS as the driver timeoutMS', async function () { + getMaxTimeMS.returns(5000); + + await connectionManager.connectToCompassConnection(mockConnectionParams); + + expect(connectStub.firstCall.args[1]).to.include({ timeoutMS: 5000 }); + }); + + it('falls back to the default timeoutMS when maxTimeMS is unset', async function () { + await connectionManager.connectToCompassConnection(mockConnectionParams); + + expect(connectStub.firstCall.args[1]).to.include({ timeoutMS: 30_000 }); + }); + it('throws error if already connected', async function () { // First connection await connectionManager.connectToCompassConnection(mockConnectionParams); diff --git a/packages/compass-generative-ai/src/tools-connection-manager.ts b/packages/compass-generative-ai/src/tools-connection-manager.ts index cf93cea5adf..ac2fe1c14b5 100644 --- a/packages/compass-generative-ai/src/tools-connection-manager.ts +++ b/packages/compass-generative-ai/src/tools-connection-manager.ts @@ -37,12 +37,14 @@ export const COMPASS_CONNECTION_ID = 'compass'; type ToolsConnectionManagerConfig = { logger: LoggerBase; getTelemetryAnonymousId: () => string; + getMaxTimeMS: () => number | undefined; mongoLogId: Logger['mongoLogId']; }; export class ToolsConnectionManager extends ConnectionManager { private logger: LoggerBase; private getTelemetryAnonymousId: () => string; + private getMaxTimeMS: () => number | undefined; private mongoLogId: ToolsConnectionManagerConfig['mongoLogId']; private activeConnection: { id: string; @@ -52,11 +54,13 @@ export class ToolsConnectionManager extends ConnectionManager { constructor({ logger, getTelemetryAnonymousId, + getMaxTimeMS, mongoLogId, }: ToolsConnectionManagerConfig) { super(); this.logger = logger; this.getTelemetryAnonymousId = getTelemetryAnonymousId; + this.getMaxTimeMS = getMaxTimeMS; this.mongoLogId = mongoLogId; } @@ -127,7 +131,10 @@ To connect, choose a connection from Compass's connection sidebar - https://www. const serviceProvider = await NodeDriverServiceProvider.connect( connectionString, { - timeoutMS: 30_000, + // mongodb-mcp-server v3 replaced the per-operation `maxTimeMS` with a + // connection-level `timeoutMS`, so the Compass preference has to be + // applied as the driver timeout. + timeoutMS: this.getMaxTimeMS() ?? 30_000, readPreference: 'secondaryPreferred', readConcern: { level: 'local', diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 7c85b8e38d4..171406d3edb 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -457,7 +457,7 @@ describe('ToolsController', function () { await waitFor(() => host.maxTimeMS === 1234); expect(host.enableMCPTelemetry).to.equal(true); expect(host.maxTimeMS).to.equal(1234); - expect(host.server.config.maxTimeMS).to.equal(1234); + expect(host.connectionManager.getMaxTimeMS()).to.equal(1234); }); it('syncs telemetry setting with the utility host', async function () { @@ -488,18 +488,18 @@ describe('ToolsController', function () { maxTimeMS: 5000, connections: [], }); - await waitFor(() => host.server.config.maxTimeMS === 5000); + await waitFor(() => host.connectionManager.getMaxTimeMS() === 5000); expect(host.maxTimeMS).to.equal(5000); - expect(host.server.config.maxTimeMS).to.equal(5000); + expect(host.connectionManager.getMaxTimeMS()).to.equal(5000); toolsController.setContext({ enableMCPTelemetry: false, maxTimeMS: undefined, connections: [], }); - await waitFor(() => host.server.config.maxTimeMS === undefined); + await waitFor(() => host.connectionManager.getMaxTimeMS() === undefined); expect(host.maxTimeMS).to.equal(undefined); - expect(host.server.config.maxTimeMS).to.equal(undefined); + expect(host.connectionManager.getMaxTimeMS()).to.equal(undefined); }); }); diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts index a0af247b48a..f5a5c9f97f1 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts @@ -104,7 +104,7 @@ describe('ToolsHost', function () { expect((host as any).enableMCPTelemetry).to.equal(true); expect((host as any).maxTimeMS).to.equal(1000); - expect((host as any).server.config.maxTimeMS).to.equal(1000); + expect((host as any).connectionManager.getMaxTimeMS()).to.equal(1000); }); it('releases the server and the connection when stopped', async function () { diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts index fb3c8d631cb..85ac176c8a2 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts @@ -11,6 +11,7 @@ import { import { AGG_COUNT_MAX_TIME_MS_CAP, MongoDBTools, + NoopExportsManager, QUERY_COUNT_MAX_TIME_MS_CAP, type MongoDBToolServer, } from '@mongodb-js/mcp-tools-mongodb'; @@ -89,6 +90,7 @@ export class ToolsHost { this.connectionManager = new ToolsConnectionManager({ logger: this.serverLogger, getTelemetryAnonymousId: () => this.telemetryAnonymousId, + getMaxTimeMS: () => this.maxTimeMS, mongoLogId: this.logger.mongoLogId.bind(this.logger), }); @@ -127,12 +129,11 @@ export class ToolsHost { connectionString: undefined, indexCheck: false, disableServerSideJs: true, - maxTimeMS: this.maxTimeMS, maxDocumentsPerQuery: 100, maxBytesPerQuery: 16_777_216, httpHost: '127.0.0.1', - queryCountMaxTimeMsCap: QUERY_COUNT_MAX_TIME_MS_CAP, - aggregationCountMaxTimeMsCap: AGG_COUNT_MAX_TIME_MS_CAP, + queryCountTimeoutMs: QUERY_COUNT_MAX_TIME_MS_CAP, + aggregationCountTimeoutMs: AGG_COUNT_MAX_TIME_MS_CAP, }, logger: this.serverLogger, keychain: this.keychain, @@ -140,22 +141,8 @@ export class ToolsHost { this.connectionManager, this.keychain ), - // `MongoDBToolServices` requires a `result` that is only read when - // `errorHandled` is true; Compass never handles connection errors. - // TODO(mongodb-mcp-server#1620): drop this cast once released. - connectionErrorHandler: - createConnectionErrorHandler() as MongoDBToolServer['connectionErrorHandler'], - // Only the unregistered `export` tool reads this. - // TODO(mongodb-mcp-server#1620): use NoopExportsManager once released. - exportsManager: { - createJSONExport: () => { - return Promise.reject( - new Error( - 'Exporting data is not supported in Compass Database Tools' - ) - ); - }, - }, + connectionErrorHandler: createConnectionErrorHandler(), + exportsManager: new NoopExportsManager(), telemetry, elicitation: new Elicitation({ server: mcpServer.server }), metrics: new NoopMetrics(), @@ -209,9 +196,6 @@ export class ToolsHost { // takes effect on the next event without a restart. this.enableMCPTelemetry = enableMCPTelemetry; this.maxTimeMS = maxTimeMS; - if (this.server) { - this.server.config.maxTimeMS = maxTimeMS; - } if (telemetryAnonymousId !== undefined) { this.telemetryAnonymousId = telemetryAnonymousId; } From 89fff476cb94ea6411e02d13743d95cd0592c033 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 6 Nov 2026 14:40:31 +0100 Subject: [PATCH 16/23] fix(compass-generative-ai): use the preset Atlas base URL for MCP telemetry The telemetry API client hardcoded the production Atlas URL, so internal dev/qa/staging presets reported to the wrong backend. The renderer already resolves the preset via `getAtlasConfigForPreset`; thread that `atlasUiBaseUrl` through `setUserConfig` and use it as the telemetry base URL, falling back to production. --- .../src/compass-mcp-telemetry.ts | 7 +++++- .../src/tools-controller.spec.ts | 14 ++++++++++++ .../src/tools-controller.ts | 11 ++++++++-- .../tools/infrastructure/tools-host.spec.ts | 22 +++++++++++++++++++ .../src/tools/infrastructure/tools-host.ts | 22 ++++++++++++++----- 5 files changed, 67 insertions(+), 9 deletions(-) diff --git a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts index 5ab0b13c382..5906413e7b1 100644 --- a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts +++ b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts @@ -28,6 +28,11 @@ export type CompassMcpTelemetryConfig = { logger: LoggerBase; keychain: IKeychain; serverMetadata: ServerMetadata; + /** + * Atlas API base URL, derived from the Atlas service backend preset. Falls + * back to production when the renderer does not provide one. + */ + apiBaseUrl?: string; }; /** @@ -90,7 +95,7 @@ export function createCompassMcpTelemetry( deviceId: new LazyDeviceId(config.logger), apiClient: new ApiClient({ options: { - baseUrl: ATLAS_API_BASE_URL, + baseUrl: config.apiBaseUrl ?? ATLAS_API_BASE_URL, userAgent: userAgentFromServerMetadata(config.serverMetadata), httpClient, }, diff --git a/packages/compass-generative-ai/src/tools-controller.spec.ts b/packages/compass-generative-ai/src/tools-controller.spec.ts index 171406d3edb..461667857dc 100644 --- a/packages/compass-generative-ai/src/tools-controller.spec.ts +++ b/packages/compass-generative-ai/src/tools-controller.spec.ts @@ -460,6 +460,20 @@ describe('ToolsController', function () { expect(host.connectionManager.getMaxTimeMS()).to.equal(1234); }); + it('sends the Atlas base URL for the configured preset', async function () { + await preferences.savePreferences({ + atlasServiceBackendPreset: 'atlas-dev', + }); + + await toolsController.startServer(); + const host = openHosts[0] as any; + + await waitFor( + () => host.atlasBaseUrl === 'https://cloud-dev.mongodb.com' + ); + expect(host.atlasBaseUrl).to.equal('https://cloud-dev.mongodb.com'); + }); + it('syncs telemetry setting with the utility host', async function () { await toolsController.startServer(); const host = openHosts[0] as any; diff --git a/packages/compass-generative-ai/src/tools-controller.ts b/packages/compass-generative-ai/src/tools-controller.ts index 4317e374a91..bd7ad057ec3 100644 --- a/packages/compass-generative-ai/src/tools-controller.ts +++ b/packages/compass-generative-ai/src/tools-controller.ts @@ -82,6 +82,12 @@ export class ToolsController { this.currentConfig = { enableMCPTelemetry, maxTimeMS }; } + private getAtlasBaseUrl(): string { + return getAtlasConfigForPreset( + this.preferences.getPreferences().atlasServiceBackendPreset + ).atlasUiBaseUrl; + } + setActiveTools(toolGroups: Set): void { this.toolGroups = toolGroups; } @@ -201,8 +207,8 @@ export class ToolsController { }; void this.portClient ?.call('setUserConfig', { - enableMCPTelemetry: context.enableMCPTelemetry, - maxTimeMS: context.maxTimeMS, + ...this.currentConfig, + atlasBaseUrl: this.getAtlasBaseUrl(), telemetryAnonymousId: this.getTelemetryAnonymousId(), }) .catch((error: unknown) => { @@ -242,6 +248,7 @@ export class ToolsController { 'setUserConfig', { ...this.currentConfig, + atlasBaseUrl: this.getAtlasBaseUrl(), telemetryAnonymousId: this.getTelemetryAnonymousId(), }, signal diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts index f5a5c9f97f1..7d3f78ca1e1 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts @@ -107,6 +107,28 @@ describe('ToolsHost', function () { expect((host as any).connectionManager.getMaxTimeMS()).to.equal(1000); }); + it('uses the Atlas base URL passed by the renderer for telemetry', async function () { + const client = createRuntimeClient(asRendererPort(channel.port1)); + await client.call('setUserConfig', { + enableMCPTelemetry: false, + atlasBaseUrl: 'https://cloud-dev.mongodb.com', + }); + await client.call('listDatabaseTools'); + + expect((host as any).telemetry.apiClient.options.baseUrl).to.equal( + 'https://cloud-dev.mongodb.com' + ); + }); + + it('defaults the telemetry base URL to production', async function () { + const client = createRuntimeClient(asRendererPort(channel.port1)); + await client.call('listDatabaseTools'); + + expect((host as any).telemetry.apiClient.options.baseUrl).to.equal( + 'https://cloud.mongodb.com/' + ); + }); + it('releases the server and the connection when stopped', async function () { const client = createRuntimeClient(asRendererPort(channel.port1)); await client.call('listDatabaseTools'); diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts index 85ac176c8a2..3375674bba6 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts @@ -79,6 +79,7 @@ export class ToolsHost { private telemetryAnonymousId = ''; private enableMCPTelemetry = false; private maxTimeMS: number | undefined; + private atlasBaseUrl: string | undefined; private stopped = false; constructor(port: MessagePort, { logger }: ToolsHostConfig) { @@ -111,6 +112,7 @@ export class ToolsHost { logger: this.serverLogger, keychain: this.keychain, serverMetadata, + apiBaseUrl: this.atlasBaseUrl, }, () => this.enableMCPTelemetry ); @@ -186,12 +188,17 @@ export class ToolsHost { ): Promise { switch (method) { case 'setUserConfig': { - const { enableMCPTelemetry, maxTimeMS, telemetryAnonymousId } = - params as { - enableMCPTelemetry: boolean; - maxTimeMS?: number; - telemetryAnonymousId?: string; - }; + const { + enableMCPTelemetry, + maxTimeMS, + telemetryAnonymousId, + atlasBaseUrl, + } = params as { + enableMCPTelemetry: boolean; + maxTimeMS?: number; + telemetryAnonymousId?: string; + atlasBaseUrl?: string; + }; // The telemetry pipeline reads the preference live, so flipping this // takes effect on the next event without a restart. this.enableMCPTelemetry = enableMCPTelemetry; @@ -199,6 +206,9 @@ export class ToolsHost { if (telemetryAnonymousId !== undefined) { this.telemetryAnonymousId = telemetryAnonymousId; } + if (atlasBaseUrl !== undefined) { + this.atlasBaseUrl = atlasBaseUrl; + } return; } case 'listDatabaseTools': { From eb66376c34338618c02d0dbd0de36f1eb7865d3f Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 6 Nov 2026 14:40:43 +0100 Subject: [PATCH 17/23] fix(compass-generative-ai): report the Compass version in MCP server metadata `serverMetadata.version` was a hardcoded `0.0.0`, so telemetry's `mcp_server_version` and the Atlas API client User-Agent never carried the running Compass version. Use `HADRON_APP_VERSION`, which the desktop utility build inlines, with `0.0.0` as the compass-web fallback. --- .../src/tools/infrastructure/tools-host.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts index 3375674bba6..f9f777c4fba 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts @@ -48,10 +48,11 @@ type ToolsHostConfig = { }; // Reported to telemetry as `mcp_server_version` (and in the API client's -// User-Agent). Compass does not currently surface its own version here. +// User-Agent). `HADRON_APP_VERSION` is inlined at build time for the desktop +// utility; compass-web's process shim has an empty env, so keep a fallback. const serverMetadata: ServerMetadata = { mcpServerName: 'mongodb-compass', - version: '0.0.0', + version: process.env.HADRON_APP_VERSION ?? '0.0.0', }; type CompassToolServer = Omit & { From 6fdf3c7e3c1510eab36f10e014dda47b148e7d6c Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 6 Nov 2026 16:12:38 +0100 Subject: [PATCH 18/23] docs(compass-generative-ai): trim MCP migration comments Drop restated and padded comments, keeping the non-obvious constraints (lazy telemetry setup, close() ordering, the maxTimeMS -> timeoutMS migration, and the HADRON_APP_VERSION fallback) to one or two lines. --- .../src/compass-mcp-telemetry.ts | 20 ++++++------------ .../src/tools-connection-manager.ts | 21 +++++++------------ .../tools/infrastructure/tools-host.spec.ts | 3 +-- .../src/tools/infrastructure/tools-host.ts | 11 ++++------ 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts index 5906413e7b1..4b72ed4f125 100644 --- a/packages/compass-generative-ai/src/compass-mcp-telemetry.ts +++ b/packages/compass-generative-ai/src/compass-mcp-telemetry.ts @@ -28,20 +28,13 @@ export type CompassMcpTelemetryConfig = { logger: LoggerBase; keychain: IKeychain; serverMetadata: ServerMetadata; - /** - * Atlas API base URL, derived from the Atlas service backend preset. Falls - * back to production when the renderer does not provide one. - */ + /** Atlas API base URL. Defaults to production when not provided. */ apiBaseUrl?: string; }; /** - * MCP telemetry for Compass's in-memory Database Tools server. - * - * Adds the `hosting_mode` property the v1 integration set, and reads the usage - * statistics preference live so toggling it needs no restart. Nothing is set up - * — no machine id, no container probe, no send timer — until the first event - * the preference allows through. + * MCP telemetry for Compass's in-memory Database Tools server. Nothing is set + * up until the first event the usage-statistics preference allows through. */ export class CompassMcpTelemetry extends AtlasTelemetry { private readonly isEnabled: () => boolean; @@ -57,8 +50,8 @@ export class CompassMcpTelemetry extends AtlasTelemetry { } public override emitEvents(events: TelemetryBaseEvent[]): void { - // ToolBase checks isTelemetryEnabled() before emitting, so setup only runs - // for events the preference actually allows. + // ToolBase checks isTelemetryEnabled() first, so setup only runs for + // allowed events. if (this.isTelemetryEnabled() && !this.setupStarted) { this.setupStarted = true; void this.setup(); @@ -67,8 +60,7 @@ export class CompassMcpTelemetry extends AtlasTelemetry { } public override async close(): Promise { - // Abort first: `super.close()` waits for setup, which waits on the machine - // id, so aborting afterwards would be too late to shorten shutdown. + // Abort first: `super.close()` waits for setup, which waits on the machine id. this.deviceId.close(); // Flush before releasing the client the drain sends through. await super.close(); diff --git a/packages/compass-generative-ai/src/tools-connection-manager.ts b/packages/compass-generative-ai/src/tools-connection-manager.ts index ac2fe1c14b5..a804dcad450 100644 --- a/packages/compass-generative-ai/src/tools-connection-manager.ts +++ b/packages/compass-generative-ai/src/tools-connection-manager.ts @@ -28,9 +28,8 @@ export const DATABASE_TOOLS_TELEMETRY_APP_NAME = 'Database Tools'; const DEFAULT_TELEMETRY_APP_NAME = 'MongoDB Compass'; /** - * The single connection handle Compass Database Tools expose to the MCP tools. - * Compass drives the connection itself (see {@link ToolsConnectionManager}), so - * the tools only ever need one opaque id to address it by. + * The handle MCP tools use to address Compass's single connection; Compass + * drives that connection itself (see {@link ToolsConnectionManager}). */ export const COMPASS_CONNECTION_ID = 'compass'; @@ -131,9 +130,8 @@ To connect, choose a connection from Compass's connection sidebar - https://www. const serviceProvider = await NodeDriverServiceProvider.connect( connectionString, { - // mongodb-mcp-server v3 replaced the per-operation `maxTimeMS` with a - // connection-level `timeoutMS`, so the Compass preference has to be - // applied as the driver timeout. + // v3 dropped the per-operation `maxTimeMS`; apply the Compass + // preference as the connection's driver `timeoutMS`. timeoutMS: this.getMaxTimeMS() ?? 30_000, readPreference: 'secondaryPreferred', readConcern: { @@ -204,14 +202,9 @@ To connect, choose a connection from Compass's connection sidebar - https://www. } /** - * A {@link ConnectionRegistry} view over the single Compass connection. - * - * mongodb-mcp-server v3 resolves every MongoDB tool call through a connection - * registry keyed by an opaque `connectionId`, but Compass owns its connection - * lifecycle (the user's sidebar connection) and only ever has one live at a - * time. This adapter exposes that connection under - * {@link COMPASS_CONNECTION_ID} so the tools can resolve it without Compass - * having to run the library's connection store. + * Exposes Compass's single sidebar connection to v3's `connectionId`-keyed + * registry as {@link COMPASS_CONNECTION_ID}, without running the library's + * connection store. */ export class ToolsConnectionRegistry implements ConnectionRegistry { private readonly entry: ConnectionEntry; diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts index 7d3f78ca1e1..a203fcd9ef4 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts @@ -162,8 +162,7 @@ describe('ToolsHost', function () { ]); }; - // Tool telemetry is fire-and-forget, and the pipeline only drains on close - // or on its timer, so give the event time to reach the client. + // Telemetry is fire-and-forget and only drains on close or the timer, so wait. const waitForSend = async () => { const deadline = Date.now() + 2000; while (!sendEvents.called && Date.now() < deadline) { diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts index f9f777c4fba..09a3ffa300e 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts @@ -47,9 +47,8 @@ type ToolsHostConfig = { logger: Logger; }; -// Reported to telemetry as `mcp_server_version` (and in the API client's -// User-Agent). `HADRON_APP_VERSION` is inlined at build time for the desktop -// utility; compass-web's process shim has an empty env, so keep a fallback. +// `HADRON_APP_VERSION` is inlined at build time for the desktop utility; +// compass-web's process shim has an empty env, so keep the fallback. const serverMetadata: ServerMetadata = { mcpServerName: 'mongodb-compass', version: process.env.HADRON_APP_VERSION ?? '0.0.0', @@ -120,8 +119,7 @@ export class ToolsHost { this.telemetry = telemetry; const server: CompassToolServer = { - // Defaults mirror `UserConfigSchema`; Compass only exposes read-only tools, - // so the write- and Atlas-specific options are unused. + // Defaults mirror `UserConfigSchema`; Compass only exposes read-only tools. config: { transport: 'stdio', httpResponseType: 'sse', @@ -200,8 +198,7 @@ export class ToolsHost { telemetryAnonymousId?: string; atlasBaseUrl?: string; }; - // The telemetry pipeline reads the preference live, so flipping this - // takes effect on the next event without a restart. + // The telemetry pipeline reads the preference live, so no restart is needed. this.enableMCPTelemetry = enableMCPTelemetry; this.maxTimeMS = maxTimeMS; if (telemetryAnonymousId !== undefined) { From 35d9551880f92136285a0bfba403f3f8a24346ec Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Fri, 6 Nov 2026 16:38:27 +0100 Subject: [PATCH 19/23] fix(e2e-tests): wait for the assistant confirmation before asserting The explain plan cancel test read the chat text as soon as the messages container was displayed, but the confirmation is appended only after `ToolsController.startServer()` resolves, so the assertion raced with it. The sibling "confirm" test only passes because clicking Confirm implicitly waits for the button. Wait for the confirmation (and for the cancelled state) instead, keeping the pause that guards the "no request sent" check. --- .../tests/assistant-mocked.test.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/compass-e2e-tests/tests/assistant-mocked.test.ts b/packages/compass-e2e-tests/tests/assistant-mocked.test.ts index d98b3fcfdc7..4f9a281f343 100644 --- a/packages/compass-e2e-tests/tests/assistant-mocked.test.ts +++ b/packages/compass-e2e-tests/tests/assistant-mocked.test.ts @@ -481,24 +481,32 @@ describe('MongoDB Assistant (with mocked backend)', function () { const chatMessages = browser.$(Selectors.AssistantChatMessages); await chatMessages.waitForDisplayed(); - expect(await chatMessages.getText()).to.include( - 'Please confirm your request' + // The confirmation is appended once the assistant tools have + // started, so wait for it rather than reading the chat as soon as + // the drawer opens + await browser.waitUntil(async () => + (await chatMessages.getText()).includes( + 'Please confirm your request' + ) ); // Click Cancel button await browser.clickVisible('button*=Cancel'); - // Wait a bit to ensure no request is sent + await browser.waitUntil(async () => + (await chatMessages.getText()).includes('Request cancelled') + ); + + // Wait a bit to ensure a wrongly sent request would have been + // recorded by the mock server by now await browser.pause(300); const finalMessages = await browser.getDisplayedMessages(); expect(finalMessages.length).to.equal(0); - expect(await chatMessages.getText()).to.include( - 'Please confirm your request' - ); - - expect(await chatMessages.getText()).to.include('Request cancelled'); + const finalText = await chatMessages.getText(); + expect(finalText).to.include('Please confirm your request'); + expect(finalText).to.include('Request cancelled'); // Verify no assistant request was made expect(mockAssistantServer.getRequests()).to.be.empty; From 66eba8b22774cd9655a40d59ce81578b18264371 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Mon, 9 Nov 2026 12:48:04 +0100 Subject: [PATCH 20/23] refactor(compass-generative-ai): move ToolsConnectionRegistry to its own module --- .../src/tools-connection-manager.ts | 86 +---------------- .../src/tools-connection-registry.ts | 92 +++++++++++++++++++ .../src/tools/infrastructure/tools-host.ts | 2 +- 3 files changed, 94 insertions(+), 86 deletions(-) create mode 100644 packages/compass-generative-ai/src/tools-connection-registry.ts diff --git a/packages/compass-generative-ai/src/tools-connection-manager.ts b/packages/compass-generative-ai/src/tools-connection-manager.ts index a804dcad450..8e442aab4be 100644 --- a/packages/compass-generative-ai/src/tools-connection-manager.ts +++ b/packages/compass-generative-ai/src/tools-connection-manager.ts @@ -1,14 +1,10 @@ import { ConnectionManager, - ConnectionEntry, ConnectionStateConnected, - ErrorCodes, - MongoDBError, - type ConnectionRegistry, type ConnectionSettings, type ConnectionStateDisconnected, } from '@mongodb-js/mcp-tools-mongodb'; -import type { Keychain, LoggerBase } from '@mongodb-js/mcp-core'; +import type { LoggerBase } from '@mongodb-js/mcp-core'; import { NodeDriverServiceProvider, type DevtoolsConnectOptions, @@ -200,83 +196,3 @@ To connect, choose a connection from Compass's connection sidebar - https://www. }; } } - -/** - * Exposes Compass's single sidebar connection to v3's `connectionId`-keyed - * registry as {@link COMPASS_CONNECTION_ID}, without running the library's - * connection store. - */ -export class ToolsConnectionRegistry implements ConnectionRegistry { - private readonly entry: ConnectionEntry; - - constructor(connectionManager: ToolsConnectionManager, keychain: Keychain) { - this.entry = new ConnectionEntry({ - connectionId: COMPASS_CONNECTION_ID, - name: COMPASS_CONNECTION_ID, - source: 'explicit', - manager: connectionManager, - keychain, - }); - } - - createEntry(): Promise { - return Promise.reject( - new Error( - 'Database Tools in MongoDB Compass manage connections through the Compass connection sidebar' - ) - ); - } - - connect(): Promise { - return Promise.reject( - new Error( - 'Database Tools in MongoDB Compass manage connections through the Compass connection sidebar' - ) - ); - } - - get(connectionId: string): Promise { - return Promise.resolve( - connectionId === COMPASS_CONNECTION_ID ? this.entry : undefined - ); - } - - peek(connectionId: string): Promise { - return this.get(connectionId); - } - - find( - predicate?: (entry: ConnectionEntry) => boolean - ): Promise { - return Promise.resolve( - predicate === undefined || predicate(this.entry) ? [this.entry] : [] - ); - } - - async resolve(connectionId: string): Promise { - const entry = await this.get(connectionId); - if (!entry) { - throw new MongoDBError( - ErrorCodes.UnknownConnectionId, - `Connection "${connectionId}" does not exist or has expired.` - ); - } - return entry.getServiceProvider(); - } - - async disconnect(connectionId: string): Promise { - const entry = await this.get(connectionId); - if (!entry) { - throw new MongoDBError( - ErrorCodes.UnknownConnectionId, - `Connection "${connectionId}" does not exist or has expired.` - ); - } - await entry.close(); - } - - close(): Promise { - // The connection is owned by Compass, not by this registry. - return Promise.resolve(); - } -} diff --git a/packages/compass-generative-ai/src/tools-connection-registry.ts b/packages/compass-generative-ai/src/tools-connection-registry.ts new file mode 100644 index 00000000000..5a8ab892a18 --- /dev/null +++ b/packages/compass-generative-ai/src/tools-connection-registry.ts @@ -0,0 +1,92 @@ +import { + ConnectionEntry, + ErrorCodes, + MongoDBError, + type ConnectionRegistry, +} from '@mongodb-js/mcp-tools-mongodb'; +import type { Keychain } from '@mongodb-js/mcp-core'; +import type { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver'; +import { + COMPASS_CONNECTION_ID, + type ToolsConnectionManager, +} from './tools-connection-manager'; + +/** + * Exposes Compass's single sidebar connection to v3's `connectionId`-keyed + * registry as {@link COMPASS_CONNECTION_ID}, without running the library's + * connection store. + */ +export class ToolsConnectionRegistry implements ConnectionRegistry { + private readonly entry: ConnectionEntry; + + constructor(connectionManager: ToolsConnectionManager, keychain: Keychain) { + this.entry = new ConnectionEntry({ + connectionId: COMPASS_CONNECTION_ID, + name: COMPASS_CONNECTION_ID, + source: 'explicit', + manager: connectionManager, + keychain, + }); + } + + createEntry(): Promise { + return Promise.reject( + new Error( + 'Database Tools in MongoDB Compass manage connections through the Compass connection sidebar' + ) + ); + } + + connect(): Promise { + return Promise.reject( + new Error( + 'Database Tools in MongoDB Compass manage connections through the Compass connection sidebar' + ) + ); + } + + get(connectionId: string): Promise { + return Promise.resolve( + connectionId === COMPASS_CONNECTION_ID ? this.entry : undefined + ); + } + + peek(connectionId: string): Promise { + return this.get(connectionId); + } + + find( + predicate?: (entry: ConnectionEntry) => boolean + ): Promise { + return Promise.resolve( + predicate === undefined || predicate(this.entry) ? [this.entry] : [] + ); + } + + async resolve(connectionId: string): Promise { + const entry = await this.get(connectionId); + if (!entry) { + throw new MongoDBError( + ErrorCodes.UnknownConnectionId, + `Connection "${connectionId}" does not exist or has expired.` + ); + } + return entry.getServiceProvider(); + } + + async disconnect(connectionId: string): Promise { + const entry = await this.get(connectionId); + if (!entry) { + throw new MongoDBError( + ErrorCodes.UnknownConnectionId, + `Connection "${connectionId}" does not exist or has expired.` + ); + } + await entry.close(); + } + + close(): Promise { + // The connection is owned by Compass, not by this registry. + return Promise.resolve(); + } +} diff --git a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts index 09a3ffa300e..775d48f43ec 100644 --- a/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts +++ b/packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts @@ -28,8 +28,8 @@ import { ToolsLogger } from '../../tools-logger'; import { COMPASS_CONNECTION_ID, ToolsConnectionManager, - ToolsConnectionRegistry, } from '../../tools-connection-manager'; +import { ToolsConnectionRegistry } from '../../tools-connection-registry'; import { removeZodTransforms } from '../../remove-zod-transforms'; import { READ_ONLY_DATABASE_TOOLS } from '../../available-tools'; import type { ToolsRpcMethod } from './protocol'; From 7e0edec0deece08957b5ec1ce78eba0590b8ebad Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Mon, 9 Nov 2026 13:18:50 +0100 Subject: [PATCH 21/23] fix(webpack-config-compass): pin webpack to 5.107.0 `webpack-compass` resolves webpack relative to this package (it sets `WEBPACK_PACKAGE` from `require.resolve('webpack/package.json')`), so the version installed here is the one the Compass builds run. With the caret range, a lockfile regeneration dedupes it to the hoisted 5.112.2, which crashes building compass-web: ERROR in [entry] ai-assistant..mjs TypeError: p.charCodeAt is not a function at propertyAccess (webpack/lib/util/property.js:88) at ModuleLibraryPlugin.renderStartup (webpack/lib/library/ModuleLibraryPlugin.js:1062) The ai-assistant worker chunk is an ESM library chunk whose entry has unused exports; 5.112.2 passes the undefined `getUsedName()` result straight into `propertyAccess`, while 5.107.0 (the version #8663 bumped this package to) does not take that path. --- configs/webpack-config-compass/package.json | 2 +- package-lock.json | 208 ++++++++++++++---- .../src/ai-assistant/index.mts | 57 ++++- .../src/ai-assistant/index.spec.mts | 2 +- 4 files changed, 217 insertions(+), 52 deletions(-) diff --git a/configs/webpack-config-compass/package.json b/configs/webpack-config-compass/package.json index 01815cfa647..f5798023660 100644 --- a/configs/webpack-config-compass/package.json +++ b/configs/webpack-config-compass/package.json @@ -84,7 +84,7 @@ "react-refresh": "^0.10.0", "source-map-loader": "^4.0.1", "style-loader": "^3.2.1", - "webpack": "^5.107.0", + "webpack": "5.107.0", "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.2", diff --git a/package-lock.json b/package-lock.json index 9e3901a7fb5..3dc3d69d308 100644 --- a/package-lock.json +++ b/package-lock.json @@ -221,7 +221,7 @@ "react-refresh": "^0.10.0", "source-map-loader": "^4.0.1", "style-loader": "^3.2.1", - "webpack": "^5.107.0", + "webpack": "5.107.0", "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.2", @@ -459,6 +459,15 @@ "node": ">=8.9.0" } }, + "configs/webpack-config-compass/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "configs/webpack-config-compass/node_modules/node-loader": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/node-loader/-/node-loader-2.0.0.tgz", @@ -545,6 +554,52 @@ "node": ">=6" } }, + "configs/webpack-config-compass/node_modules/webpack": { + "version": "5.107.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.107.0.tgz", + "integrity": "sha512-PSxeHk/dmLYZlnTU+vL1Gej6Evg5RNtl3flhxBresfznFnzxinHMzHKloHnywM/3ouQv7/AlZCswWDIkNSggUA==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.8", + "@types/json-schema": "^7.0.15", + "@webassemblyjs/ast": "^1.14.1", + "@webassemblyjs/wasm-edit": "^1.14.1", + "@webassemblyjs/wasm-parser": "^1.14.1", + "acorn": "^8.16.0", + "acorn-import-phases": "^1.0.3", + "browserslist": "^4.28.1", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^5.21.4", + "es-module-lexer": "^2.1.0", + "eslint-scope": "5.1.1", + "events": "^3.2.0", + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.2.11", + "loader-runner": "^4.3.2", + "mime-db": "^1.54.0", + "neo-async": "^2.6.2", + "schema-utils": "^4.3.3", + "tapable": "^2.3.0", + "terser-webpack-plugin": "^5.5.0", + "watchpack": "^2.5.1", + "webpack-sources": "^3.4.1" + }, + "bin": { + "webpack": "bin/webpack.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependenciesMeta": { + "webpack-cli": { + "optional": true + } + } + }, "configs/webpack-config-compass/node_modules/webpack-bundle-analyzer": { "version": "4.10.2", "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.2.tgz", @@ -13181,14 +13236,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@npmcli/arborist/node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/@npmcli/arborist/node_modules/fs-minipass": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-3.0.1.tgz", @@ -19567,6 +19614,18 @@ "acorn": "^8" } }, + "node_modules/acorn-import-phases": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz", + "integrity": "sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + }, + "peerDependencies": { + "acorn": "^8.14.0" + } + }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", @@ -20173,16 +20232,6 @@ "ieee754": "^1.2.1" } }, - "node_modules/archiver-utils/node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/archiver-utils/node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -27999,6 +28048,15 @@ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, "node_modules/eventsource": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", @@ -29807,6 +29865,12 @@ "node": ">= 6" } }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "license": "BSD-2-Clause" + }, "node_modules/glob/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -37014,6 +37078,19 @@ "node": ">=8" } }, + "node_modules/loader-runner": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.2.tgz", + "integrity": "sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==", + "license": "MIT", + "engines": { + "node": ">=6.11.5" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, "node_modules/locate-app": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/locate-app/-/locate-app-2.5.0.tgz", @@ -38600,6 +38677,7 @@ "resolved": "https://registry.npmjs.org/minimizer-webpack-plugin/-/minimizer-webpack-plugin-5.14.0.tgz", "integrity": "sha512-PnvQXCJxhgH2ZVVO7Lj0sM6q8L1XGxnUvd8wVQIRwi8khMCLq5wg0Ngxe44bcuZL2FSN81RdVE7YHEVzTKsQDQ==", "license": "MIT", + "peer": true, "dependencies": { "jest-worker": "^27.4.5", "schema-utils": "^4.6.0", @@ -39753,8 +39831,7 @@ "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, "node_modules/netmask": { "version": "2.0.2", @@ -48461,6 +48538,66 @@ "node": ">=10" } }, + "node_modules/terser-webpack-plugin": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.6.1.tgz", + "integrity": "sha512-201R5j+sJpK8nFWwKVyNfZot8FaJbLZDq5evriVzbV1wDtSXDjRUDRfJzHpAaxFDMEhsZL1QkeqM61wgsS3KaQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "jest-worker": "^27.4.5", + "schema-utils": "^4.3.0", + "terser": "^5.31.1" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + }, + "peerDependenciesMeta": { + "@minify-html/node": { + "optional": true + }, + "@swc/core": { + "optional": true + }, + "@swc/css": { + "optional": true + }, + "@swc/html": { + "optional": true + }, + "clean-css": { + "optional": true + }, + "cssnano": { + "optional": true + }, + "csso": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "html-minifier-terser": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "postcss": { + "optional": true + }, + "uglify-js": { + "optional": true + } + } + }, "node_modules/tesseract.js": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/tesseract.js/-/tesseract.js-6.0.1.tgz", @@ -50679,16 +50816,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/webdriverio/node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/webdriverio/node_modules/htmlparser2": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz", @@ -50891,6 +51018,7 @@ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.112.2.tgz", "integrity": "sha512-B2tp1LI9D8GVpPDqprdt12ukTkXXahj9MzqSWJq4faSPgOUM7CdZaGAB6HrL/8E6UwbBpdj4vzWDbKoFnVoU6g==", "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "^1.0.8", "@types/json-schema": "^7.0.15", @@ -51145,19 +51273,12 @@ "dev": true, "license": "MIT" }, - "node_modules/webpack/node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/webpack/node_modules/mime-db": { "version": "1.54.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", "license": "MIT", + "peer": true, "engines": { "node": ">= 0.6" } @@ -55133,15 +55254,6 @@ "ieee754": "^1.2.1" } }, - "packages/compass-web/node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, - "engines": { - "node": ">=0.8.x" - } - }, "packages/compass-web/node_modules/mongodb-connection-string-url": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.2.tgz", diff --git a/packages/compass-utilities/src/ai-assistant/index.mts b/packages/compass-utilities/src/ai-assistant/index.mts index bf5985a19af..c08694e66b0 100644 --- a/packages/compass-utilities/src/ai-assistant/index.mts +++ b/packages/compass-utilities/src/ai-assistant/index.mts @@ -1,5 +1,58 @@ -import { currentParentPort } from '../ipc.mts'; -import { main } from './main.mts'; +import process from 'node:process'; + +import { listen } from '@mongodb-js/compass-events'; +import { ToolsHost } from '@mongodb-js/compass-generative-ai/utility'; +import { createUtilityLogger } from '../logging.mts'; +import type { UtilityParentPort } from '../ipc.mts'; +import { currentParentPort, onPort } from '../ipc.mts'; + +export const name = 'ai-assistant'; + +export function main(parentPort: UtilityParentPort): Disposable { + using ds = new DisposableStack(); + + ds.use( + listen(process, 'unhandledRejection', (reason) => { + throw reason; + }) + ); + + const logger = createUtilityLogger(parentPort, name); + + const hosts = new Set(); + ds.defer(() => { + for (const host of hosts) { + void host.stop(); + } + }); + + ds.use( + onPort(parentPort, (port) => { + const host = new ToolsHost(port, { logger }); + hosts.add(host); + listen( + port, + 'close', + () => { + hosts.delete(host); + void host.stop().catch((error) => { + logger.log.error( + logger.mongoLogId(1_001_000_454), + 'ai-assistant', + 'Error when stopping the tools host', + { + error: error instanceof Error ? error.message : String(error), + } + ); + }); + }, + { once: true } + ); + }) + ); + + return ds.move(); +} const parentPort = currentParentPort(); if (parentPort) { diff --git a/packages/compass-utilities/src/ai-assistant/index.spec.mts b/packages/compass-utilities/src/ai-assistant/index.spec.mts index 1493a0baac5..3e72634e390 100644 --- a/packages/compass-utilities/src/ai-assistant/index.spec.mts +++ b/packages/compass-utilities/src/ai-assistant/index.spec.mts @@ -2,7 +2,7 @@ import process from 'node:process'; import { EventEmitter } from 'node:events'; import { expect } from 'chai'; import type { MessagePortMain, ParentPort } from 'electron'; -import { main } from './main.mts'; +import { main } from './index.mts'; function createFakePort(): MessagePortMain & { sent: unknown[] } { const sent: unknown[] = []; From 5c30fcc9edddcc3051ca7b21afd02420d1c49eb5 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Mon, 9 Nov 2026 13:18:53 +0100 Subject: [PATCH 22/23] chore(compass-utilities): restore the ai-assistant utility entry The export-free entry (`index.mts` + `main.mts`) was a workaround for the webpack 5.112.2 crash. With webpack pinned back to 5.107.0 the entry can export `name`/`main` again and the spec can import from it directly. --- .../src/ai-assistant/main.mts | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 packages/compass-utilities/src/ai-assistant/main.mts diff --git a/packages/compass-utilities/src/ai-assistant/main.mts b/packages/compass-utilities/src/ai-assistant/main.mts deleted file mode 100644 index 02afe8f5957..00000000000 --- a/packages/compass-utilities/src/ai-assistant/main.mts +++ /dev/null @@ -1,55 +0,0 @@ -import process from 'node:process'; - -import { listen } from '@mongodb-js/compass-events'; -import { ToolsHost } from '@mongodb-js/compass-generative-ai/utility'; -import { createUtilityLogger } from '../logging.mts'; -import type { UtilityParentPort } from '../ipc.mts'; -import { onPort } from '../ipc.mts'; - -export const name = 'ai-assistant'; - -export function main(parentPort: UtilityParentPort): Disposable { - using ds = new DisposableStack(); - - ds.use( - listen(process, 'unhandledRejection', (reason) => { - throw reason; - }) - ); - - const logger = createUtilityLogger(parentPort, name); - - const hosts = new Set(); - ds.defer(() => { - for (const host of hosts) { - void host.stop(); - } - }); - - ds.use( - onPort(parentPort, (port) => { - const host = new ToolsHost(port, { logger }); - hosts.add(host); - listen( - port, - 'close', - () => { - hosts.delete(host); - void host.stop().catch((error) => { - logger.log.error( - logger.mongoLogId(1_001_000_454), - 'ai-assistant', - 'Error when stopping the tools host', - { - error: error instanceof Error ? error.message : String(error), - } - ); - }); - }, - { once: true } - ); - }) - ); - - return ds.move(); -} From 823b31a4d8b6524c48cc7abc01c8484f2291d6ef Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Mon, 9 Nov 2026 13:24:37 +0100 Subject: [PATCH 23/23] chore(webpack-config-compass): keep the caret range for webpack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The exact pin is not needed: the lock carries the nested `configs/webpack-config-compass/node_modules/webpack@5.107.0` (the copy `webpack-compass` resolves via `WEBPACK_PACKAGE`), and npm keeps an existing lock entry as long as it satisfies the range. Back to `^5.107.0`, consistent with the rest of the repo, with the lock doing the pinning. Note: this relies on the lock entry, so a from-scratch lock resolution would dedupe it to the hoisted 5.112.2 (which crashes the compass-web build) — the same latent state main is in. --- configs/webpack-config-compass/package.json | 2 +- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/webpack-config-compass/package.json b/configs/webpack-config-compass/package.json index f5798023660..01815cfa647 100644 --- a/configs/webpack-config-compass/package.json +++ b/configs/webpack-config-compass/package.json @@ -84,7 +84,7 @@ "react-refresh": "^0.10.0", "source-map-loader": "^4.0.1", "style-loader": "^3.2.1", - "webpack": "5.107.0", + "webpack": "^5.107.0", "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.2", diff --git a/package-lock.json b/package-lock.json index 3dc3d69d308..58786336249 100644 --- a/package-lock.json +++ b/package-lock.json @@ -221,7 +221,7 @@ "react-refresh": "^0.10.0", "source-map-loader": "^4.0.1", "style-loader": "^3.2.1", - "webpack": "5.107.0", + "webpack": "^5.107.0", "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.2",