home / mcp / mongodb mcp server
MCP server that provide tools to LLMs such as claude in cursor to interact with MongoDB
Configuration
View docs{
"mcpServers": {
"1rb-mongo-mcp": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}You can empower your AI assistants to interact directly with MongoDB by exposing MongoDB operations through an MCP (Model Context Protocol) server. This lets you query collections, inspect schemas, manage data, and apply access controls from natural language prompts, all while keeping your data secure and consistently formatted for the AI client youβre using.
You connect an MCP client to the MongoDB MCP Server and start issuing natural language prompts to explore data. Expect to query available collections, view collection schemas, filter documents, and perform standard data operations like insert, update, and delete. The server converts your requests into MongoDB operations, validates inputs, and returns structured results the AI client can present.
Prerequisites you need to satisfy before installing the MCP server include Node.js version 18 or higher and a MongoDB instance (local or remote). You also should have an MCP client such as Claude Desktop or Cursor.ai ready to connect.
Install via Node package manager using the following command to run the MCP server through a one-off tool invocation (no global installation required):
npx -y @ smithery/cli install mongo-mcp --client claudeYou can run the server in local development mode using a direct Node command or through an npx-based invocation. Use the following configurations to connect your MCP client to MongoDB.
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"dist/index.js",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}Lists all collections in the connected MongoDB database.
Queries documents with filtering and projection support.
Inserts a single document into a specified collection.
Updates a single document in a collection based on a filter.
Deletes a single document from a collection.
Creates an index on a collection for specified fields.
Removes an index from a collection.
Lists all indexes for a collection.