How to Configure Windsurf MongoDB Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up windsurf mongodb prevent delete rules, assign a restricted database role to your agent. You must remove drop and delete rights from the user account the agent uses. Teams often give AI coding agents full read and write roles to speed up work. When an agent has broad rights, one bad prompt can wipe out whole collections. Stopping destructive actions at the database level keeps your data safe during coding sessions. How windsurf mongodb prevent delete works with database roles Cogniti

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 windsurf mongodb prevent delete rules, assign a restricted database role to your agent. You must remove drop and delete rights from the user account the agent uses. Teams often give AI coding agents full read and write roles to speed up work. When an agent has broad rights, one bad prompt can wipe out whole collections. Stopping destructive actions at the database level keeps your data safe during coding sessions.

How windsurf mongodb prevent delete works with database roles

Cognition renamed Windsurf to Devin Desktop in June 2026, though it keeps the same IDE features. Its agent can run terminal commands on its own once a user gives permission. The agent runs in a dedicated shell that loads your local profile and variables. It can also reach external databases through Model Context Protocol servers set up on your machine. When the agent talks to a database, it uses the login details from your local setup.

MongoDB controls access through role-based rules that apply to a specific database. A role grants the right to run specific actions on defined resources down to the collection level. Both self-hosted setups and Atlas database users rely on these same core privilege actions. The built-in read role lets a user find records and list collections or indexes. It also allows viewing database stats and collection stats. It does not allow the user to add, change, remove, or drop collections.

On the other hand, the read and write role grants much broader power to the user. It includes the right to insert records, update fields, remove documents, and drop collections. If you want the agent to only inspect schemas and query data, assign the read role. If the agent needs to add test data without deleting rows, build a custom role. Your custom role can grant find, insert, and update actions while leaving out remove and drop actions.

Why native roles leave a gap during live sessions

Static database roles work well when an agent always performs the exact same task. A read-only account blocks every delete command before the database engine can run it. Still, real engineering work often requires a mix of safe writes and risky operations. Developers need to insert test records, update staging documents, and fix broken data states. Giving the agent a static custom role takes time to maintain across many collections.

Also, native database roles only check who logs in at the start of a session. Once a user has a role with write rights, every allowed action runs right away. The database cannot pause a single risky command to ask a human for approval. It also cannot mask sensitive fields like emails, phone numbers, card numbers, or national IDs in query results. If an agent queries a user table, the database returns the raw fields to the terminal.

MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing agent commands in flight

Relying only on local shell variables also creates key management headaches for security teams. Since the agent shell loads the user profile, any stored database password sits on the laptop. If a developer shares a config file, those database logins can leak across the team. Teams have to rotate shared passwords by hand whenever someone leaves or changes roles.

To fix this, engineering teams look for ways to inspect database commands in flight. Checking each statement before it runs lets you block delete actions without rewriting complex database roles. You can allow safe queries to pass while stopping collection drops or bulk deletes right away. Pairing command checks with field masking rewrites matched fields in results before the agent sees them. This approach keeps staging and production data safe while letting developers use AI tools freely.

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

Can the built-in read role stop all delete actions in MongoDB?

Yes, the built-in read role only grants actions like find and list collections. It leaves out remove and drop collection actions so the user cannot delete data.

How does the Windsurf agent reach my MongoDB database?

Windsurf, now called Devin Desktop, runs terminal commands in a shell that loads your profile. It can also use local Model Context Protocol servers to run database queries.

What happens if I give my AI agent the readWrite role?

The readWrite role includes remove and drop collection rights on that database. If the agent runs a bad command, it can delete documents or drop whole collections.

The query runs. The emails stay hidden.