How to Configure Copilot Studio MongoDB Prevent Delete
To set up copilot studio mongodb prevent delete rules, assign restricted database roles. You must remove drop and delete actions from the agent user account. Many teams link AI agents to backend databases using shared admin credentials. This broad setup lets an agent wipe whole collections by mistake. A safer design pairs strict database roles with scoped agent actions. How copilot studio mongodb prevent delete works in native roles MongoDB controls access through role-based rules on each dat
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 copilot studio mongodb prevent delete rules, assign restricted database roles. You must remove drop and delete actions from the agent user account. Many teams link AI agents to backend databases using shared admin credentials. This broad setup lets an agent wipe whole collections by mistake. A safer design pairs strict database roles with scoped agent actions.
How copilot studio mongodb prevent delete works in native roles
MongoDB controls access through role-based rules on each database. A role grants specific actions on target resources down to the collection level. Both self-hosted servers and cloud clusters build roles from the same privilege actions.
The built-in read role grants read access to all non-system collections. It allows safe actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It leaves out insert, update, remove, and dropCollection actions by default. If your agent only needs to look up records, use this read role.
Sometimes an AI agent must add new records or edit existing ones. Teams often pick the built-in readWrite role for these tasks. Still, the readWrite role includes everything in read plus data change actions. Those actions include insert, update, remove, createCollection, createIndex, dropIndex, and dropCollection. Giving an agent the readWrite role means it can still delete records.
To allow writes while blocking deletes, you must build a custom role. Define the role on the target database and pick each action by hand. Include find, insert, and update for the collections the agent uses. Leave out the remove action and the dropCollection action in that role. Finally, bind your agent database user to this new custom role.
Why native roles leave gaps in agent workflows
Native database roles decide who can log in and which actions work. They do a great job of blocking remove commands at the storage layer. Yet static roles cannot inspect the content of a query in flight.
An agent with update rights can still ruin your data without deleting rows. For example, a bad prompt might tell the agent to overwrite a collection. The agent could set every customer email or phone number to a blank value. Because the command is an update, the custom role allows it to run.
MongoDB Authentication & Authorization + Copilot Security Implications: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also apply the same rules to every query from that account. The database sees one shared service account instead of the end user. You cannot require human approval for big updates while letting small reads pass. You also cannot rewrite sensitive fields like card numbers or national IDs in results.
Designing safe actions for AI agents
Beyond database roles, you should restrict how the agent reaches your data. Do not give the agent a raw query tool that accepts any command. Instead, build fixed actions or connectors for each specific task. Each action should take clear inputs and run a preset database query.
Separate your database users by the job they do for the agent. Use one read-only user for lookup actions and another user for insert tasks. This split keeps a flaw in a lookup flow from changing any data. Review your database logs often to spot odd query patterns early. Combine these tight actions with collection-level roles for a solid base.
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 built-in MongoDB read role block all deletes?
Yes, the built-in read role only allows read actions like find and listCollections. It does not include remove or dropCollection actions on non-system collections.
Why is the readWrite role risky for Copilot Studio agents?
The readWrite role bundles insert and update rights with remove and dropCollection rights. An agent using this role can delete documents or drop a whole collection.
Can an agent still damage data without the remove action?
Yes, an agent with update rights can overwrite existing fields with blank values. You still need query checks and narrow action inputs to protect your records.
Related guides
In this post