How to Configure JetBrains AI MongoDB Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a jetbrains ai mongodb prevent delete rule, assign read roles to your database user. You can also build a custom role that omits the remove and dropCollection actions. Many engineering teams connect their IDE to a database using a shared admin account. When an AI assistant runs queries through that broad account, one bad prompt can wipe out production records. Scoping down database permissions is the first step to stopping accidental data loss. How a native jetbrains ai mongodb preve

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 jetbrains ai mongodb prevent delete rule, assign read roles to your database user. You can also build a custom role that omits the remove and dropCollection actions. Many engineering teams connect their IDE to a database using a shared admin account. When an AI assistant runs queries through that broad account, one bad prompt can wipe out production records. Scoping down database permissions is the first step to stopping accidental data loss.

How a native jetbrains ai mongodb prevent delete setup works

MongoDB controls access through role-based rules. Each role grants specific actions on defined resources. A role applies to the database where you define it. You can grant access down to a single collection. Note that MongoDB Atlas and self-hosted setups have different built-in roles. Still, both systems build their roles from the same set of privilege actions.

The simplest way to block deletes is the built-in read role. This role lets a user read all non-system collections and the system.js collection. It allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It does not include insert, update, remove, or dropCollection. When your IDE connects with a read role, the database blocks any delete command from the AI assistant.

Sometimes an engineer needs to add or change data while still blocking deletes. The standard readWrite role is too broad for this task. It includes everything in the read role plus insert, update, and remove. It also allows createCollection, createIndex, dropIndex, and dropCollection. To allow writes without deletes, you must define a custom role in MongoDB. You give this custom role the find, insert, and update actions on your target collections. You leave out the remove and dropCollection actions so the user cannot delete records.

What native roles solve and what they leave open

Native database roles decide who can log in and which actions a user account can run. This stops a read-only account from dropping a collection or deleting rows. It works well when every tool and user has a strict, single-purpose account. Yet daily engineering work rarely fits into a single static role.

Developers often use the same IDE database connection to inspect data, test migrations, and fix bugs. If you lock that database user to a read role, the developer cannot run valid updates. If you give the user a custom role that blocks remove, you still face operational gaps. Native roles apply to the whole user session rather than checking individual statements in flight. They do not ask a human for approval when a risky command appears.

AI Data Exfiltration Prevention + MongoDB Authentication & Authorization: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native roles also do not solve data exposure during AI chats. When an IDE assistant reads a collection to help write a query, it pulls real rows into context. Standard roles return raw emails, phone numbers, card numbers, and national IDs to any user with find access. Maintaining dozens of custom roles across every database and collection also takes constant work for platform teams.

How to manage custom roles across developer tools

If you rely on native roles, start by separating human admin accounts from IDE accounts. Create a dedicated database user just for local tools and AI assistants. Assign the built-in read role by default so the tool can only inspect schemas and run find queries.

When a project requires data changes from the IDE, build a custom role on that specific database. Scope the role to the exact collections the developer works on. Include only find, insert, and update actions, and leave out remove and dropCollection. Review these custom roles often to make sure old permissions do not linger after a project ends.

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

Does the MongoDB readWrite role allow delete commands?

Yes, the built-in readWrite role allows delete commands. It includes the remove and dropCollection actions along with insert, update, createCollection, createIndex, and dropIndex.

How does the MongoDB read role block data deletion?

The read role only grants read actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. Because it omits the remove and dropCollection actions, the database rejects any delete request.

Can I block deletes on just one MongoDB collection?

Yes, MongoDB roles can grant access down to the collection level. You can create a custom role that allows find, insert, and update on one collection while leaving out remove.

The query runs. The emails stay hidden.