For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

MongoDB MCP Server Overview

The MongoDB MCP Server allows you to interact with your MongoDB data and deployments from AI clients in natural language.

You can use the MongoDB MCP Server with any MongoDB deployment, including MongoDB Atlas, MongoDB Atlas Local, MongoDB Community Edition, and MongoDB Enterprise Advanced.

MongoDB offers two MCP Server deployment types: Local MCP for MongoDB MCP Server, which you run and manage yourself, and MongoDB Atlas Managed MCP Server, which MongoDB hosts and manages for you in Atlas. To learn more, see What is the MongoDB MCP Server? below.

This page describes key concepts and use cases. If you're already familiar with MCP, you can get started.

Model Context Protocol (MCP) is an open standard developed by Anthropic to standardize how LLMs connect to and interact with external resources and services. MCP consists of a client-server architecture with the following key components:

  • MCP Host: Application or environment where you want to use MCP, such as a chat interface or IDE. For example, Claude Desktop or VS Code.

  • MCP Clients: Components within the host that handle connections to MCP servers. For a list of clients that support MCP, see MCP Clients.

  • MCP Servers: Programs that expose specific capabilities to the client. For example, the MongoDB MCP Server.

    The primary way that MCP servers expose capabilities to clients is through tools. Tools are pre-defined, executable functions that enable LLMs to perform specific actions, such as interacting with external data sources like MongoDB.

To learn more, see MCP documentation.

The MongoDB MCP Server is our official MCP server implementation that gives your AI client a set of tools that can be used to interact with your MongoDB data and deployments. These tools include various administrative actions, such as managing cluster resources, database operations like querying and indexing, and performance optimization through the Performance Advisor.

Diagram of the MongoDB MCP Server workflow with tools

MongoDB offers two deployment types for the MongoDB MCP Server:

  • Local MCP for MongoDB MCP Server: You run the MCP server yourself and directly manage your AI agent connections and MCP server infrastructure.

  • MongoDB Atlas Managed MCP Server: MongoDB runs the MCP server in Atlas and manages the AI agent connections and MCP server infrastructure for you.

You can set up either deployment type with the MongoDB MCP Plugin or by using a configuration file:

  • MongoDB MCP Plugin for AI Clients: You install MongoDB from an AI client's marketplace. An AI client is an interface that you use to prompt an AI model. The MongoDB MCP Plugin for the MongoDB Atlas Managed MCP Server provides user-delegated access for interactive AI clients.

  • Manual configuration file setup: You manually add the MongoDB MCP Server configuration and your OAuth client credentials to a configuration file for your AI client. This setup path is best for working with programmatic agents. Programmatic agents are automated, workflow-driven agents that can run multi-step workflows without a user's input or guidance.

The following table compares Local MCP for MongoDB MCP Server and MongoDB Atlas Managed MCP Server. Use this to help you select which deployment type best suits your needs:

Local MCP for MongoDB MCP Server
MongoDB Atlas Managed MCP Server

Hosting Model

You install, run, and maintain the MongoDB MCP Server yourself. You are responsible for server upgrades, connectivity, and credential rotation.

MongoDB hosts, runs, and maintains the MongoDB MCP Server in Atlas. There is no MCP server infrastructure for you to deploy, upgrade, or operate.

Supported Database Deployments

Self-Managed (On-premises) and Atlas (Cloud)

Atlas (Cloud) only

Access Control Level

Up to collection-level dataplane access

Up to project-level dataplane access

Best For

Users who want direct, granular control over where the MongoDB MCP Server runs and how it connects to MongoDB deployments.

Users using Atlas deployments who want MongoDB to host and manage the server for them.

With MongoDB Atlas Managed MCP Server, MongoDB hosts and manages the MongoDB MCP Server in Atlas instead of requiring you to run the server on your own machine or infrastructure. Because MongoDB operates the server, you don't deploy, upgrade, or maintain any MCP infrastructure, and you don't manage connection strings, secrets, or certificates for the connection to your Atlas deployment.

MongoDB Atlas Managed MCP Server provides the following benefits:

  • Streamlined deployment access: When using the MongoDB MCP Plugin to connect to the MongoDB Atlas Managed MCP Server, you can access your database deployments directly using Atlas App Connections without needing to manage service account credentials.

  • Wide user support: MongoDB Atlas Managed MCP Server supports both users working with interactive AI clients and users using programmatic agents.

  • Administrator governance controls: Including org-level opt-in and read-only enforcement for AI clients and per-configuration roles, IP access lists, and read-only settings for programmatic agents.

Local MCP for MongoDB MCP Server is the self-managed MongoDB MCP Server path. You run the MCP server yourself and manually connect it to your MongoDB deployment and tools.

Use Local MCP when you want direct control over how and where the MCP server runs. In exchange for this control, you take on hosting and maintaining the server, including server upgrades and credential management.

You also use Local MCP when you want to use the MongoDB MCP Server with local deployment types, such as MongoDB Atlas Local, MongoDB Community Edition, and MongoDB Enterprise Advanced.

The MongoDB MCP Server allows you to interact with your MongoDB data and deployments using natural language, streamlining developer workflows and making it easier to perform complex tasks from AI interfaces. For example, the MongoDB MCP Server enables the following use cases:

Use case
Description
Prompt example

Data exploration

Learn and explain your database schema and relationships.

Show the schema of the 'users' collection and explain the purpose of each field.

Database operations

Create, read, update, and delete data in your MongoDB collections.

Find all users from the past week and update their orders to 'shipped'.

Database Management

Perform administrative tasks to manage your clusters, database users, and more.

Create a new database user for my Atlas cluster with read-only access.

Code generation

Describe the data you need, then generate relevant MongoDB queries and application code.

Review the schema for the 'users' collection, then generate a Python script that deletes profiles older than 2 years.

Performance optimization

Analyze query performance and get recommendations for indexes and schema improvements.

Show me slow queries from the last 24 hours and suggest indexes to improve performance.

For a list of the specific tools available in the MongoDB MCP Server, see MongoDB MCP Server Tools.

You can set up Local MCP for MongoDB MCP Server and MongoDB Atlas Managed MCP Server using either the MongoDB MCP Plugin from an AI client's marketplace or by manually configuring the MongoDB MCP Server in a configuration file for your AI client.

The MongoDB MCP Plugin helps users give AI clients user-delegated access to explore MongoDB deployments. This method uses Atlas App Connections, which lets you authorize an AI client to access your Atlas resources through an OAuth flow tied to your Atlas identity.

This method requires no MCP infrastructure or credentials to manage. With the MongoDB MCP Plugin:

  • You find MongoDB as a connector or plugin in an AI client's marketplace and authorize it using Atlas App Connections.

  • The AI client acts on your behalf using your Atlas identity.

  • Token refresh is automatic. You don't manage a connection string, secret, or certificate.

  • You can view and revoke the AI clients you connected at any time.

To learn more, see Atlas App Connections Overview.

You can manually add a MongoDB MCP Server configuration to your AI client's configuration file. This setup method is especially useful for programmatic agent access.

The credentials you use depend on your deployment type

For Local MCP for MongoDB MCP Server, you add your own credentials to connect to your MongoDB deployment, including cluster connection strings and optional Atlas API credentials for Atlas tools.

For MongoDB Atlas Managed MCP Server, an Atlas Organization Owner or Project Owner creates an MongoDB Atlas Managed MCP Server configuration via Atlas. This configuration:

  • Provisions a service account and returns a client ID, a client secret, and the MongoDB Atlas Managed MCP Server URL (https://mcp.mongodb.com) that you provide to your agent.

  • Uses separate ingress and egress Atlas service accounts. The AI client receives ingress credentials that grant access only to MongoDB Atlas Managed MCP Server. The server then uses a separate egress service account, configured with the required Atlas permissions, to make API calls on the AI client's behalf. Egress credentials are not exposed to the AI client.

  • Authenticates the AI client using the service account and uses the roles that the administrator assigns, rather than an individual user's identity.

Administrators get granular, per-configuration control over MongoDB Atlas Managed MCP Server, including:

  • The Atlas roles granted

  • An IP access list

  • A read-only flag (enabled by default)

Some AI clients don't natively support the MCP configuration service account OAuth client-credentials flow that MongoDB Atlas Managed MCP Server uses for programmatic access. To connect these clients, use the mongodb-atlas-mcp-remote npm package. You run this package using npx in your client's configuration file. The package acquires an access token from your MCP configuration service account credentials and forwards requests to MongoDB Atlas Managed MCP Server, handling token caching and refresh for you. This allows you to seamlessly connect AI clients to the MongoDB Atlas Managed MCP Server.

Use this package only for AI clients that connect through a configuration file. Client-specific instructions on the Get Started with the MongoDB MCP Server page already use the package.

If you build a programmatic agent using an AI framework such as LangChain, don't use this package. Instead, fetch an access token and call MongoDB Atlas Managed MCP Server directly from your application code. To learn more, see Get Started with the MongoDB MCP Server and select AI Framework Clients from the AI CLIENT dropdown.

To configure the MongoDB MCP Server and learn how to use it, see the following resources:

Quickly get started with the MongoDB MCP Server.

View the prerequisites for configuring the MongoDB MCP Server.

View all available configuration and connection options.

View all available tools in the MongoDB MCP Server.

Test example prompts to use with the MongoDB MCP Server.

Learn about the security best practices for the MongoDB MCP Server.

View the MongoDB MCP Server source code and contributing guidelines.