This MongoDB MCP server enables Large Language Models (LLMs) to interact with MongoDB databases through natural language. It allows querying collections, inspecting schemas, and managing data without writing complex queries or code.
The easiest way to install MongoDB MCP Server for Claude Desktop is via Smithery:
npx -y @smithery/cli install mongo-mcp --client claude
You can also configure it manually by adding the server to your Claude Desktop config file.
Find your MongoDB connection URL and add this configuration to:
~/Library/Application\ Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}
If you don't have a MongoDB server to connect to, you can create a test sandbox:
docker-compose up -d
npm run seed
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"dist/index.js",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}
"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"
"Find all electronics products that are in stock and cost less than $1000"
"Show me all orders from the user [email protected]"
"List the products with ratings above 4.5"
"What indexes exist on the users collection?"
"Create an index on the products collection for the 'category' field"
"List all indexes across all collections"
"Insert a new product with name 'Gaming Laptop' in the products collection"
"Update the status of order with ID X to 'shipped'"
"Find and delete all products that are out of stock"
The MCP server provides several tools for interacting with MongoDB:
find
: Query documents with filtering and projectionlistCollections
: List available collectionsinsertOne
: Insert a single documentupdateOne
: Update a single documentdeleteOne
: Delete a single documentcreateIndex
: Create a new indexdropIndex
: Remove an indexindexes
: List indexes for a collectionThe seed script creates three collections with sample data:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.