Everything stays in your Atlas account: a database user, a service account, MongoDB tooling installed through an environment blueprint, and optionally an MCP server. Start narrow (read-only production) and widen roles later; the roles are the boundary, and you change them in Atlas without touching Devin.
Two planes, two identities
A database user can’t call the Atlas Administration API, and a service account can’t read documents through the API. Most teams start with the data plane only and add the service account when Devin needs Performance Advisor or slow-query logs (dedicated clusters, M10 and up). Two caveats:
- A service account that can create database users (
GROUP_OWNER,GROUP_DATABASE_ACCESS_ADMIN) can mint itself a data-plane identity. The MongoDB MCP server does exactly that when asked to connect to a cluster (Option B). - Slow-query data includes literal query values.
Choose how Devin connects
All three paths use the same network access (Step 1) and identities (Step 2); they differ in what Devin gets to hold.Why connect Devin to MongoDB?
- The schema lives in the documents. MongoDB has no
information_schema, and Mongoose or Prisma models drift from what is stored. Devin samples the live collections and works from the real shape. - The slow-query loop closes in one session. Devin reads Performance Advisor and the slow-query log, runs
explain()on the real collection, finds the code that issues the query, and opens a PR with the fix and the proposed index. - The database user’s roles decide what Devin can touch. Start read-only on production with a
devin_devsandbox for writes, and every action lands in Atlas logs under Devin’s own identity.
Prerequisites
Atlas- A project with a cluster.
Organization Ownerto create a service account;Project Ownerfor the database user and access lists.
- Permission to edit the environment blueprint and add Secrets.
- For the MCP paths, Manage MCP Servers.
- Devin’s IPs on the project IP access list (Step 1).
- If you use a Devin network policy, allow
*.mongodb.netandcloud.mongodb.com, plus the hosts the blueprint installs from:pgp.mongodb.comandrepo.mongodb.org(Option A),registry.npmjs.organdnodejs.org(Option B). The driver connects on port 27017, not 443; policy entries are hostnames or CIDRs, so there’s no port to set. Snapshot builds run under the same policy.
Step 1: Open network access
Atlas refuses connections from IPs not on the project IP access list. Add the IPs listed under IP allowlisting, not from memory. Dedicated tenants have their own egress; confirm with your account team.--type ipAddress for single addresses and --type cidrBlock for the range.
If your organization requires an API access list on service accounts, add the same IPs on the service account’s page in Atlas. Calls from an unlisted IP fail with 403.
Step 2: Create Devin’s identities
Database user
Read on production databases, read/write in a sandbox, scoped to named clusters:--scope the user can reach every cluster in the project. Use a custom database role when built-in roles can’t express the boundary. Generate the password with a password manager and don’t leave it in shell history. Copy this user’s connection string; don’t give Devin the cluster admin user.
Service account (only if Devin needs the control plane)
In Atlas, Identity & Access > Applications at the organization level. Start read-only, and pick the shortest client-secret lifetime your rotation allows.Step 3: Connect Devin
Option A: CLI in a blueprint
1. Add Devin Secrets
On the blueprint’s Secrets tab:
Secrets are injected per session, so rotating a value needs no rebuild. The Atlas CLI reads the client ID and secret from these environment variables, so there is no
atlas auth login. On first use it caches an access token in ~/.config/atlascli/config.toml; that’s fine inside a session, but never create that file in initialize.
2. Add the blueprint
jammy if your image isn’t Ubuntu 22.04.
The knowledge block matters more than the install: without it, sessions run atlas auth login (a browser flow nobody can finish) or ask for a connection string that is already in the environment.
3. Build the snapshot
Save the blueprint, wait for Success, then start a new session. Open sessions keep the old snapshot.Option B: MongoDB MCP server
The officialmongodb-mcp-server runs as a local process inside the session and uses the Step 2 identities. To get its guardrails, add it as a custom MCP server (Customize > MCPs > Add MCP > Add custom MCP, transport STDIO) rather than through the marketplace mongodb plugin, whose manifest doesn’t expose --readOnly or --indexCheck.
Pin
<version> to a release you’ve tested; npx fetches the package on every session start. With the read-only service account from Step 2, atlas-connect-cluster returns 401; Devin reaches data through the preconfigured connection from MDB_MCP_CONNECTION_STRING, which is the intended path.
--readOnlyskips registering create, update, and delete tools, and rejects aggregations containing$outor$merge. Without it, those aggregations run after a confirmation prompt, or unconfirmed if the MCP client doesn’t support prompts. Use it for anything pointed at production.--indexCheckrejects queries whose plan is a collection scan. It’s a performance guardrail; ifexplainitself fails, the query runs anyway.
^20.19.0 || ^22.13.0 || >=24.0.0. Check node --version in a session; if it’s older, or npx isn’t on the path the MCP process sees, add Node to the blueprint:
Option C: MongoDB Atlas plugin
The MongoDB Atlas plugin connects Devin to MongoDB’s hosted MCP server (mcp.mongodb.com) and installs MongoDB’s agent skills. Devin acts with the Atlas roles of the user who signs in, capped by the organization’s AI client access mode.
- An Organization Owner enables AI client access (Organization Settings > App Connections) and sets the access mode to Read, so write tools aren’t registered. The setting applies to every AI client in the organization, not only Devin.
- Create a dedicated Atlas user for Devin with
GROUP_READ_ONLYandGROUP_DATA_ACCESS_READ_ONLY, only in projects it may read.GROUP_DATA_ACCESS_READ_ONLYreads documents in every database in the project, so this is wider than thedevin-sessionsuser. - Install the plugin and complete the OAuth login once in Customize > MCPs, signed in as that user, not as yourself.
- Pin the plugin to a commit once it works.
Traffic comes from MongoDB’s and Devin’s hosted infrastructure, not the session, so Step 1’s IP lists and your network policy don’t apply. Access ends after 7 days of inactivity or 30 days from sign-in, whichever comes first; sign in again. Revoking access doesn’t delete database users or other artifacts the client created, so audit them.
Rebuilds and version pinning
The blueprint installs whateverapt resolves at build time, and Option B’s npx fetches mongodb-mcp-server on every session start. Pin both (mongodb-atlas-cli=<version>, mongodb-mongosh=<version>, mongodb-mcp-server@<version>) once they work, and bump them deliberately. Rotating a secret needs no rebuild; changing an installed tool does.
Step 4: Set permissions
Authentication says who Devin is; database and Atlas roles say what it can touch. MCP flags and knowledge instructions are conveniences on top, not the boundary.
For Explore, suggested indexes need only
GROUP_READ_ONLY (query values come back masked). The slow-query list, sample query values, and log downloads also need GROUP_DATA_ACCESS_READ_ONLY; the GROUP_DATA_ACCESS_READ_WRITE the Atlas CLI help asks for isn’t needed. With GROUP_READ_ONLY alone, the MCP atlas-get-performance-advisor tool reports “No slow query logs found” rather than the 401, so an empty result may be a role problem.
Step 5: Verify
Start a new session and ask Devin to run: Connectivity. Which user, which roles, and (if configured) whether the Atlas CLI authenticates:not authorized on <prod-db> to execute command on dedicated clusters, user is not allowed to do action [insert] on [<prod-db>.devin_probe] on M0/Flex); the second should succeed:
connectionStatus match the profile you granted; an open connection alone proves little. For the MCP server, ask Devin to list databases through the MCP tools (it uses the preconfigured connection), then to insert a document: with --readOnly there is no insert-many tool, and an aggregation with $out is refused.
Troubleshooting
Limitations
Stored credentials are required. Devin’s short-lived OIDC token can’t be used with MongoDB today: the Administration API accepts only service-account secrets or API keys. Atlas Workload Identity Federation covers the data plane on dedicated clusters, but needs a driver-level token callback and hasn’t been tested with Devin’s issuer. If you want to try it, tell your account team. Self-hosted MongoDB. The data-plane steps (database user,MONGODB_URI, mongosh, MCP server) apply unchanged. There is no Atlas service account or IP access list; network access goes through your VPN or your own allowlist.

