mcpField
M
MongoDB MCP Server πŸš€

MongoDB MCP Server πŸš€

Local
github.com/syedasad-kiwiDatabases3Updated 78w ago

About MongoDB MCP Server πŸš€

MongoDB MCP Server provides an MCP interface for working with MongoDB databases, collections, and documents. It supports asynchronous operations, MongoDB Atlas connections, Docker deployment, and query tools.

Key features

  1. 01MongoDB CRUD operations
  2. 02MongoDB Atlas connection handling
  3. 03Asynchronous operation patterns
  4. 04Database listing and document queries
  5. 05Docker deployment support

Use cases

  1. 01List databases in a MongoDB instance
  2. 02Find documents using collection filters
  3. 03Connect an MCP client to MongoDB

MCP support

The server exposes MongoDB operations to MCP clients, including connectivity checks, database listing, and document queries. It can use stdio or SSE transport.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json Β· Universal config
{
"mcpServers": {
"mongodb-mcp-bridge": {
"command": "uvx",
"args": [
"mongodb-mcp-bridge"
]
}
}
}
Run commanduvx mongodb-mcp-bridge

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypimongodb-mcp-bridge

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

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

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.