MongoDB连接器

一个为Claude Desktop提供MongoDB数据库连接功能的模型上下文协议(MCP)服务器,支持完整的CRUD操作和模式发现。

  • by rounakbende10
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 rounakbende10/FastMongo-MCP

使用说明

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 databases
  • list_collections(database) - Get collections in a database
  • list_schema_collections(database) - Get schema with sample documents
  • insert_document(database, collection, document) - Insert new documents
  • query_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 Desktop
  • requirements.txt - Python dependencies
  • pyproject.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