AI Agents Database Access Permissions: How to Control What Agents Can Read and Write
Learn how to control AI agent database access permissions: limit reads, validate writes, enforce business rules, and audit every action with Claix Retrieve and Guard.
Claix · Updated November 2026. Related guides: why direct SQL access is dangerous (/blog/why-ai-agent-direct-sql-access-is-dangerous), seven gaps in a read-only Postgres role (/blog/read-only-postgres-role-for-ai-agents), database guardrails for AI agents (/blog/database-guardrails-for-ai-agents), and multi-tenant AI agent database access (/blog/ai-agent-multi-tenant-database-access). Products: Claix Retrieve and Claix Guard.
Giving an AI agent access to a production database is different from giving a human developer access.
A developer usually works with a known task, a review process and an understanding of the system. An AI agent can receive an instruction, choose a tool, generate a query and act in seconds. That speed is useful, but it also makes permissions, validation and auditability essential.
The core question is not simply: “Can the agent connect to the database?” The real question is: “What can this agent read, what can it change, for which user, and how do we prove what happened?”
This guide explains how to design database access permissions for AI agents, why read-only access is only one layer, and how Claix helps teams control both retrieval and writes.
Why database permissions matter for AI agents
AI agents increasingly need live business data. They may answer questions about orders, inventory, customers, reservations, support tickets or internal operations.
Without controlled database access, an agent can face several risks:
- It can retrieve data it should not see.
- It can expose customer or tenant data in the wrong context.
- It can generate expensive or inefficient queries.
- It can propose writes that violate business rules.
- It can modify or delete records unintentionally.
- It can make actions difficult to audit after the fact.
A prompt is not a permission model. Instructions can be misunderstood, overridden or manipulated. A robust system needs technical boundaries that do not depend on the model behaving perfectly.
The four layers of AI agent database access
A secure database access model for AI agents should combine several controls. No single layer is enough on its own.
| Layer | What it controls | Example |
|---|---|---|
| Database role and privileges | What the database user can do | A read-only Postgres role cannot run writes |
| Retrieval scope | Which tables and columns an agent can use | A support agent can access orders, but not payment details |
| Business rules | Which actions are allowed in a specific context | Discounts cannot exceed 20 percent |
| Audit and tracing | What was requested, decided and executed | Every query and write decision is reviewable |
Database privileges are the foundation. They prevent an agent from doing things the database role itself does not allow.
But they do not solve every problem. A read-only role can still retrieve data from tables that should not be exposed to a particular user. And a write-capable role can perform a valid operation that violates a business rule.
That is why teams need a control layer above raw database credentials.
Read-only access is necessary, but not sufficient
Read-only database access is a good default for AI agents that only need to answer questions. It prevents the agent from creating, updating or deleting records through that connection.
However, read-only access does not answer every permission question.
An agent with read-only access may still be able to retrieve:
- Records belonging to another customer or tenant.
- Sensitive columns that are not relevant to its task.
- Large volumes of data that should not enter the model context.
- Internal operational data that a specific user should not see.
For example, a support agent may need to check the status of a customer’s order. It does not need access to every order in the system, every internal note, or every column in the orders table.
The right boundary is not only: “This agent can read the database.” It is: “This agent can retrieve only the data required for this task, for this user, within the limits we define.” See also the gaps in a standard read-only Postgres role (/blog/read-only-postgres-role-for-ai-agents).
What AI agent database permissions should include
A practical permission model for AI agents should answer these questions:
- Which database can the agent access?
- Which tables can it retrieve from?
- Which columns can it read?
- Which records belong to the current user or tenant?
- How much data can a single request return?
- Can the agent execute writes?
- Which write operations are allowed?
- Which columns can be modified?
- Which values and thresholds are permitted?
- What happens when a rule is violated?
- What was requested, allowed, denied and executed?
These questions separate database security from application-level authorization and business policy.
A database can enforce some of these rules. But it cannot easily express rules such as “an agent may update an order status, but never change its price” or “refunds above a threshold should be reviewed by a person.” That is where a dedicated control layer becomes useful.
How Claix controls AI agent database access
Claix Retrieve is a controlled data retrieval layer for AI agents. It connects to a relational database and lets each agent retrieve only the tables and columns you allow, guided by your own rules and returned as validated results or typed answers.
Claix separates the problem into two parts:
- Claix Retrieve controls what an agent can read.
- Claix Guard controls what an agent can change.
Together, they create a boundary between the agent and the database.
Claix Retrieve: controlled reads
With Claix Retrieve, you define a route. A route specifies the tables and columns an agent can access, along with a guide containing your rules and vocabulary.
You then create an agent. The agent has its own endpoint, business prompt and attached routes.
This means a support agent and an internal operations assistant can share the same database while having different access boundaries.
For example:
- A support agent may access order status and customer contact information.
- An operations agent may access inventory and shift data.
- Neither agent needs access to the full database schema.
Claix connects using a read-only role. Agents only reach the tables and columns included in their assigned routes. Everything outside that perimeter is not available to them.
Typed answers instead of raw text
Claix Retrieve can return typed values such as booleans, numbers, lists and JSON objects. This matters because an agent workflow often needs to make a decision based on a specific value.
Instead of parsing free text, your workflow can receive a clear answer such as:
- A boolean for “is this item in stock?”
- A number for “how many orders are pending?”
- A list of IDs for “which customers need follow-up?”
- A JSON object for structured operational data.
This reduces ambiguity and makes it easier to build reliable agent workflows.
Query validation and tracing
Claix validates queries before they run and traces every request. You can review what was asked, which route answered and what came back.
This creates an audit trail that is useful when you need to understand an unexpected result, investigate an incident or improve an agent’s behavior.
Claix Guard: controlled writes
Claix Guard is a rules checker for database changes proposed by AI agents. Before an agent runs an INSERT, UPDATE or DELETE, Guard checks the proposed statement against rules you approved.
The result is simple:
- Allow: your code can execute the statement.
- Deny: your code should not execute it, and the agent receives the reason.
There is no third verdict. If a change should be reviewed by a person, Guard denies it and your own workflow (Slack, email, n8n) routes that denial for review.
Claix Guard does not execute the statement. Your own code does, using its own database credentials.
This separation is important. The agent proposes an action. Guard evaluates it. Your executor decides whether to run it.
What Guard can enforce
Claix Guard lets you define rules in plain English, review the proposed exact rules and approve them before enforcement.
Examples include:
- Agents can create and update orders, but never delete them.
- Agents can update an order status, but never its price.
- Discounts cannot exceed a defined percentage.
- Refunds above a threshold are denied so your workflow can send them to a person.
- An update or delete must target a specific record.
- Certain status transitions are not allowed.
- The number of refunds per hour is limited.
These are business rules. They go beyond what a database role or schema constraint can normally express.
Why deterministic checks matter
Claix Guard uses exact rules rather than asking another AI model whether a statement looks safe. The same statement with the same parameters receives the same decision.
That makes the check predictable, explainable and testable.
A model can help propose rules when you create them. But the check itself is deterministic, so it does not depend on a model’s judgment at execution time.
A practical architecture for AI agent database access
A strong setup combines database-level controls with an application-level control layer.
| Control | Purpose |
|---|---|
| Dedicated read-only role | Prevents writes through the retrieval connection |
| Narrow write role | Limits which tables and columns an executor can modify |
| Claix Retrieve routes | Defines which tables and columns each agent can read |
| Claix Guard rules | Defines which writes are allowed and why |
| Row-level security | Helps isolate records by user or tenant |
| Constraints and validation | Enforces data integrity at the database level |
| Audit logs and traces | Records requests, decisions and outcomes |
Claix does not replace database permissions. It adds a control layer on top of them.
For reads, Claix Retrieve defines the retrieval boundary. For writes, Claix Guard checks proposed changes before your code executes them.
Common mistakes when giving AI agents database access
Giving the agent direct database credentials
If an agent holds write credentials, it can bypass application-level controls. Keep credentials in a trusted executor and make that executor call Guard before every write. Execute only when Guard returns allow. See why direct SQL access is dangerous (/blog/why-ai-agent-direct-sql-access-is-dangerous).
Treating a prompt as a permission
A prompt can guide behavior, but it is not an enforcement mechanism. Technical controls should decide what an agent can do.
Using one shared agent for every task
Different tasks need different access. A support agent, an operations agent and an internal analytics assistant should not automatically have the same data access.
Ignoring tenant boundaries
If multiple customers share the same database, row-level isolation and tenant-aware retrieval rules are essential. A read-only role alone does not guarantee that one tenant cannot access another tenant’s data. See AI agent multi-tenant database access (/blog/ai-agent-multi-tenant-database-access).
Skipping audit trails
When something goes wrong, you need to know what the agent requested, which rule applied and what the system did. Logs and traces are not optional for production systems.
How to get started with Claix
Claix Retrieve supports Postgres, including Postgres-compatible setups such as Supabase. You connect a database with a read-only role, review the generated Data Map, define routes and agents, then call an endpoint from your existing stack.
Claix is available through REST, MCP and A2A. That means you can use it with agent frameworks, MCP-compatible clients, automation tools and systems that can send HTTP requests.
For teams that need to control writes, Claix Guard supports PostgreSQL, MySQL and MariaDB.
Frequently asked questions
- What are AI agents database access permissions?
- They are the technical and policy controls that decide what an AI agent can read, what it can change, for which user or tenant, and how those actions are audited. A prompt is not a permission model.
- Is a read-only database role enough for AI agents?
- No. A read-only role is a necessary foundation, but it does not limit which tables, columns or tenant rows an agent can retrieve, and it does not express business rules for writes.
- What is the difference between Claix Retrieve and Claix Guard?
- Claix Retrieve controls what an agent can read from selected tables and columns. Claix Guard checks proposed INSERT, UPDATE and DELETE statements against approved rules and returns allow or deny. Guard does not execute SQL.
- Does Claix Guard execute SQL?
- No. Claix Guard only checks the proposed statement and parameters. Your own executor holds the write credentials and runs the statement only when Guard returns allow.
- Which databases does Claix support?
- Claix Retrieve connects with a read-only role to Postgres, including Postgres-compatible setups such as Supabase. Claix Guard supports PostgreSQL, MySQL and MariaDB.
- Can Claix Guard return a “needs approval” verdict?
- No. Guard returns allow or deny only. If a high-risk change should be reviewed by a person, Guard denies it and your own workflow routes that denial to Slack, email, n8n or another review process.
- How should I structure permissions for multiple agents?
- Give each agent its own retrieval boundary. A support agent, an operations agent and an analytics assistant should not automatically share the same tables and columns, even when they use the same database.
Conclusion
AI agent database access permissions require more than a database username and password.
You need to control what agents can read, which data they can access, which writes they can propose, which business rules apply and what happened after execution.
Claix provides that control layer:
- Retrieve limits and structures what agents can read.
- Guard checks proposed writes before they run.
- Traces make requests and decisions reviewable.
If you are building AI agents that connect to production data, design permissions as a system, not as an afterthought. Start with Claix Retrieve and Claix Guard.
You might also like…
Guide · Guard
Database Guardrails for AI Agents: How to Prevent Unsafe Writes Before They Run
Guide · Security
AI Agent Multi-Tenant Database Access: How to Isolate Customer Data
Guide · Security
Why Giving an AI Agent Direct SQL Access Is Dangerous (and What to Do Instead)
Security · Postgres
Read-only Postgres role for AI agents: step-by-step setup