How to Configure Goose MongoDB Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up goose mongodb permissions, create a dedicated database user with a scoped role. Then pass that user account to the local Goose extension on your machine. Teams often start by reusing a shared admin login for quick testing. Broad roles let an autonomous agent change data, drop collections, or read every table. Scoping the database user down to specific collections reduces the risk of bad writes. How native goose mongodb permissions work Goose runs on a developer laptop and talks to e

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 goose mongodb permissions, create a dedicated database user with a scoped role. Then pass that user account to the local Goose extension on your machine. Teams often start by reusing a shared admin login for quick testing. Broad roles let an autonomous agent change data, drop collections, or read every table. Scoping the database user down to specific collections reduces the risk of bad writes.

How native goose mongodb permissions work

Goose runs on a developer laptop and talks to external tools through extensions. When Goose queries a MongoDB cluster, it uses the database login you provide. The agent inherits every right attached to that database user account. MongoDB manages these rights through role-based authorization on the server side. Each role grants privileges to run specific actions on defined resources. A role applies to the database where an admin defines it. You can scope these rules down to the collection level of detail. Note that MongoDB Atlas users have different built-in roles than self-hosted deployment users. Still, both setups build their roles from the same set of privilege actions.

For most AI exploration tasks, teams start with the built-in read role. The read role grants read access to all non-system collections in its database. It allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It blocks write actions such as insert, update, remove, and dropCollection. If Goose needs to write data, teams assign the readWrite role instead. The readWrite role includes all read rights plus the power to change data. It adds insert, update, remove, createCollection, createIndex, dropIndex, and dropCollection actions. Giving an agent readWrite rights means a bad prompt could delete a collection. If the agent only needs one collection, build a custom role for it.

What native roles solve and what they leave open

Native database roles decide which user can log in and touch a collection. They stop an agent with read rights from dropping tables or changing records. This setup works well as a first line of defense for static apps. Still, AI agents generate new queries on the fly during each session. Once the user logs in, the database allows every valid action in that role.

Collection-level roles do not filter individual fields inside a returned document. If a collection holds customer records, a find query returns the full document. Sensitive fields like emails, phone numbers, card numbers, and national IDs flow back to Goose. The model context then holds those raw values during the local session. Also, storing static database passwords on developer laptops creates key rotation work. If an agent needs to run one update, granting full readWrite rights is risky. Teams cannot pause a single risky delete action while letting safe updates run. Native roles check who logs in, not what each statement does in flight.

MongoDB Authentication & Authorization + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping agent queries at the statement level

Safe AI database workflows need controls that inspect requests after the login step. Instead of giving Goose broad readWrite roles, keep the base account restricted. Review single write actions one by one when the agent requests them. Rewrite matched fields like emails or card numbers in results before they return. Keep database secrets off local laptops so developers do not manage raw keys. This approach lets Goose inspect schemas and query data with much less risk.

Inspect MongoDB wire traffic in flight

Built-in MongoDB roles govern collection access at setup time. They cannot score command risk per call or mask sensitive document values on the fly. By design, hoop.dev is an open-source proxy that sits next to MongoDB as a sidecar for your MongoDB. It reads every command from mongosh, drivers, or agent tools.

First, hoop.dev guardrails block bad deletes, drops, and write pipelines. Next, hoop.dev data masking rewrites sensitive values in returned documents based on your rules and logs each decision. Explore the repo on GitHub.

Frequently asked questions

Which built-in role should I give Goose for safe exploration?

Assign the built-in read role on the specific database Goose needs to check. This role allows find and listCollections actions while blocking insert, update, and dropCollection.

Can native goose mongodb permissions hide specific document fields?

No, standard MongoDB roles only scope access down to the collection level. Any allowed find query returns all fields in the matched documents to the client.

Why is the readWrite role risky for an AI agent?

The readWrite role includes destructive actions like remove, dropIndex, and dropCollection. A flawed prompt could cause the agent to delete data across that database.

The query runs. The emails stay hidden.