home / mcp / mongodb mcp server
A mongo db server for the model context protocol (MCP)
Configuration
View docs{
"mcpServers": {
"quantgeekdev-mongo-mcp": {
"command": "npx",
"args": [
"-y",
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}You can interact with MongoDB databases through natural language by running a MongoDB MCP Server. It lets you inspect collection schemas, query documents with filters, manage indexes, and perform basic document operations directly from your preferred MCP client.
You connect your MCP client to the MongoDB MCP Server to start talking to your database. Use natural language prompts to inspect schemas, search for documents, manage indexes, and perform inserts, updates, or deletions. Start by configuring the server as a local or remote MCP and choose prompts that align with the available tools.
Prerequisites: Node.js 18+, npm or npx, and an MCP client (such as Claude Desktop or another MCP-enabled client). Optional: Docker and Docker Compose if you want to run a sandbox locally.
Step 1: Install the MongoDB MCP Server package for MCP clients when using a local setup. The configuration specifies how the MCP client will launch the server and connect to MongoDB.
Step 2: For a local development workflow, run the MCP server using Node and point it to your MongoDB connection string. You can specify the connection string directly in the command arguments.
Step 3: If you prefer using a remote MCP runner, you can leverage the provided CLI to install the MongoDB MCP Server for your MCP client, then configure your client to connect to it.
Configuration examples are shown below for two common setups. Use these exactly as written to connect to your MongoDB instance from your MCP client.
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"dist/index.js",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}Query documents with filtering and projection to retrieve matching records.
List all available collections in the connected database.
Insert a single new document into a collection.
Update a single document that matches a filter.
Delete a single document that matches a filter.
Create a new index on a collection to optimize queries.
Remove an existing index from a collection.
List all indexes for a specific collection.