MongoDB Atlas Permissions
MongoDB Atlas permissions control what users and apps can do inside your database clusters. They use role-based rules to grant actions on databases and individual collections. Database admins use these rules to keep production data safe from mistakes. Engineers and AI agents need the right role before they run any query. Good access control stops bad writes and keeps your data clean. How mongodb atlas permissions work in practice MongoDB uses role-based rules to manage all database access. A
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
MongoDB Atlas permissions control what users and apps can do inside your database clusters. They use role-based rules to grant actions on databases and individual collections.
Database admins use these rules to keep production data safe from mistakes. Engineers and AI agents need the right role before they run any query. Good access control stops bad writes and keeps your data clean.
How mongodb atlas permissions work in practice
MongoDB uses role-based rules to manage all database access. A role pairs a set of allowed actions with a specific resource. Each role applies to the database where an admin defines it. You can limit access down to a single collection when needed.
Cloud database users have different built-in roles than self-hosted users. Still, both setups use the same basic privilege actions under the hood. When an engineer or AI agent logs in, the system checks their assigned roles. If the role allows the action on that collection, the query runs.
For daily work, teams rely on two main built-in roles. The read role lets a user read all non-system collections in a database. It also grants read access to the system JavaScript collection. This role includes actions to find documents, list collections, and list indexes. Users can also check database stats, view collection stats, and watch change streams. The read role never allows insert, update, remove, or drop collection actions.
When an app or engineer must change data, they need the read and write role. This role includes every action from the read role plus data change rights. Users can insert, update, and remove documents across the database. They can also create collections, build indexes, drop indexes, and drop whole collections.
Security and operational tradeoffs of static roles
Built-in roles give teams a strong start for database security. They stop a read-only user or AI agent from deleting a table. Yet collection-level roles have big limits during an active database session. A role decides if a user can read a collection at all. It does not filter what sits inside the documents they read.
MongoDB Authentication & Authorization + AI Agent Permissions: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
If an engineer has read rights on a customer collection, they pull whole documents. Those results often hold sensitive fields like emails, phone numbers, or card numbers. Static roles cannot hide a national ID inside a document during a query. To restrict fields with native roles alone, admins must split collections apart. That creates extra work and breaks how apps read data.
Shared database keys also cause problems for growing engineering teams. When five people share one read-and-write role, your audit logs lose clarity. You see the role name in the log, not the person who ran the drop command. Rotating keys for every short debugging task takes too much time. Teams end up leaving broad roles active way longer than they should.
Why teams add query-level controls to database roles
Modern teams pair database roles with an extra layer of session control. Instead of handing out static keys, admins route traffic through a central check point. Engineers log in with their normal work identity to start a session. The system maps their identity to the right database role on the fly.
This approach also solves the data exposure problem inside large collections. Data masking rewrites matched fields in query results before they reach the user. Emails, phone numbers, and card numbers get masked right in the return stream. Engineers can debug real production issues while sensitive values stay hidden. You keep simple roles in the database while gaining fine control over every query.
Check MongoDB commands and documents on the wire
MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.
Frequently asked questions
What is the lowest level of access for a MongoDB role?
A role applies to a database and can grant access down to a single collection. Native roles do not restrict specific fields inside a collection on their own.
What is the difference between the read and readWrite roles?
The read role lets users find data, list collections or indexes, and view stats. The readWrite role adds actions to insert, update, remove data, and manage collections or indexes.
Do MongoDB Atlas users have the same roles as self-hosted users?
No, cloud database users have different built-in roles than self-hosted database users. Still, both sets of roles are built from the exact same privilege actions.
Related guides
In this post