db-connector-nosql-mongo
A specialized Model Context Protocol (MCP) utility designed for fluid interaction with MongoDB data stores. It empowers large language models to dynamically examine collection schemata, execute sophisticated document retrieval and filtering operations, and manage fundamental data lifecycle tasks (creation, modification, removal) using conversational input.
Author

rock913
Quick Info
Actions
Tags
🗄️ MongoDB MCP Service Gateway for Generative AI
This is an MCP server implementation facilitating direct, natural-language-driven access to MongoDB instances for Artificial Intelligence models. Achieve comprehensive control over collections, schema introspection, and data manipulation without writing direct database queries.
✨ Core Capabilities
- 🔍 Introspection of collection structures and metadata
- 📊 Advanced document querying, including complex filtering logic
- 📈 Management and inspection of database indexes
- 📝 Full CRUD support: insertion, modification, and logical deletion of records
Demo Visual
https://github.com/user-attachments/assets/2389bf23-a10d-49f9-bca9-2b39a1ebe654
🚀 Initial Setup Guide
To deploy this service, secure your MongoDB connection URI and integrate the following configuration block into your Claude Desktop configuration file:
macOS Path: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows Path: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://
Automated Installation via Smithery
Utilize the Smithery CLI tool for one-step deployment targeting Claude Desktop:
bash npx -y @smithery/cli install mongo-mcp --client claude
System Requirements
- Node.js version 18 or newer
- npx executable
- Docker and Docker Compose (Optional: Required only for running the included local testing environment)
- A compatible MCP client application (e.g., Claude Desktop)
Local Sandbox Initialization
For isolated testing without external dependencies, follow these provisioning steps:
- Launch the self-contained MongoDB environment:
bash docker-compose up -d
- Populate the database with sample payloads:
bash npm run seed
Configuration for Local Development Mode
When running directly from source (e.g., for debugging), use this configuration snippet, pointing to the local runtime:
{ "mcpServers": { "mongodb": { "command": "node", "args": [ "dist/index.js", "mongodb://root:example@localhost:27017/test?authSource=admin" ] } } }
Sample Data Schema Overview
The seeding utility populates three distinct collections to demonstrate capability:
Users Collection
- Biographical data (name, electronic mail, chronological age)
- Geo-location data nested structure (street address, GPS coordinates)
- Enumerated preferences (interests array)
- Account registration timestamps
Products Catalog
- Merchandise specifics (designation, Stock Keeping Unit, classification)
- Detailed technical attributes (nested specifications)
- Fiscal data (pricing and current stock levels)
- Community feedback metrics (tags and aggregated scores)
Transactions (Orders)
- Line item details for purchases
- References linking back to purchasing user entities
- Logistics and monetary settlement information
- Current workflow status tracking
🎯 Illustrative Use Cases
Engage Claude with these queries to test the service's scope:
Foundational Operations
plaintext "Enumerate the collections present in the active database." "Display the structural definition for the 'users' collection." "Retrieve all user entities located within 'San Francisco'."
Complex Retrieval Logic
plaintext "Identify all merchandise items classified as 'electronics' that possess inventory and are priced below $1000." "Fetch every recorded transaction associated with the email address john@example.com." "Provide a list of all products achieving an average user rating exceeding 4.5 stars."
Index Management Directives
plaintext "Report on the indexing structures applied to the users collection." "Establish a new index on the products collection targeting the 'category' attribute." "Output a consolidated list of all defined indexes across every collection."
Record Manipulation Commands
plaintext "Commit a new record into the products catalog named 'Gaming Laptop'." "Modify the processing status for the order identified by ID X to 'dispatched'." "Locate and permanently erase all product entries currently marked as unavailable."
📝 Exposed Service Endpoints
The server exposes the following specific functions for tool invocation:
Retrieval & Modification Tools
find: Executes queries utilizing criteria matching and field projection.listCollections: Returns a roster of existing collections.insertOne: Adds a single new document to a specified collection.updateOne: Modifies the fields of a single matching document.deleteOne: Permanently removes one matching document.
Index Utility Tools
createIndex: Provisions a new indexing structure.dropIndex: Decommissions an existing index.indexes: Lists the indexes associated with a given collection.
📜 Licensing Information
This software is distributed under the terms of the MIT License.
