How to Configure MongoDB Atlas Proxy
To set up a mongodb atlas proxy, place a network node before your cluster. Then route client traffic through that node and set up database roles. Teams often start by routing traffic through a private network and assigning built-in roles. When these roles are too broad, users can read or change entire collections at once. A single mistake during a debug session can wipe out a whole table. Plus, read roles still return raw emails, phone numbers, and card numbers in query results. How a mongodb
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.
To set up a mongodb atlas proxy, place a network node before your cluster. Then route client traffic through that node and set up database roles. Teams often start by routing traffic through a private network and assigning built-in roles. When these roles are too broad, users can read or change entire collections at once. A single mistake during a debug session can wipe out a whole table. Plus, read roles still return raw emails, phone numbers, and card numbers in query results.
How a mongodb atlas proxy works with native roles
A network path gets a user to the cluster door. Once inside, MongoDB uses role-based rules to control what that user can do. A role grants the right to run specific actions on a set of data. The role applies to the database where you define it. It can grant rights down to a single collection.
Note that MongoDB Atlas database users have their own set of built-in roles. These differ from the built-in roles in self-hosted deployments. Still, both sets use the exact same core privilege actions under the hood.
For daily work, teams rely on two primary built-in roles. The read role lets a user read all non-system collections in a database. It also covers the system.js collection. This role permits actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It blocks actions that alter data, like insert, update, remove, or dropCollection.
When an engineer needs to fix records, teams often grant the readWrite role. This role includes every action in the read role plus data change rights. A user with readWrite can run insert, update, remove, and createCollection. They can also run createIndex, dropIndex, and dropCollection on that database.
What native roles solve and what they miss
Native roles and network routing solve the first half of the access problem. They check who can log in and which collections they can touch. If a developer only needs to inspect data, the read role stops accidental writes. It blocks dropCollection and remove actions before they can hurt production tables.
Still, collection-level roles leave a big gap during live sessions. A role decides who logs in, not what individual queries do in flight. First, the read role is all-or-nothing at the collection level. If a user can run find on a customer collection, they get every field. The database returns raw emails, phone numbers, card numbers, and national IDs in the results.
Database Proxy (ProxySQL, PgBouncer) + MongoDB Authentication & Authorization: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Second, the readWrite role bundles routine fixes with high-risk actions. You might grant readWrite so an engineer can update one broken record. That same role also gives them the right to run dropCollection or dropIndex. Native roles cannot pause a dangerous command to ask a peer for approval.
Why static network setups fall short for teams
Many teams put a basic network forwarder in front of their cloud clusters. This gives them a single IP address to allowlist in the cloud console. While this simplifies network rules, a basic forwarder does not read database traffic. It passes bytes back and forth without checking the commands inside.
Teams still have to hand out database keys and manage role assignments by hand. When an incident happens, engineers often share a high-privilege login to save time. Afterward, nobody knows who ran which query on that shared account. Fixing this requires inspecting queries and rewriting sensitive fields in results before they reach the client.
Inspect MongoDB wire traffic in flight
Built-in MongoDB roles govern collection access at setup time. They cannot score command risk per call or mask sensitive document values on the fly. By design, hoop.dev sits inline in the MongoDB protocol next to your server as a sidecar for your MongoDB. On every production command from mongosh, drivers, or AI agents, hoop.dev decides whether to pass, mask, block, or hold it for human review.
First, hoop.dev guardrails block bad deletes, drops, and write pipelines or hold them for approval. Next, hoop.dev data masking rewrites sensitive values in returned documents in memory and logs each decision. Explore the repo on GitHub.
Frequently asked questions
How granular are native MongoDB roles?
MongoDB roles apply to the database where they are defined. They can grant permissions down to the collection level. However, they do not filter out specific fields inside those collections on their own.
What is the difference between the read and readWrite roles?
The read role allows actions like find, listCollections, and changeStream on non-system collections. The readWrite role adds actions that change data, including insert, update, remove, createIndex, dropIndex, and dropCollection.
Do MongoDB Atlas users have the same roles as self-hosted users?
No, MongoDB Atlas database users have a different set of built-in roles than self-hosted users. Still, both sets of roles are built from the exact same underlying privilege actions.
Related guides
In this post