MongoDB MCP Server
Offers containerized deployment of the MongoDB MCP Server, allowing isolated execution without requiring a local Node.js installation.
Enables interaction with MongoDB databases and MongoDB Atlas, providing tools for querying, updating, and managing collections and documents, as well as creating and managing Atlas clusters, projects, database users, and access lists.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MongoDB MCP Server show me the last 10 orders from the ecommerce database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MongoDB MCP Server
A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas.
đ Table of Contents
Related MCP server: MongoDB MCP Server for LLMs
Prerequisites
Node.js (v20.10.0 or later)
node -vA 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 for more details.
If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance.
Setup
Quick Start
Note: When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See Atlas API Permissions for details.
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
Option 1: Connection String args
You can pass your connection string via args, make sure to use a valid username and password.
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"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 args
Use your Atlas API Service Accounts credentials. Must follow all the steps in Atlas API Access section.
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--apiClientId",
"your-atlas-service-accounts-client-id",
"--apiClientSecret",
"your-atlas-service-accounts-client-secret"
]
}
}
}Option 3: Standalone Service using command arguments
Start Server using npx command:
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret"For a complete list of arguments see Configuration Options
To configure your Atlas Service Accounts credentials please refer to Atlas API Access
Option 4: Standalone Service using environment variables
npx -y mongodb-mcp-serverYou can use environment variables in the config file or set them and run the server via npx.
Connection String via environment variables in the MCP file example
Atlas API credentials via environment variables in the MCP file example
Option 5: 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
docker run --rm -i \
mongodb/mongodb-mcp-server:latestOption B: With MongoDB connection string
docker run --rm -i \
-e MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" \
mongodb/mongodb-mcp-server:latestOption C: With Atlas API credentials
docker run --rm -i \
-e MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" \
-e MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" \
mongodb/mongodb-mcp-server:latestDocker in MCP Configuration File
Without options:
{
"mcpServers": {
"MongoDB": {
"command": "docker",
"args": ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"]
}
}
}With connection string:
{
"mcpServers": {
"MongoDB": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"MDB_MCP_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/myDatabase",
"mongodb/mongodb-mcp-server:latest"
]
}
}
}With Atlas API credentials:
{
"mcpServers": {
"MongoDB": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id",
"-e",
"MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret",
"mongodb/mongodb-mcp-server:latest"
]
}
}
}đ ī¸ Supported Tools
Tool List
MongoDB Atlas Tools
atlas-list-orgs- Lists MongoDB Atlas organizationsatlas-list-projects- Lists MongoDB Atlas projectsatlas-create-project- Creates a new MongoDB Atlas projectatlas-list-clusters- Lists MongoDB Atlas clustersatlas-inspect-cluster- Inspect a specific MongoDB Atlas clusteratlas-create-free-cluster- Create a free MongoDB Atlas clusteratlas-connect-cluster- Connects to MongoDB Atlas clusteratlas-inspect-access-list- Inspect IP/CIDR ranges with access to MongoDB Atlas clustersatlas-create-access-list- Configure IP/CIDR access list for MongoDB Atlas clustersatlas-list-db-users- List MongoDB Atlas database usersatlas-create-db-user- Creates a MongoDB Atlas database useratlas-list-alerts- List MongoDB Atlas Alerts for a Project
NOTE: atlas tools are only available when you set credentials on configuration section.
MongoDB Database Tools
connect- Connect to a MongoDB instancefind- Run a find query against a MongoDB collectionaggregate- Run an aggregation against a MongoDB collectioncount- Get the number of documents in a MongoDB collectioninsert-one- Insert a single document into a MongoDB collectioninsert-many- Insert multiple documents into a MongoDB collectioncreate-index- Create an index for a MongoDB collectionupdate-one- Update a single document in a MongoDB collectionupdate-many- Update multiple documents in a MongoDB collectionrename-collection- Rename a MongoDB collectiondelete-one- Delete a single document from a MongoDB collectiondelete-many- Delete multiple documents from a MongoDB collectiondrop-collection- Remove a collection from a MongoDB databasedrop-database- Remove a MongoDB databaselist-databases- List all databases for a MongoDB connectionlist-collections- List all collections for a given databasecollection-indexes- Describe the indexes for a collectioncollection-schema- Describe the schema for a collectioncollection-storage-size- Get the size of a collection in MBdb-stats- Return statistics about a MongoDB database
Configuration
The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest):
Command-line arguments
Environment variables
Configuration Options
Option | Description |
| Atlas API client ID for authentication. Required for running Atlas tools. |
| Atlas API client secret for authentication. Required for running Atlas tools. |
| MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the |
| Folder to store logs. |
| An array of tool names, operation types, and/or categories of tools that will be disabled. |
| When set to true, only allows read and metadata operation types, disabling create/update/delete operations. |
| When set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan. |
| When set to disabled, disables telemetry collection. |
Log Path
Default log location is as follows:
Windows:
%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logsmacOS/Linux:
~/.mongodb/mongodb-mcp/.app-logs
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, list collections, collection schema, etc.
Read-Only Mode
The readOnly configuration option allows you to restrict the MCP server to only use tools with "read" 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=trueCommand-line argument:
--readOnly
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=trueCommand-line argument:
--indexCheck
When index check mode is active, you'll see an error message if a query is rejected due to not using an index.
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=disabledCommand-line argument:
--telemetry disabledDO_NOT_TRACK environment variable:
export DO_NOT_TRACK=1
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 section below.
Create a Service Account:
Log in to MongoDB Atlas at 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 for details.
Click "Create"
To learn more about Service Accounts, check the MongoDB Atlas documentation.
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
Add Access List Entry:
Add your IP address to the API access list
Configure the MCP Server:
Use one of the configuration methods below to set your
apiClientIdandapiClientSecret
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.
Configuration Methods
Environment Variables
Set environment variables with the prefix MDB_MCP_ followed by the option name in uppercase with underscores:
# 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"
export MDB_MCP_LOG_PATH="/path/to/logs"
MCP configuration file examples
Connection String with environment variables
{
"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
{
"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:
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret" --connectionString="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" --logPath=/path/to/logs --readOnly --indexCheckMCP configuration file examples
Connection String with command-line arguments
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
]
}
}
}Atlas API credentials with command-line arguments
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--apiClientId",
"your-atlas-service-accounts-client-id",
"--apiClientSecret",
"your-atlas-service-accounts-client-secret"
]
}
}
}đ¤Contributing
Interested in contributing? Great! Please check our Contributing Guide for guidelines on code contributions, standards, adding new tools, and troubleshooting information.
Available Tools
22 toolsaggregateARead-only
Run an aggregation against a MongoDB collection
Inputs: database (required), collection (required), pipeline (required), responseBytesLimit.
collection-indexesBRead-only
Describe the indexes for a collection
Inputs: database (required), collection (required).
collection-schemaBRead-only
Describe the schema for a collection
Inputs: database (required), collection (required), sampleSize, responseBytesLimit.
collection-storage-sizeBRead-only
Gets the size of the collection
Inputs: database (required), collection (required).
connectARead-only
Connect to a MongoDB instance. The config resource captures if the server is already connected to a MongoDB cluster. If the user has configured a connection string or has previously called the connect tool, a connection is already established and there's no need to call this tool unless the user has explicitly requested to switch to a new MongoDB cluster.
Inputs: connectionString (required).
countARead-only
Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
Inputs: database (required), collection (required), query.
create-collectionA
Creates a new collection in a database. If the database doesn't exist, it will be created automatically.
Inputs: database (required), collection (required).
create-indexB
Create an index for a collection
Inputs: database (required), collection (required), definition (required), name.
db-statsBRead-only
Returns statistics that reflect the use state of a single database
Inputs: database (required).
delete-manyADestructive
Removes all documents that match the filter from a MongoDB collection
Inputs: database (required), collection (required), filter.
drop-collectionADestructive
Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.
Inputs: database (required), collection (required).
drop-databaseADestructive
Removes the specified database, deleting the associated data files
Inputs: database (required).
drop-indexBDestructive
Drop an index for the provided database and collection.
Inputs: database (required), collection (required), indexName (required), type.
explainBRead-only
Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
Inputs: database (required), collection (required), method (required), verbosity.
exportARead-only
Export a query or aggregation results in the specified EJSON format.
Inputs: database (required), collection (required), exportTitle (required), exportTarget (required), +1 more.
findBRead-only
Run a find query against a MongoDB collection
Inputs: database (required), collection (required), filter, projection, +3 more.
insert-manyB
Insert an array of documents into a MongoDB collection
Inputs: database (required), collection (required), documents (required).
list-collectionsBRead-only
List all collections for a given database
Inputs: database (required).
list-databasesBRead-only
List all databases for a MongoDB connection
Inputs: no named parameters.
mongodb-logsBRead-only
Returns the most recent logged mongod events
Inputs: type, limit.
rename-collectionB
Renames a collection in a MongoDB database
Inputs: database (required), collection (required), newName (required), dropTarget.
update-manyB
Updates all documents that match the specified filter for a collection
Inputs: database (required), collection (required), update (required), filter, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogâĻ
TDQS
Scored across 22 tools
Each tool has a distinct purpose with clear boundaries, targeting specific MongoDB operations like querying (find, aggregate), management (create-collection, drop-collection), or diagnostics (explain, db-stats). No tools appear to overlap in functionality, making it easy for an agent to select the correct one based on the task.
Most tools follow a consistent verb-noun or noun-verb pattern using kebab-case (e.g., create-collection, list-databases), with a few minor deviations like 'connect' (verb-only) and 'mongodb-logs' (noun-noun). Overall, the naming is predictable and readable, though not perfectly uniform.
With 22 tools, the count is slightly high but reasonable for a comprehensive MongoDB server covering operations from CRUD to administration and diagnostics. It avoids being excessive (under 25) and provides broad coverage without feeling overly bloated for the domain.
The tool set offers complete coverage of MongoDB operations, including CRUD (find, insert-many, update-many, delete-many), schema management (collection-schema, create-index), database/collection lifecycle (create/drop/rename), and diagnostics (explain, logs). No obvious gaps exist for core workflows in this domain.
Maintenance
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoâĻ
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.20 npm175MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.1MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.MIT

MongoDB MCP Serverofficial
AlicenseBqualityAmaintenanceA Model Context Protocol server that enables AI assistants to interact with MongoDB Atlas resources through natural language, supporting database operations and Atlas management functions.281,164Apache 2.0