mongodb-mcp-server
mongodb-js · mongodb-js/mongodb-mcp-server
This MCP server enables AI agents to connect and interact with MongoDB databases and MongoDB Atlas Clusters, offering both direct marketplace plugins and local server setup options.
A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.
Preview
What you can do with it
- Allow your AI agent to query and manage data in a MongoDB Atlas database via a marketplace plugin.
- Set up a local MCP server to enable AI agents to interact with a self-managed MongoDB deployment.
- Integrate database operations directly into your agent's coding workflow for data-driven applications.
Verified live · 27 tools
We started this MCP server in an isolated sandbox and it exposed these tools:
aggregate-dbRun an aggregation against a MongoDB database
aggregateRun an aggregation against a MongoDB collection
collection-indexesDescribe the indexes for a collection
collection-schemaDescribe the schema for a collection
collection-storage-sizeGets the size of the collection
connectConnect to a MongoDB instance and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time.
countGets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
create-collectionCreates a new collection in a database. If the database doesn't exist, it will be created automatically.
create-indexCreate an index for a collection
db-statsReturns statistics that reflect the use state of a single database
delete-manyRemoves all documents that match the filter from a MongoDB collection
disconnectClose a MongoDB connection and revoke its connectionId.
drop-collectionRemoves a collection or view from the database. The method also removes any indexes associated with the dropped collection.
drop-databaseRemoves the specified database, deleting the associated data files
drop-indexDrop an index for the provided database and collection.
npx -y mongodb-mcp-server@latest · 08/10/2026
Safety check
Usable, but read the notes first.
- ●Reads credential files (SSH keys, cloud or npm tokens).
skills/mongodb-mcp-v3-migration/SKILL.md
Automated scan of the repo files. Always review code you run.
From the README
MongoDB MCP Server
A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas.
Quick Start
Using the official MongoDB plugins for AI agents
MongoDB MCP Server comes bundled with the official MongoDB plugins for AI agents. The following plugins are available:
mongodb-atlas — connects to the MongoDB-hosted Atlas MCP server over OAuth. This does not require you to run anything locally, and is the recommended way to connect to MongoDB Atlas from your AI agent:
- Cursor: marketplace
- VSCode: Open the Extensions view (
⇧⌘X/Ctrl+Shift+X), search for@agentPlugins, and installmongodb-atlas. - Claude: marketplace
- Codex: Open
/pluginsand installmongodb-atlas. - GitHub Copilot CLI: Run
copilot plugin install mongodb-atlas. - Grok: Open
/marketplacein Grok Build and installmongodb-atlas.
mongodb — runs the MongoDB MCP server locally and connects to any self-managed deployment:
- Cursor: marketplace
- Claude: marketplace
- Gemini: marketplace
- Codex: Run
codex plugin marketplace add mongodb/agent-skills, then open/pluginsand installmongodb. - GitHub Copilot CLI: Run
copilot plugin install mongodb. - Grok: Open
/marketplacein Grok Build and installmongodb.
Using the setup script
You can manually set up the local MCP server by running the following command:
npx -y mongodb-mcp-server@latest setup
This will guide you through an interactive setup process, including configuring your MongoDB connection string or Atlas API credentials.
For more advanced setup options, see the Manual Setup section below.
Using the MongoDB MCP Server setup skill
You can add and use the MongoDB MCP Server setup skill to configure your local MCP server using an AI agent.
npx skills add https://github.com/mongodb/agent-skills --skill mongodb-mcp-setup
Using manual configuration
See Manual Setup for instructions on how to manually configure the MongoDB MCP Server.
📚 Table of Contents
- 🚀 Getting Started
- 🛠️ Supported Tools
- 📄 Supported Resources
- ⚙️ Configuration
- 🚀 Deploy on Public Clouds
- 🤝 Contributing
Prerequisites
[!NOTE] Node 20.x support is deprecated and will be removed in a future release. Please upgrade to Node 22.13 or later. See https://nodejs.org/en/blog/migrations/v20-to-v22 for migration details.
-
Node.js
- At least v22.13.0. Check with
node -v.
- At least v22.13.0. Check with
-
A MongoDB connection string or Atlas API credentials.
- 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 for more details.
- If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance.
Manual Setup
🔒 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 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:
Default Safety Notice: All examples below include
--readOnlyby default to ensure safe, read-only access to your data. Remove--readOnlyif 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.
{
"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.