How to Configure OpenHands MongoDB Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands mongodb approval by pairing agent confirmation prompts with strict database roles. This dual setup stops automated coding agents from changing production collections without a human check. Many teams start by giving their AI agent a shared admin database user. That broad role lets the agent run any command as soon as it logs in. One bad prompt can then wipe a collection or leak private records. How openhands mongodb approval works with native roles A safe setup starts ins

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 openhands mongodb approval by pairing agent confirmation prompts with strict database roles. This dual setup stops automated coding agents from changing production collections without a human check. Many teams start by giving their AI agent a shared admin database user. That broad role lets the agent run any command as soon as it logs in. One bad prompt can then wipe a collection or leak private records.

How openhands mongodb approval works with native roles

A safe setup starts inside the database itself. MongoDB controls user permissions through role-based rules. Each role grants specific actions on defined resources down to the collection level. You should create a dedicated database user just for your automated agent.

For tasks that only inspect data, assign the built-in read role. The read role allows find, listCollections, listIndexes, dbStats, collStats, and changeStream actions. It blocks insert, update, remove, and dropCollection commands on non-system collections. If the agent must change data, teams assign the readWrite role instead. That role adds insert, update, remove, createCollection, createIndex, dropIndex, and dropCollection actions.

On the client side, the agent runs inside a local container or workspace. You can set the agent to ask for human confirmation before it runs shell actions. When the agent writes a database script, it pauses and waits for a user click. The human operator reads the proposed command and approves or rejects the action.

What native permissions solve and what they miss

Native database roles and local agent prompts solve basic login security. They ensure an unverified user cannot log in to your cluster. They also stop a read-only user from running write commands. Still, this setup still leaves large operational gaps during live sessions.

First, database roles apply to the whole session, not to single queries. Once a user has the readWrite role, it can drop a collection at any time. The database cannot pause a single dropCollection command to ask a team lead on Slack. Second, local agent prompts only check that a script is about to run. If an agent runs a broad script, the human might miss a hidden delete call.

Approval Chains & Escalation + MongoDB Authentication & Authorization: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Third, collection-level roles do not filter sensitive fields inside documents. When the agent runs a find action, the database returns full documents. Those results often contain emails, phone numbers, card numbers, or national IDs. Without field-level rewriting in flight, those raw values flow straight into the model context.

Why static credentials increase risk for coding agents

Local agent setups usually read database passwords from environment variables or local files. Because the agent can read the workspace, it can also read those static keys. If a prompt injection occurs, the model might print the connection string in its output.

Rotating keys across developer machines takes hours of manual work. Teams also lack a central audit log showing which human approved which specific database query. Database logs only show the shared agent username, not the engineer running the task.

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. It reads the MongoDB wire protocol and checks commands and bulk writes as JSON while passing login through untouched.

Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents that match your rules. Every command and verdict is logged. See the open-source code on GitHub.

Frequently asked questions

Can MongoDB pause a single write query for human approval?

No, MongoDB checks roles when a command runs and either allows or denies it right away. It does not have a built-in queue to hold a single query for human review.

Does the MongoDB read role hide sensitive fields like emails?

No, the built-in read role grants access down to the collection level, not the field level. Any find query returns all fields in the matched documents, including emails and card numbers.

Why is the readWrite role risky for an AI coding agent?

The readWrite role includes dropCollection and remove actions alongside standard insert and update permissions. An agent with this role can delete whole collections if a script contains a bug.

The query runs. The emails stay hidden.