Skip to main content

Mongo-MCP

smithery badge English | 简体中文

A Machine Chat Protocol (MCP) service for MongoDB operations. This service provides a set of tools that allow Large Language Models (LLMs) to interact with MongoDB databases through basic CRUD operations and administrative tasks.

Requirements

  • Python 3.10 or above
  • A running MongoDB database service
  • It is recommended to use uv to run the program

Features

  • MongoDB instance connection management
  • List databases and collections
  • Document CRUD operations
    • Insert documents
    • Query documents (supports complex queries and projections)
    • Update documents
    • Delete documents
  • Full support for MongoDB query syntax and projections
  • Comprehensive error handling and logging
  • Stdin/stdout (stdio) based MCP transport implementation

Usage

Run directly with uvx

uvx run mongo-mcp

The server uses the stdio transport method, making it suitable for integration with MCP clients that support this transport method.

Cursor Example Configuration

If you use Cursor as your development environment, you can add the following configuration to your .cursor/mcp.json file for local debugging:

{
    "mcpServers": {
        "mongo-mcp": {
            "command": "uvx",
            "args": [
                "mongo-mcp"
            ],
            "env": {
                "MONGODB_URI": "mongodb://localhost:27017",
                "MONGODB_DEFAULT_DB": "MONGODB_DEFAULT_DB",
                "LOG_LEVEL": "INFO"
            }
        }
    }
}

Environment Variables

  • MONGODB_URI: MongoDB connection string (default: "mongodb://localhost:27017")
  • MONGODB_DEFAULT_DB: Default database name (optional)
  • LOG_LEVEL: Logging level (default: "INFO")
    • Available values: DEBUG, INFO, WARNING, ERROR, CRITICAL

Supported Operations

  • List all databases
  • List all collections in a specified database
  • Insert documents
  • Query documents (supports query conditions and field projections)
  • Update documents (supports single and bulk updates)
  • Delete documents (supports single and bulk deletions)

Development Guide

  1. Clone the repository
git clone https://github.com/yourusername/mongo-mcp.git
cd mongo-mcp
  1. Install development dependencies
# Using pip
pip install -e "[dev]"

# Or using uv (recommended for faster installation)
uv pip install -e "[dev]"
  1. Run tests
pytest
  1. Code Structure
  • server.py: MCP server implementation
  • db.py: Core MongoDB operations implementation
  • config.py: Configuration management
  • tools/: MCP tools implementation
  • tests/: Test cases

Logging

Log files are stored in the logs directory by default. The log level can be controlled through the LOG_LEVEL environment variable.

License

MIT

Contributing

Contributions via Issues and Pull Requests are welcome. Before submitting a PR, please ensure:

  1. All tests pass
  2. Appropriate test cases are added
  3. Documentation is updated

Metadata

Release files for mongo-mcp 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongo-mcp 0.1.3
File Size Uploaded Provenance Actions
mongo_mcp-0.1.3.tar.gz 48.2 kB Without provenance Details for mongo_mcp-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mongo-mcp 0.1.3
File Interpreter ABI Platform Actions
mongo_mcp-0.1.3-py3-none-any.whl Python 3 none any Details for mongo_mcp-0.1.3-py3-none-any.whl

Total release size: 60.4 kB

Release files / mongo_mcp-0.1.3.tar.gz

Download URL mongo_mcp-0.1.3.tar.gz
Size 48.2 kB
Tags Source
SHA-256 checksum
How to use checksums
591c4db178c293a6e1106e1e33e0fd6005e96d3948902cc5b2eeda8e4e1291ef
BLAKE2b-256 checksum
How to use checksums
cdeabadf28954f0f5590a3612a8f772ed22d5fc785618c7a481eedc9f729d4f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.7

Release files / mongo_mcp-0.1.3-py3-none-any.whl

Download URL mongo_mcp-0.1.3-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e1eeded41641c6385a875a9470f8c5122be816b0da712306dc2adb0117968f0
BLAKE2b-256 checksum
How to use checksums
d549904d847147ce3c35963c62632c2bfce60f27b1ba77b03cbeed930568e6e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.7

Security for mongo-mcp 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page