Skip to main content

MCP server implementation for MongoDB integration

Project description

MongoDB MCP Server 🚀

A powerful Model Context Protocol (MCP) server implementation for MongoDB integration, providing seamless interaction with MongoDB databases through a standardized protocol.

🌟 Author

Syed Asad

📋 Overview

This MCP server implementation provides a robust interface for interacting with MongoDB databases through the Model Context Protocol. It supports operations on databases, collections, and documents with proper async/await patterns and error handling.

✨ Features

  • 🔄 Full MongoDB CRUD operations support
  • 🔐 Secure connection handling with MongoDB Atlas
  • 🚦 Async/await patterns for optimal performance
  • 🛡️ Comprehensive error handling
  • 📦 Docker support for easy deployment
  • 🔍 Query execution with proper type hints

🚀 Quick Start

Using uvx (Python)

# Run directly with uvx
uvx mongodb-mcp-bridge

# With SSE transport for remote connections
uvx mongodb-mcp-bridge --transport=sse

Using npx (Node.js)

# Run directly with npx
npx mongodb-mcp-bridge

# With SSE transport for remote connections
npx mongodb-mcp-bridge --transport=sse

Environment Variables

Set these environment variables before running the server:

# Required
MONGODB_URI="your_mongodb_connection_string"

# Optional
MONGODB_DB="default_database_name"
MCP_PORT="6274"  # Default port for MCP Inspector

Using Docker 🐳

# Build the Docker image
docker build -t mongodb-mcp-server .

# Run the container
docker run -e MONGODB_URI="your_mongodb_uri" -p 6274:6274 mongodb-mcp-server

🔗 IDE Integration

VS Code Setup

Add this to your VS Code settings.json:

{
  "mcp": {
    "inputs": [
      {
        "type": "promptString",
        "id": "mongodbUri",
        "description": "MongoDB Connection URI"
      }
    ],
    "servers": {
      "mongodb": {
        "command": "uvx",
        "args": ["mongodb-mcp-bridge", "--transport=sse"],
        "env": {
          "MONGODB_URI": "$(mongodbUri)"
        }
      }
    }
  }
}

Cursor/Windsurf Setup

For Cursor or Windsurf, configure the MCP server with:

{
  "mcp": {
    "servers": {
      "mongodb": {
        "url": "http://localhost:6274"
      }
    }
  }
}

📚 Available Tools

  1. ping

    • Quick connection test to verify MongoDB connectivity
  2. list_databases

    • List all available databases in the MongoDB instance
  3. find_documents

    • Query documents in a collection with filtering options
    • Parameters:
      • database: Database name
      • collection: Collection name
      • query: MongoDB query object (optional)
      • limit: Maximum number of documents to return (default: 10)

🔍 Example Usage

Using the MCP Inspector (http://127.0.0.1:6274):

// List all databases
{
    "tool": "list_databases"
}

// Find documents in a collection
{
    "tool": "find_documents",
    "database": "your_database",
    "collection": "your_collection",
    "query": {"status": "active"},
    "limit": 5
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Model Context Protocol (MCP) team for the protocol specification
  • MongoDB team for the excellent database and drivers
  • All contributors and users of this project

Made with ❤️ by Syed Asad

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongodb_mcp_bridge-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mongodb_mcp_bridge-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file mongodb_mcp_bridge-0.1.0.tar.gz.

File metadata

  • Download URL: mongodb_mcp_bridge-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for mongodb_mcp_bridge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6aadd5f466482ac9cc7aa68126015c48f5316c306eb82060ea8c2d4bbce15098
MD5 5f0e114410cd62476a9115bf542c14a0
BLAKE2b-256 fec92c5f747bf019a349b36c6ce50b2577b5acf0b57990c11d4c87c141a2b077

See more details on using hashes here.

File details

Details for the file mongodb_mcp_bridge-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mongodb_mcp_bridge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3b0330cf19975250601b1d0979233afc27eb32926d79d0c2bd4898df5ebbcc0
MD5 7d9a0a2006526b75ece32588adb85381
BLAKE2b-256 c8e98c5f84ec0a7ce04f456c6e04df2cf6054cb7a466394d114ba72f91f6735b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page