How to Configure JetBrains AI MongoDB Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up jetbrains ai mongodb read only access by assigning the native read role to a database user. Then, you connect your editor to the database using those restricted login details. Many teams start by sharing a single admin account across their coding tools. That broad setup lets an assistant run queries that can change or drop collections by mistake. How jetbrains ai mongodb read only access works MongoDB controls who can do what through role-based rules. Each role gives a user permiss

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.

You set up jetbrains ai mongodb read only access by assigning the native read role to a database user. Then, you connect your editor to the database using those restricted login details. Many teams start by sharing a single admin account across their coding tools. That broad setup lets an assistant run queries that can change or drop collections by mistake.

How jetbrains ai mongodb read only access works

MongoDB controls who can do what through role-based rules. Each role gives a user permission to run specific actions on set resources. A role applies to the database where you define it. You can also narrow these permissions down to the collection level. Self-hosted setups and MongoDB Atlas have different built-in roles. Still, both options use the same base list of privilege actions.

To keep your coding assistant from changing data, assign the built-in read role. This role lets the user read all non-system collections in that database. It also allows reading the system.js collection. Under the hood, it grants actions like find, listCollections, and listIndexes. It also permits dbStats, collStats, and changeStream actions. Most importantly, it leaves out insert, update, remove, and dropCollection actions.

By contrast, the readWrite role includes everything in the read role plus write permissions. It adds actions like insert, update, remove, and createCollection. It also allows createIndex, dropIndex, and dropCollection. Removing these write actions at the database level stops the AI tool from altering records.

What native database roles solve and what they miss

Native roles are the right first step for safe database exploration. They block destructive commands before those commands ever touch your storage engine. When the coding assistant suggests and runs a query, the database checks the role first. If a query tries to delete a collection or update a document, the database blocks it.

Still, a database role only decides who can log in and which actions can run. It does not inspect what individual queries return in flight. A user with the read role can still pull every document from a sensitive collection. If those documents hold customer emails, phone numbers, card numbers, or national IDs, the query returns them in plain text.

Auditor Read-Only Access + AI Model Access Control: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Those raw results go straight into the editor context and out to the model provider. Native roles also require you to hand out static database keys to every developer machine. Managing and rotating those local keys across a whole team creates extra manual work. Plus, standard role checks do not give you a unified audit log linking prompts to exact database queries.

How to scope collection permissions for safer AI queries

You can make native setups safer by avoiding broad database-wide roles when possible. Instead of granting read access to a whole database, build a custom role. Grant the find and listCollections actions only on the specific collections the developer needs. Leave out collections that store billing records, user keys, or private logs.

Even with collection-level rules, production collections often mix safe fields with private data. A single user document might hold both app settings and a personal phone number. Because MongoDB roles work down to the collection level, they do not hide individual fields inside a returned document. To rewrite sensitive fields like emails or card numbers in query results, you need controls that inspect traffic in flight.

Add command guardrails and field masking beside MongoDB

Collection roles and IP rules control who connects to MongoDB. Yet an active client or agent session can still run a pipeline that writes data or reads raw personal fields. In practice, hoop.dev runs beside your database as a sidecar for your MongoDB. It checks every wire command and result document without changing your drivers or credentials.

Using hoop.dev MongoDB controls, guardrails refuse banned commands before they run. Data masking rewrites matched fields in returned documents in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for GDPR, HIPAA, and PCI DSS programs. View the project on GitHub.

Frequently asked questions

Which MongoDB role should I give to JetBrains AI?

Assign the built-in read role on the specific database you want to query. For tighter control, create a custom role that grants find permissions on single collections.

Does the MongoDB read role block all data changes?

Yes, the built-in read role leaves out insert, update, remove, and dropCollection actions. The database will reject any command that tries to write or delete data.

Can native MongoDB roles hide sensitive fields from AI tools?

No, native roles only control access down to the collection level. If a user can read a collection, queries will return all fields, including emails or card numbers.

The query runs. The emails stay hidden.