From fae790a34797877ea78dc65ea78db5b6059d226a Mon Sep 17 00:00:00 2001 From: gagik Date: Tue, 4 Nov 2025 16:18:41 +0100 Subject: [PATCH 1/7] chore: working tool calls --- .yalc/mongodb-mcp-server/LICENSE | 202 ++ .yalc/mongodb-mcp-server/README.md | 720 ++++++ .yalc/mongodb-mcp-server/package.json | 94 + package-lock.json | 2197 ++++++++++++++++- .../src/compass-assistant-provider.tsx | 23 +- .../src/components/assistant-chat.tsx | 2 + .../src/docs-provider-transport.ts | 11 + packages/compass-assistant/src/prompts.ts | 4 +- .../src/connections-navigation-tree.spec.tsx | 2 + .../src/constants.tsx | 1 + .../src/item-actions.ts | 6 + .../.yalc/mongodb-mcp-server/LICENSE | 202 ++ .../.yalc/mongodb-mcp-server/README.md | 720 ++++++ .../.yalc/mongodb-mcp-server/package.json | 94 + .../.yalc/mongodb-mcp-server/yalc.sig | 1 + packages/compass-generative-ai/package.json | 5 + packages/compass-generative-ai/src/index.ts | 14 + .../src/mcp-connection-error-handler.ts | 21 + .../src/mcp-connection-manager.ts | 175 ++ .../src/mcp-controller.ts | 360 +++ .../compass-generative-ai/src/mcp-service.ts | 5 + .../compass-generative-ai/src/provider.tsx | 61 +- packages/compass-generative-ai/yalc.lock | 9 + .../src/preferences-schema.tsx | 13 + .../components/settings/gen-ai-settings.tsx | 1 + .../connections-navigation.tsx | 6 + .../multiple-connections/sidebar.tsx | 30 + packages/compass-sidebar/src/index.ts | 11 + packages/compass-sidebar/src/modules/index.ts | 2 + packages/compass-sidebar/src/plugin.tsx | 8 +- packages/compass-sidebar/src/stores/store.ts | 4 + packages/compass-web/src/entrypoint.tsx | 125 +- packages/compass/src/app/components/home.tsx | 45 +- 33 files changed, 5052 insertions(+), 122 deletions(-) create mode 100644 .yalc/mongodb-mcp-server/LICENSE create mode 100644 .yalc/mongodb-mcp-server/README.md create mode 100644 .yalc/mongodb-mcp-server/package.json create mode 100644 packages/compass-generative-ai/.yalc/mongodb-mcp-server/LICENSE create mode 100644 packages/compass-generative-ai/.yalc/mongodb-mcp-server/README.md create mode 100644 packages/compass-generative-ai/.yalc/mongodb-mcp-server/package.json create mode 100644 packages/compass-generative-ai/.yalc/mongodb-mcp-server/yalc.sig create mode 100644 packages/compass-generative-ai/src/mcp-connection-error-handler.ts create mode 100644 packages/compass-generative-ai/src/mcp-connection-manager.ts create mode 100644 packages/compass-generative-ai/src/mcp-controller.ts create mode 100644 packages/compass-generative-ai/src/mcp-service.ts create mode 100644 packages/compass-generative-ai/yalc.lock diff --git a/.yalc/mongodb-mcp-server/LICENSE b/.yalc/mongodb-mcp-server/LICENSE new file mode 100644 index 00000000000..7a4a3ea2424 --- /dev/null +++ b/.yalc/mongodb-mcp-server/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/.yalc/mongodb-mcp-server/README.md b/.yalc/mongodb-mcp-server/README.md new file mode 100644 index 00000000000..f60caa25d13 --- /dev/null +++ b/.yalc/mongodb-mcp-server/README.md @@ -0,0 +1,720 @@ +[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?logo=data:image/svg%2bxml;base64,PHN2ZyBmaWxsPSIjRkZGRkZGIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciICB2aWV3Qm94PSIwIDAgNDggNDgiIHdpZHRoPSIyNHB4IiBoZWlnaHQ9IjI0cHgiPjxwYXRoIGQ9Ik00NC45OTkgMTAuODd2MjYuMjFjMCAxLjAzLS41OSAxLjk3LTEuNTEgMi40Mi0yLjY4IDEuMjktOCAzLjg1LTguMzUgNC4wMS0uMTMuMDctLjM4LjItLjY3LjMxLjM1LS42LjUzLTEuMy41My0yLjAyVjYuMmMwLS43NS0uMi0xLjQ1LS41Ni0yLjA2LjA5LjA0LjE3LjA4LjI0LjExLjIuMSA1Ljk4IDIuODYgOC44IDQuMkM0NC40MDkgOC45IDQ0Ljk5OSA5Ljg0IDQ0Ljk5OSAxMC44N3pNNy40OTkgMjYuMDNjMS42IDEuNDYgMy40MyAzLjEzIDUuMzQgNC44NmwtNC42IDMuNWMtLjc3LjU3LTEuNzguNS0yLjU2LS4wNS0uNS0uMzYtMS44OS0xLjY1LTEuODktMS42NS0xLjAxLS44MS0xLjA2LTIuMzItLjExLTMuMTlDMy42NzkgMjkuNSA1LjE3OSAyOC4xMyA3LjQ5OSAyNi4wM3pNMzEuOTk5IDYuMnYxMC4xMWwtNy42MyA1LjgtNi44NS01LjIxYzQuOTgtNC41MyAxMC4wMS05LjExIDEyLjY1LTExLjUyQzMwLjg2OSA0Ljc0IDMxLjk5OSA1LjI1IDMxLjk5OSA2LjJ6TTMyIDQxLjc5OFYzMS42OUw4LjI0IDEzLjYxYy0uNzctLjU3LTEuNzgtLjUtMi41Ni4wNS0uNS4zNi0xLjg5IDEuNjUtMS44OSAxLjY1LTEuMDEuODEtMS4wNiAyLjMyLS4xMSAzLjE5IDAgMCAyMC4xNDUgMTguMzM4IDI2LjQ4NSAyNC4xMTZDMzAuODcxIDQzLjI2IDMyIDQyLjc1MyAzMiA0MS43OTh6Ii8+PC9zdmc+)](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%2C%22--readOnly%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D) +[![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Server-1e1e1e?logo=data:image/svg%2bxml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgc3R5bGU9ImZsZXg6bm9uZTtsaW5lLWhlaWdodDoxIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxZW0iCiAgICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHRpdGxlPkN1cnNvcjwvdGl0bGU+CiAgICA8cGF0aCBkPSJNMTEuOTI1IDI0bDEwLjQyNS02LTEwLjQyNS02TDEuNSAxOGwxMC40MjUgNnoiCiAgICAgICAgZmlsbD0idXJsKCNsb2JlLWljb25zLWN1cnNvcnVuZGVmaW5lZC1maWxsLTApIj48L3BhdGg+CiAgICA8cGF0aCBkPSJNMjIuMzUgMThWNkwxMS45MjUgMHYxMmwxMC40MjUgNnoiIGZpbGw9InVybCgjbG9iZS1pY29ucy1jdXJzb3J1bmRlZmluZWQtZmlsbC0xKSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTExLjkyNSAwTDEuNSA2djEybDEwLjQyNS02VjB6IiBmaWxsPSJ1cmwoI2xvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMikiPjwvcGF0aD4KICAgIDxwYXRoIGQ9Ik0yMi4zNSA2TDExLjkyNSAyNFYxMkwyMi4zNSA2eiIgZmlsbD0iIzU1NSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIyLjM1IDZsLTEwLjQyNSA2TDEuNSA2aDIwLjg1eiIgZmlsbD0iI2ZmZiI+PC9wYXRoPgogICAgPGRlZnM+CiAgICAgICAgPGxpbmVhckdyYWRpZW50IGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBpZD0ibG9iZS1pY29ucy1jdXJzb3J1bmRlZmluZWQtZmlsbC0wIgogICAgICAgICAgICB4MT0iMTEuOTI1IiB4Mj0iMTEuOTI1IiB5MT0iMTIiIHkyPSIyNCI+CiAgICAgICAgICAgIDxzdG9wIG9mZnNldD0iLjE2IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9Ii4zOSI+PC9zdG9wPgogICAgICAgICAgICA8c3RvcCBvZmZzZXQ9Ii42NTgiIHN0b3AtY29sb3I9IiNmZmYiIHN0b3Atb3BhY2l0eT0iLjgiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgICAgIDxsaW5lYXJHcmFkaWVudCBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImxvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMSIKICAgICAgICAgICAgeDE9IjIyLjM1IiB4Mj0iMTEuOTI1IiB5MT0iNi4wMzciIHkyPSIxMi4xNSI+CiAgICAgICAgICAgIDxzdG9wIG9mZnNldD0iLjE4MiIgc3RvcC1jb2xvcj0iI2ZmZiIgc3RvcC1vcGFjaXR5PSIuMzEiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIuNzE1IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9IjAiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgICAgIDxsaW5lYXJHcmFkaWVudCBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImxvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMiIKICAgICAgICAgICAgeDE9IjExLjkyNSIgeDI9IjEuNSIgeTE9IjAiIHkyPSIxOCI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNmZmYiIHN0b3Atb3BhY2l0eT0iLjYiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIuNjY3IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9Ii4yMiI+PC9zdG9wPgogICAgICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgICA8L2RlZnM+Cjwvc3ZnPgo=)](https://cursor.com/install-mcp?name=MongoDB&config=eyJjb21tYW5kIjoibnB4IC15IG1vbmdvZGItbWNwLXNlcnZlciAtLXJlYWRPbmx5In0%3D) + +# MongoDB MCP Server + +A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas. + +## πŸ“š Table of Contents + +- [πŸš€ Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Setup](#setup) + - [Quick Start](#quick-start) +- [πŸ› οΈ Supported Tools](#supported-tools) + - [MongoDB Atlas Tools](#mongodb-atlas-tools) + - [MongoDB Database Tools](#mongodb-database-tools) +- [πŸ“„ Supported Resources](#supported-resources) +- [βš™οΈ Configuration](#configuration) + - [Configuration Options](#configuration-options) + - [Atlas API Access](#atlas-api-access) + - [Configuration Methods](#configuration-methods) + - [Environment Variables](#environment-variables) + - [Command-Line Arguments](#command-line-arguments) + - [MCP Client Configuration](#mcp-configuration-file-examples) + - [Proxy Support](#proxy-support) +- [πŸš€ Deploy on Public Clouds](#deploy-on-public-clouds) + - [Azure Cloud](#azure) +- [🀝 Contributing](#contributing) + + + +## Prerequisites + +- Node.js + - At least 20.19.0 + - When using v22 then at least v22.12.0 + - Otherwise any version 23+ + +```shell +node -v +``` + +- A MongoDB connection string or Atlas API credentials, **_the Server will not start unless configured_**. + - **_Service Accounts Atlas API credentials_** are required to use the Atlas tools. You can create a service account in MongoDB Atlas and use its credentials for authentication. See [Atlas API Access](#atlas-api-access) for more details. + - If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance. + +## Setup + +### Quick Start + +> **πŸ”’ Security Recommendation 1:** When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See [Atlas API Permissions](#atlas-api-permissions) for details. + +> **πŸ”’ Security Recommendation 2:** For enhanced security, we strongly recommend using environment variables to pass sensitive configuration such as connection strings and API credentials instead of command line arguments. Command line arguments can be visible in process lists and logged in various system locations, potentially exposing your secrets. Environment variables provide a more secure way to handle sensitive information. + +Most MCP clients require a configuration file to be created or modified to add the MCP server. + +Note: The configuration file syntax can be different across clients. Please refer to the following links for the latest expected syntax: + +- **Windsurf**: https://docs.windsurf.com/windsurf/mcp +- **VSCode**: https://code.visualstudio.com/docs/copilot/chat/mcp-servers +- **Claude Desktop**: https://modelcontextprotocol.io/quickstart/user +- **Cursor**: https://docs.cursor.com/context/model-context-protocol + +> **Default Safety Notice:** All examples below include `--readOnly` by default to ensure safe, read-only access to your data. Remove `--readOnly` if you need to enable write operations. + +#### Option 1: Connection String + +You can pass your connection string via environment variables, make sure to use a valid username and password. + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"], + "env": { + "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase" + } + } + } +} +``` + +NOTE: The connection string can be configured to connect to any MongoDB cluster, whether it's a local instance or an Atlas cluster. + +#### Option 2: Atlas API Credentials + +Use your Atlas API Service Accounts credentials. Must follow all the steps in [Atlas API Access](#atlas-api-access) section. + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"], + "env": { + "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", + "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" + } + } + } +} +``` + +#### Option 3: Standalone Service using environment variables and command line arguments + +You can source environment variables defined in a config file or explicitly set them like we do in the example below and run the server via npx. + +```shell +# Set your credentials as environment variables first +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Then start the server +npx -y mongodb-mcp-server@latest --readOnly +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +- For a complete list of configuration options see [Configuration Options](#configuration-options) +- To configure your Atlas Service Accounts credentials please refer to [Atlas API Access](#atlas-api-access) +- Connection String via environment variables in the MCP file [example](#connection-string-with-environment-variables) +- Atlas API credentials via environment variables in the MCP file [example](#atlas-api-credentials-with-environment-variables) + +#### Option 4: Using Docker + +You can run the MongoDB MCP Server in a Docker container, which provides isolation and doesn't require a local Node.js installation. + +#### Run with Environment Variables + +You may provide either a MongoDB connection string OR Atlas API credentials: + +##### Option A: No configuration + +```shell +docker run --rm -i \ + mongodb/mongodb-mcp-server:latest +``` + +##### Option B: With MongoDB connection string + +```shell +# Set your credentials as environment variables first +export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Then start the docker container +docker run --rm -i \ + -e MDB_MCP_CONNECTION_STRING \ + -e MDB_MCP_READ_ONLY="true" \ + mongodb/mongodb-mcp-server:latest +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +##### Option C: With Atlas API credentials + +```shell +# Set your credentials as environment variables first +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Then start the docker container +docker run --rm -i \ + -e MDB_MCP_API_CLIENT_ID \ + -e MDB_MCP_API_CLIENT_SECRET \ + -e MDB_MCP_READ_ONLY="true" \ + mongodb/mongodb-mcp-server:latest +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +##### Docker in MCP Configuration File + +Without options: + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "docker", + "args": [ + "run", + "--rm", + "-e", + "MDB_MCP_READ_ONLY=true", + "-i", + "mongodb/mongodb-mcp-server:latest" + ] + } + } +} +``` + +With connection string: + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "docker", + "args": [ + "run", + "--rm", + "-i", + "-e", + "MDB_MCP_CONNECTION_STRING", + "-e", + "MDB_MCP_READ_ONLY=true", + "mongodb/mongodb-mcp-server:latest" + ], + "env": { + "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + } + } + } +} +``` + +With Atlas API credentials: + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "docker", + "args": [ + "run", + "--rm", + "-i", + "-e", + "MDB_MCP_READ_ONLY=true", + "-e", + "MDB_MCP_API_CLIENT_ID", + "-e", + "MDB_MCP_API_CLIENT_SECRET", + "mongodb/mongodb-mcp-server:latest" + ], + "env": { + "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", + "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" + } + } + } +} +``` + +#### Option 5: Running as an HTTP Server + +> **⚠️ Security Notice:** This server now supports Streamable HTTP transport for remote connections. **HTTP transport is NOT recommended for production use without implementing proper authentication and security measures.** + +**Suggested Security Measures Examples:** + +- Implement authentication (e.g., API gateway, reverse proxy) +- Use HTTPS/TLS encryption +- Deploy behind a firewall or in private networks +- Implement rate limiting +- Never expose directly to the internet + +For more details, see [MCP Security Best Practices](https://modelcontextprotocol.io/docs/concepts/transports#security-considerations). + +You can run the MongoDB MCP Server as an HTTP server instead of the default stdio transport. This is useful if you want to interact with the server over HTTP, for example from a web client or to expose the server on a specific port. + +To start the server with HTTP transport, use the `--transport http` option: + +```shell +npx -y mongodb-mcp-server@latest --transport http +``` + +By default, the server will listen on `http://127.0.0.1:3000`. You can customize the host and port using the `--httpHost` and `--httpPort` options: + +```shell +npx -y mongodb-mcp-server@latest --transport http --httpHost=0.0.0.0 --httpPort=8080 +``` + +- `--httpHost` (default: 127.0.0.1): The host to bind the HTTP server. +- `--httpPort` (default: 3000): The port number for the HTTP server. + +> **Note:** The default transport is `stdio`, which is suitable for integration with most MCP clients. Use `http` transport if you need to interact with the server over HTTP. + +## πŸ› οΈ Supported Tools + +### Tool List + +#### MongoDB Atlas Tools + +- `atlas-list-orgs` - Lists MongoDB Atlas organizations +- `atlas-list-projects` - Lists MongoDB Atlas projects +- `atlas-create-project` - Creates a new MongoDB Atlas project +- `atlas-list-clusters` - Lists MongoDB Atlas clusters +- `atlas-inspect-cluster` - Inspect a specific MongoDB Atlas cluster +- `atlas-create-free-cluster` - Create a free MongoDB Atlas cluster +- `atlas-connect-cluster` - Connects to MongoDB Atlas cluster +- `atlas-inspect-access-list` - Inspect IP/CIDR ranges with access to MongoDB Atlas clusters +- `atlas-create-access-list` - Configure IP/CIDR access list for MongoDB Atlas clusters +- `atlas-list-db-users` - List MongoDB Atlas database users +- `atlas-create-db-user` - Creates a MongoDB Atlas database user +- `atlas-list-alerts` - List MongoDB Atlas Alerts for a Project +- `atlas-get-performance-advisor` - Gets Atlas Performance Advisor recommendations (index suggestions, drop index suggestions, schema suggestions, slow query logs) + +NOTE: atlas tools are only available when you set credentials on [configuration](#configuration) section. + +#### MongoDB Atlas Local Tools + +- `atlas-local-list-deployments` - Lists MongoDB Atlas Local deployments +- `atlas-local-create-deployment` - Creates a MongoDB Atlas Local deployment +- `atlas-local-connect-deployment` - Connects to a MongoDB Atlas Local deployment +- `atlas-local-delete-deployment` - Deletes a MongoDB Atlas Local deployment + +#### MongoDB Database Tools + +- `connect` - Connect to a MongoDB instance +- `find` - Run a find query against a MongoDB collection. The number of documents returned is limited by the `limit` parameter and the server's `maxDocumentsPerQuery` configuration, whichever is smaller. The total size of the returned documents is also limited by the `responseBytesLimit` parameter and the server's `maxBytesPerQuery` configuration, whichever is smaller. +- `aggregate` - Run an aggregation against a MongoDB collection. The number of documents returned is limited by the server's `maxDocumentsPerQuery` configuration. The total size of the returned documents is also limited by the `responseBytesLimit` parameter and the server's `maxBytesPerQuery` configuration, whichever is smaller. +- `count` - Get the number of documents in a MongoDB collection +- `insert-one` - Insert a single document into a MongoDB collection +- `insert-many` - Insert multiple documents into a MongoDB collection +- `create-index` - Create an index for a MongoDB collection +- `update-one` - Update a single document in a MongoDB collection +- `update-many` - Update multiple documents in a MongoDB collection +- `rename-collection` - Rename a MongoDB collection +- `delete-one` - Delete a single document from a MongoDB collection +- `delete-many` - Delete multiple documents from a MongoDB collection +- `drop-collection` - Remove a collection from a MongoDB database +- `drop-database` - Remove a MongoDB database +- `list-databases` - List all databases for a MongoDB connection +- `list-collections` - List all collections for a given database +- `collection-indexes` - Describe the indexes for a collection +- `collection-schema` - Describe the schema for a collection +- `collection-storage-size` - Get the size of a collection in MB +- `db-stats` - Return statistics about a MongoDB database +- `export` - Export query or aggregation results to EJSON format. Creates a uniquely named export accessible via the `exported-data` resource. + +## πŸ“„ Supported Resources + +- `config` - Server configuration, supplied by the user either as environment variables or as startup arguments with sensitive parameters redacted. The resource can be accessed under URI `config://config`. +- `debug` - Debugging information for MongoDB connectivity issues. Tracks the last connectivity attempt and error information. The resource can be accessed under URI `debug://mongodb`. +- `exported-data` - A resource template to access the data exported using the export tool. The template can be accessed under URI `exported-data://{exportName}` where `exportName` is the unique name for an export generated by the export tool. + +## Configuration + +> **πŸ”’ Security Best Practice:** We strongly recommend using environment variables for sensitive configuration such as API credentials (`MDB_MCP_API_CLIENT_ID`, `MDB_MCP_API_CLIENT_SECRET`) and connection strings (`MDB_MCP_CONNECTION_STRING`) instead of command-line arguments. Environment variables are not visible in process lists and provide better security for your sensitive data. + +The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest): + +1. Command-line arguments +2. Environment variables + +### Configuration Options + +| CLI Option | Environment Variable | Default | Description | +| -------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apiClientId` | `MDB_MCP_API_CLIENT_ID` | `` | Atlas API client ID for authentication. Required for running Atlas tools. | +| `apiClientSecret` | `MDB_MCP_API_CLIENT_SECRET` | `` | Atlas API client secret for authentication. Required for running Atlas tools. | +| `atlasTemporaryDatabaseUserLifetimeMs` | `MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS` | `14400000` | Time in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being automatically deleted. | +| `confirmationRequiredTools` | `MDB_MCP_CONFIRMATION_REQUIRED_TOOLS` | `"atlas-create-access-list,atlas-create-db-user,drop-database,drop-collection,delete-many,drop-index"` | Comma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation. | +| `connectionString` | `MDB_MCP_CONNECTION_STRING` | `` | MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the connect tool before interacting with MongoDB data. | +| `disableEmbeddingsValidation` | `MDB_MCP_DISABLE_EMBEDDINGS_VALIDATION` | `false` | When set to true, disables validation of embeddings dimensions. | +| `disabledTools` | `MDB_MCP_DISABLED_TOOLS` | `""` | Comma separated values of tool names, operation types, and/or categories of tools that will be disabled. | +| `exportCleanupIntervalMs` | `MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS` | `120000` | Time in milliseconds between export cleanup cycles that remove expired export files. | +| `exportTimeoutMs` | `MDB_MCP_EXPORT_TIMEOUT_MS` | `300000` | Time in milliseconds after which an export is considered expired and eligible for cleanup. | +| `exportsPath` | `MDB_MCP_EXPORTS_PATH` | see below\* | Folder to store exported data files. | +| `httpHost` | `MDB_MCP_HTTP_HOST` | `"127.0.0.1"` | Host address to bind the HTTP server to (only used when transport is 'http'). | +| `httpPort` | `MDB_MCP_HTTP_PORT` | `3000` | Port number for the HTTP server (only used when transport is 'http'). | +| `idleTimeoutMs` | `MDB_MCP_IDLE_TIMEOUT_MS` | `600000` | Idle timeout for a client to disconnect (only applies to http transport). | +| `indexCheck` | `MDB_MCP_INDEX_CHECK` | `false` | When set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan. | +| `logPath` | `MDB_MCP_LOG_PATH` | see below\* | Folder to store logs. | +| `loggers` | `MDB_MCP_LOGGERS` | `"disk,mcp"` see below\* | Comma separated values of logger types. | +| `maxBytesPerQuery` | `MDB_MCP_MAX_BYTES_PER_QUERY` | `16777216` | The maximum size in bytes for results from a find or aggregate tool call. This serves as an upper bound for the responseBytesLimit parameter in those tools. | +| `maxDocumentsPerQuery` | `MDB_MCP_MAX_DOCUMENTS_PER_QUERY` | `100` | The maximum number of documents that can be returned by a find or aggregate tool call. For the find tool, the effective limit will be the smaller of this value and the tool's limit parameter. | +| `notificationTimeoutMs` | `MDB_MCP_NOTIFICATION_TIMEOUT_MS` | `540000` | Notification timeout for a client to be aware of disconnect (only applies to http transport). | +| `previewFeatures` | `MDB_MCP_PREVIEW_FEATURES` | `""` | Comma separated values of preview features that are enabled. | +| `readOnly` | `MDB_MCP_READ_ONLY` | `false` | When set to true, only allows read, connect, and metadata operation types, disabling create/update/delete operations. | +| `telemetry` | `MDB_MCP_TELEMETRY` | `"enabled"` | When set to disabled, disables telemetry collection. | +| `transport` | `MDB_MCP_TRANSPORT` | `"stdio"` | Either 'stdio' or 'http'. | +| `voyageApiKey` | `MDB_MCP_VOYAGE_API_KEY` | `""` | API key for Voyage AI embeddings service (required for vector search operations with text-to-embedding conversion). | + +#### Logger Options + +The `loggers` configuration option controls where logs are sent. You can specify one or more logger types as a comma-separated list. The available options are: + +- `mcp`: Sends logs to the MCP client (if supported by the client/transport). +- `disk`: Writes logs to disk files. Log files are stored in the log path (see `logPath` above). +- `stderr`: Outputs logs to standard error (stderr), useful for debugging or when running in containers. + +**Default:** `disk,mcp` (logs are written to disk and sent to the MCP client). + +You can combine multiple loggers, e.g. `--loggers disk stderr` or `export MDB_MCP_LOGGERS="mcp,stderr"`. + +##### Example: Set logger via environment variable + +```shell +export MDB_MCP_LOGGERS="disk,stderr" +``` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +##### Example: Set logger via command-line argument + +```shell +npx -y mongodb-mcp-server@latest --loggers mcp stderr +``` + +##### Log File Location + +When using the `disk` logger, log files are stored in: + +- **Windows:** `%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs` +- **macOS/Linux:** `~/.mongodb/mongodb-mcp/.app-logs` + +You can override the log directory with the `logPath` option. + +#### Disabled Tools + +You can disable specific tools or categories of tools by using the `disabledTools` option. This option accepts an array of strings, +where each string can be a tool name, operation type, or category. + +The way the array is constructed depends on the type of configuration method you use: + +- For **environment variable** configuration, use a comma-separated string: `export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema"`. +- For **command-line argument** configuration, use a space-separated string: `--disabledTools create update delete atlas collectionSchema`. + +Categories of tools: + +- `atlas` - MongoDB Atlas tools, such as list clusters, create cluster, etc. +- `mongodb` - MongoDB database tools, such as find, aggregate, etc. + +Operation types: + +- `create` - Tools that create resources, such as create cluster, insert document, etc. +- `update` - Tools that update resources, such as update document, rename collection, etc. +- `delete` - Tools that delete resources, such as delete document, drop collection, etc. +- `read` - Tools that read resources, such as find, aggregate, list clusters, etc. +- `metadata` - Tools that read metadata, such as list databases/collections/indexes, infer collection schema, etc. +- `connect` - Tools that allow you to connect or switch the connection to a MongoDB instance. If this is disabled, you will need to provide a connection string through the config when starting the server. + +#### Require Confirmation + +If your client supports [elicitation](https://modelcontextprotocol.io/specification/draft/client/elicitation), you can set the MongoDB MCP server to request user confirmation before executing certain tools. + +When a tool is marked as requiring confirmation, the server will send an elicitation request to the client. The client with elicitation support will then prompt the user for confirmation and send the response back to the server. If the client does not support elicitation, the tool will execute without confirmation. + +You can set the `confirmationRequiredTools` configuration option to specify the names of tools which require confirmation. By default, the following tools have this setting enabled: `drop-database`, `drop-collection`, `delete-many`, `atlas-create-db-user`, `atlas-create-access-list`. + +#### Read-Only Mode + +The `readOnly` configuration option allows you to restrict the MCP server to only use tools with "read", "connect", and "metadata" operation types. When enabled, all tools that have "create", "update" or "delete" operation types will not be registered with the server. + +This is useful for scenarios where you want to provide access to MongoDB data for analysis without allowing any modifications to the data or infrastructure. + +You can enable read-only mode using: + +- **Environment variable**: `export MDB_MCP_READ_ONLY=true` +- **Command-line argument**: `--readOnly` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +When read-only mode is active, you'll see a message in the server logs indicating which tools were prevented from registering due to this restriction. + +#### Index Check Mode + +The `indexCheck` configuration option allows you to enforce that query operations must use an index. When enabled, queries that perform a collection scan will be rejected to ensure better performance. + +This is useful for scenarios where you want to ensure that database queries are optimized. + +You can enable index check mode using: + +- **Environment variable**: `export MDB_MCP_INDEX_CHECK=true` +- **Command-line argument**: `--indexCheck` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +When index check mode is active, you'll see an error message if a query is rejected due to not using an index. + +#### Exports + +The data exported by the `export` tool is temporarily stored in the configured `exportsPath` on the machine running the MCP server until cleaned up by the export cleanup process. If the `exportsPath` configuration is not provided, the following defaults are used: + +- **Windows:** `%LOCALAPPDATA%\mongodb\mongodb-mcp\exports` +- **macOS/Linux:** `~/.mongodb/mongodb-mcp/exports` + +The `exportTimeoutMs` configuration controls the time after which the exported data is considered expired and eligible for cleanup. By default, exports expire after 5 minutes (300000ms). + +The `exportCleanupIntervalMs` configuration controls how frequently the cleanup process runs to remove expired export files. By default, cleanup runs every 2 minutes (120000ms). + +#### Telemetry + +The `telemetry` configuration option allows you to disable telemetry collection. When enabled, the MCP server will collect usage data and send it to MongoDB. + +You can disable telemetry using: + +- **Environment variable**: `export MDB_MCP_TELEMETRY=disabled` +- **Command-line argument**: `--telemetry disabled` +- **DO_NOT_TRACK environment variable**: `export DO_NOT_TRACK=1` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +#### Opting into Preview Features + +The MongoDB MCP Server may offer functionality that is still in development and may change in future releases. These features are considered "preview features" and are not enabled by default. Generally, these features are well tested, but may not offer the complete functionality we intend to provide in the final release or we'd like to gather feedback before making them generally available. To enable one or more preview features, use the `previewFeatures` configuration option. + +- For **environment variable** configuration, use a comma-separated string: `export MDB_MCP_PREVIEW_FEATURES="vectorSearch,feature1,feature2"`. +- For **command-line argument** configuration, use a space-separated string: `--previewFeatures vectorSearch feature1 feature2`. + +List of available preview features: + +- `vectorSearch` - Enables tools or functionality related to Vector Search in MongoDB Atlas: + - Index management, such as creating, listing, and dropping search and vector search indexes. + - Querying collections using vector search capabilities. This requires a configured embedding model that will be used to generate vector representations of the query data. Currently, only [Voyage AI](https://www.voyageai.com) embedding models are supported. Set the `voyageApiKey` configuration option with your Voyage AI API key to use this feature. + +### Atlas API Access + +To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas: + +> **ℹ️ Note:** For a detailed breakdown of the minimum required permissions for each Atlas operation, see the [Atlas API Permissions](#atlas-api-permissions) section below. + +1. **Create a Service Account:** + - Log in to MongoDB Atlas at [cloud.mongodb.com](https://cloud.mongodb.com) + - Navigate to Access Manager > Organization Access + - Click Add New > Applications > Service Accounts + - Enter name, description and expiration for your service account (e.g., "MCP, MCP Server Access, 7 days") + - **Assign only the minimum permissions needed for your use case.** + - See [Atlas API Permissions](#atlas-api-permissions) for details. + - Click "Create" + +To learn more about Service Accounts, check the [MongoDB Atlas documentation](https://www.mongodb.com/docs/atlas/api/service-accounts-overview/). + +2. **Save Client Credentials:** + + - After creation, you'll be shown the Client ID and Client Secret + - **Important:** Copy and save the Client Secret immediately as it won't be displayed again + +3. **Add Access List Entry:** + + - Add your IP address to the API access list + +4. **Configure the MCP Server:** + - Use one of the configuration methods below to set your `apiClientId` and `apiClientSecret` + +### Atlas API Permissions + +> **Security Warning:** Granting the Organization Owner role is rarely necessary and can be a security risk. Assign only the minimum permissions needed for your use case. + +#### Quick Reference: Required roles per operation + +| What you want to do | Safest Role to Assign (where) | +| ------------------------------------ | --------------------------------------- | +| List orgs/projects | Org Member or Org Read Only (Org) | +| Create new projects | Org Project Creator (Org) | +| View clusters/databases in a project | Project Read Only (Project) | +| Create/manage clusters in a project | Project Cluster Manager (Project) | +| Manage project access lists | Project IP Access List Admin (Project) | +| Manage database users | Project Database Access Admin (Project) | + +- **Prefer project-level roles** for most operations. Assign only to the specific projects you need to manage or view. +- **Avoid Organization Owner** unless you require full administrative control over all projects and settings in the organization. + +For a full list of roles and their privileges, see the [Atlas User Roles documentation](https://www.mongodb.com/docs/atlas/reference/user-roles/#service-user-roles). + +### Configuration Methods + +#### Environment Variables + +Set environment variables with the prefix `MDB_MCP_` followed by the option name in uppercase with underscores: + +**Linux/macOS (bash/zsh):** + +```bash +# Set Atlas API credentials (via Service Accounts) +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Set a custom MongoDB connection string +export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Set log path +export MDB_MCP_LOG_PATH="/path/to/logs" +``` + +**Windows Command Prompt (cmd):** + +```cmd +set "MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id" +set "MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret" + +set "MDB_MCP_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +set "MDB_MCP_LOG_PATH=C:\path\to\logs" +``` + +**Windows PowerShell:** + +```powershell +# Set Atlas API credentials (via Service Accounts) +$env:MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +$env:MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Set a custom MongoDB connection string +$env:MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Set log path +$env:MDB_MCP_LOG_PATH="C:\path\to\logs" +``` + +#### MCP configuration file examples + +##### Connection String with environment variables + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server"], + "env": { + "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + } + } + } +} +``` + +##### Atlas API credentials with environment variables + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server"], + "env": { + "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", + "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" + } + } + } +} +``` + +#### Command-Line Arguments + +Pass configuration options as command-line arguments when starting the server: + +> **πŸ”’ Security Note:** For sensitive configuration like API credentials and connection strings, use environment variables instead of command-line arguments. + +```shell +# Set sensitive data as environment variable +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" +export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Start the server with command line arguments +npx -y mongodb-mcp-server@latest --logPath=/path/to/logs --readOnly --indexCheck +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +#### MCP configuration file examples + +##### Connection String with command-line arguments + +> **πŸ”’ Security Note:** We do not recommend passing connection string as command line argument. Connection string might contain credentials which can be visible in process lists and logged in various system locations, potentially exposing your credentials. Instead configure [connection string through environment variables](#connection-string-with-environment-variables) + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": [ + "-y", + "mongodb-mcp-server", + "--connectionString", + "mongodb+srv://username:password@cluster.mongodb.net/myDatabase", + "--readOnly" + ] + } + } +} +``` + +##### Atlas API credentials with command-line arguments + +> **πŸ”’ Security Note:** We do not recommend passing Atlas API credentials as command line argument. The provided credentials can be visible in process lists and logged in various system locations, potentially exposing your credentials. Instead configure [Atlas API credentials through environment variables](#atlas-api-credentials-with-environment-variables) + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": [ + "-y", + "mongodb-mcp-server", + "--apiClientId", + "your-atlas-service-accounts-client-id", + "--apiClientSecret", + "your-atlas-service-accounts-client-secret", + "--readOnly" + ] + } + } +} +``` + +### Proxy Support + +The MCP Server will detect typical PROXY environment variables and use them for +connecting to the Atlas API, your MongoDB Cluster, or any other external calls +to third-party services like OID Providers. The behaviour is the same as what +`mongosh` does, so the same settings will work in the MCP Server. + +## πŸš€Deploy on Public Clouds + +You can deploy the MongoDB MCP Server to your preferred cloud provider using the deployment assets under `deploy/`. Each guide explains the prerequisites, configuration, and automation scripts that streamline the rollout. + +### Azure + +For detailed Azure instructions, see [deploy/azure/README.md](deploy/azure/README.md). + +## 🀝Contributing + +Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information. diff --git a/.yalc/mongodb-mcp-server/package.json b/.yalc/mongodb-mcp-server/package.json new file mode 100644 index 00000000000..5b253e2e58c --- /dev/null +++ b/.yalc/mongodb-mcp-server/package.json @@ -0,0 +1,94 @@ +{ + "name": "mongodb-mcp-server", + "description": "MongoDB Model Context Protocol Server", + "version": "1.2.0", + "type": "module", + "mcpName": "io.github.mongodb-js/mongodb-mcp-server", + "exports": { + ".": { + "import": { + "types": "./dist/esm/lib.d.ts", + "default": "./dist/esm/lib.js" + }, + "require": { + "types": "./dist/cjs/lib.d.ts", + "default": "./dist/cjs/lib.js" + } + } + }, + "main": "./dist/cjs/lib.js", + "types": "./dist/cjs/lib.d.ts", + "author": "MongoDB ", + "homepage": "https://github.com/mongodb-js/mongodb-mcp-server", + "repository": { + "url": "https://github.com/mongodb-js/mongodb-mcp-server.git" + }, + "bin": { + "mongodb-mcp-server": "dist/esm/index.js" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "dist" + ], + "scripts": { + "start": "node dist/index.js --transport http --loggers stderr mcp", + "start:stdio": "node dist/index.js --transport stdio --loggers stderr mcp", + "build:clean": "rm -rf dist", + "build:update-package-version": "tsx scripts/updatePackageVersion.ts", + "build:esm": "tsc --project tsconfig.esm.json && chmod +x dist/esm/index.js", + "build:cjs": "tsc --project tsconfig.cjs.json", + "build:universal-package": "tsx scripts/createUniversalPackage.ts", + "build": "npm run build:clean && concurrently \"npm run build:esm\" \"npm run build:cjs\" && npm run build:universal-package", + "inspect": "npm run build && mcp-inspector -- dist/esm/index.js", + "prettier": "prettier", + "check": "concurrently \"npm run build\" \"npm run check:types\" \"npm run check:lint\" \"npm run check:format\" \"npm run check:dependencies\"", + "check:lint": "eslint .", + "check:dependencies": "knip --strict", + "check:format": "prettier -c .", + "check:types": "tsc --noEmit --project tsconfig.json", + "fix": "npm run fix:lint && npm run reformat", + "fix:lint": "eslint . --fix", + "reformat": "prettier --write .", + "generate": "./scripts/generate.sh && npm run generate:arguments", + "generate:arguments": "tsx scripts/generateArguments.ts", + "test": "vitest --project eslint-rules --project unit-and-integration --coverage", + "pretest:accuracy": "npm run build", + "test:accuracy": "sh ./scripts/accuracy/runAccuracyTests.sh", + "test:long-running-tests": "vitest --project long-running-tests --coverage", + "atlas:cleanup": "vitest --project atlas-cleanup" + }, + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/sdk": "^1.17.4", + "@mongodb-js/device-id": "^0.3.1", + "@mongodb-js/devtools-proxy-support": "^0.5.3", + "@mongosh/arg-parser": "^3.19.0", + "@mongosh/service-provider-node-driver": "^3.17.0", + "ai": "^5.0.72", + "bson": "^6.10.4", + "express": "^5.1.0", + "lru-cache": "^11.1.0", + "mongodb-connection-string-url": "^3.0.2", + "mongodb-log-writer": "^2.4.1", + "mongodb-redact": "^1.2.0", + "mongodb-schema": "^12.6.2", + "node-fetch": "^3.3.2", + "node-machine-id": "1.1.12", + "oauth4webapi": "^3.8.0", + "openapi-fetch": "^0.14.0", + "ts-levenshtein": "^1.0.7", + "voyage-ai-provider": "^2.0.0", + "yargs-parser": "21.1.1", + "zod": "^3.25.76" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >= 23.0.0" + }, + "optionalDependencies": { + "@mongodb-js/atlas-local": "^1.0.2", + "kerberos": "^2.2.2" + }, + "yalcSig": "381112cf4afb16b0a08d1b0cd3d9c26f" +} diff --git a/package-lock.json b/package-lock.json index d3d09c04455..1cbb8e664cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10417,6 +10417,509 @@ "dev": true, "license": "MIT" }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.21.0.tgz", + "integrity": "sha512-YFBsXJMFCyI1zP98u7gezMFKX4lgu/XpoZJk7ufI6UlFKXLj2hAMUuRlQX/nrmIPOmhRrG6tw2OQ2ZA/ZlXYpQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.0.1", + "express-rate-limit": "^7.5.0", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.23.8", + "zod-to-json-schema": "^3.24.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@cfworker/json-schema": "^4.1.1" + }, + "peerDependenciesMeta": { + "@cfworker/json-schema": { + "optional": true + } + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "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==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/express": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.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" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "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": ">= 0.8" + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "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==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/mime-types": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "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==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/raw-body": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz", + "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.7.0", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "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/@modelcontextprotocol/sdk/node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/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" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema": { + "version": "3.24.6", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.6.tgz", + "integrity": "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.24.1" + } + }, + "node_modules/@mongodb-js/atlas-local": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local/-/atlas-local-1.0.2.tgz", + "integrity": "sha512-7x0vPe/17WMkOJfQLF/rGlqvo84RAFmrXUM++Rt3vLfPfLY8Pe5yE3N58FsYw72ZE838/viTdU6eyp/p/MFRwQ==", + "license": "Apache-2.0", + "optional": true, + "engines": { + "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" + }, + "optionalDependencies": { + "@mongodb-js/atlas-local-darwin-arm64": "1.0.2", + "@mongodb-js/atlas-local-darwin-x64": "1.0.2", + "@mongodb-js/atlas-local-linux-arm64-gnu": "1.0.2", + "@mongodb-js/atlas-local-linux-x64-gnu": "1.0.2", + "@mongodb-js/atlas-local-win32-x64-msvc": "1.0.2" + } + }, + "node_modules/@mongodb-js/atlas-local-darwin-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-darwin-arm64/-/atlas-local-darwin-arm64-1.0.2.tgz", + "integrity": "sha512-E7qzpBQj/hgPZQBjTOVTqcQgFjQeYxDLrGWVw0OXcPYXFOg8epWs87AtSS+JojzsdtBpU1ZnzYAJcLV0pJuNow==", + "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.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-darwin-x64/-/atlas-local-darwin-x64-1.0.2.tgz", + "integrity": "sha512-neK99QtGkrYHS03pEY+8N9+OL9YNwuiOYo34HyjIxRZ7EL3CC+H0ccQ9XEysns0oY7kfRYCnDHfxpl946CWbag==", + "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.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-linux-arm64-gnu/-/atlas-local-linux-arm64-gnu-1.0.2.tgz", + "integrity": "sha512-vBVlph+6cwOEJpZiur3gfD0qaOfxBUAPyy9FNL4WqYegxD8EWPOWx+nMN+21qwh2yuNmEQfEqQzI3sx+KIlHvQ==", + "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_modules/@mongodb-js/atlas-local-linux-x64-gnu": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-linux-x64-gnu/-/atlas-local-linux-x64-gnu-1.0.2.tgz", + "integrity": "sha512-Hbjx/QXZ/E6lXjay+Egq7L6MMZvAwg5o05yWbb/wct34sGwvDIGojIN5pT1VuqLl87Vyo8L3IljnrHp/+J5CeQ==", + "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/@mongodb-js/atlas-local-win32-x64-msvc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-win32-x64-msvc/-/atlas-local-win32-x64-msvc-1.0.2.tgz", + "integrity": "sha512-zfoEXSVrXtyeE4jJ4oUY++TOy8JpM9+oVr7goudzzQ/odNo/MnTUgsLEZoYQ2p5XsgTZFLm/nB9a2f5MFhJ3hw==", + "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-service": { "resolved": "packages/atlas-service", "link": true @@ -11110,9 +11613,9 @@ } }, "node_modules/@mongodb-js/oidc-plugin": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@mongodb-js/oidc-plugin/-/oidc-plugin-2.0.4.tgz", - "integrity": "sha512-mB7kEK80+DD2QrB01GmtFKm02ItJpIO9j7OARMHI4RL+rVQD3Ey9giluf3xQtuSdcmg7a+bf5fkJgQZCWMvRPg==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/oidc-plugin/-/oidc-plugin-2.0.5.tgz", + "integrity": "sha512-hCtqStgSaas7W+1ueCI6gJFNuM4scPpHe1S85+AOoFw6Q23HdhK7qdCBk2+IUkvdKmfRzOBtNglIFrlukhbmMg==", "license": "Apache-2.0", "dependencies": { "express": "^5.1.0", @@ -12053,6 +12556,156 @@ "whatwg-url": "^14.1.0 || ^13.0.0" } }, + "node_modules/@mongosh/service-provider-node-driver": { + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/@mongosh/service-provider-node-driver/-/service-provider-node-driver-3.17.3.tgz", + "integrity": "sha512-yMYBvY6681qb5yOo48uRerhQX6ZBPgvB8rVQ/fKMCjyeL1n3acEI6hOBEPAF5yHdjNHtyClxVfH4pbdZSb8NdA==", + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/devtools-connect": "^3.9.4", + "@mongodb-js/oidc-plugin": "^2.0.5", + "@mongosh/errors": "2.4.4", + "@mongosh/service-provider-core": "3.6.1", + "@mongosh/types": "^3.14.0", + "aws4": "^1.12.0", + "mongodb": "^6.19.0", + "mongodb-connection-string-url": "^3.0.2", + "socks": "^2.8.3" + }, + "engines": { + "node": ">=14.15.1" + }, + "optionalDependencies": { + "kerberos": "2.1.0", + "mongodb-client-encryption": "^6.5.0" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "license": "ISC", + "optional": true + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/kerberos": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-2.1.0.tgz", + "integrity": "sha512-HvOl6O6cyEN/8Z4CAocHe/sekJtvt5UrxUdCuu7bXDZ2Hnsy6OpsQbISW+lpm03vrbO2ir+1QQ5Sx/vMEhHnog==", + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "bindings": "^1.5.0", + "node-addon-api": "^6.1.0", + "prebuild-install": "7.1.1" + }, + "engines": { + "node": ">=12.9.0" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", + "license": "MIT", + "optional": true + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/node-abi": { + "version": "3.80.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.80.0.tgz", + "integrity": "sha512-LyPuZJcI9HVwzXK1GPxWNzrr+vr8Hp/3UqlmWxxh8p54U1ZbclOqbSog9lWHaCX+dBaiGi6n/hIX+mKu74GmPA==", + "license": "MIT", + "optional": true, + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/node-addon-api": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", + "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", + "license": "MIT", + "optional": true + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "license": "MIT", + "optional": true, + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/tar-fs": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", + "license": "MIT", + "optional": true, + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/@mongosh/service-provider-node-driver/node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "license": "MIT", + "optional": true, + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/@mongosh/shell-api": { "version": "3.24.0", "resolved": "https://registry.npmjs.org/@mongosh/shell-api/-/shell-api-3.24.0.tgz", @@ -17446,6 +18099,15 @@ } } }, + "node_modules/@vercel/oidc": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@vercel/oidc/-/oidc-3.0.3.tgz", + "integrity": "sha512-yNEQvPcVrK9sIe637+I0jD6leluPxzwJKx/Haw6F4H77CdDsszUn5V3o96LPziXkSNE2B83+Z3mjqGKBK/R6Gg==", + "license": "Apache-2.0", + "engines": { + "node": ">= 20" + } + }, "node_modules/@vue/compiler-core": { "version": "3.5.6", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.6.tgz", @@ -19681,9 +20343,10 @@ } }, "node_modules/aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", + "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==", + "license": "MIT" }, "node_modules/axe-core": { "version": "4.10.3", @@ -21984,7 +22647,6 @@ "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dev": true, "license": "MIT", "dependencies": { "object-assign": "^4", @@ -26274,6 +26936,27 @@ "node": ">=0.4.x" } }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", + "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -26400,6 +27083,21 @@ "ms": "^2.1.1" } }, + "node_modules/express-rate-limit": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, "node_modules/express/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -35406,10 +36104,13 @@ "link": true }, "node_modules/mongodb-redact": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/mongodb-redact/-/mongodb-redact-1.1.8.tgz", - "integrity": "sha512-EbZ+q7LsVz7q8n49mGIcXgP2UiBp6R6vHEVbmGnF21ThCnP6AIho7wqpHqyjqqGjg54DoXQJTCwHPSknsCHv6g==", - "license": "Apache-2.0" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/mongodb-redact/-/mongodb-redact-1.2.2.tgz", + "integrity": "sha512-Xpl0buo5yZ2qlKRr3y4UBqrSOFaDI5FRF0tppKcNteJ6HxoaITgjT255LQdO3JZ/d+pLuT5i4sHLMqEwMj6bug==", + "license": "Apache-2.0", + "dependencies": { + "regexp.escape": "^2.0.1" + } }, "node_modules/mongodb-schema": { "version": "12.6.3", @@ -36211,8 +36912,7 @@ "node_modules/node-machine-id": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", - "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", - "dev": true + "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==" }, "node_modules/node-preload": { "version": "0.2.1", @@ -37377,9 +38077,9 @@ } }, "node_modules/oauth4webapi": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/oauth4webapi/-/oauth4webapi-3.6.2.tgz", - "integrity": "sha512-hwWLiyBYuqhVdcIUJMJVKdEvz+DCweOcbSfqDyIv9PuUwrNfqrzfHP2bypZgZdbYOS67QYqnAnvZa2BJwBBrHw==", + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/oauth4webapi/-/oauth4webapi-3.8.2.tgz", + "integrity": "sha512-FzZZ+bht5X0FKe7Mwz3DAVAmlH1BV5blSak/lHMBKz0/EBMhX6B10GlQYI51+oRp8ObJaX0g6pXrAxZh5s8rjw==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/panva" @@ -37608,6 +38308,21 @@ "dev": true, "license": "MIT" }, + "node_modules/openapi-fetch": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/openapi-fetch/-/openapi-fetch-0.14.1.tgz", + "integrity": "sha512-l7RarRHxlEZYjMLd/PR0slfMVse2/vvIAGm75/F7J6MlQ8/b9uUQmUF2kCPrQhJqMXSxmYWObVgeYXbFYzZR+A==", + "license": "MIT", + "dependencies": { + "openapi-typescript-helpers": "^0.0.15" + } + }, + "node_modules/openapi-typescript-helpers": { + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/openapi-typescript-helpers/-/openapi-typescript-helpers-0.0.15.tgz", + "integrity": "sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==", + "license": "MIT" + }, "node_modules/openapi3-ts": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/openapi3-ts/-/openapi3-ts-4.5.0.tgz", @@ -38540,6 +39255,15 @@ "node": ">=0.10.0" } }, + "node_modules/pkce-challenge": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", + "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==", + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, "node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -41539,6 +42263,26 @@ "dev": true, "license": "MIT" }, + "node_modules/regexp.escape": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexp.escape/-/regexp.escape-2.0.1.tgz", + "integrity": "sha512-JItRb4rmyTzmERBkAf6J87LjDPy/RscIwmaJQ3gsFlAzrmZbZU8LwBw5IydFZXW9hqpgbPlGbMhtpqtuAhMgtg==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.3", + "es-errors": "^1.3.0", + "for-each": "^0.3.3", + "safe-regex-test": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/regexp.prototype.flags": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", @@ -44821,6 +45565,12 @@ "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", @@ -51024,9 +51774,14 @@ "@mongodb-js/compass-telemetry": "^1.19.1", "@mongodb-js/compass-utils": "^0.9.21", "@mongodb-js/connection-info": "^0.22.0", + "@mongosh/service-provider-node-driver": "^3.17.0", + "ai": "^5.0.72", "bson": "^6.10.4", "compass-preferences-model": "^2.64.0", "mongodb": "^6.19.0", + "mongodb-build-info": "^1.7.2", + "mongodb-connection-string-url": "^3.0.1", + "mongodb-mcp-server": "file:.yalc/mongodb-mcp-server", "mongodb-schema": "^12.6.3", "react": "^17.0.2", "react-redux": "^8.1.3", @@ -51056,6 +51811,190 @@ "xvfb-maybe": "^0.2.1" } }, + "packages/compass-generative-ai/.yalc/mongodb-mcp-server": { + "version": "1.2.0", + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/sdk": "^1.17.4", + "@mongodb-js/device-id": "^0.3.1", + "@mongodb-js/devtools-proxy-support": "^0.5.3", + "@mongosh/arg-parser": "^3.19.0", + "@mongosh/service-provider-node-driver": "^3.17.0", + "ai": "^5.0.72", + "bson": "^6.10.4", + "express": "^5.1.0", + "lru-cache": "^11.1.0", + "mongodb-connection-string-url": "^3.0.2", + "mongodb-log-writer": "^2.4.1", + "mongodb-redact": "^1.2.0", + "mongodb-schema": "^12.6.2", + "node-fetch": "^3.3.2", + "node-machine-id": "1.1.12", + "oauth4webapi": "^3.8.0", + "openapi-fetch": "^0.14.0", + "ts-levenshtein": "^1.0.7", + "voyage-ai-provider": "^2.0.0", + "yargs-parser": "21.1.1", + "zod": "^3.25.76" + }, + "bin": { + "mongodb-mcp-server": "dist/esm/index.js" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >= 23.0.0" + }, + "optionalDependencies": { + "@mongodb-js/atlas-local": "^1.0.2", + "kerberos": "^2.2.2" + } + }, + "packages/compass-generative-ai/node_modules/@ai-sdk/gateway": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@ai-sdk/gateway/-/gateway-2.0.6.tgz", + "integrity": "sha512-FmhR6Tle09I/RUda8WSPpJ57mjPWzhiVVlB50D+k+Qf/PBW0CBtnbAUxlNSR5v+NIZNLTK3C56lhb23ntEdxhQ==", + "license": "Apache-2.0", + "dependencies": { + "@ai-sdk/provider": "2.0.0", + "@ai-sdk/provider-utils": "3.0.16", + "@vercel/oidc": "3.0.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "zod": "^3.25.76 || ^4.1.8" + } + }, + "packages/compass-generative-ai/node_modules/@ai-sdk/provider-utils": { + "version": "3.0.16", + "resolved": "https://registry.npmjs.org/@ai-sdk/provider-utils/-/provider-utils-3.0.16.tgz", + "integrity": "sha512-lsWQY9aDXHitw7C1QRYIbVGmgwyT98TF3MfM8alNIXKpdJdi+W782Rzd9f1RyOfgRmZ08gJ2EYNDhWNK7RqpEA==", + "license": "Apache-2.0", + "dependencies": { + "@ai-sdk/provider": "2.0.0", + "@standard-schema/spec": "^1.0.0", + "eventsource-parser": "^3.0.6" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "zod": "^3.25.76 || ^4.1.8" + } + }, + "packages/compass-generative-ai/node_modules/@mongodb-js/device-id": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@mongodb-js/device-id/-/device-id-0.3.3.tgz", + "integrity": "sha512-y2SIriQec/HvIzFI1QCJAmjedShwbgmgUWkh3+qPgT2OyRKWE0yB7Lii/jANCtUNqqwBcUsMHY9/mPnuu5wfPQ==", + "license": "Apache-2.0" + }, + "packages/compass-generative-ai/node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "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/ai": { + "version": "5.0.87", + "resolved": "https://registry.npmjs.org/ai/-/ai-5.0.87.tgz", + "integrity": "sha512-9Cjx7o8IY9zAczigX0Tk/BaQwjPe/M6DpEjejKSBNrf8mOPIvyM+pJLqJSC10IsKci3FPsnaizJeJhoetU1Wfw==", + "license": "Apache-2.0", + "dependencies": { + "@ai-sdk/gateway": "2.0.6", + "@ai-sdk/provider": "2.0.0", + "@ai-sdk/provider-utils": "3.0.16", + "@opentelemetry/api": "1.9.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "zod": "^3.25.76 || ^4.1.8" + } + }, + "packages/compass-generative-ai/node_modules/body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "packages/compass-generative-ai/node_modules/content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "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/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "packages/compass-generative-ai/node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -51065,12 +52004,225 @@ "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.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.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.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "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": ">= 0.8" + } + }, + "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.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "packages/compass-generative-ai/node_modules/kerberos": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-2.2.2.tgz", + "integrity": "sha512-42O7+/1Zatsc3MkxaMPpXcIl/ukIrbQaGoArZEAr6GcEi2qhfprOBYOPhj+YvSMJkEkdpTjApUx+2DuWaKwRhg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "node-addon-api": "^6.1.0", + "prebuild-install": "^7.1.2" + }, + "engines": { + "node": ">=12.9.0" + } + }, + "packages/compass-generative-ai/node_modules/lru-cache": { + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz", + "integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==", + "license": "ISC", + "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.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "packages/compass-generative-ai/node_modules/mongodb-build-info": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/mongodb-build-info/-/mongodb-build-info-1.8.1.tgz", + "integrity": "sha512-O6bWoFnDRyDS/ki9cTkYqh2EWITYAqnVrkaGWhbEVuzDhqoNYLtMgukEyusmsJV+5wpO3lAUiyBbKNq1g4vl3g==", + "license": "Apache-2.0", + "dependencies": { + "debug": "^4.4.0", + "mongodb-connection-string-url": "^3.0.0" + } + }, + "packages/compass-generative-ai/node_modules/mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "packages/compass-generative-ai/node_modules/mongodb-mcp-server": { + "resolved": "packages/compass-generative-ai/.yalc/mongodb-mcp-server", + "link": true + }, + "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-addon-api": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", + "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", + "license": "MIT", + "optional": true + }, + "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", @@ -51099,6 +52251,89 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "packages/compass-generative-ai/node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "packages/compass-generative-ai/node_modules/raw-body": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz", + "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.7.0", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "packages/compass-generative-ai/node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "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/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "packages/compass-generative-ai/node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, "packages/compass-generative-ai/node_modules/sinon": { "version": "9.2.4", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", @@ -51117,6 +52352,56 @@ "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/voyage-ai-provider": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/voyage-ai-provider/-/voyage-ai-provider-2.0.0.tgz", + "integrity": "sha512-AX00egENhHOAfuHAhvmoBVQNG6+f717763CfyPefjahDTxbt6nCE0IlDXn5nkzLIu00JoM/PDFYDYQ17NYQqPw==", + "license": "MIT", + "dependencies": { + "@ai-sdk/provider": "^2.0.0", + "@ai-sdk/provider-utils": "^3.0.0" + }, + "peerDependencies": { + "zod": "^3.25.76 || ^4" + }, + "peerDependenciesMeta": { + "zod": { + "optional": true + } + } + }, + "packages/compass-generative-ai/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, "packages/compass-generative-ai/node_modules/zod": { "version": "3.25.76", "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", @@ -62764,6 +64049,318 @@ } } }, + "@modelcontextprotocol/sdk": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.21.0.tgz", + "integrity": "sha512-YFBsXJMFCyI1zP98u7gezMFKX4lgu/XpoZJk7ufI6UlFKXLj2hAMUuRlQX/nrmIPOmhRrG6tw2OQ2ZA/ZlXYpQ==", + "requires": { + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.0.1", + "express-rate-limit": "^7.5.0", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.23.8", + "zod-to-json-schema": "^3.24.1" + }, + "dependencies": { + "accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "requires": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + } + }, + "ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "requires": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + } + }, + "ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "requires": { + "ajv": "^8.0.0" + } + }, + "body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "requires": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + } + }, + "content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "requires": { + "safe-buffer": "5.2.1" + } + }, + "cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==" + }, + "debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "requires": { + "ms": "^2.1.3" + } + }, + "encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==" + }, + "express": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "requires": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.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" + } + }, + "finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "requires": { + "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" + } + }, + "fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==" + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==" + }, + "merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==" + }, + "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==" + }, + "mime-types": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "requires": { + "mime-db": "^1.54.0" + } + }, + "negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==" + }, + "qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "requires": { + "side-channel": "^1.1.0" + } + }, + "raw-body": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz", + "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", + "requires": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.7.0", + "unpipe": "1.0.0" + }, + "dependencies": { + "iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + } + } + }, + "send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "requires": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + } + }, + "serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "requires": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + } + }, + "statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==" + }, + "type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "requires": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + } + }, + "zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==" + }, + "zod-to-json-schema": { + "version": "3.24.6", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.6.tgz", + "integrity": "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==", + "requires": {} + } + } + }, + "@mongodb-js/atlas-local": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local/-/atlas-local-1.0.2.tgz", + "integrity": "sha512-7x0vPe/17WMkOJfQLF/rGlqvo84RAFmrXUM++Rt3vLfPfLY8Pe5yE3N58FsYw72ZE838/viTdU6eyp/p/MFRwQ==", + "optional": true, + "requires": { + "@mongodb-js/atlas-local-darwin-arm64": "1.0.2", + "@mongodb-js/atlas-local-darwin-x64": "1.0.2", + "@mongodb-js/atlas-local-linux-arm64-gnu": "1.0.2", + "@mongodb-js/atlas-local-linux-x64-gnu": "1.0.2", + "@mongodb-js/atlas-local-win32-x64-msvc": "1.0.2" + } + }, + "@mongodb-js/atlas-local-darwin-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-darwin-arm64/-/atlas-local-darwin-arm64-1.0.2.tgz", + "integrity": "sha512-E7qzpBQj/hgPZQBjTOVTqcQgFjQeYxDLrGWVw0OXcPYXFOg8epWs87AtSS+JojzsdtBpU1ZnzYAJcLV0pJuNow==", + "optional": true + }, + "@mongodb-js/atlas-local-darwin-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-darwin-x64/-/atlas-local-darwin-x64-1.0.2.tgz", + "integrity": "sha512-neK99QtGkrYHS03pEY+8N9+OL9YNwuiOYo34HyjIxRZ7EL3CC+H0ccQ9XEysns0oY7kfRYCnDHfxpl946CWbag==", + "optional": true + }, + "@mongodb-js/atlas-local-linux-arm64-gnu": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-linux-arm64-gnu/-/atlas-local-linux-arm64-gnu-1.0.2.tgz", + "integrity": "sha512-vBVlph+6cwOEJpZiur3gfD0qaOfxBUAPyy9FNL4WqYegxD8EWPOWx+nMN+21qwh2yuNmEQfEqQzI3sx+KIlHvQ==", + "optional": true + }, + "@mongodb-js/atlas-local-linux-x64-gnu": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-linux-x64-gnu/-/atlas-local-linux-x64-gnu-1.0.2.tgz", + "integrity": "sha512-Hbjx/QXZ/E6lXjay+Egq7L6MMZvAwg5o05yWbb/wct34sGwvDIGojIN5pT1VuqLl87Vyo8L3IljnrHp/+J5CeQ==", + "optional": true + }, + "@mongodb-js/atlas-local-win32-x64-msvc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@mongodb-js/atlas-local-win32-x64-msvc/-/atlas-local-win32-x64-msvc-1.0.2.tgz", + "integrity": "sha512-zfoEXSVrXtyeE4jJ4oUY++TOy8JpM9+oVr7goudzzQ/odNo/MnTUgsLEZoYQ2p5XsgTZFLm/nB9a2f5MFhJ3hw==", + "optional": true + }, "@mongodb-js/atlas-service": { "version": "file:packages/atlas-service", "requires": { @@ -65000,11 +66597,13 @@ "@mongodb-js/prettier-config-compass": "^1.2.9", "@mongodb-js/testing-library-compass": "^1.3.17", "@mongodb-js/tsconfig-compass": "^1.2.12", + "@mongosh/service-provider-node-driver": "^3.17.0", "@types/chai": "^4.2.21", "@types/chai-dom": "^0.0.10", "@types/mocha": "^9.0.0", "@types/react": "^17.0.5", "@types/sinon-chai": "^3.2.5", + "ai": "^5.0.72", "bson": "^6.10.4", "chai": "^4.3.6", "compass-preferences-model": "^2.64.0", @@ -65012,6 +66611,9 @@ "electron-mocha": "^12.2.0", "mocha": "^10.2.0", "mongodb": "^6.19.0", + "mongodb-build-info": "^1.7.2", + "mongodb-connection-string-url": "^3.0.1", + "mongodb-mcp-server": "file:.yalc/mongodb-mcp-server", "mongodb-schema": "^12.6.3", "nyc": "^15.1.0", "p-queue": "^7.4.1", @@ -65025,18 +66627,283 @@ "zod": "^3.25.76" }, "dependencies": { + "@ai-sdk/gateway": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@ai-sdk/gateway/-/gateway-2.0.6.tgz", + "integrity": "sha512-FmhR6Tle09I/RUda8WSPpJ57mjPWzhiVVlB50D+k+Qf/PBW0CBtnbAUxlNSR5v+NIZNLTK3C56lhb23ntEdxhQ==", + "requires": { + "@ai-sdk/provider": "2.0.0", + "@ai-sdk/provider-utils": "3.0.16", + "@vercel/oidc": "3.0.3" + } + }, + "@ai-sdk/provider-utils": { + "version": "3.0.16", + "resolved": "https://registry.npmjs.org/@ai-sdk/provider-utils/-/provider-utils-3.0.16.tgz", + "integrity": "sha512-lsWQY9aDXHitw7C1QRYIbVGmgwyT98TF3MfM8alNIXKpdJdi+W782Rzd9f1RyOfgRmZ08gJ2EYNDhWNK7RqpEA==", + "requires": { + "@ai-sdk/provider": "2.0.0", + "@standard-schema/spec": "^1.0.0", + "eventsource-parser": "^3.0.6" + } + }, + "@mongodb-js/device-id": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@mongodb-js/device-id/-/device-id-0.3.3.tgz", + "integrity": "sha512-y2SIriQec/HvIzFI1QCJAmjedShwbgmgUWkh3+qPgT2OyRKWE0yB7Lii/jANCtUNqqwBcUsMHY9/mPnuu5wfPQ==" + }, + "@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "requires": { + "@types/webidl-conversions": "*" + } + }, + "accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "requires": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + } + }, + "ai": { + "version": "5.0.87", + "resolved": "https://registry.npmjs.org/ai/-/ai-5.0.87.tgz", + "integrity": "sha512-9Cjx7o8IY9zAczigX0Tk/BaQwjPe/M6DpEjejKSBNrf8mOPIvyM+pJLqJSC10IsKci3FPsnaizJeJhoetU1Wfw==", + "requires": { + "@ai-sdk/gateway": "2.0.6", + "@ai-sdk/provider": "2.0.0", + "@ai-sdk/provider-utils": "3.0.16", + "@opentelemetry/api": "1.9.0" + } + }, + "body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "requires": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + } + }, + "content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "requires": { + "safe-buffer": "5.2.1" + } + }, + "cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==" + }, + "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==" + }, + "debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "requires": { + "ms": "^2.1.3" + } + }, "diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, + "encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==" + }, "eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", "dev": true }, + "express": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "requires": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.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" + } + }, + "finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "requires": { + "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" + } + }, + "fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==" + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "kerberos": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-2.2.2.tgz", + "integrity": "sha512-42O7+/1Zatsc3MkxaMPpXcIl/ukIrbQaGoArZEAr6GcEi2qhfprOBYOPhj+YvSMJkEkdpTjApUx+2DuWaKwRhg==", + "optional": true, + "requires": { + "node-addon-api": "^6.1.0", + "prebuild-install": "^7.1.2" + } + }, + "lru-cache": { + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz", + "integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==" + }, + "media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==" + }, + "merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==" + }, + "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==" + }, + "mime-types": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "requires": { + "mime-db": "^1.54.0" + } + }, + "mongodb-build-info": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/mongodb-build-info/-/mongodb-build-info-1.8.1.tgz", + "integrity": "sha512-O6bWoFnDRyDS/ki9cTkYqh2EWITYAqnVrkaGWhbEVuzDhqoNYLtMgukEyusmsJV+5wpO3lAUiyBbKNq1g4vl3g==", + "requires": { + "debug": "^4.4.0", + "mongodb-connection-string-url": "^3.0.0" + } + }, + "mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "requires": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "mongodb-mcp-server": { + "version": "file:packages/compass-generative-ai/.yalc/mongodb-mcp-server", + "requires": { + "@modelcontextprotocol/sdk": "^1.17.4", + "@mongodb-js/atlas-local": "^1.0.2", + "@mongodb-js/device-id": "^0.3.1", + "@mongodb-js/devtools-proxy-support": "^0.5.3", + "@mongosh/arg-parser": "^3.19.0", + "@mongosh/service-provider-node-driver": "^3.17.0", + "ai": "^5.0.72", + "bson": "^6.10.4", + "express": "^5.1.0", + "kerberos": "^2.2.2", + "lru-cache": "^11.1.0", + "mongodb-connection-string-url": "^3.0.2", + "mongodb-log-writer": "^2.4.1", + "mongodb-redact": "^1.2.0", + "mongodb-schema": "^12.6.2", + "node-fetch": "^3.3.2", + "node-machine-id": "1.1.12", + "oauth4webapi": "^3.8.0", + "openapi-fetch": "^0.14.0", + "ts-levenshtein": "^1.0.7", + "voyage-ai-provider": "^2.0.0", + "yargs-parser": "21.1.1", + "zod": "^3.25.76" + } + }, + "negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==" + }, + "node-addon-api": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", + "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", + "optional": true + }, + "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==", + "requires": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + } + }, "p-queue": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-7.4.1.tgz", @@ -65053,6 +66920,64 @@ "integrity": "sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew==", "dev": true }, + "qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "requires": { + "side-channel": "^1.1.0" + } + }, + "raw-body": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz", + "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", + "requires": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.7.0", + "unpipe": "1.0.0" + }, + "dependencies": { + "iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + } + } + }, + "send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "requires": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + } + }, + "serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "requires": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + } + }, "sinon": { "version": "9.2.4", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", @@ -65067,6 +66992,35 @@ "supports-color": "^7.1.0" } }, + "statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==" + }, + "type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "requires": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + } + }, + "voyage-ai-provider": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/voyage-ai-provider/-/voyage-ai-provider-2.0.0.tgz", + "integrity": "sha512-AX00egENhHOAfuHAhvmoBVQNG6+f717763CfyPefjahDTxbt6nCE0IlDXn5nkzLIu00JoM/PDFYDYQ17NYQqPw==", + "requires": { + "@ai-sdk/provider": "^2.0.0", + "@ai-sdk/provider-utils": "^3.0.0" + } + }, + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==" + }, "zod": { "version": "3.25.76", "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", @@ -68129,9 +70083,9 @@ } }, "@mongodb-js/oidc-plugin": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@mongodb-js/oidc-plugin/-/oidc-plugin-2.0.4.tgz", - "integrity": "sha512-mB7kEK80+DD2QrB01GmtFKm02ItJpIO9j7OARMHI4RL+rVQD3Ey9giluf3xQtuSdcmg7a+bf5fkJgQZCWMvRPg==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/oidc-plugin/-/oidc-plugin-2.0.5.tgz", + "integrity": "sha512-hCtqStgSaas7W+1ueCI6gJFNuM4scPpHe1S85+AOoFw6Q23HdhK7qdCBk2+IUkvdKmfRzOBtNglIFrlukhbmMg==", "requires": { "express": "^5.1.0", "node-fetch": "^3.3.2", @@ -69433,6 +71387,126 @@ } } }, + "@mongosh/service-provider-node-driver": { + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/@mongosh/service-provider-node-driver/-/service-provider-node-driver-3.17.3.tgz", + "integrity": "sha512-yMYBvY6681qb5yOo48uRerhQX6ZBPgvB8rVQ/fKMCjyeL1n3acEI6hOBEPAF5yHdjNHtyClxVfH4pbdZSb8NdA==", + "requires": { + "@mongodb-js/devtools-connect": "^3.9.4", + "@mongodb-js/oidc-plugin": "^2.0.5", + "@mongosh/errors": "2.4.4", + "@mongosh/service-provider-core": "3.6.1", + "@mongosh/types": "^3.14.0", + "aws4": "^1.12.0", + "kerberos": "2.1.0", + "mongodb": "^6.19.0", + "mongodb-client-encryption": "^6.5.0", + "mongodb-connection-string-url": "^3.0.2", + "socks": "^2.8.3" + }, + "dependencies": { + "@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "requires": { + "@types/webidl-conversions": "*" + } + }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "optional": true + }, + "kerberos": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-2.1.0.tgz", + "integrity": "sha512-HvOl6O6cyEN/8Z4CAocHe/sekJtvt5UrxUdCuu7bXDZ2Hnsy6OpsQbISW+lpm03vrbO2ir+1QQ5Sx/vMEhHnog==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "node-addon-api": "^6.1.0", + "prebuild-install": "7.1.1" + } + }, + "mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "requires": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", + "optional": true + }, + "node-abi": { + "version": "3.80.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.80.0.tgz", + "integrity": "sha512-LyPuZJcI9HVwzXK1GPxWNzrr+vr8Hp/3UqlmWxxh8p54U1ZbclOqbSog9lWHaCX+dBaiGi6n/hIX+mKu74GmPA==", + "optional": true, + "requires": { + "semver": "^7.3.5" + } + }, + "node-addon-api": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", + "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", + "optional": true + }, + "prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "optional": true, + "requires": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + } + }, + "tar-fs": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", + "optional": true, + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "optional": true, + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + } + } + }, "@mongosh/shell-api": { "version": "3.24.0", "resolved": "https://registry.npmjs.org/@mongosh/shell-api/-/shell-api-3.24.0.tgz", @@ -73713,6 +75787,11 @@ "dev": true, "requires": {} }, + "@vercel/oidc": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@vercel/oidc/-/oidc-3.0.3.tgz", + "integrity": "sha512-yNEQvPcVrK9sIe637+I0jD6leluPxzwJKx/Haw6F4H77CdDsszUn5V3o96LPziXkSNE2B83+Z3mjqGKBK/R6Gg==" + }, "@vue/compiler-core": { "version": "3.5.6", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.6.tgz", @@ -75419,9 +77498,9 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", + "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==" }, "axe-core": { "version": "4.10.3", @@ -77615,7 +79694,6 @@ "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dev": true, "requires": { "object-assign": "^4", "vary": "^1" @@ -80856,6 +82934,19 @@ "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha512-kEcvvCBByWXGnZy6JUlgAp2gBIUjfCAV6P6TgT1/aaQKcmuAEC4OZTV1I4EWQLz2gxZw76atuVyvHhTxvi0Flw==" }, + "eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "requires": { + "eventsource-parser": "^3.0.1" + } + }, + "eventsource-parser": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", + "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==" + }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -80996,6 +83087,12 @@ } } }, + "express-rate-limit": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "requires": {} + }, "ext": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", @@ -88830,9 +90927,12 @@ } }, "mongodb-redact": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/mongodb-redact/-/mongodb-redact-1.1.8.tgz", - "integrity": "sha512-EbZ+q7LsVz7q8n49mGIcXgP2UiBp6R6vHEVbmGnF21ThCnP6AIho7wqpHqyjqqGjg54DoXQJTCwHPSknsCHv6g==" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/mongodb-redact/-/mongodb-redact-1.2.2.tgz", + "integrity": "sha512-Xpl0buo5yZ2qlKRr3y4UBqrSOFaDI5FRF0tppKcNteJ6HxoaITgjT255LQdO3JZ/d+pLuT5i4sHLMqEwMj6bug==", + "requires": { + "regexp.escape": "^2.0.1" + } }, "mongodb-schema": { "version": "12.6.3", @@ -89403,8 +91503,7 @@ "node-machine-id": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", - "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", - "dev": true + "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==" }, "node-preload": { "version": "0.2.1", @@ -90298,9 +92397,9 @@ "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, "oauth4webapi": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/oauth4webapi/-/oauth4webapi-3.6.2.tgz", - "integrity": "sha512-hwWLiyBYuqhVdcIUJMJVKdEvz+DCweOcbSfqDyIv9PuUwrNfqrzfHP2bypZgZdbYOS67QYqnAnvZa2BJwBBrHw==" + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/oauth4webapi/-/oauth4webapi-3.8.2.tgz", + "integrity": "sha512-FzZZ+bht5X0FKe7Mwz3DAVAmlH1BV5blSak/lHMBKz0/EBMhX6B10GlQYI51+oRp8ObJaX0g6pXrAxZh5s8rjw==" }, "object-assign": { "version": "4.1.1", @@ -90448,6 +92547,19 @@ } } }, + "openapi-fetch": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/openapi-fetch/-/openapi-fetch-0.14.1.tgz", + "integrity": "sha512-l7RarRHxlEZYjMLd/PR0slfMVse2/vvIAGm75/F7J6MlQ8/b9uUQmUF2kCPrQhJqMXSxmYWObVgeYXbFYzZR+A==", + "requires": { + "openapi-typescript-helpers": "^0.0.15" + } + }, + "openapi-typescript-helpers": { + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/openapi-typescript-helpers/-/openapi-typescript-helpers-0.0.15.tgz", + "integrity": "sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==" + }, "openapi3-ts": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/openapi3-ts/-/openapi3-ts-4.5.0.tgz", @@ -91159,6 +93271,11 @@ "pinkie": "^2.0.0" } }, + "pkce-challenge": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", + "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==" + }, "pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -93425,6 +95542,19 @@ "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", "dev": true }, + "regexp.escape": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexp.escape/-/regexp.escape-2.0.1.tgz", + "integrity": "sha512-JItRb4rmyTzmERBkAf6J87LjDPy/RscIwmaJQ3gsFlAzrmZbZU8LwBw5IydFZXW9hqpgbPlGbMhtpqtuAhMgtg==", + "requires": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.3", + "es-errors": "^1.3.0", + "for-each": "^0.3.3", + "safe-regex-test": "^1.0.3" + } + }, "regexp.prototype.flags": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", @@ -95911,6 +98041,11 @@ "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", "requires": {} }, + "ts-levenshtein": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ts-levenshtein/-/ts-levenshtein-1.0.7.tgz", + "integrity": "sha512-wautEf7gl2ITJuRTTYxnlrLjzUUcwFSdg46bcu4RlzoE/zQM++TJjBFRf2Xhil49GiHqKCqmpjf1lBkWnAHj0A==" + }, "ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", diff --git a/packages/compass-assistant/src/compass-assistant-provider.tsx b/packages/compass-assistant/src/compass-assistant-provider.tsx index e9ced74b509..388872b2998 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.tsx @@ -34,10 +34,16 @@ import { type TrackFunction, useTelemetry, } from '@mongodb-js/compass-telemetry/provider'; -import type { AtlasAiService } from '@mongodb-js/compass-generative-ai/provider'; +import { + type MCPController, + useMCPController, + type AtlasAiService, + mcpControllerLocator, +} from '@mongodb-js/compass-generative-ai/provider'; import { atlasAiServiceLocator } from '@mongodb-js/compass-generative-ai/provider'; import { buildConversationInstructionsPrompt } from './prompts'; import { createOpenAI } from '@ai-sdk/openai'; +import { type ToolSet } from 'ai'; export const ASSISTANT_DRAWER_ID = 'compass-assistant-drawer'; @@ -60,6 +66,7 @@ export type AssistantMessage = UIMessage & { instructions?: string; /** Excludes history if this message is the last message being sent */ sendWithoutHistory?: boolean; + availableTools?: string; }; }; @@ -244,7 +251,6 @@ export const AssistantProvider: React.FunctionComponent< if (chat.status === 'streaming') { await chat.stop(); } - await chat.sendMessage(message, options); }, }); @@ -271,6 +277,7 @@ export const CompassAssistantProvider = registerCompassPlugin( originForPrompt: string; chat?: Chat; atlasAiService?: AtlasAiService; + mcpController?: MCPController; }>) => { if (!chat) { throw new Error('Chat was not provided by the state'); @@ -290,8 +297,11 @@ export const CompassAssistantProvider = registerCompassPlugin( }, activate: ( { chat: initialChat, originForPrompt, appNameForPrompt }, - { atlasService, atlasAiService, logger, track } + { atlasService, atlasAiService, logger, track, mcpController } ) => { + if (!mcpController) { + throw new Error('mcpController was not provided by the state'); + } const chat = initialChat ?? createDefaultChat({ @@ -300,10 +310,11 @@ export const CompassAssistantProvider = registerCompassPlugin( atlasService, logger, track, + getTools: () => mcpController.getTools(), }); return { - store: { state: { chat, atlasAiService } }, + store: { state: { chat, atlasAiService, mcpController } }, deactivate: () => {}, }; }, @@ -314,6 +325,7 @@ export const CompassAssistantProvider = registerCompassPlugin( atlasAuthService: atlasAuthServiceLocator, track: telemetryLocator, logger: createLoggerLocator('COMPASS-ASSISTANT'), + mcpController: mcpControllerLocator, } ); @@ -324,12 +336,14 @@ export function createDefaultChat({ logger, track, options, + getTools, }: { originForPrompt: string; appNameForPrompt: string; atlasService: AtlasService; logger: Logger; track: TrackFunction; + getTools: () => ToolSet; options?: { transport: Chat['transport']; }; @@ -338,6 +352,7 @@ export function createDefaultChat({ transport: options?.transport ?? new DocsProviderTransport({ + getTools, origin: originForPrompt, instructions: buildConversationInstructionsPrompt({ target: appNameForPrompt, diff --git a/packages/compass-assistant/src/components/assistant-chat.tsx b/packages/compass-assistant/src/components/assistant-chat.tsx index 5bd5a1ee153..1b7fb5b856e 100644 --- a/packages/compass-assistant/src/components/assistant-chat.tsx +++ b/packages/compass-assistant/src/components/assistant-chat.tsx @@ -22,6 +22,7 @@ import { import { ConfirmationMessage } from './confirmation-message'; import { useTelemetry } from '@mongodb-js/compass-telemetry/provider'; import { NON_GENUINE_WARNING_MESSAGE } from '../preset-messages'; +import { useMCPController } from '@mongodb-js/compass-generative-ai'; const { DisclaimerText } = LgChatChatDisclaimer; const { ChatWindow } = LgChatChatWindow; @@ -442,6 +443,7 @@ export const AssistantChat: React.FunctionComponent = ({ messageBody={displayText} data-testid={`assistant-message-${id}`} > + {`Message: ${JSON.stringify(message)}`} {isSender === false && ( diff --git a/packages/compass-assistant/src/docs-provider-transport.ts b/packages/compass-assistant/src/docs-provider-transport.ts index 7bb20232742..1b7a7fd854f 100644 --- a/packages/compass-assistant/src/docs-provider-transport.ts +++ b/packages/compass-assistant/src/docs-provider-transport.ts @@ -1,6 +1,7 @@ import { type ChatTransport, type LanguageModel, + type ToolSet, type UIMessageChunk, convertToModelMessages, streamText, @@ -18,20 +19,24 @@ export function shouldExcludeMessage({ metadata }: AssistantMessage) { export class DocsProviderTransport implements ChatTransport { private model: LanguageModel; private origin: string; + private getTools: () => ToolSet; private instructions: string; constructor({ instructions, model, origin, + getTools, }: { instructions: string; model: LanguageModel; origin: string; + getTools: () => ToolSet; }) { this.instructions = instructions; this.model = model; this.origin = origin; + this.getTools = getTools; } static emptyStream = new ReadableStream({ @@ -62,6 +67,11 @@ export class DocsProviderTransport implements ChatTransport { const lastMessage = filteredMessages[filteredMessages.length - 1]; + console.log( + 'lastMessage.metadata?.availableTools', + lastMessage, + this.getTools() + ); const result = streamText({ model: this.model, messages: lastMessage.metadata?.sendWithoutHistory @@ -71,6 +81,7 @@ export class DocsProviderTransport implements ChatTransport { headers: { 'X-Request-Origin': this.origin, }, + tools: this.getTools(), providerOptions: { openai: { store: false, diff --git a/packages/compass-assistant/src/prompts.ts b/packages/compass-assistant/src/prompts.ts index 5faea6cef94..f0bab84361a 100644 --- a/packages/compass-assistant/src/prompts.ts +++ b/packages/compass-assistant/src/prompts.ts @@ -39,9 +39,7 @@ You are able to: You CANNOT: -1. Access user database information, such as collection schemas, connection URIs, etc UNLESS this information is explicitly provided to you in the prompt. -2. Query MongoDB directly or execute code. -3. Access the current state of the UI +1. Access the current state of the UI `; }; diff --git a/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx b/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx index 71b99e5de88..c06c7da1bc0 100644 --- a/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx +++ b/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx @@ -992,6 +992,8 @@ describe('ConnectionsNavigationTree', function () { 'Show connection info', 'Refresh databases', { separator: true }, + 'Use for MCP server', + { separator: true }, 'Disconnect', ]); }); diff --git a/packages/compass-connections-navigation/src/constants.tsx b/packages/compass-connections-navigation/src/constants.tsx index ce8c7911228..8f93efc22f7 100644 --- a/packages/compass-connections-navigation/src/constants.tsx +++ b/packages/compass-connections-navigation/src/constants.tsx @@ -24,6 +24,7 @@ export type Actions = | 'open-non-genuine-mongodb-modal' | 'open-csfle-modal' | 'refresh-databases' + | 'connection-use-for-mcp' // database item related actions | 'select-database' | 'create-database' diff --git a/packages/compass-connections-navigation/src/item-actions.ts b/packages/compass-connections-navigation/src/item-actions.ts index 7642565f27c..debb53a8262 100644 --- a/packages/compass-connections-navigation/src/item-actions.ts +++ b/packages/compass-connections-navigation/src/item-actions.ts @@ -309,6 +309,12 @@ export const connectionContextMenuActions = ({ icon: 'Refresh', }, { separator: true }, + { + action: 'connection-use-for-mcp', + icon: 'Cloud', + label: 'Use for MCP server', + }, + { separator: true }, { action: 'connection-disconnect', icon: 'Disconnect', diff --git a/packages/compass-generative-ai/.yalc/mongodb-mcp-server/LICENSE b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/LICENSE new file mode 100644 index 00000000000..7a4a3ea2424 --- /dev/null +++ b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/compass-generative-ai/.yalc/mongodb-mcp-server/README.md b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/README.md new file mode 100644 index 00000000000..f60caa25d13 --- /dev/null +++ b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/README.md @@ -0,0 +1,720 @@ +[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?logo=data:image/svg%2bxml;base64,PHN2ZyBmaWxsPSIjRkZGRkZGIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciICB2aWV3Qm94PSIwIDAgNDggNDgiIHdpZHRoPSIyNHB4IiBoZWlnaHQ9IjI0cHgiPjxwYXRoIGQ9Ik00NC45OTkgMTAuODd2MjYuMjFjMCAxLjAzLS41OSAxLjk3LTEuNTEgMi40Mi0yLjY4IDEuMjktOCAzLjg1LTguMzUgNC4wMS0uMTMuMDctLjM4LjItLjY3LjMxLjM1LS42LjUzLTEuMy41My0yLjAyVjYuMmMwLS43NS0uMi0xLjQ1LS41Ni0yLjA2LjA5LjA0LjE3LjA4LjI0LjExLjIuMSA1Ljk4IDIuODYgOC44IDQuMkM0NC40MDkgOC45IDQ0Ljk5OSA5Ljg0IDQ0Ljk5OSAxMC44N3pNNy40OTkgMjYuMDNjMS42IDEuNDYgMy40MyAzLjEzIDUuMzQgNC44NmwtNC42IDMuNWMtLjc3LjU3LTEuNzguNS0yLjU2LS4wNS0uNS0uMzYtMS44OS0xLjY1LTEuODktMS42NS0xLjAxLS44MS0xLjA2LTIuMzItLjExLTMuMTlDMy42NzkgMjkuNSA1LjE3OSAyOC4xMyA3LjQ5OSAyNi4wM3pNMzEuOTk5IDYuMnYxMC4xMWwtNy42MyA1LjgtNi44NS01LjIxYzQuOTgtNC41MyAxMC4wMS05LjExIDEyLjY1LTExLjUyQzMwLjg2OSA0Ljc0IDMxLjk5OSA1LjI1IDMxLjk5OSA2LjJ6TTMyIDQxLjc5OFYzMS42OUw4LjI0IDEzLjYxYy0uNzctLjU3LTEuNzgtLjUtMi41Ni4wNS0uNS4zNi0xLjg5IDEuNjUtMS44OSAxLjY1LTEuMDEuODEtMS4wNiAyLjMyLS4xMSAzLjE5IDAgMCAyMC4xNDUgMTguMzM4IDI2LjQ4NSAyNC4xMTZDMzAuODcxIDQzLjI2IDMyIDQyLjc1MyAzMiA0MS43OTh6Ii8+PC9zdmc+)](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%2C%22--readOnly%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D) +[![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Server-1e1e1e?logo=data:image/svg%2bxml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgc3R5bGU9ImZsZXg6bm9uZTtsaW5lLWhlaWdodDoxIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxZW0iCiAgICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHRpdGxlPkN1cnNvcjwvdGl0bGU+CiAgICA8cGF0aCBkPSJNMTEuOTI1IDI0bDEwLjQyNS02LTEwLjQyNS02TDEuNSAxOGwxMC40MjUgNnoiCiAgICAgICAgZmlsbD0idXJsKCNsb2JlLWljb25zLWN1cnNvcnVuZGVmaW5lZC1maWxsLTApIj48L3BhdGg+CiAgICA8cGF0aCBkPSJNMjIuMzUgMThWNkwxMS45MjUgMHYxMmwxMC40MjUgNnoiIGZpbGw9InVybCgjbG9iZS1pY29ucy1jdXJzb3J1bmRlZmluZWQtZmlsbC0xKSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTExLjkyNSAwTDEuNSA2djEybDEwLjQyNS02VjB6IiBmaWxsPSJ1cmwoI2xvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMikiPjwvcGF0aD4KICAgIDxwYXRoIGQ9Ik0yMi4zNSA2TDExLjkyNSAyNFYxMkwyMi4zNSA2eiIgZmlsbD0iIzU1NSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIyLjM1IDZsLTEwLjQyNSA2TDEuNSA2aDIwLjg1eiIgZmlsbD0iI2ZmZiI+PC9wYXRoPgogICAgPGRlZnM+CiAgICAgICAgPGxpbmVhckdyYWRpZW50IGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBpZD0ibG9iZS1pY29ucy1jdXJzb3J1bmRlZmluZWQtZmlsbC0wIgogICAgICAgICAgICB4MT0iMTEuOTI1IiB4Mj0iMTEuOTI1IiB5MT0iMTIiIHkyPSIyNCI+CiAgICAgICAgICAgIDxzdG9wIG9mZnNldD0iLjE2IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9Ii4zOSI+PC9zdG9wPgogICAgICAgICAgICA8c3RvcCBvZmZzZXQ9Ii42NTgiIHN0b3AtY29sb3I9IiNmZmYiIHN0b3Atb3BhY2l0eT0iLjgiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgICAgIDxsaW5lYXJHcmFkaWVudCBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImxvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMSIKICAgICAgICAgICAgeDE9IjIyLjM1IiB4Mj0iMTEuOTI1IiB5MT0iNi4wMzciIHkyPSIxMi4xNSI+CiAgICAgICAgICAgIDxzdG9wIG9mZnNldD0iLjE4MiIgc3RvcC1jb2xvcj0iI2ZmZiIgc3RvcC1vcGFjaXR5PSIuMzEiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIuNzE1IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9IjAiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgICAgIDxsaW5lYXJHcmFkaWVudCBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImxvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMiIKICAgICAgICAgICAgeDE9IjExLjkyNSIgeDI9IjEuNSIgeTE9IjAiIHkyPSIxOCI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNmZmYiIHN0b3Atb3BhY2l0eT0iLjYiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIuNjY3IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9Ii4yMiI+PC9zdG9wPgogICAgICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgICA8L2RlZnM+Cjwvc3ZnPgo=)](https://cursor.com/install-mcp?name=MongoDB&config=eyJjb21tYW5kIjoibnB4IC15IG1vbmdvZGItbWNwLXNlcnZlciAtLXJlYWRPbmx5In0%3D) + +# MongoDB MCP Server + +A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas. + +## πŸ“š Table of Contents + +- [πŸš€ Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Setup](#setup) + - [Quick Start](#quick-start) +- [πŸ› οΈ Supported Tools](#supported-tools) + - [MongoDB Atlas Tools](#mongodb-atlas-tools) + - [MongoDB Database Tools](#mongodb-database-tools) +- [πŸ“„ Supported Resources](#supported-resources) +- [βš™οΈ Configuration](#configuration) + - [Configuration Options](#configuration-options) + - [Atlas API Access](#atlas-api-access) + - [Configuration Methods](#configuration-methods) + - [Environment Variables](#environment-variables) + - [Command-Line Arguments](#command-line-arguments) + - [MCP Client Configuration](#mcp-configuration-file-examples) + - [Proxy Support](#proxy-support) +- [πŸš€ Deploy on Public Clouds](#deploy-on-public-clouds) + - [Azure Cloud](#azure) +- [🀝 Contributing](#contributing) + + + +## Prerequisites + +- Node.js + - At least 20.19.0 + - When using v22 then at least v22.12.0 + - Otherwise any version 23+ + +```shell +node -v +``` + +- A MongoDB connection string or Atlas API credentials, **_the Server will not start unless configured_**. + - **_Service Accounts Atlas API credentials_** are required to use the Atlas tools. You can create a service account in MongoDB Atlas and use its credentials for authentication. See [Atlas API Access](#atlas-api-access) for more details. + - If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance. + +## Setup + +### Quick Start + +> **πŸ”’ Security Recommendation 1:** When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See [Atlas API Permissions](#atlas-api-permissions) for details. + +> **πŸ”’ Security Recommendation 2:** For enhanced security, we strongly recommend using environment variables to pass sensitive configuration such as connection strings and API credentials instead of command line arguments. Command line arguments can be visible in process lists and logged in various system locations, potentially exposing your secrets. Environment variables provide a more secure way to handle sensitive information. + +Most MCP clients require a configuration file to be created or modified to add the MCP server. + +Note: The configuration file syntax can be different across clients. Please refer to the following links for the latest expected syntax: + +- **Windsurf**: https://docs.windsurf.com/windsurf/mcp +- **VSCode**: https://code.visualstudio.com/docs/copilot/chat/mcp-servers +- **Claude Desktop**: https://modelcontextprotocol.io/quickstart/user +- **Cursor**: https://docs.cursor.com/context/model-context-protocol + +> **Default Safety Notice:** All examples below include `--readOnly` by default to ensure safe, read-only access to your data. Remove `--readOnly` if you need to enable write operations. + +#### Option 1: Connection String + +You can pass your connection string via environment variables, make sure to use a valid username and password. + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"], + "env": { + "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase" + } + } + } +} +``` + +NOTE: The connection string can be configured to connect to any MongoDB cluster, whether it's a local instance or an Atlas cluster. + +#### Option 2: Atlas API Credentials + +Use your Atlas API Service Accounts credentials. Must follow all the steps in [Atlas API Access](#atlas-api-access) section. + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"], + "env": { + "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", + "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" + } + } + } +} +``` + +#### Option 3: Standalone Service using environment variables and command line arguments + +You can source environment variables defined in a config file or explicitly set them like we do in the example below and run the server via npx. + +```shell +# Set your credentials as environment variables first +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Then start the server +npx -y mongodb-mcp-server@latest --readOnly +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +- For a complete list of configuration options see [Configuration Options](#configuration-options) +- To configure your Atlas Service Accounts credentials please refer to [Atlas API Access](#atlas-api-access) +- Connection String via environment variables in the MCP file [example](#connection-string-with-environment-variables) +- Atlas API credentials via environment variables in the MCP file [example](#atlas-api-credentials-with-environment-variables) + +#### Option 4: Using Docker + +You can run the MongoDB MCP Server in a Docker container, which provides isolation and doesn't require a local Node.js installation. + +#### Run with Environment Variables + +You may provide either a MongoDB connection string OR Atlas API credentials: + +##### Option A: No configuration + +```shell +docker run --rm -i \ + mongodb/mongodb-mcp-server:latest +``` + +##### Option B: With MongoDB connection string + +```shell +# Set your credentials as environment variables first +export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Then start the docker container +docker run --rm -i \ + -e MDB_MCP_CONNECTION_STRING \ + -e MDB_MCP_READ_ONLY="true" \ + mongodb/mongodb-mcp-server:latest +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +##### Option C: With Atlas API credentials + +```shell +# Set your credentials as environment variables first +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Then start the docker container +docker run --rm -i \ + -e MDB_MCP_API_CLIENT_ID \ + -e MDB_MCP_API_CLIENT_SECRET \ + -e MDB_MCP_READ_ONLY="true" \ + mongodb/mongodb-mcp-server:latest +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +##### Docker in MCP Configuration File + +Without options: + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "docker", + "args": [ + "run", + "--rm", + "-e", + "MDB_MCP_READ_ONLY=true", + "-i", + "mongodb/mongodb-mcp-server:latest" + ] + } + } +} +``` + +With connection string: + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "docker", + "args": [ + "run", + "--rm", + "-i", + "-e", + "MDB_MCP_CONNECTION_STRING", + "-e", + "MDB_MCP_READ_ONLY=true", + "mongodb/mongodb-mcp-server:latest" + ], + "env": { + "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + } + } + } +} +``` + +With Atlas API credentials: + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "docker", + "args": [ + "run", + "--rm", + "-i", + "-e", + "MDB_MCP_READ_ONLY=true", + "-e", + "MDB_MCP_API_CLIENT_ID", + "-e", + "MDB_MCP_API_CLIENT_SECRET", + "mongodb/mongodb-mcp-server:latest" + ], + "env": { + "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", + "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" + } + } + } +} +``` + +#### Option 5: Running as an HTTP Server + +> **⚠️ Security Notice:** This server now supports Streamable HTTP transport for remote connections. **HTTP transport is NOT recommended for production use without implementing proper authentication and security measures.** + +**Suggested Security Measures Examples:** + +- Implement authentication (e.g., API gateway, reverse proxy) +- Use HTTPS/TLS encryption +- Deploy behind a firewall or in private networks +- Implement rate limiting +- Never expose directly to the internet + +For more details, see [MCP Security Best Practices](https://modelcontextprotocol.io/docs/concepts/transports#security-considerations). + +You can run the MongoDB MCP Server as an HTTP server instead of the default stdio transport. This is useful if you want to interact with the server over HTTP, for example from a web client or to expose the server on a specific port. + +To start the server with HTTP transport, use the `--transport http` option: + +```shell +npx -y mongodb-mcp-server@latest --transport http +``` + +By default, the server will listen on `http://127.0.0.1:3000`. You can customize the host and port using the `--httpHost` and `--httpPort` options: + +```shell +npx -y mongodb-mcp-server@latest --transport http --httpHost=0.0.0.0 --httpPort=8080 +``` + +- `--httpHost` (default: 127.0.0.1): The host to bind the HTTP server. +- `--httpPort` (default: 3000): The port number for the HTTP server. + +> **Note:** The default transport is `stdio`, which is suitable for integration with most MCP clients. Use `http` transport if you need to interact with the server over HTTP. + +## πŸ› οΈ Supported Tools + +### Tool List + +#### MongoDB Atlas Tools + +- `atlas-list-orgs` - Lists MongoDB Atlas organizations +- `atlas-list-projects` - Lists MongoDB Atlas projects +- `atlas-create-project` - Creates a new MongoDB Atlas project +- `atlas-list-clusters` - Lists MongoDB Atlas clusters +- `atlas-inspect-cluster` - Inspect a specific MongoDB Atlas cluster +- `atlas-create-free-cluster` - Create a free MongoDB Atlas cluster +- `atlas-connect-cluster` - Connects to MongoDB Atlas cluster +- `atlas-inspect-access-list` - Inspect IP/CIDR ranges with access to MongoDB Atlas clusters +- `atlas-create-access-list` - Configure IP/CIDR access list for MongoDB Atlas clusters +- `atlas-list-db-users` - List MongoDB Atlas database users +- `atlas-create-db-user` - Creates a MongoDB Atlas database user +- `atlas-list-alerts` - List MongoDB Atlas Alerts for a Project +- `atlas-get-performance-advisor` - Gets Atlas Performance Advisor recommendations (index suggestions, drop index suggestions, schema suggestions, slow query logs) + +NOTE: atlas tools are only available when you set credentials on [configuration](#configuration) section. + +#### MongoDB Atlas Local Tools + +- `atlas-local-list-deployments` - Lists MongoDB Atlas Local deployments +- `atlas-local-create-deployment` - Creates a MongoDB Atlas Local deployment +- `atlas-local-connect-deployment` - Connects to a MongoDB Atlas Local deployment +- `atlas-local-delete-deployment` - Deletes a MongoDB Atlas Local deployment + +#### MongoDB Database Tools + +- `connect` - Connect to a MongoDB instance +- `find` - Run a find query against a MongoDB collection. The number of documents returned is limited by the `limit` parameter and the server's `maxDocumentsPerQuery` configuration, whichever is smaller. The total size of the returned documents is also limited by the `responseBytesLimit` parameter and the server's `maxBytesPerQuery` configuration, whichever is smaller. +- `aggregate` - Run an aggregation against a MongoDB collection. The number of documents returned is limited by the server's `maxDocumentsPerQuery` configuration. The total size of the returned documents is also limited by the `responseBytesLimit` parameter and the server's `maxBytesPerQuery` configuration, whichever is smaller. +- `count` - Get the number of documents in a MongoDB collection +- `insert-one` - Insert a single document into a MongoDB collection +- `insert-many` - Insert multiple documents into a MongoDB collection +- `create-index` - Create an index for a MongoDB collection +- `update-one` - Update a single document in a MongoDB collection +- `update-many` - Update multiple documents in a MongoDB collection +- `rename-collection` - Rename a MongoDB collection +- `delete-one` - Delete a single document from a MongoDB collection +- `delete-many` - Delete multiple documents from a MongoDB collection +- `drop-collection` - Remove a collection from a MongoDB database +- `drop-database` - Remove a MongoDB database +- `list-databases` - List all databases for a MongoDB connection +- `list-collections` - List all collections for a given database +- `collection-indexes` - Describe the indexes for a collection +- `collection-schema` - Describe the schema for a collection +- `collection-storage-size` - Get the size of a collection in MB +- `db-stats` - Return statistics about a MongoDB database +- `export` - Export query or aggregation results to EJSON format. Creates a uniquely named export accessible via the `exported-data` resource. + +## πŸ“„ Supported Resources + +- `config` - Server configuration, supplied by the user either as environment variables or as startup arguments with sensitive parameters redacted. The resource can be accessed under URI `config://config`. +- `debug` - Debugging information for MongoDB connectivity issues. Tracks the last connectivity attempt and error information. The resource can be accessed under URI `debug://mongodb`. +- `exported-data` - A resource template to access the data exported using the export tool. The template can be accessed under URI `exported-data://{exportName}` where `exportName` is the unique name for an export generated by the export tool. + +## Configuration + +> **πŸ”’ Security Best Practice:** We strongly recommend using environment variables for sensitive configuration such as API credentials (`MDB_MCP_API_CLIENT_ID`, `MDB_MCP_API_CLIENT_SECRET`) and connection strings (`MDB_MCP_CONNECTION_STRING`) instead of command-line arguments. Environment variables are not visible in process lists and provide better security for your sensitive data. + +The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest): + +1. Command-line arguments +2. Environment variables + +### Configuration Options + +| CLI Option | Environment Variable | Default | Description | +| -------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apiClientId` | `MDB_MCP_API_CLIENT_ID` | `` | Atlas API client ID for authentication. Required for running Atlas tools. | +| `apiClientSecret` | `MDB_MCP_API_CLIENT_SECRET` | `` | Atlas API client secret for authentication. Required for running Atlas tools. | +| `atlasTemporaryDatabaseUserLifetimeMs` | `MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS` | `14400000` | Time in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being automatically deleted. | +| `confirmationRequiredTools` | `MDB_MCP_CONFIRMATION_REQUIRED_TOOLS` | `"atlas-create-access-list,atlas-create-db-user,drop-database,drop-collection,delete-many,drop-index"` | Comma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation. | +| `connectionString` | `MDB_MCP_CONNECTION_STRING` | `` | MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the connect tool before interacting with MongoDB data. | +| `disableEmbeddingsValidation` | `MDB_MCP_DISABLE_EMBEDDINGS_VALIDATION` | `false` | When set to true, disables validation of embeddings dimensions. | +| `disabledTools` | `MDB_MCP_DISABLED_TOOLS` | `""` | Comma separated values of tool names, operation types, and/or categories of tools that will be disabled. | +| `exportCleanupIntervalMs` | `MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS` | `120000` | Time in milliseconds between export cleanup cycles that remove expired export files. | +| `exportTimeoutMs` | `MDB_MCP_EXPORT_TIMEOUT_MS` | `300000` | Time in milliseconds after which an export is considered expired and eligible for cleanup. | +| `exportsPath` | `MDB_MCP_EXPORTS_PATH` | see below\* | Folder to store exported data files. | +| `httpHost` | `MDB_MCP_HTTP_HOST` | `"127.0.0.1"` | Host address to bind the HTTP server to (only used when transport is 'http'). | +| `httpPort` | `MDB_MCP_HTTP_PORT` | `3000` | Port number for the HTTP server (only used when transport is 'http'). | +| `idleTimeoutMs` | `MDB_MCP_IDLE_TIMEOUT_MS` | `600000` | Idle timeout for a client to disconnect (only applies to http transport). | +| `indexCheck` | `MDB_MCP_INDEX_CHECK` | `false` | When set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan. | +| `logPath` | `MDB_MCP_LOG_PATH` | see below\* | Folder to store logs. | +| `loggers` | `MDB_MCP_LOGGERS` | `"disk,mcp"` see below\* | Comma separated values of logger types. | +| `maxBytesPerQuery` | `MDB_MCP_MAX_BYTES_PER_QUERY` | `16777216` | The maximum size in bytes for results from a find or aggregate tool call. This serves as an upper bound for the responseBytesLimit parameter in those tools. | +| `maxDocumentsPerQuery` | `MDB_MCP_MAX_DOCUMENTS_PER_QUERY` | `100` | The maximum number of documents that can be returned by a find or aggregate tool call. For the find tool, the effective limit will be the smaller of this value and the tool's limit parameter. | +| `notificationTimeoutMs` | `MDB_MCP_NOTIFICATION_TIMEOUT_MS` | `540000` | Notification timeout for a client to be aware of disconnect (only applies to http transport). | +| `previewFeatures` | `MDB_MCP_PREVIEW_FEATURES` | `""` | Comma separated values of preview features that are enabled. | +| `readOnly` | `MDB_MCP_READ_ONLY` | `false` | When set to true, only allows read, connect, and metadata operation types, disabling create/update/delete operations. | +| `telemetry` | `MDB_MCP_TELEMETRY` | `"enabled"` | When set to disabled, disables telemetry collection. | +| `transport` | `MDB_MCP_TRANSPORT` | `"stdio"` | Either 'stdio' or 'http'. | +| `voyageApiKey` | `MDB_MCP_VOYAGE_API_KEY` | `""` | API key for Voyage AI embeddings service (required for vector search operations with text-to-embedding conversion). | + +#### Logger Options + +The `loggers` configuration option controls where logs are sent. You can specify one or more logger types as a comma-separated list. The available options are: + +- `mcp`: Sends logs to the MCP client (if supported by the client/transport). +- `disk`: Writes logs to disk files. Log files are stored in the log path (see `logPath` above). +- `stderr`: Outputs logs to standard error (stderr), useful for debugging or when running in containers. + +**Default:** `disk,mcp` (logs are written to disk and sent to the MCP client). + +You can combine multiple loggers, e.g. `--loggers disk stderr` or `export MDB_MCP_LOGGERS="mcp,stderr"`. + +##### Example: Set logger via environment variable + +```shell +export MDB_MCP_LOGGERS="disk,stderr" +``` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +##### Example: Set logger via command-line argument + +```shell +npx -y mongodb-mcp-server@latest --loggers mcp stderr +``` + +##### Log File Location + +When using the `disk` logger, log files are stored in: + +- **Windows:** `%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs` +- **macOS/Linux:** `~/.mongodb/mongodb-mcp/.app-logs` + +You can override the log directory with the `logPath` option. + +#### Disabled Tools + +You can disable specific tools or categories of tools by using the `disabledTools` option. This option accepts an array of strings, +where each string can be a tool name, operation type, or category. + +The way the array is constructed depends on the type of configuration method you use: + +- For **environment variable** configuration, use a comma-separated string: `export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema"`. +- For **command-line argument** configuration, use a space-separated string: `--disabledTools create update delete atlas collectionSchema`. + +Categories of tools: + +- `atlas` - MongoDB Atlas tools, such as list clusters, create cluster, etc. +- `mongodb` - MongoDB database tools, such as find, aggregate, etc. + +Operation types: + +- `create` - Tools that create resources, such as create cluster, insert document, etc. +- `update` - Tools that update resources, such as update document, rename collection, etc. +- `delete` - Tools that delete resources, such as delete document, drop collection, etc. +- `read` - Tools that read resources, such as find, aggregate, list clusters, etc. +- `metadata` - Tools that read metadata, such as list databases/collections/indexes, infer collection schema, etc. +- `connect` - Tools that allow you to connect or switch the connection to a MongoDB instance. If this is disabled, you will need to provide a connection string through the config when starting the server. + +#### Require Confirmation + +If your client supports [elicitation](https://modelcontextprotocol.io/specification/draft/client/elicitation), you can set the MongoDB MCP server to request user confirmation before executing certain tools. + +When a tool is marked as requiring confirmation, the server will send an elicitation request to the client. The client with elicitation support will then prompt the user for confirmation and send the response back to the server. If the client does not support elicitation, the tool will execute without confirmation. + +You can set the `confirmationRequiredTools` configuration option to specify the names of tools which require confirmation. By default, the following tools have this setting enabled: `drop-database`, `drop-collection`, `delete-many`, `atlas-create-db-user`, `atlas-create-access-list`. + +#### Read-Only Mode + +The `readOnly` configuration option allows you to restrict the MCP server to only use tools with "read", "connect", and "metadata" operation types. When enabled, all tools that have "create", "update" or "delete" operation types will not be registered with the server. + +This is useful for scenarios where you want to provide access to MongoDB data for analysis without allowing any modifications to the data or infrastructure. + +You can enable read-only mode using: + +- **Environment variable**: `export MDB_MCP_READ_ONLY=true` +- **Command-line argument**: `--readOnly` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +When read-only mode is active, you'll see a message in the server logs indicating which tools were prevented from registering due to this restriction. + +#### Index Check Mode + +The `indexCheck` configuration option allows you to enforce that query operations must use an index. When enabled, queries that perform a collection scan will be rejected to ensure better performance. + +This is useful for scenarios where you want to ensure that database queries are optimized. + +You can enable index check mode using: + +- **Environment variable**: `export MDB_MCP_INDEX_CHECK=true` +- **Command-line argument**: `--indexCheck` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +When index check mode is active, you'll see an error message if a query is rejected due to not using an index. + +#### Exports + +The data exported by the `export` tool is temporarily stored in the configured `exportsPath` on the machine running the MCP server until cleaned up by the export cleanup process. If the `exportsPath` configuration is not provided, the following defaults are used: + +- **Windows:** `%LOCALAPPDATA%\mongodb\mongodb-mcp\exports` +- **macOS/Linux:** `~/.mongodb/mongodb-mcp/exports` + +The `exportTimeoutMs` configuration controls the time after which the exported data is considered expired and eligible for cleanup. By default, exports expire after 5 minutes (300000ms). + +The `exportCleanupIntervalMs` configuration controls how frequently the cleanup process runs to remove expired export files. By default, cleanup runs every 2 minutes (120000ms). + +#### Telemetry + +The `telemetry` configuration option allows you to disable telemetry collection. When enabled, the MCP server will collect usage data and send it to MongoDB. + +You can disable telemetry using: + +- **Environment variable**: `export MDB_MCP_TELEMETRY=disabled` +- **Command-line argument**: `--telemetry disabled` +- **DO_NOT_TRACK environment variable**: `export DO_NOT_TRACK=1` + +> **πŸ’‘ Platform Note:** For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +#### Opting into Preview Features + +The MongoDB MCP Server may offer functionality that is still in development and may change in future releases. These features are considered "preview features" and are not enabled by default. Generally, these features are well tested, but may not offer the complete functionality we intend to provide in the final release or we'd like to gather feedback before making them generally available. To enable one or more preview features, use the `previewFeatures` configuration option. + +- For **environment variable** configuration, use a comma-separated string: `export MDB_MCP_PREVIEW_FEATURES="vectorSearch,feature1,feature2"`. +- For **command-line argument** configuration, use a space-separated string: `--previewFeatures vectorSearch feature1 feature2`. + +List of available preview features: + +- `vectorSearch` - Enables tools or functionality related to Vector Search in MongoDB Atlas: + - Index management, such as creating, listing, and dropping search and vector search indexes. + - Querying collections using vector search capabilities. This requires a configured embedding model that will be used to generate vector representations of the query data. Currently, only [Voyage AI](https://www.voyageai.com) embedding models are supported. Set the `voyageApiKey` configuration option with your Voyage AI API key to use this feature. + +### Atlas API Access + +To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas: + +> **ℹ️ Note:** For a detailed breakdown of the minimum required permissions for each Atlas operation, see the [Atlas API Permissions](#atlas-api-permissions) section below. + +1. **Create a Service Account:** + - Log in to MongoDB Atlas at [cloud.mongodb.com](https://cloud.mongodb.com) + - Navigate to Access Manager > Organization Access + - Click Add New > Applications > Service Accounts + - Enter name, description and expiration for your service account (e.g., "MCP, MCP Server Access, 7 days") + - **Assign only the minimum permissions needed for your use case.** + - See [Atlas API Permissions](#atlas-api-permissions) for details. + - Click "Create" + +To learn more about Service Accounts, check the [MongoDB Atlas documentation](https://www.mongodb.com/docs/atlas/api/service-accounts-overview/). + +2. **Save Client Credentials:** + + - After creation, you'll be shown the Client ID and Client Secret + - **Important:** Copy and save the Client Secret immediately as it won't be displayed again + +3. **Add Access List Entry:** + + - Add your IP address to the API access list + +4. **Configure the MCP Server:** + - Use one of the configuration methods below to set your `apiClientId` and `apiClientSecret` + +### Atlas API Permissions + +> **Security Warning:** Granting the Organization Owner role is rarely necessary and can be a security risk. Assign only the minimum permissions needed for your use case. + +#### Quick Reference: Required roles per operation + +| What you want to do | Safest Role to Assign (where) | +| ------------------------------------ | --------------------------------------- | +| List orgs/projects | Org Member or Org Read Only (Org) | +| Create new projects | Org Project Creator (Org) | +| View clusters/databases in a project | Project Read Only (Project) | +| Create/manage clusters in a project | Project Cluster Manager (Project) | +| Manage project access lists | Project IP Access List Admin (Project) | +| Manage database users | Project Database Access Admin (Project) | + +- **Prefer project-level roles** for most operations. Assign only to the specific projects you need to manage or view. +- **Avoid Organization Owner** unless you require full administrative control over all projects and settings in the organization. + +For a full list of roles and their privileges, see the [Atlas User Roles documentation](https://www.mongodb.com/docs/atlas/reference/user-roles/#service-user-roles). + +### Configuration Methods + +#### Environment Variables + +Set environment variables with the prefix `MDB_MCP_` followed by the option name in uppercase with underscores: + +**Linux/macOS (bash/zsh):** + +```bash +# Set Atlas API credentials (via Service Accounts) +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Set a custom MongoDB connection string +export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Set log path +export MDB_MCP_LOG_PATH="/path/to/logs" +``` + +**Windows Command Prompt (cmd):** + +```cmd +set "MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id" +set "MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret" + +set "MDB_MCP_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +set "MDB_MCP_LOG_PATH=C:\path\to\logs" +``` + +**Windows PowerShell:** + +```powershell +# Set Atlas API credentials (via Service Accounts) +$env:MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +$env:MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" + +# Set a custom MongoDB connection string +$env:MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Set log path +$env:MDB_MCP_LOG_PATH="C:\path\to\logs" +``` + +#### MCP configuration file examples + +##### Connection String with environment variables + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server"], + "env": { + "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + } + } + } +} +``` + +##### Atlas API credentials with environment variables + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": ["-y", "mongodb-mcp-server"], + "env": { + "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", + "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" + } + } + } +} +``` + +#### Command-Line Arguments + +Pass configuration options as command-line arguments when starting the server: + +> **πŸ”’ Security Note:** For sensitive configuration like API credentials and connection strings, use environment variables instead of command-line arguments. + +```shell +# Set sensitive data as environment variable +export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" +export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" +export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" + +# Start the server with command line arguments +npx -y mongodb-mcp-server@latest --logPath=/path/to/logs --readOnly --indexCheck +``` + +> **πŸ’‘ Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions. + +#### MCP configuration file examples + +##### Connection String with command-line arguments + +> **πŸ”’ Security Note:** We do not recommend passing connection string as command line argument. Connection string might contain credentials which can be visible in process lists and logged in various system locations, potentially exposing your credentials. Instead configure [connection string through environment variables](#connection-string-with-environment-variables) + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": [ + "-y", + "mongodb-mcp-server", + "--connectionString", + "mongodb+srv://username:password@cluster.mongodb.net/myDatabase", + "--readOnly" + ] + } + } +} +``` + +##### Atlas API credentials with command-line arguments + +> **πŸ”’ Security Note:** We do not recommend passing Atlas API credentials as command line argument. The provided credentials can be visible in process lists and logged in various system locations, potentially exposing your credentials. Instead configure [Atlas API credentials through environment variables](#atlas-api-credentials-with-environment-variables) + +```json +{ + "mcpServers": { + "MongoDB": { + "command": "npx", + "args": [ + "-y", + "mongodb-mcp-server", + "--apiClientId", + "your-atlas-service-accounts-client-id", + "--apiClientSecret", + "your-atlas-service-accounts-client-secret", + "--readOnly" + ] + } + } +} +``` + +### Proxy Support + +The MCP Server will detect typical PROXY environment variables and use them for +connecting to the Atlas API, your MongoDB Cluster, or any other external calls +to third-party services like OID Providers. The behaviour is the same as what +`mongosh` does, so the same settings will work in the MCP Server. + +## πŸš€Deploy on Public Clouds + +You can deploy the MongoDB MCP Server to your preferred cloud provider using the deployment assets under `deploy/`. Each guide explains the prerequisites, configuration, and automation scripts that streamline the rollout. + +### Azure + +For detailed Azure instructions, see [deploy/azure/README.md](deploy/azure/README.md). + +## 🀝Contributing + +Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information. diff --git a/packages/compass-generative-ai/.yalc/mongodb-mcp-server/package.json b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/package.json new file mode 100644 index 00000000000..ee60c576598 --- /dev/null +++ b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/package.json @@ -0,0 +1,94 @@ +{ + "name": "mongodb-mcp-server", + "description": "MongoDB Model Context Protocol Server", + "version": "1.2.0", + "type": "module", + "mcpName": "io.github.mongodb-js/mongodb-mcp-server", + "exports": { + ".": { + "import": { + "types": "./dist/esm/lib.d.ts", + "default": "./dist/esm/lib.js" + }, + "require": { + "types": "./dist/cjs/lib.d.ts", + "default": "./dist/cjs/lib.js" + } + } + }, + "main": "./dist/cjs/lib.js", + "types": "./dist/cjs/lib.d.ts", + "author": "MongoDB ", + "homepage": "https://github.com/mongodb-js/mongodb-mcp-server", + "repository": { + "url": "https://github.com/mongodb-js/mongodb-mcp-server.git" + }, + "bin": { + "mongodb-mcp-server": "dist/esm/index.js" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "dist" + ], + "scripts": { + "start": "node dist/index.js --transport http --loggers stderr mcp", + "start:stdio": "node dist/index.js --transport stdio --loggers stderr mcp", + "build:clean": "rm -rf dist", + "build:update-package-version": "tsx scripts/updatePackageVersion.ts", + "build:esm": "tsc --project tsconfig.esm.json && chmod +x dist/esm/index.js", + "build:cjs": "tsc --project tsconfig.cjs.json", + "build:universal-package": "tsx scripts/createUniversalPackage.ts", + "build": "npm run build:clean && concurrently \"npm run build:esm\" \"npm run build:cjs\" && npm run build:universal-package", + "inspect": "npm run build && mcp-inspector -- dist/esm/index.js", + "prettier": "prettier", + "check": "concurrently \"npm run build\" \"npm run check:types\" \"npm run check:lint\" \"npm run check:format\" \"npm run check:dependencies\"", + "check:lint": "eslint .", + "check:dependencies": "knip --strict", + "check:format": "prettier -c .", + "check:types": "tsc --noEmit --project tsconfig.json", + "fix": "npm run fix:lint && npm run reformat", + "fix:lint": "eslint . --fix", + "reformat": "prettier --write .", + "generate": "./scripts/generate.sh && npm run generate:arguments", + "generate:arguments": "tsx scripts/generateArguments.ts", + "test": "vitest --project eslint-rules --project unit-and-integration --coverage", + "pretest:accuracy": "npm run build", + "test:accuracy": "sh ./scripts/accuracy/runAccuracyTests.sh", + "test:long-running-tests": "vitest --project long-running-tests --coverage", + "atlas:cleanup": "vitest --project atlas-cleanup" + }, + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/sdk": "^1.17.4", + "@mongodb-js/device-id": "^0.3.1", + "@mongodb-js/devtools-proxy-support": "^0.5.3", + "@mongosh/arg-parser": "^3.19.0", + "@mongosh/service-provider-node-driver": "^3.17.0", + "ai": "^5.0.72", + "bson": "^6.10.4", + "express": "^5.1.0", + "lru-cache": "^11.1.0", + "mongodb-connection-string-url": "^3.0.2", + "mongodb-log-writer": "^2.4.1", + "mongodb-redact": "^1.2.0", + "mongodb-schema": "^12.6.2", + "node-fetch": "^3.3.2", + "node-machine-id": "1.1.12", + "oauth4webapi": "^3.8.0", + "openapi-fetch": "^0.14.0", + "ts-levenshtein": "^1.0.7", + "voyage-ai-provider": "^2.0.0", + "yargs-parser": "21.1.1", + "zod": "^3.25.76" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >= 23.0.0" + }, + "optionalDependencies": { + "@mongodb-js/atlas-local": "^1.0.2", + "kerberos": "^2.2.2" + }, + "yalcSig": "dc0fcdeb0947410388492935c9f2cf73" +} diff --git a/packages/compass-generative-ai/.yalc/mongodb-mcp-server/yalc.sig b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/yalc.sig new file mode 100644 index 00000000000..b07a6f9edd0 --- /dev/null +++ b/packages/compass-generative-ai/.yalc/mongodb-mcp-server/yalc.sig @@ -0,0 +1 @@ +dc0fcdeb0947410388492935c9f2cf73 \ No newline at end of file diff --git a/packages/compass-generative-ai/package.json b/packages/compass-generative-ai/package.json index d86c2dd5306..6fc6a44cc58 100644 --- a/packages/compass-generative-ai/package.json +++ b/packages/compass-generative-ai/package.json @@ -60,9 +60,14 @@ "@mongodb-js/compass-telemetry": "^1.19.1", "@mongodb-js/compass-utils": "^0.9.21", "@mongodb-js/connection-info": "^0.22.0", + "@mongosh/service-provider-node-driver": "^3.17.0", "bson": "^6.10.4", "compass-preferences-model": "^2.64.0", "mongodb": "^6.19.0", + "ai": "^5.0.72", + "mongodb-build-info": "^1.7.2", + "mongodb-connection-string-url": "^3.0.1", + "mongodb-mcp-server": "file:.yalc/mongodb-mcp-server", "mongodb-schema": "^12.6.3", "react": "^17.0.2", "react-redux": "^8.1.3", diff --git a/packages/compass-generative-ai/src/index.ts b/packages/compass-generative-ai/src/index.ts index 525d5b12008..3cbac14bc5f 100644 --- a/packages/compass-generative-ai/src/index.ts +++ b/packages/compass-generative-ai/src/index.ts @@ -36,3 +36,17 @@ export type { MockDataSchemaRawField, MockDataSchemaResponse, } from './atlas-ai-service'; + +export { + MCPController, + MCPConnectionManager, + createMCPConnectionErrorHandler, +} from './mcp-service'; + +export type { MCPServerInfo, MCPConnectParams } from './mcp-service'; + +export { + mcpControllerLocator, + MCPControllerProvider, + useMCPController, +} from './provider'; diff --git a/packages/compass-generative-ai/src/mcp-connection-error-handler.ts b/packages/compass-generative-ai/src/mcp-connection-error-handler.ts new file mode 100644 index 00000000000..6d6fec72799 --- /dev/null +++ b/packages/compass-generative-ai/src/mcp-connection-error-handler.ts @@ -0,0 +1,21 @@ +import type { + ConnectionErrorHandled, + ConnectionErrorHandler, +} from 'mongodb-mcp-server'; + +/** + * Creates a connection error handler for the MCP server in Compass. + * This handler is called when connection errors occur in the MCP server. + */ +export function createMCPConnectionErrorHandler(): ConnectionErrorHandler { + return function (error: Error): ConnectionErrorHandled { + // In Compass, we'll log connection errors but not show UI notifications + // since connection management is handled by Compass's connection system + // Optionally log error elsewhere if desired, but don't use console in production code + // Return false to indicate we handled the error gracefully + return { + errorHandled: true, + result: {} as any, + }; + }; +} diff --git a/packages/compass-generative-ai/src/mcp-connection-manager.ts b/packages/compass-generative-ai/src/mcp-connection-manager.ts new file mode 100644 index 00000000000..99a9c026012 --- /dev/null +++ b/packages/compass-generative-ai/src/mcp-connection-manager.ts @@ -0,0 +1,175 @@ +import { + ConnectionManager, + type AnyConnectionState, + type ConnectionStateDisconnected, + type LoggerBase, +} from 'mongodb-mcp-server'; +import { + NodeDriverServiceProvider, + type DevtoolsConnectOptions, +} from '@mongosh/service-provider-node-driver'; +import type { ServiceProvider } from '@mongosh/service-provider-core'; +import { isAtlas, isAtlasStream } from 'mongodb-build-info'; +import ConnectionString from 'mongodb-connection-string-url'; + +export interface MCPConnectParams { + connectionId: string; + connectionString: string; + connectOptions: DevtoolsConnectOptions; +} + +export const MCP_SERVER_TELEMETRY_APP_NAME_SUFFIX = 'MongoDB MCP Server'; +const DEFAULT_TELEMETRY_APP_NAME = 'MongoDB Compass'; + +type MCPConnectionManagerConfig = { + logger: LoggerBase; + getTelemetryAnonymousId: () => string; +}; + +export class MCPConnectionManager extends ConnectionManager { + private logger: LoggerBase; + private getTelemetryAnonymousId: () => string; + private activeConnection: { + id: string; + provider: ServiceProvider; + } | null = null; + + constructor({ logger, getTelemetryAnonymousId }: MCPConnectionManagerConfig) { + super(); + this.logger = logger; + this.getTelemetryAnonymousId = getTelemetryAnonymousId; + } + + override connect(): Promise { + return Promise.reject( + new Error( + // eslint-disable-next-line no-multi-str + "MongoDB MCP Server in MongoDB Compass makes use of the connection that MongoDB Compass is connected to. \ +To connect, choose a connection from Compass's connection sidebar - https://www.mongodb.com/docs/compass/connect/" + ) + ); + } + + async connectToCompassConnection( + connectParams: MCPConnectParams + ): Promise { + try { + const { connectionId, connectOptions, connectionString } = + this.overridePresetAppName(connectParams); + const serviceProvider = await NodeDriverServiceProvider.connect( + connectionString, + connectOptions + ); + await serviceProvider.runCommand('admin', { hello: 1 }); + this.activeConnection = { + id: connectionId, + provider: serviceProvider, + }; + return this.changeState('connection-success', { + tag: 'connected', + serviceProvider, + isSearchSupported: () => Promise.resolve(false), + }); + } catch (error) { + this.logger.error({ + id: { __value: 1_001_000_411 }, + context: 'compass-mcp-connection-manager', + message: `Error connecting to Compass connection - ${ + error instanceof Error ? error.message : String(error) + }`, + }); + return this.changeState('connection-error', { + tag: 'errored', + errorReason: error instanceof Error ? error.message : String(error), + }); + } + } + + override async disconnect(): Promise { + try { + await this.activeConnection?.provider?.close(); + } catch (error) { + this.logger.error({ + id: { __value: 1_001_000_412 }, + context: 'compass-mcp-connection-manager', + message: `Error disconnecting from Compass connection - ${ + error instanceof Error ? error.message : String(error) + }`, + }); + } + + this.activeConnection = null; + return this.changeState('connection-close', { + tag: 'disconnected', + }); + } + + override async close(): Promise { + await this.disconnect(); + this._events.emit('close', this.currentConnectionState); + } + + async updateConnection( + connectParams: MCPConnectParams | undefined + ): Promise { + if (connectParams?.connectionId === this.activeConnection?.id) { + return; + } + + await this.disconnect(); + + if (!connectParams) { + return; + } + + if (isAtlasStream(connectParams.connectionString)) { + this.logger.warning({ + id: { __value: 1_001_000_413 }, + context: 'compass-mcp-connection-manager', + message: 'Attempting a connection to an Atlas Stream.', + }); + this.changeState('connection-error', { + tag: 'errored', + errorReason: + 'MongoDB MCP server does not support connecting to Atlas Streams', + }); + return; + } + + await this.connectToCompassConnection(connectParams); + } + + overridePresetAppName(connectParams: MCPConnectParams): MCPConnectParams { + const connectionURL = new ConnectionString(connectParams.connectionString); + const connectOptions: DevtoolsConnectOptions = { + ...connectParams.connectOptions, + }; + const searchParams = + connectionURL.typedSearchParams(); + const appName = searchParams.get('appName'); + + if ( + !appName || + (appName.startsWith(DEFAULT_TELEMETRY_APP_NAME) && + !appName.includes(MCP_SERVER_TELEMETRY_APP_NAME_SUFFIX)) + ) { + const defaultAppName = `${DEFAULT_TELEMETRY_APP_NAME} ${MCP_SERVER_TELEMETRY_APP_NAME_SUFFIX}`; + const telemetryAnonymousId = this.getTelemetryAnonymousId(); + const connectionId = connectParams.connectionId; + const newAppName = isAtlas(connectParams.connectionString) + ? `${defaultAppName}${ + telemetryAnonymousId ? `--${telemetryAnonymousId}` : '' + }--${connectionId}` + : defaultAppName; + + searchParams.set('appName', newAppName); + connectOptions.appName = newAppName; + } + + return { + connectionId: connectParams.connectionId, + connectionString: connectionURL.toString(), + connectOptions, + }; + } +} diff --git a/packages/compass-generative-ai/src/mcp-controller.ts b/packages/compass-generative-ai/src/mcp-controller.ts new file mode 100644 index 00000000000..564eeab211f --- /dev/null +++ b/packages/compass-generative-ai/src/mcp-controller.ts @@ -0,0 +1,360 @@ +import type { Logger } from '@mongodb-js/compass-logging'; +import type { PreferencesAccess } from 'compass-preferences-model/provider'; +import type { DevtoolsConnectOptions } from '@mongosh/service-provider-node-driver'; +import type { + LoggerType, + LogLevel, + LogPayload, + ConnectionManagerFactoryFn, + ConnectionManager, + TransportRunnerConfig, + Server, + UserConfig, +} from 'mongodb-mcp-server'; +import { TransportRunnerBase, UserConfigSchema } from 'mongodb-mcp-server'; +import { LoggerBase, Keychain } from 'mongodb-mcp-server'; +import type { MCPConnectParams } from './mcp-connection-manager'; +import { MCPConnectionManager } from './mcp-connection-manager'; +import { createMCPConnectionErrorHandler } from './mcp-connection-error-handler'; +import type { ConnectionsService } from '@mongodb-js/compass-connections/src/stores/store-context'; +import { type ToolSet, tool } from 'ai'; +import z from 'zod'; + +class CompassMCPLogger extends LoggerBase { + private readonly _logger: Logger; + protected type: LoggerType = 'console'; + + constructor(keychain: Keychain, logger: Logger) { + super(keychain); + this._logger = logger; + } + + protected logCore(level: LogLevel, payload: LogPayload): void { + const logMethod = this.mapToMongoDBLogLevel(level); + + this._logger.log[logMethod]( + this._logger.mongoLogId(1_001_000_400), + 'MCP Server', + `${payload.id.__value} - ${payload.context}: ${payload.message}`, + ...(payload.attributes ? [payload.attributes] : []) + ); + } + + protected mapToMongoDBLogLevel( + level: LogLevel + ): 'debug' | 'info' | 'warn' | 'error' { + switch (level) { + case 'debug': + return 'debug'; + case 'info': + return 'info'; + case 'warning': + return 'warn'; + case 'error': + return 'error'; + default: + return 'info'; + } + } +} + +/** + * In-memory MCP runner that doesn't bind to any external transport. + * The server is kept in memory for direct programmatic access. + */ +class InMemoryRunner extends TransportRunnerBase { + public server?: Server; + public readonly userConfig: UserConfig; + + constructor(config: TransportRunnerConfig) { + super(config); + this.userConfig = config.userConfig; + } + + async start(): Promise { + this.server = await this.setupServer(); + } + + async closeTransport(): Promise { + await this.server?.close(); + } +} + +export type MCPServerInfo = { + runner: InMemoryRunner; + server: Server; // Server instance from mongodb-mcp-server +}; + +type MCPControllerConfig = { + logger: Logger; + preferences: PreferencesAccess; + getTelemetryAnonymousId: () => string; + connections: ConnectionsService; +}; + +export class MCPController { + private logger: Logger; + private connections: ConnectionsService; + private preferences: PreferencesAccess; + private getTelemetryAnonymousId: () => string; + private mcpConnectionManagers: MCPConnectionManager[] = []; + private currentConnectionId?: string; + private currentConnectionString?: string; + private currentConnectOptions?: DevtoolsConnectOptions; + + constructor({ + logger, + preferences, + getTelemetryAnonymousId, + connections, + }: MCPControllerConfig) { + this.logger = logger; + this.connections = connections; + this.preferences = preferences; + this.getTelemetryAnonymousId = getTelemetryAnonymousId; + const mcpConfig = UserConfigSchema.parse({ + disabledTools: ['connect'], + loggers: ['mcp'], + }); + this.runner = new InMemoryRunner({ + userConfig: mcpConfig, + createConnectionManager: ( + ...params: Parameters + ) => MCPController.createConnectionManager(this, ...params), + connectionErrorHandler: createMCPConnectionErrorHandler(), + additionalLoggers: [new CompassMCPLogger(Keychain.root, this.logger)], + telemetryProperties: { + hosting_mode: 'compass', + }, + }); + } + + private readonly runner: InMemoryRunner; + get server(): Server | undefined { + return this.runner?.server; + } + + public async activate(): Promise { + // Check if MCP server should be auto-started + const { enableMcpServer } = this.preferences.getPreferences(); + if (enableMcpServer) { + await this.startServer(); + } + } + + public async startServer(): Promise { + try { + if (this.runner.server) { + this.logger.log.info( + this.logger.mongoLogId(1_001_000_401), + 'MCP Server', + 'MCP server start requested. An MCP server is already running, will not start a new server.' + ); + return; + } + + this.logger.log.info( + this.logger.mongoLogId(1_001_000_402), + 'MCP Server', + 'Starting in-memory MCP server with config', + { + ...this.runner.userConfig, + apiClientId: '', + apiClientSecret: '', + } + ); + + await this.runner.start(); + + this.logger.log.info( + this.logger.mongoLogId(1_001_000_403), + 'MCP Server', + 'In-memory MCP server started successfully' + ); + } catch (error) { + // In case of errors we don't want Compass to crash so we + // silence MCP start errors and instead log them for debugging. + this.logger.log.error( + this.logger.mongoLogId(1_001_000_404), + 'MCP Server', + 'Error when attempting to start MCP server', + { error } + ); + } + } + + private static async createConnectionManager( + mcpController: MCPController, + ...params: Parameters + ): Promise { + const [{ logger: mcpLogger }] = params; + const connectionManager = new MCPConnectionManager({ + logger: mcpLogger, + getTelemetryAnonymousId: mcpController.getTelemetryAnonymousId, + }); + + // Track this ConnectionManager instance for future connection updates + mcpController.mcpConnectionManagers.push(connectionManager); + + // Set up listener on close event to perform a cleanup when the Client + // closes connection to MCP server and eventually ConnectionManager shuts down. + connectionManager.events.on('close', (): void => { + mcpController.logger.log.info( + mcpController.logger.mongoLogId(1_001_000_405), + 'MCP Server', + 'MCPConnectionManager closed. Performing cleanup', + { + connectionManagerClientName: connectionManager.clientName, + } + ); + mcpController.mcpConnectionManagers = + mcpController.mcpConnectionManagers.filter( + (manager) => manager !== connectionManager + ); + }); + + // The newly created ConnectionManager needs to be brought up to date with + // the current connection state. + await mcpController.switchConnectionManagerToCurrentConnection( + connectionManager + ); + return connectionManager; + } + + public async stopServer(): Promise { + try { + if (!this.runner.server) { + this.logger.log.info( + this.logger.mongoLogId(1_001_000_406), + 'MCP Server', + 'MCP server stop requested. No MCP server running, nothing to stop.' + ); + return; + } + await this.runner.server.close(); + this.logger.log.info( + this.logger.mongoLogId(1_001_000_407), + 'MCP Server', + 'MCP server stopped successfully' + ); + } catch (error) { + this.logger.log.error( + this.logger.mongoLogId(1_001_000_408), + 'MCP Server', + 'Error when attempting to close the MCP server', + { error } + ); + } + } + + public getTools(): ToolSet { + if (!this.runner.server) { + return {}; + } + console.log( + 'this.runner.server?.getAvailableTools()', + this.runner.server?.getAvailableTools() + ); + return Object.fromEntries( + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + this.runner.server + ?.getAvailableTools() + .filter((toolBase) => !toolBase.name.includes('atlas')) + .slice(0, 10) + .map((toolBase) => { + return [ + toolBase.name, + tool({ + name: toolBase.name, + description: toolBase.description, + inputSchema: z.object(toolBase.argsShape), + execute: async (args, options) => { + return await toolBase.execute(args, { + signal: options.abortSignal ?? new AbortSignal(), + requestId: options.toolCallId, + sendNotification: async () => {}, + sendRequest: () => undefined as any, + }); + }, + }), + ]; + }) ?? [] + ); + } + + public async onActiveConnectionChanged( + connectionId: string | undefined + ): Promise { + this.logger.log.info( + this.logger.mongoLogId(1_001_000_409), + 'MCP Server', + 'Active connection changed, will switch connection manager to new connection', + { + connectionId, + serverStarted: !!this.server, + } + ); + + // Look up connection details if connection ID is provided + let connectionString: string | undefined; + let connectOptions: DevtoolsConnectOptions | undefined; + + if (connectionId) { + const dataService = + this.connections.getDataServiceForConnection(connectionId); + if (dataService) { + const connectionOptions = dataService.getMongoClientConnectionOptions(); + if (connectionOptions) { + connectionString = connectionOptions.url; + connectOptions = connectionOptions.options; + } + } else { + this.logger.log.warn( + this.logger.mongoLogId(1_001_000_411), + 'MCP Server', + 'Could not find data service for connection', + { connectionId } + ); + } + } + + // Store current connection details for connection managers + this.currentConnectionId = connectionId; + this.currentConnectionString = connectionString; + this.currentConnectOptions = connectOptions; + + await Promise.all( + this.mcpConnectionManagers.map((manager) => + this.switchConnectionManagerToCurrentConnection(manager) + ) + ); + } + + private async switchConnectionManagerToCurrentConnection( + connectionManager: MCPConnectionManager + ): Promise { + try { + const connectParams: MCPConnectParams | undefined = + this.currentConnectionId && this.currentConnectionString + ? { + connectionId: this.currentConnectionId, + connectionString: this.currentConnectionString, + connectOptions: (this.currentConnectOptions ?? + {}) as DevtoolsConnectOptions, + } + : undefined; + await connectionManager.updateConnection(connectParams); + } catch (error) { + this.logger.log.error( + this.logger.mongoLogId(1_001_000_410), + 'MCP Server', + 'Error when attempting to switch connection for connection manager', + { error } + ); + } + } + + public async deactivate(): Promise { + await this.stopServer(); + } +} diff --git a/packages/compass-generative-ai/src/mcp-service.ts b/packages/compass-generative-ai/src/mcp-service.ts new file mode 100644 index 00000000000..0f7b0e72bf8 --- /dev/null +++ b/packages/compass-generative-ai/src/mcp-service.ts @@ -0,0 +1,5 @@ +export { MCPController } from './mcp-controller'; +export type { MCPServerInfo } from './mcp-controller'; +export { MCPConnectionManager } from './mcp-connection-manager'; +export type { MCPConnectParams } from './mcp-connection-manager'; +export { createMCPConnectionErrorHandler } from './mcp-connection-error-handler'; diff --git a/packages/compass-generative-ai/src/provider.tsx b/packages/compass-generative-ai/src/provider.tsx index 9a6d6dbfb56..c1acd497b3b 100644 --- a/packages/compass-generative-ai/src/provider.tsx +++ b/packages/compass-generative-ai/src/provider.tsx @@ -1,14 +1,20 @@ -import React, { createContext, useContext, useMemo } from 'react'; +import React, { createContext, useContext, useMemo, useEffect } from 'react'; import { AtlasAiService } from './atlas-ai-service'; -import { preferencesLocator } from 'compass-preferences-model/provider'; +import { MCPController } from './mcp-controller'; +import { + preferencesLocator, + usePreference, +} from 'compass-preferences-model/provider'; import { useLogger } from '@mongodb-js/compass-logging/provider'; import { atlasServiceLocator } from '@mongodb-js/atlas-service/provider'; import { createServiceLocator, createServiceProvider, } from '@mongodb-js/compass-app-registry'; +import { connectionsLocator } from '@mongodb-js/compass-connections/provider'; const AtlasAiServiceContext = createContext(null); +const MCPControllerContext = createContext(null); export const AtlasAiServiceProvider: React.FC<{ apiURLPreset: 'admin-api' | 'cloud'; @@ -36,6 +42,38 @@ export const AtlasAiServiceProvider: React.FC<{ ); }); +export const MCPControllerProvider: React.FC = createServiceProvider( + function MCPControllerProvider({ children }) { + const logger = useLogger('MCP-CONTROLLER'); + const mcpEnabled = usePreference('enableMcpServer'); + const preferences = preferencesLocator(); + const connections = connectionsLocator(); + const mcpController = useMemo(() => { + return new MCPController({ + logger, + preferences, + getTelemetryAnonymousId: () => { + return preferences.getPreferences().telemetryAnonymousId ?? ''; + }, + connections, + }); + }, [logger, mcpEnabled, connections, preferences]); + + useEffect(() => { + void mcpController.activate(); + return () => { + void mcpController.deactivate(); + }; + }, [mcpController]); + + return ( + + {children} + + ); + } +); + function useAtlasAiServiceContext(): AtlasAiService { const service = useContext(AtlasAiServiceContext); if (!service) { @@ -44,8 +82,27 @@ function useAtlasAiServiceContext(): AtlasAiService { return service; } +function useMCPControllerContext(): MCPController { + const controller = useContext(MCPControllerContext); + if (!controller) { + throw new Error('No MCPController available in this context'); + } + return controller; +} + export const atlasAiServiceLocator = createServiceLocator( useAtlasAiServiceContext, 'atlasAiServiceLocator' ); + +export const mcpControllerLocator = createServiceLocator( + useMCPControllerContext, + 'mcpControllerLocator' +); + +// Export the hook for direct use in components +export const useMCPController = useMCPControllerContext; + export { AtlasAiService } from './atlas-ai-service'; +export { MCPController } from './mcp-controller'; +export type { MCPServerInfo } from './mcp-controller'; diff --git a/packages/compass-generative-ai/yalc.lock b/packages/compass-generative-ai/yalc.lock new file mode 100644 index 00000000000..7e8be4dd8b2 --- /dev/null +++ b/packages/compass-generative-ai/yalc.lock @@ -0,0 +1,9 @@ +{ + "version": "v1", + "packages": { + "mongodb-mcp-server": { + "signature": "dc0fcdeb0947410388492935c9f2cf73", + "replaced": "^1.2.0" + } + } +} \ No newline at end of file diff --git a/packages/compass-preferences-model/src/preferences-schema.tsx b/packages/compass-preferences-model/src/preferences-schema.tsx index eeefc5b4f0b..847828dfc5d 100644 --- a/packages/compass-preferences-model/src/preferences-schema.tsx +++ b/packages/compass-preferences-model/src/preferences-schema.tsx @@ -72,6 +72,7 @@ export type UserConfigurablePreferences = PermanentFeatureFlags & maxTimeMS?: number; installURLHandlers: boolean; protectConnectionStringsForNewConnections: boolean; + enableMcpServer: boolean; // This preference is not a great fit for user preferences, but everything // except for user preferences doesn't allow required preferences to be // defined, so we are sticking it here @@ -1092,6 +1093,18 @@ export const storedUserPreferencesProps: Required<{ validator: z.number().min(0).default(0), type: 'number', }, + enableMcpServer: { + ui: true, + cli: true, + global: true, + description: { + short: 'Enable MongoDB MCP Server', + long: 'Automatically start the MongoDB MCP (Model Context Protocol) Server when connecting to a MongoDB instance. The MCP server enables AI assistants to interact with your MongoDB databases.', + }, + deriveValue: deriveNetworkTrafficOptionState('enableMcpServer'), + validator: z.boolean().default(false), + type: 'boolean', + }, ...allFeatureFlagsProps, }; diff --git a/packages/compass-settings/src/components/settings/gen-ai-settings.tsx b/packages/compass-settings/src/components/settings/gen-ai-settings.tsx index 140927d36a8..99b240dd8f3 100644 --- a/packages/compass-settings/src/components/settings/gen-ai-settings.tsx +++ b/packages/compass-settings/src/components/settings/gen-ai-settings.tsx @@ -15,6 +15,7 @@ export const GenAISettings: React.FunctionComponent<{ {isAIFeatureEnabled && ( <> + )} diff --git a/packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx b/packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx index c6c457bc539..4eb6079f127 100644 --- a/packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx +++ b/packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx @@ -144,6 +144,7 @@ type ConnectionsNavigationComponentProps = { onOpenNonGenuineMongoDBModal(connectionId: string): void; onOpenConnectionInfo(id: string): void; onDisconnect(id: string): void; + onUseConnectionForMcp(info: ConnectionInfo): void; onOpenConnectViaModal?: ( atlasMetadata: ConnectionInfo['atlasMetadata'] ) => void; @@ -190,6 +191,7 @@ const ConnectionsNavigation: React.FC = ({ onOpenNonGenuineMongoDBModal, onOpenConnectionInfo, onDisconnect, + onUseConnectionForMcp, onDatabaseExpand, fetchAllCollections, onRefreshDatabases: _onRefreshDatabases, @@ -421,6 +423,9 @@ const ConnectionsNavigation: React.FC = ({ case 'show-connect-via-modal': onOpenConnectViaModal?.(getConnectionInfo(item).atlasMetadata); return; + case 'connection-use-for-mcp': + onUseConnectionForMcp(getConnectionInfo(item)); + return; case 'select-database': openCollectionsWorkspace(connectionId, getNamespace(item)); return; @@ -473,6 +478,7 @@ const ConnectionsNavigation: React.FC = ({ onOpenCsfleModal, onOpenNonGenuineMongoDBModal, onOpenConnectViaModal, + onUseConnectionForMcp, connections, openCollectionsWorkspace, openCollectionWorkspace, diff --git a/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx b/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx index 1af3783fee2..f6b414c5184 100644 --- a/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx +++ b/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx @@ -25,6 +25,7 @@ import CSFLEConnectionModal, { } from '../csfle-connection-modal'; import type { ConnectionsFilter } from '../use-filtered-connections'; import { setConnectionIsCSFLEEnabled } from '../../modules/data-service'; +import { useMCPController } from '@mongodb-js/compass-generative-ai'; const TOAST_TIMEOUT_MS = 5000; // 5 seconds. @@ -106,6 +107,7 @@ export function MultipleConnectionSidebar({ const maybeProtectConnectionString = useMaybeProtectConnectionString(); const connectionsWithStatus = useConnectionsWithStatus(); + const mcpController = useMCPController(); const { connect, connectInNewWindow, @@ -165,6 +167,33 @@ export function MultipleConnectionSidebar({ [csfleModalConnectionId, onConnectionCsfleModeChanged] ); + const onUseConnectionForMcp = useCallback( + (connectionInfo: ConnectionInfo) => { + void mcpController + .onActiveConnectionChanged(connectionInfo.id) + .then(() => { + openToast('mcp-connection-success', { + title: 'Success', + description: `MCP server is now using connection: ${ + connectionInfo.favorite?.name ?? + connectionInfo.connectionOptions.connectionString + }`, + variant: 'success', + timeout: TOAST_TIMEOUT_MS, + }); + }) + .catch((error: Error) => { + openToast('mcp-connection-error', { + title: 'Error', + description: `Failed to switch MCP server connection: ${error.message}`, + variant: 'warning', + timeout: TOAST_TIMEOUT_MS, + }); + }); + }, + [mcpController] + ); + return (