home / mcp / mongodb mcp server
Provides read/write access to MongoDB data via MCP clients, supporting connection strings and Atlas API credentials.
Configuration
View docs{
"mcpServers": {
"aiminnovations-mongodb-mcp-juniper": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_LOG_PATH": "/path/to/logs",
"MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id",
"MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret",
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
}
}
}
}You can run a MongoDB MCP Server to interact with MongoDB databases and Atlas using a single, configurable MCP endpoint. This server exposes a set of MongoDB tools and Atlas tools, enabling read-only querying, data operations, and Atlas cluster management through MCP clients while keeping sensitive credentials secure via environment variables.
Choose a configuration method that fits your deployment. You can connect using a MongoDB connection string, authenticate with Atlas service account credentials, run a standalone setup with environment variables, or deploy via Docker. The server supports both read-only and full access modes depending on how you configure it. You can enable HTTP transport later if you need to expose the server over HTTP, but ensure you apply proper security measures.
Prerequisites: you need Node.js installed (any version that meets the MCPβs requirements) and a MongoDB connection string or Atlas API credentials.
Step 1: Prepare one of the MCP configurations shown below. Step 2: Start the MCP server per the chosen method.
[
{
"name": "mongodb_conn",
"type": "stdio",
"command": "npx",
"args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
}
},
{
"name": "mongodb_atlas",
"type": "stdio",
"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"
}
},
{
"name": "mongodb_standalone",
"type": "stdio",
"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",
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
}
},
{
"name": "mongodb_docker",
"type": "stdio",
"command": "docker",
"args": ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"]
},
{
"name": "mongodb_docker_conn",
"type": "stdio",
"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:[email protected]/myDatabase"
}
},
{
"name": "mongodb_docker_atlas",
"type": "stdio",
"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"
}
}
]By default, the MCP server uses stdio transport suitable for integration with MCP clients. If you need to interact over HTTP, you can enable the HTTP transport with the appropriate startup flag, but ensure you apply strong security controls such as authentication, TLS, and network controls.
Always prefer environment variables for sensitive configuration like connection strings and API credentials. Enable read-only mode if you only need data analysis access. Use a restricted Atlas API service account with minimum required permissions. Consider deploying behind a firewall or in a private network, and enable authentication when exposing the server via HTTP.
To use Atlas API tools, create a service account in MongoDB Atlas and grant only the minimum permissions needed for your tasks. Then configure the MCP server with the credentials in one of the supported configuration methods.
Environment variables provide a secure way to supply credentials. The MCP server also supports command-line arguments for configuration, but sensitive values should be passed via environment variables whenever possible.
If you encounter connectivity issues, verify that the connection string is correct, the Atlas service account has the proper permissions, and the MCP server has access to external endpoints through any required proxies.
If you want to contribute, follow established guidelines for contributing, debugging, and troubleshooting to help improve the MongoDB MCP Server.
Lists MongoDB Atlas organizations
Lists MongoDB Atlas projects
Creates a new MongoDB Atlas project
Lists MongoDB Atlas clusters
Inspect a specific MongoDB Atlas cluster
Create a free MongoDB Atlas cluster
Connects to MongoDB Atlas cluster
Inspect IP/CIDR ranges with access to MongoDB Atlas clusters
Configure IP/CIDR access list for Atlas clusters
List Atlas users
Creates Atlas database user
List Atlas project alerts
Connect to a MongoDB instance
Run a find query against a collection
Run an aggregation against a collection
Get the number of documents in a collection
Insert a single document into a collection
Insert multiple documents into a collection
Create an index for a collection
Update a single document in a collection
Update multiple documents in a collection
Rename a MongoDB collection
Delete a single document from a collection
Delete multiple documents from a collection
Remove a collection from a database
Remove a MongoDB database
List all databases for a connection
List all collections for a database
Describe indexes for a collection
Describe the schema for a collection
Get the size of a collection in MB
Return statistics about a MongoDB database
Export query or aggregation results to EJSON format
Atlas placeholder tool example