MongoDB

MongoDB’s official MCP Server that connects AI assistants like GitHub Copilot, Claude, and others directly to your MongoDB databases and Atlas deployments.

It turns natural language prompts or automated workflows into safe, structured database operations without requiring manual query writing or deep MongoDB expertise.

Features

  • 🗃️ Dual Access Modes: Connect via MongoDB connection string or MongoDB Atlas API credentials
  • 🔒 Built-in Safety Controls: Read-only mode, index enforcement, and configurable tool restrictions
  • 🧰 Rich Toolset: 20+ database operations (find, aggregate, insert, drop, etc.) plus 10+ Atlas management tools
  • 📤 Export Support: Save query results as EJSON files accessible via URI resources
  • 📊 Observability: Built-in logging to disk, stderr, or MCP client with debug resources for connectivity issues
  • 🌐 Transport Flexibility: Supports stdio (default) and HTTP (with security caveats)
  • 🛡️ Secure Credential Handling: Encourages environment variables over command-line args for secrets
  • ⚙️ Fine-Grained Permissions: Disable tools by name, category (e.g., atlas, delete), or operation type

How to Use It

1. Add a JSON object to your MCP client’s configuration file.

Connection String Method (Recommended for Simplicity)

This is the easiest way to connect to an existing database, whether it’s running locally or on Atlas. Pass the connection string securely using an environment variable in your client’s config file.

{
  "mcpServers": {
    "MongoDB": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "mongodb+srv://user:[email protected]/myDatabase"
      }
    }
  }
}

Atlas API Credentials Method (For Full Atlas Management)

If you want to manage your Atlas environment (create projects, clusters, etc.), you’ll need to use API credentials from a Service Account.

First, create a Service Account in your Atlas organization’s Access Manager. Grant it the necessary permissions. Atlas will provide a Client ID and a Client Secret. Save the secret immediately, as it won’t be shown again.

Then, configure your client like this:

{
  "mcpServers": {
    "MongoDB": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "your-atlas-service-account-client-id",
        "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-account-client-secret"
      }
    }
  }
}

Using Docker

If you prefer not to install Node.js locally, you can run the server in a Docker container. The configuration is similar; you just change the command and args to execute a docker run command.

{
  "mcpServers": {
    "MongoDB": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "MDB_MCP_CONNECTION_STRING",
        "-e", "MDB_MCP_READ_ONLY=true",
        "mongodb/mongodb-mcp-server:latest"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "mongodb+srv://user:[email protected]/myDatabase"
      }
    }
  }
}

2. After saving the configuration file, restart your client. The MongoDB tools should now be available to your AI assistant.

MongoDB Atlas Tools

  • atlas-list-orgs: Lists your MongoDB Atlas organizations.
  • atlas-list-projects: Lists all projects within your MongoDB Atlas organizations.
  • atlas-create-project: Creates a new project in MongoDB Atlas.
  • atlas-list-clusters: Lists the database clusters in a specific MongoDB Atlas project.
  • atlas-inspect-cluster: Provides detailed information about a specific MongoDB Atlas cluster.
  • atlas-create-free-cluster: Deploys a new free-tier M0 cluster in MongoDB Atlas.
  • atlas-connect-cluster: Connects the server to a specified MongoDB Atlas cluster.
  • atlas-inspect-access-list: Shows the IP/CIDR ranges that have access to your MongoDB Atlas clusters.
  • atlas-create-access-list: Configures the IP/CIDR access list for your MongoDB Atlas clusters.
  • atlas-list-db-users: Lists all database users for a project in MongoDB Atlas.
  • atlas-create-db-user: Creates a new database user within a MongoDB Atlas project.
  • atlas-list-alerts: Lists all alerts for a given project in MongoDB Atlas.

MongoDB Database Tools

  • connect: Establishes a connection to a MongoDB instance.
  • find: Executes a find query on a specified collection.
  • aggregate: Runs an aggregation pipeline against a collection.
  • count: Returns the total number of documents in a collection.
  • insert-one: Adds a single document to a collection.
  • insert-many: Adds multiple documents to a collection at once.
  • create-index: Creates a new index on a collection.
  • update-one: Modifies a single document that matches a filter.
  • update-many: Modifies all documents that match a filter.
  • rename-collection: Changes the name of a collection.
  • delete-one: Removes a single document from a collection.
  • delete-many: Removes all documents from a collection that match a filter.
  • drop-collection: Deletes an entire collection from a database.
  • drop-database: Deletes an entire database.
  • list-databases: Lists all available databases for the current connection.
  • list-collections: Lists all collections within a specific database.
  • collection-indexes: Describes the existing indexes for a collection.
  • collection-schema: Analyzes a collection and describes its schema.
  • collection-storage-size: Reports the storage size of a collection in megabytes.
  • db-stats: Provides statistics for a specific database.
  • export: Exports the results of a query or aggregation to an EJSON file.

FAQs

Q: Do I need both a connection string and Atlas API keys?
A: No, you typically use one or the other. Use the connection string for direct database queries (find, aggregate, etc.). Use the Atlas API credentials when you need to perform administrative actions on your Atlas account, like creating projects or clusters.

Q: My connection isn’t working. How can I debug it?
A: First, double-check your credentials in the configuration. Ensure your IP address is on the Atlas IP Access List if you’re connecting to an Atlas cluster. The server also provides a debug://mongodb resource that tracks the last connectivity attempt and any errors, which can be very helpful. Also, check the server logs, which can be configured to output to disk or stderr.

Q: Can I run this as a shared service for my team?
A: Yes, the server supports an HTTP transport mode (--transport http). This allows you to run it on a server and have multiple clients connect to it over the network. However, you must implement proper security measures like authentication and encryption, as the HTTP transport is not secure by default. It’s best to place it behind a firewall or within a private network.

Latest MCP Servers

CVE

An MCP Server that connects Claude to 27 security tools for CVE triage, EPSS checks, KEV status, exploit lookup, and package scanning.

WebMCP

webmcp is an MCP server that connects MCP clients to web search, page fetching, and local LLM-based extraction. It’s ideal…

Google Meta Ads GA4

An MCP server that connects AI assistants to Google Ads, Meta Ads, and GA4 for reporting, edits, and cross-platform analysis.

View More MCP Servers >>

Featured MCP Servers

Notion

Notion's official MCP Server allows you to interact with Notion workspaces through the Notion API.

Claude Peers

An MCP server that enables Claude Code instances to discover each other and exchange messages instantly via a local broker daemon with SQLite persistence.

Excalidraw

Excalidraw's official MCP server that streams interactive hand-drawn diagrams to Claude, ChatGPT, and VS Code with smooth camera control and fullscreen editing.

More Featured MCP Servers >>

FAQs

Q: What exactly is the Model Context Protocol (MCP)?

A: MCP is an open standard, like a common language, that lets AI applications (clients) and external data sources or tools (servers) talk to each other. It helps AI models get the context (data, instructions, tools) they need from outside systems to give more accurate and relevant responses. Think of it as a universal adapter for AI connections.

Q: How is MCP different from OpenAI's function calling or plugins?

A: While OpenAI's tools allow models to use specific external functions, MCP is a broader, open standard. It covers not just tool use, but also providing structured data (Resources) and instruction templates (Prompts) as context. Being an open standard means it's not tied to one company's models or platform. OpenAI has even started adopting MCP in its Agents SDK.

Q: Can I use MCP with frameworks like LangChain?

A: Yes, MCP is designed to complement frameworks like LangChain or LlamaIndex. Instead of relying solely on custom connectors within these frameworks, you can use MCP as a standardized bridge to connect to various tools and data sources. There's potential for interoperability, like converting MCP tools into LangChain tools.

Q: Why was MCP created? What problem does it solve?

A: It was created because large language models often lack real-time information and connecting them to external data/tools required custom, complex integrations for each pair. MCP solves this by providing a standard way to connect, reducing development time, complexity, and cost, and enabling better interoperability between different AI models and tools.

Q: Is MCP secure? What are the main risks?

A: Security is a major consideration. While MCP includes principles like user consent and control, risks exist. These include potential server compromises leading to token theft, indirect prompt injection attacks, excessive permissions, context data leakage, session hijacking, and vulnerabilities in server implementations. Implementing robust security measures like OAuth 2.1, TLS, strict permissions, and monitoring is crucial.

Q: Who is behind MCP?

A: MCP was initially developed and open-sourced by Anthropic. However, it's an open standard with active contributions from the community, including companies like Microsoft and VMware Tanzu who maintain official SDKs.

Get the latest & top AI tools sent directly to your email.

Subscribe now to explore the latest & top AI tools and resources, all in one convenient newsletter. No spam, we promise!