How to Configure Semantic Kernel MongoDB Read Only Access
You set up semantic kernel mongodb read only access by giving your app user a database read role. Then you pass those user keys to the memory store or plugin in your app. Many teams start by reusing a broad read and write role from local tests. If a prompt causes an unexpected tool call, that broad role can change or delete records. Locking down the database user stops write actions before they start. How semantic kernel mongodb read only access works in native roles MongoDB controls what a u
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 semantic kernel mongodb read only access by giving your app user a database read role. Then you pass those user keys to the memory store or plugin in your app. Many teams start by reusing a broad read and write role from local tests. If a prompt causes an unexpected tool call, that broad role can change or delete records. Locking down the database user stops write actions before they start.
How semantic kernel mongodb read only access works in native roles
MongoDB controls what a user can do through role-based rules. A role gives a user the right to run specific actions on set resources. That role applies to the database where you define it. You can also narrow a role down to a single collection. Note that cloud hosted users and self-hosted users have different built-in role lists. Even so, both setups use the same core privilege actions under the hood.
For an AI app that only needs to look up facts, use the built-in read role. The read role lets the app read all non-system collections in that database. It allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It leaves out write actions like insert, update, remove, and dropCollection. By contrast, the readWrite role includes all read actions plus those data change actions. It also allows createCollection, createIndex, and dropIndex, which an AI reader does not need.
In your AI app, plugins and memory stores use the database driver to run queries. When the app logs in with a read role user, the database checks every action. Any attempt to insert, update, or remove a document fails at the database level.
Why native roles alone leave gaps in AI data flows
Native database roles solve a big part of the security puzzle. They decide who can log in and which collections they can read or change. If a plugin tries to drop a collection, the read role blocks it cold. This stops bad prompts or bugs from wrecking your stored data.
Still, a database role is an all-or-nothing check on a collection. Once a user has the read role on a database, it can read every field there. The role cannot tell the difference between safe text and private user fields. If a collection holds emails, phone numbers, card numbers, or national IDs, the query returns them. Those raw fields then flow straight into the model prompt and external logs.
Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static database keys in app settings also create headaches for ops teams. Every replica of your AI app often shares the same database user name and password. When you look at database logs, every query comes from that single shared user. You cannot link a strange find query back to a specific person or task. Also, if a read query scans a huge collection without limits, the role allows it.
Scoping collections and separating vector stores from app data
You can shrink the blast radius by splitting vector data from core business records. Keep embeddings and public text chunks in their own database or collection. Then define a custom role that grants read actions only on that specific collection. Do not use the database-wide read role if the database holds private user tables.
Keep separate database users for the job that writes embeddings and the app that reads them. The background sync job gets the readWrite role so it can insert and update vectors. The live AI app gets only the read role on the vector collection. This split ensures that live user prompts never share a session with a write-capable user.
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
Which MongoDB role should an AI plugin use for read-only queries?
Assign the built-in read role on the target database, or a custom collection-level read role. The read role permits find and collection stats while blocking insert, update, remove, and dropCollection.
Can the MongoDB read role hide sensitive fields like emails or card numbers?
No, the built-in read role grants access to whole documents inside non-system collections. To hide emails, phone numbers, card numbers, or national IDs, you need field redaction or masking.
Why should vector sync jobs and AI query plugins use different database users?
Sync jobs need the readWrite role to insert documents and manage indexes. Query plugins only need the read role, so splitting users blocks live prompts from modifying data.
Related guides
In this post