Gene Library Courses Download Pricing Contact Sign in
mongodb logo
databases Official Website

MongoDB MCP Server – Database and Atlas Operations

MongoDB's official MCP server gives AI agents structured access to MongoDB deployments and supported Atlas administration tools. Use it to inspect data, run queries and aggregations, manage database resources, review performance recommendations, and assist with authorized MongoDB development workflows.

#document-database#atlas#vector-search

Overview

MongoDB's official MCP server connects compatible AI clients to MongoDB Atlas,
Atlas Local, Community Edition, and Enterprise Advanced deployments. It gives
an agent structured tools for working with current database and deployment
context instead of relying only on schema descriptions or query results pasted
manually into a conversation.

What the MCP server enables

MongoDB groups its tools into database, Atlas, and local Atlas capabilities.
Depending on the configured credentials, enabled features, and read-only mode,
an AI agent can:

  • List databases and collections and inspect collection schemas and metadata.
  • Run find queries and aggregation pipelines against authorized data.
  • Create collections and indexes and insert, update, or delete documents when
    write access is enabled.
  • Work with MongoDB Vector Search, including supported index and semantic-search
    workflows.
  • Inspect Atlas organizations, projects, clusters, database users, logs, and
    performance recommendations when Atlas API credentials are configured.
  • Manage supported local Atlas deployments and export query or aggregation
    results to EJSON files.

When to use it

Use MongoDB MCP when an AI workflow needs live database context or must perform
approved MongoDB operations. Typical uses include exploring an unfamiliar data
model, drafting and testing queries, analyzing application data, reviewing
indexes, investigating performance, preparing reports, managing development or
staging resources, and assisting with Atlas administration.

Connection and authentication

MongoDB recommends running the official mongodb-mcp-server@latest package over
stdio for local MCP clients. The server connects to a deployment through
MDB_MCP_CONNECTION_STRING. Atlas administration tools additionally require an
Atlas service account client ID and client secret through
MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET.

The server can also run as a standalone Streamable HTTP service. By default it
listens at http://127.0.0.1:3000/mcp. MongoDB warns that the server does not
provide inbound authentication itself, so remote HTTP deployments must be
protected by an authenticated reverse proxy or API gateway, HTTPS, network
isolation, and rate limiting.

Key considerations

Write operations are enabled unless read-only mode is configured. For production
data, MongoDB recommends both the --readOnly server option and a dedicated
database user with read-only privileges. Store connection strings and Atlas
credentials in environment variables or a secret manager rather than command
arguments or source control. Require human approval for destructive actions,
and never expose the standalone HTTP endpoint directly to an untrusted network.

Supported Transports

stdio

Command: npx

Args:

  • -y
  • mongodb-mcp-server@latest
  • --readOnly

streamable_http

URL: http://127.0.0.1:3000/mcp

Frequently Asked Questions

When should an AI agent use the MongoDB MCP server?
Use it when a workflow needs live MongoDB or Atlas context, such as exploring schemas, running queries and aggregations, reviewing indexes, investigating performance, managing development resources, or performing approved Atlas administration tasks.
What does the MongoDB MCP server add to an AI agent's capabilities?
It gives the agent structured access to current MongoDB data, metadata, database operations, Atlas resources, performance recommendations, and supported vector-search workflows instead of relying only on static model knowledge or manually pasted database output.
What can an AI agent access or manage through MongoDB MCP?
Depending on credentials and configuration, the agent can inspect databases, collections, schemas, documents, indexes, and query results; run aggregation pipelines; use supported write operations; work with Atlas organizations, projects, clusters, users, logs, and recommendations; and manage local Atlas deployments. Read-only mode removes write and destructive tools.
How is authentication configured for the MongoDB MCP server?
Database access is configured with a MongoDB connection string, preferably through MDB_MCP_CONNECTION_STRING. Atlas administration tools require an Atlas service account client ID and secret through MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET. Store all credentials outside source control and use least-privilege database roles.
Which transport should be used for the MongoDB MCP server?
Use stdio for the recommended local deployment in which one MCP client starts the official npm package. Use Streamable HTTP only when a standalone service is required. The default HTTP endpoint is local-only, and any remote exposure must add external authentication, HTTPS, network controls, and rate limiting.