List all collections in the MongoDB database
Query documents with filtering and projection
Insert a single document into a collection
Update a single document in a collection
Delete a single document from a collection
Create a new index on a collection
Remove an index from a collection
List all indexes for a collection
MongoDB Database Manager provides a seamless interface for LLMs to interact directly with MongoDB databases. It enables AI assistants to query collections, inspect schemas, and manage data through natural language commands without requiring users to write complex MongoDB queries. With this tool, you can perform a wide range of database operations including document querying, filtering, index management, and CRUD operations (Create, Read, Update, Delete). The server acts as a bridge between natural language instructions and MongoDB's query language, making database interactions more accessible.
MongoDB Database Manager allows AI assistants to interact with MongoDB databases through natural language. This tool bridges the gap between conversational requests and MongoDB's query language, enabling seamless database operations without writing complex queries.
Install the package
You can install the MongoDB Database Manager using npm:
npm install -g mongo-mcp
Alternatively, you can use npx to run it without installation.
Configure your MCP client
Add the MongoDB Database Manager to your Claude Desktop configuration file:
For MacOS: Edit ~/Library/Application\ Support/Claude/claude_desktop_config.json
For Windows: Edit %APPDATA%/Claude/claude_desktop_config.json
Add the following configuration, replacing the MongoDB connection string with your own:
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}
Using Smithery (Optional)
If you prefer an automated setup, you can use Smithery:
npx -y @smithery/cli install mongo-mcp --client claude
If you don't have a MongoDB server available, you can set up a test environment:
Start a MongoDB container with Docker:
Create a docker-compose.yml
file with:
version: '3.1'
services:
mongo:
image: mongo
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
Then run:
docker-compose up -d
Configure for local development:
Update your Claude Desktop config to point to the local MongoDB instance:
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}
Once configured, you can interact with your MongoDB database through natural language. Here are some example prompts to try:
If you encounter issues:
Connection Problems:
Permission Issues:
Client Configuration: