A Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases
A Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.
https://github.com/user-attachments/assets/2389bf23-a10d-49f9-bca9-2b39a1ebe654
To get started, find your mongodb connection url and add this configuration to your Claude Desktop config file:
MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}
To install MongoDB MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mongo-mcp --client claude
If you don't have a mongo db server to connect to and want to create a sample sandbox, follow these steps
docker-compose up -d
npm run seed
Add this configuration to your Claude Desktop config file:
MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"dist/index.js",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}
The seed script creates three collections with sample data:
Try these prompts with Claude to explore the functionality:
"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 john@example.com"
"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 server provides these tools for database interaction:
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 collectionThis project is licensed under the MIT License - see the LICENSE file for details.
Knowledge graph-based persistent memory system
Read-only database access with schema inspection
Database interaction and business intelligence capabilities
Embeddings, vector search, document storage, and full-text search with the open-source AI application database
Query your ClickHouse database server.
Immutable ledger database with live synchronization
Provides AI assistants with a secure and structured way to explore and analyze data in GreptimeDB.
Connect to a Hologres instance, get table metadata, query and analyze data.
Open source MCP server specializing in easy, fast, and secure tools for Databases.
Search, Query and interact with data in your Milvus Vector Database.