Announcing CIMD support for MCP Client registration
Learn more

MongoDB Atlas MCP vs API for AI Agents (2026)

Srinivas Karre
Founding Engineer

MongoDB Atlas gives an agent two very different surfaces. The MongoDB MCP server, hosted inside Atlas or run locally, reaches documents as well as clusters. The Atlas Administration API manages the platform, from metrics and backups to alerts and billing, and cannot read a single document. This guide compares what each path lets an agent do, the service accounts and OAuth grants each one puts you on, and how to run an operations agent across many customer projects in production.

TL;DR

  • MongoDB ships one MCP server in two forms. The MongoDB Atlas Managed MCP Server at https://mcp.mongodb.com went GA on August 13, 2026 and is hosted inside Atlas. The open source mongodb-mcp-server (v3.0.5, October 1, 2026) runs locally over stdio or HTTP and also reaches Community Edition, Enterprise Advanced, and local Atlas deployments. Both expose database tools (find, aggregate, insert-many, drop-database) next to Atlas tools (atlas-create-cluster, atlas-get-performance-advisor).
  • The Atlas Administration API at https://cloud.mongodb.com/api/atlas/v2 manages the platform: projects, clusters, database users, IP access lists, alerts, metrics, backups, and billing. It cannot read a single document. Data access goes through a driver and a database user, and the old Atlas Data API reached end of life on September 30, 2025.
  • Auth splits three ways. Interactive MCP clients use OAuth 2.1 Authorization Code with PKCE through Atlas App Connections, but only for clients MongoDB registers in advance. Your own agents use an MCP configuration that provisions a pair of service accounts. The Admin API takes service account tokens from the OAuth 2.0 Client Credentials flow (one hour, no refresh, 100 active tokens per account) or legacy API keys over HTTP Digest.
  • MCP is the faster path for a developer in Claude Code or Cursor who wants to query a collection, inspect a schema, or ask why a cluster is slow. The API is the right path for headless agents that triage alerts, take snapshots before changes, rotate database users, and operate many customer projects at once.
  • Scalekit's mongodb connector exposes 82 prebuilt tools over the Atlas Administration API (55 read, 20 write, 7 destructive). Each customer connects an Atlas service account once, Scalekit stores it encrypted and mints tokens on every call, so the MCP vs API decision doesn't change your auth infrastructure.

The decision your MongoDB Atlas agent forces first

Your agent needs to operate your customers' MongoDB Atlas: tell an on-call engineer why the primary's CPU spiked at 2am, list the indexes Performance Advisor wants added, take a snapshot before a schema migration, or add a CIDR block to a project's IP access list for a new office. MongoDB now hosts a Model Context Protocol (MCP) server inside Atlas, publishes the same server as an open source package you run yourself, and has a versioned REST Administration API. They overlap on clusters, database users, and Performance Advisor. They diverge on whether the agent can touch data, on backups and metrics, and on whose identity each call carries. Here's how to pick.

What MongoDB Atlas MCP and MongoDB Atlas API actually are

MongoDB Atlas MCP

The MongoDB MCP Server comes in two deployment types. The MongoDB Atlas Managed MCP Server is hosted and maintained by MongoDB at https://mcp.mongodb.com, reaches Atlas clusters only, and was announced GA on August 13, 2026. In Claude Code, setup is /plugin install mongodb-atlas@claude-plugins-official followed by an Atlas OAuth sign-in. The Local MCP is the open source mongodb-js/mongodb-mcp-server, started with npx -y mongodb-mcp-server@latest over stdio (default) or HTTP on 127.0.0.1:3000. Its release notes show v3.0.0 on September 17, 2026 and v3.0.5 on October 1, 2026.

The tools reference splits the surface into Atlas tools (organizations, projects, clusters, access lists, database users, alerts, Performance Advisor, Stream Processing), database tools (find, aggregate, count, explain, collection-schema, insert-many, update-many, delete-many, create-index, drop-collection, drop-database), local Atlas deployment tools that need Docker, and two assistant tools that search MongoDB's documentation. Not every tool exists on both deployment types: remote-atlas-connect is the managed server's connection tool, the atlas-local-* tools are local only, and Voyage AI embedding generation needs a key configured on the local server.

MongoDB Atlas API

The Atlas Administration API is REST at https://cloud.mongodb.com/api/atlas/v2, versioned by date in the Accept header (for example application/vnd.atlas.2023-02-01+json). It manages organizations, projects, clusters and Flex clusters, database users and custom roles, IP access lists, alerts and alert configurations, process metrics, Performance Advisor, Atlas Search indexes, cloud backups and restores, Online Archive, activity feed events, and invoices. MongoDB is direct about the boundary: the Admin API "doesn't provide access to the data stored in your clusters."

There are two ways to authenticate:

  • Service accounts (recommended): OAuth 2.0 Client Credentials. You POST to https://cloud.mongodb.com/api/oauth/token with the client ID and a secret beginning mdb_sa_sk_ in a Basic header, and get a Bearer token with expires_in: 3600.
  • API keys (legacy): a public and private key pair sent with HTTP Digest authentication. MongoDB calls them "a legacy authentication method."

Comparing them where it matters for agents

What your agent can actually do

Capability
MongoDB Atlas MCP (managed or local)
Atlas Administration API
Query documents
Yes
No: No data access; needs a driver and a database user
Write or delete documents
Yes: In read-write mode
No
Inspect collection schema and query plans
Yes
Limited: Return names and storage metrics only
Create, scale, and pause clusters
Yes: M10 to M80
Yes
Delete clusters and projects
No: No Atlas delete tool for clusters or projects
Yes
Database users, roles, and IP access lists
Limited: List and inspect only
Yes
Performance Advisor
Yes: Slow query sample capped at 50
Yes
Build indexes
Yes: On the collection, including Vector Search and lexical search indexes
Yes: One member at a time
Alerts
Limited
Yes
Host metrics and connection logs
No: No measurements tool
Yes
Backups and restores
No
Yes
Activity feed and billing
No
Yes

The MCP server is the only path in this comparison that reaches documents. It is built for a developer who wants to explore data, write queries, and fix a slow collection with a model watching the schema. The Admin API is built for operating Atlas: it is the only path to metrics, backups, restore jobs, alert acknowledgement, and the activity feed. Stream Processing goes the other way: the MCP server has atlas-streams-build and atlas-streams-manage, and Scalekit's connector has no Stream Processing tools.

What the MCP path makes easier

"Why is the orders collection slow" on the raw Admin API means listing projects, listing clusters, listing processes to find the primary's hostname:port, pulling slow query log lines, and then pulling suggested indexes for the cluster. None of that shows the model what a document looks like. On the MCP server, collection-schema samples the collection, explain returns the winning plan, and atlas-get-performance-advisor returns slow queries and suggested indexes in one call, so the model can reason about the query and the data together. Writing the schema is the hard part. Not the API call.

The MCP server also carries guardrails the API leaves to you. Read-only mode (--readOnly locally, an organization access mode or an MCP configuration flag on the managed server) means write tools are never registered with the session. Destructive tools such as drop-database and delete-many ask for confirmation by default, and the local server rejects collection scans when indexCheck is on. Server-side JavaScript ($where, $function, $accumulator) has been off by default since v1.13.0.

The tradeoff is that MongoDB owns the surface and it is moving fast. v2.0.0 on August 4, 2026 made every database tool require an explicit connection ID, and v3.0.0 six weeks later moved to a new MCP protocol revision. An agent tuned against one tool contract can break on @latest.

The auth path each one puts you on

On the managed MCP path, interactive, an AI client uses OAuth 2.1 Authorization Code with PKCE through Atlas App Connections. The client "acts using that user's existing Atlas permissions" and cannot exceed them. This model "works only with AI clients that MongoDB registers in advance": ChatGPT, Claude Code, Claude Desktop and Web, Codex, Cursor, Devin, fx, and Grok Build. An Organization Owner must turn it on, and it is disabled by default for existing organizations. The access mode (Read, Read and write, or Disabled) applies to the whole organization; MongoDB's limitations rule out per-user, per-cluster, or per-client controls and delegating a subset of a user's permissions. Access ends after 7 days of inactivity or 30 days from the grant. After a user revokes, the current access token stays valid for up to 10 minutes.

On the managed MCP path, programmatic, your own agent connects through an MCP configuration that an Organization Owner or Project Owner creates with the MCP Configuration API. Atlas creates a pair of service accounts: one lets the agent reach the server, the other is what audit events record, which keeps egress credentials away from the AI client. Each configuration has its own roles, an optional IP access list, and a read-only flag that Atlas preselects. The agent authenticates with Client Credentials using the configuration's client ID and a secret whose lifetime you set with secretExpiresAfterHours. Clients that can't run that flow use the mongodb-atlas-mcp-remote stdio package with MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET.

On the local MCP path, you supply credentials directly: a connection string in MDB_MCP_CONNECTION_STRING for database tools, and a service account's client ID and secret for Atlas tools. Without a connection string, atlas-connect-cluster uses the service account to create a temporary database user with a random password that expires after 4 hours, with readAnyDatabase in read-only mode or readWriteAnyDatabase otherwise. MongoDB's prerequisites note the server "does not hide or disable tools based on permissions," so a tool the account can't use fails at runtime.

On the direct API path, service accounts belong to exactly one organization and carry Atlas roles such as Project Read Only or Project Cluster Manager. The client secret is shown once. Access tokens last one hour and "you can't refresh an access token"; you request a new one. Each service account holds at most 100 active tokens, and the 101st request fails with 403 and Access Token limit reached. An agent that mints a token per worker or per request hits that ceiling while staying inside every rate limit.

The IP access list is the twist that matters for agents. Organizations created in the Atlas UI require an IP access list for the Admin API, and a request from an unlisted address gets 403. The list applies to using a token, not minting it, so a token request succeeds from anywhere and the first real call fails. Wherever your agent's calls originate, including a vendor that calls on its behalf, has to be on that list. Delegated App Connections access, including MCP clients, is exempt from API access lists, which is why MongoDB tells organizations that need every Admin API call to come from known addresses not to enable delegated access.

Both paths still need per-user isolation

In a multi-tenant B2B agent, MCP gives you a credential per user and the direct API gives you a credential per user or per customer. In neither case does the path itself solve storage, rotation, or revocation; those are infrastructure problems regardless of which path you choose.

Atlas sharpens the boundary because the blast radius is infrastructure, not records. A service account with Organization Owner can delete every cluster in the organization. The convenient setup, one organization-level service account per customer, gives every user of your agent the same reach across every project. The safer setup is one service account per customer project with the narrowest role the agent role needs: Project Read Only for a triage assistant, Project Cluster Manager for one that scales clusters. That multiplies the secrets you hold, each with its own expiry date and its own API access list.

Recommended reading: access control for multi-tenant AI agents

What you own in production

On the MCP path, the managed server removes hosting, upgrades, and connection strings. You still own the OAuth sessions in clients you may not control, or the MCP configuration secrets for your own agents, plus their expiry dates. The managed server enforces rate limits of 2,000 requests per minute per IP and 500 per minute per user, returns 429 above them, and MongoDB says those limits "might change without prior notice." Disabling AI client access ends control-plane access immediately, but "data-plane access through artifacts that a client already created, such as database users, continues to work." Cleaning up those database users is yours.

The local server adds a process to run. MongoDB's guidance is to keep credentials in environment variables rather than arguments, scope service accounts to project roles, and chmod 600 config files. Since v3.0.0, binding the HTTP transport to anything other than loopback requires an explicit dangerousHostBinding opt-in.

On the API path, you own schemas, pagination, the token cache, and retries. Atlas rate limits with a token bucket per endpoint set and scope rather than one global quota. A 429 body reads like "Request capacity: 10. Refill rate: 5 per 60 seconds" for the organizations endpoint, and responses may carry RateLimit-Limit, RateLimit-Remaining, and Retry-After. MongoDB says not to depend on those headers being present, and recommends backing off 10, 20, then 40 seconds with jitter. GET /api/atlas/v2/rateLimits shows the buckets for a project or organization. Cluster changes are asynchronous: mongodb_cluster_update returns with stateName UPDATING, and the agent has to poll until the change reports APPLIED. The Admin API is reachable only over the public internet, not through VPC peering or private endpoints.

When to use MCP, when to use the API

Use MongoDB Atlas MCP when:

  • A developer in Claude Code or Cursor asks "why is the orders query slow," and explain, collection-schema, and atlas-get-performance-advisor answer it against real documents.
  • An engineer prototypes a feature against a dev cluster and wants the agent to create a Vector Search index with create-index and test it with aggregate.
  • A data analyst explores a collection in natural language under the organization's Read mode, with Atlas attributing every audited action to the person who signed in.
  • The deployment isn't Atlas at all: Community Edition, Enterprise Advanced, or a local Atlas deployment, which only the local server reaches.

Use the Atlas Administration API when:

  • The agent runs headless: an alert fires, and the agent pulls mongodb_process_measurements_get and mongodb_slow_queries_list for the primary, then acknowledges the alert with mongodb_alert_acknowledge while a human investigates.
  • The workflow is a deterministic pipeline: mongodb_backup_snapshot_take before every migration, then mongodb_rolling_index_create for an approved Performance Advisor suggestion.
  • You operate many customer projects and need a credential per customer, retries that respect 429 and Retry-After, and an execution log your side controls.
  • The task needs something the MCP server doesn't expose: restores, maintenance windows, custom roles, connection access logs, Online Archive, the activity feed, or invoices.

The credential problem that exists on both paths

Both paths hand you an Atlas credential. Neither hands you a vault. A multi-tenant agent serving 80 customer organizations, with one triage service account and one operator service account per customer, holds 160 client secrets. Each secret is shown once, expires on a date someone picked from a menu, and is worth whatever roles the account carries. Each has an API access list that must include wherever your calls come from. Each mints tokens that last an hour, can't be refreshed, and count against a ceiling of 100 active tokens, so a fleet of workers that each fetches its own token can lock a customer out of their own automation.

The MCP path changes the shape, not the problem. Interactive App Connections grants live in chat clients for up to 30 days and can't be narrowed below the user's role. MCP configurations for your own agents are service account pairs with secrets, exactly like the API path. The tempting shortcut on either path is one Organization Owner service account per customer: fewer secrets, larger blast radius per secret, and every audit event attributed to the same machine identity.

Scalekit's mongodb connector stores each customer's Atlas service account encrypted in the token vault and authenticates every call, so the MCP vs API decision doesn't change your auth infrastructure. Your agent passes an identifier; credentials never touch the agent runtime or the LLM context.

Recommended reading: OAuth vs API keys for AI agents

How to connect a MongoDB Atlas agent with Scalekit

Scalekit's mongodb connector is an API-path connector built by Scalekit over the Atlas Administration API, with 82 tools: 55 read, 20 write, and 7 destructive. It covers organizations and projects, dedicated and Flex clusters, processes and metrics, Performance Advisor, alerts and alert configurations, database users and custom roles, IP access lists, Atlas Search indexes, rolling index builds, backups and restores, Online Archive, maintenance windows, activity feeds, teams, and invoices. It does not read documents, because the Admin API can't. It authenticates with a service account: each customer connects one once, and Scalekit authenticates every call with it.

The seven destructive tools are mongodb_cluster_delete, mongodb_flex_cluster_delete, mongodb_project_delete, mongodb_database_user_delete, mongodb_custom_role_delete, mongodb_access_list_entry_delete, and mongodb_search_index_delete. None of them belongs in a model's default tool set.

Prerequisites and the connection name

In the Scalekit dashboard, go to AgentKit > Connections and create a MongoDB Atlas connection. The name you give it is the connection_name your code passes, and the string must match the dashboard exactly. This is the most common integration error.

On the Atlas side, each customer creates a service account under Project Identity & Access > Create Application > Service Account with the narrowest project role the agent needs, and saves the client ID and secret. If the organization requires an API access list, the addresses Scalekit calls from must be on it; the connector page does not list them, so confirm them with Scalekit before you turn that setting on. Copy SCALEKIT_ENVIRONMENT_URL, SCALEKIT_CLIENT_ID, and SCALEKIT_CLIENT_SECRET from Developers > API Credentials into .env.

pip install scalekit-sdk-python python-dotenv langchain-openai

Authorize each customer once

get_or_create_connected_account returns the connected account for an identifier. If it is not ACTIVE, get_authorization_link returns a link to Scalekit's Hosted Connect Widget. For a service account connection like MongoDB Atlas, the widget shows a form for the credentials the connection requires instead of an OAuth consent screen. Scalekit encrypts and stores what the customer enters; your code never receives the secret. Because a service account is a machine identity with project roles, the identifier here is your ID for the customer project and agent role, not for a person.

import os from dotenv import load_dotenv from scalekit import ScalekitClient load_dotenv() scalekit_client = ScalekitClient( env_url=os.environ["SCALEKIT_ENVIRONMENT_URL"], client_id=os.environ["SCALEKIT_CLIENT_ID"], client_secret=os.environ["SCALEKIT_CLIENT_SECRET"], ) actions = scalekit_client.actions CONNECTION_NAME = "mongodb" # must match the connection name in AgentKit > Connections identifier = "acme_prod_triage" # your app's stable ID for this customer project and agent role account = actions.get_or_create_connected_account( connection_name=CONNECTION_NAME, identifier=identifier, ) if account.connected_account.status != "ACTIVE": link = actions.get_authorization_link( connection_name=CONNECTION_NAME, identifier=identifier, ) print("Open this link and enter the Atlas service account credentials:", link.link) input("Press Enter after submitting the form...") account = actions.get_or_create_connected_account( connection_name=CONNECTION_NAME, identifier=identifier, ) if account.connected_account.status != "ACTIVE": raise RuntimeError(f"MongoDB Atlas is {account.connected_account.status}, not ACTIVE")

Retrieve the MongoDB Atlas tools this account can call

This is not a catalog load. The agent asks for the tools this connected account is authorized to call, then narrows them to the seven an incident triage assistant needs. Loading all 82 would put mongodb_cluster_update, mongodb_database_user_delete, and mongodb_backup_restore_job_create in front of a model whose job is to explain a CPU spike. None of the seven below changes anything in Atlas.

tools = actions.langchain.get_tools( identifier=identifier, connection_names=[CONNECTION_NAME], tool_names=[ "mongodb_projects_list", "mongodb_clusters_list", "mongodb_alerts_list", "mongodb_processes_list", "mongodb_process_measurements_get", "mongodb_slow_queries_list", "mongodb_suggested_indexes_list", ], page_size=100, ) tool_map = {t.name: t for t in tools} print(sorted(tool_map))

Run the agent loop

The loop runs until the model stops requesting tools. Every call runs with this service account's Atlas roles, so the system prompt tells the model how Atlas IDs chain together and what a 403 means.

from langchain_core.messages import HumanMessage, SystemMessage, ToolMessage from langchain_openai import ChatOpenAI llm = ChatOpenAI(model="gpt-4o").bind_tools(tools) messages = [ SystemMessage( "You triage MongoDB Atlas incidents. Atlas calls a project id group_id. " "Call mongodb_projects_list to find group_id, then mongodb_clusters_list for " "cluster names, then mongodb_processes_list to get process ids in hostname:port " "form. Use typeName REPLICA_PRIMARY to find the primary. For metrics, call " "mongodb_process_measurements_get with granularity PT1M and period PT6H, and " "metrics such as PROCESS_CPU_USER, CONNECTIONS, and OPCOUNTER_QUERY. Never guess " "ids. If a call returns 403, say the service account lacks the role or the caller " "is not on the API access list." ), HumanMessage( "Project 'checkout-prod', cluster 'orders-prod': what is open right now, what did " "the primary's CPU and connections do over the last six hours, which slow queries " "ran in the last hour, and which indexes does Performance Advisor suggest?" ), ] while True: response = llm.invoke(messages) messages.append(response) if not response.tool_calls: print(response.content) break for tc in response.tool_calls: tool = tool_map.get(tc["name"]) if tool: result = tool.invoke(tc["args"]) else: result = f"Unknown tool: {tc['name']}" messages.append(ToolMessage(content=str(result), tool_call_id=tc["id"]))

Deterministic calls with execute_tool

For pipelines, skip the model. execute_tool runs one tool with a fixed input and returns data plus an execution_id you can log. This job reads Performance Advisor's suggestions for a cluster, takes an on-demand snapshot, waits for it to complete, and then builds each approved index as a rolling build so the primary is never blocked. The approval list comes from your own review step; the job never builds an index nobody signed off on. The connected account here should belong to an operator service account with Project Cluster Manager or a role that can take snapshots and build indexes.

import time OPERATOR = "acme_prod_operator" # a separate connected account with write roles GROUP_ID = os.environ["ATLAS_GROUP_ID"] # 24-hex project id, from mongodb_projects_list CLUSTER = "orders-prod" APPROVED_NAMESPACES = {"shop.orders", "shop.customers"} # set by your human review step def run(tool_name: str, tool_input: dict): result = actions.execute_tool( tool_name=tool_name, tool_input=tool_input, connection_name=CONNECTION_NAME, identifier=OPERATOR, ) print(result.execution_id, tool_name) return result.data suggestions = run( "mongodb_suggested_indexes_list", {"group_id": GROUP_ID, "cluster_name": CLUSTER}, ) suggested = (suggestions.get("content") or {}).get("suggestedIndexes", []) approved = [s for s in suggested if s.get("namespace") in APPROVED_NAMESPACES] if not approved: raise SystemExit("No approved index suggestions for this cluster") snapshot = run( "mongodb_backup_snapshot_take", { "group_id": GROUP_ID, "cluster_name": CLUSTER, "description": "Before Performance Advisor index builds", "retention_in_days": 7, }, ) snapshot_id = snapshot["id"] for _ in range(60): status = run( "mongodb_backup_snapshot_get", {"group_id": GROUP_ID, "cluster_name": CLUSTER, "snapshot_id": snapshot_id}, ) if status.get("status") == "completed": break if status.get("status") == "failed": raise RuntimeError(f"Snapshot {snapshot_id} failed") time.sleep(30) else: raise TimeoutError(f"Snapshot {snapshot_id} did not complete in 30 minutes") for s in approved: database_name, collection_name = s["namespace"].split(".", 1) keys = [{field: str(direction)} for part in s["index"] for field, direction in part.items()] run( "mongodb_rolling_index_create", { "group_id": GROUP_ID, "cluster_name": CLUSTER, "database_name": database_name, "collection_name": collection_name, "keys": keys, }, )

Two details decide whether this is safe. mongodb_backup_snapshot_take requires cloud backup on the cluster, and Atlas rejects it while another on-demand snapshot is queued or running, so a retry loop must check mongodb_backup_snapshots_list before taking another. mongodb_rolling_index_create returns as soon as Atlas accepts the request and builds in the background, so a follow-up check belongs in your pipeline, not in the model's head. The MCP server has no snapshot tool, and its create-index builds directly on the collection.

Multi-tool, multi-tenant MongoDB Atlas agents on a virtual MCP server

The mongodb connector has 82 tools. At roughly 200 tokens each, that is about 16,400 tokens of tool definitions before the agent does any work. A model choosing among mongodb_clusters_list, mongodb_clusters_list_all, mongodb_flex_clusters_list, and mongodb_organization_projects_list picks the wrong one more often than a model holding only the one it needs. Overreach is the bigger risk in infrastructure: a triage assistant that also holds mongodb_cluster_update can pause a production cluster on a bad inference, and one that holds mongodb_cluster_delete can do worse. The fix is not better prompting. It is surface reduction. A Scalekit virtual MCP server declares exactly which tools an agent role can see, and session tokens keep each run bound to one customer's connected accounts. Docs: set up a virtual MCP server.

Create the server once per agent role

from scalekit.actions.models.mcp_config import McpConfigConnectionToolMapping vmcp = actions.mcp.create_config( name="atlas-incident-triage", description="Reads MongoDB Atlas alerts, metrics, and slow queries and posts a Slack summary", connection_tool_mappings=[ McpConfigConnectionToolMapping( connection_name="mongodb", tools=[ "mongodb_projects_list", "mongodb_clusters_list", "mongodb_alerts_list", "mongodb_processes_list", "mongodb_process_measurements_get", "mongodb_slow_queries_list", ], ), McpConfigConnectionToolMapping( connection_name="slack", tools=["slack_send_message"], ), ], ) print(vmcp.config.id, vmcp.config.mcp_server_url)

Mint a session token per user, per run

One server definition serves every customer. Before each run, check that the identifier's accounts are active and mint a short-lived session token scoped to them. Any MCP client that speaks Streamable HTTP can connect; this example uses langchain-mcp-adapters (pip install langchain-mcp-adapters) and passes the token as a Bearer header.

import asyncio from datetime import timedelta from langchain_mcp_adapters.client import MultiServerMCPClient config_id = vmcp.config.id mcp_server_url = vmcp.config.mcp_server_url user_id = "acme_prod_triage" accounts = actions.mcp.list_mcp_connected_accounts( config_id=config_id, identifier=user_id, include_auth_link=True, ) not_ready = [ a for a in accounts.connected_accounts if str(a.connected_account_status).upper() != "ACTIVE" ] for a in not_ready: print(f"{a.connection_name} is {a.connected_account_status}: {a.authentication_link}") if not_ready: raise RuntimeError("Connect the accounts above before starting this run") session_token = actions.mcp.create_session_token( mcp_config_id=config_id, identifier=user_id, expiry=timedelta(minutes=30), ).token async def load_tools(): client = MultiServerMCPClient( { "scalekit": { "transport": "streamable_http", "url": mcp_server_url, "headers": {"Authorization": f"Bearer {session_token}"}, } } ) return await client.get_tools() mcp_tools = asyncio.run(load_tools()) print([t.name for t in mcp_tools])

The agent sees seven tools instead of 82. The endpoint is static; the identity is per customer. Atlas's own read-only switch is all or nothing for a configuration; this server can hand one role mongodb_alert_acknowledge and nothing else that writes, and leave mongodb_backup_restore_job_create to a separate operator role that a human triggers.

Observability: every MongoDB Atlas action tied to a user

Every execute_tool call returns an execution_id, and every execution is attributed to a connected account, which maps to one customer project and one agent role. When a customer asks which agent run acknowledged the 3am CPU alert or built an index on shop.orders, the answer is a lookup, not an investigation. mongodb_project_events_list returns Atlas's own activity feed for the project, filtered by cluster or event type, so you can reconcile what your execution log says the agent did against what Atlas recorded.

Attribution is also where the paths differ. On App Connections, audit events record both the Atlas user and the AI client. On MCP configurations and the Admin API, events record the service account. Atlas does not record individual tool calls on the managed MCP server, and read-only Admin API calls are not written to the audit log at all, so "which run read the access logs" exists only on your side. If one service account serves every agent role for a customer, every change in Atlas shows that one identity. Shared credentials work for a single user. They do not survive a second user.

Recommended reading: audit trails for agent auth

Which one to build against

If your agent is a developer's assistant in Claude Code, Cursor, or ChatGPT, querying collections, inspecting schemas, and fixing slow queries with a person watching, MongoDB's Atlas Managed MCP Server is a good fit, and the local server covers deployments outside Atlas; its tool contract has changed twice this year, so pin versions. If your agent runs unattended, triages alerts, takes snapshots, builds approved indexes, rotates database users, or operates many customer projects, build against the Atlas Administration API, where you choose the credential, the tools, and the retry behavior. If your agent needs both data and operations, run both paths with separate credentials. Either way, you hold an Atlas service account per customer that can reshape production infrastructure, and that's what needs production-grade infrastructure.

FAQs

Does MongoDB have an official MCP server for Atlas?

Yes, in two forms. The Atlas Managed MCP Server is hosted by MongoDB, reaches Atlas clusters only and went generally available in August 2026. The open source local server runs over stdio or HTTP and also reaches Community Edition, Enterprise Advanced and local Atlas deployments. Both expose database tools next to Atlas tools.

Can the Atlas Administration API read documents?

No. MongoDB states the Administration API does not provide access to the data stored in your clusters. It manages projects, clusters, database users, access lists, alerts, metrics, backups, restores, activity feeds and invoices. Reading documents needs a driver and a database user, or the MCP server.

How do Atlas service account tokens work for agents?

A service account belongs to one organization and carries Atlas roles. It exchanges a client ID and secret for a Bearer token that lasts one hour and cannot be refreshed. Each account holds at most 100 active tokens, and the IP access list applies when a token is used, so the first real call can fail even though minting succeeded.

How does access work on the managed MCP server?

Interactive clients use OAuth with PKCE through Atlas App Connections, only for clients MongoDB registers in advance, and act with the user's existing Atlas permissions. Your own agents use an MCP configuration that creates a pair of service accounts with their own roles, an optional IP access list and a read-only flag.

When should an agent use the Atlas Administration API instead of MCP?

Use the API for headless alert triage, snapshots before migrations, rolling index builds for approved suggestions, maintenance windows, custom roles, connection logs, the activity feed and invoices, and when you operate many customer projects. Use MCP when a developer explores data, inspects schemas and fixes slow queries with a person watching.

How does Scalekit connect an AI agent to MongoDB Atlas?

Scalekit's MongoDB Atlas connector wraps the Administration API in 82 tools. Each customer connects a service account once through a hosted form, Scalekit stores it encrypted and authenticates every call, and the agent never sees the secret. You narrow the tools per agent role and serve them through a virtual MCP server.

Build your MongoDB Atlas agent with Scalekit

Browse the Scalekit MongoDB Atlas connector and the MongoDB Atlas connector docs with the full tool list. See Scalekit pricing, or talk to us.

No items found.
On this page
Share this article
Scalekit
Find us on ProductHunt

Acquire enterprise customers with
‍zero upfront cost.

Every feature unlocked. No hidden fees.