MongoDB Connector MCP Server
A Model Context Protocol (MCP) server that provides MongoDB database connectivity for Claude Desktop.
🚀 Quick Start
Install and Use with Claude Desktop
# Install dependencies
uv pip install -r requirements.txt
# Install MCP server in Claude Desktop
uv run mcp install main.py📋 Available Tools
list_databases()- Get all MongoDB databaseslist_collections(database)- Get collections in a databaselist_schema_collections(database)- Get schema with sample documentsinsert_document(database, collection, document)- Insert new documentsquery_documents(database, collection, query)- Query documents
🔧 Configuration
MongoDB Connection
Update the connection string in main.py:
client = MongoClient("mongodb://127.0.0.1:27017/")📁 Files
main.py- MCP server for Claude Desktoprequirements.txt- Python dependenciespyproject.toml- Project configuration
🎯 Usage
Once installed in Claude Desktop, you can use prompts like:
- "List all databases in my MongoDB"
- "Show me the collections in the booksdb database"
- "Insert a new book document"
- "Query for books by a specific author"
✅ Features
- JSON-Serializable: All responses are properly formatted
- ObjectId Handling: Automatically converts MongoDB ObjectIds to strings
- Error Handling: Robust error handling with proper error messages
- Schema Discovery: Provides sample documents for AI understanding
- Full CRUD: Complete Create, Read, Update, Delete operations
