Server facts
MongoDB MCP Server
Project
- Author
- mongodb-js
- Repository
- github.com/mongodb-js/mongodb-mcp-server
- License
- Apache-2.0
- Category
- Databases
Tech
- Runtime / language
- node
- Transports
- stdio
- Remote available
- No
- Authentication
- Not specified
Activity
- GitHub stars
- 1,143
- Last commit
- Data as of
Tags
- Database Queries
- Mongodb
- Mongodb Atlas
- Schema Inspection
Overview
MongoDB MCP Server exposes database and Atlas interactions to MCP-compatible assistants. A connection string can target either a local MongoDB instance or an Atlas cluster, while Atlas-specific tools require service-account credentials. The supplied tool inventory spans document queries, aggregation, collection schemas, indexes, storage measurements, execution-plan inspection, and database statistics. It also includes operations that insert, update, delete, rename, or remove database objects. Separate knowledge tools search MongoDB Assistant resources and enumerate their available sources, allowing documentation-oriented questions alongside direct database work.
The README's client examples enable read-only mode, which must be removed when write access is needed. It recommends passing connection strings and credentials through environment variables rather than exposing them in process arguments, and assigning minimal Atlas permissions. A recent Node.js runtime is required: the stated baseline is version 22.13.0, with Node 20 support marked deprecated. Users can launch through npx or Docker; the container option avoids installing Node.js locally. Standard input/output is the default transport, and Streamable HTTP is also documented. The HTTP instructions explicitly warn against direct internet exposure without authentication and other protective measures. Multiple database connections can coexist, with identifiers used by subsequent operations and tools available to list or close active connections.
Install & configure
Requirements
- Node.js 22.13.0 or later
- A MongoDB connection string or Atlas service-account credentials
- An MCP-compatible client
npx -y mongodb-mcp-server@latest --readOnlyThis is the README's read-only connection-string setup. Atlas operations instead need MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET. Docker and HTTP alternatives are documented; HTTP needs deployment-level authentication and protection.
Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.
Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"mongodb-mcp-server": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}Config file · Project: .cursor/mcp.json
User: ~/.cursor/mcp.json
The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"mongodb-mcp-server": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}Config file · Workspace: .vscode/mcp.json
For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.
{
"servers": {
"mongodb-mcp-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json
Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json
Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"mongodb-mcp-server": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}Config file · Project scope: .mcp.json at the repository root
The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"mongodb-mcp-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.
Tools
Source: repository tool metadata. Tool descriptions are a documented snapshot, not a live capability check.
| Tool | What it does |
|---|---|
| aggregate-db | Execute a database-level aggregation pipeline. |
| aggregate | Execute an aggregation pipeline on a collection. |
| collection-indexes | Inspect indexes attached to a collection. |
| collection-schema | Inspect a collection's document structure. |
| collection-storage-size | Report storage size for a collection. |
| connect | Open an independent MongoDB connection and return its identifier. |
| count | Count collection documents, optionally constrained by a query. |
| create-collection | Add a collection, creating its database if necessary. |
| create-index | Add an index to a collection. |
| db-stats | Report usage statistics for one database. |
| delete-many | Delete collection documents selected by a filter. |
| disconnect | Close a connection; a configured default connection can reopen on later use. |
| drop-collection | Remove a collection or view together with its indexes. |
| drop-database | Delete a database and its associated data files. |
| drop-index | Remove a specified collection index. |
| explain | Inspect execution statistics for the optimizer's selected query plan. |
| export | Save query or aggregation output in the requested EJSON format. |
| find | Search documents within a collection. |
| insert-many | Insert a document array, splitting large payloads into batches when needed. |
| list-collections | Enumerate collections belonging to a database. |
| list-connections | Show active connection identifiers, including any preconfigured connection. |
| list-databases | Enumerate databases reachable through a connection. |
| mongodb-logs | Read recent events logged by mongod. |
| rename-collection | Change a collection's name. |
| update-many | Modify collection documents that satisfy a filter. |
| list-knowledge-sources | Discover sources and filtering options in the MongoDB Assistant knowledge base. |
| search-knowledge | Search MongoDB documentation and expert resources with source and version filters. |
Names, permissions, and defaults can change. Check the current upstream documentation before granting access.
Use cases
- Inspect collection schemas and indexes before writing queries.
- Run document searches and aggregation pipelines from an assistant.
- Review query plans, database statistics, and recent MongoDB logs.
- Search MongoDB documentation and curated knowledge sources.
Strengths
- Covers both local MongoDB and Atlas connections.
- Read-only examples provide a conservative starting configuration.
- Offers database operations and MongoDB knowledge lookup in one server.
Limitations
- Atlas tools require separate service-account credentials.
- HTTP deployments need additional security controls.
- Write-enabled tools can delete data and database objects.
Frequently asked questions
Independent listing, not an affiliation or security review. Grant the least access needed and verify the upstream instructions before running code.