Governance Guarantees You Can Audit When AI Agents Read From Supabase
Scoped identity, modeled datasets, and query records make agent access auditable.

Sponsored by Dreambase, which builds a governed analytics and observability layer for Supabase.
Governed data access for AI agents on Supabase requires an MCP server backed by scoped identity, pre-modeled analytical datasets, and attributable query records. MCP supplies the interface, while the data layer must enforce permissions and metric definitions. The guarantees that survive an audit are those enforced on every request, with enough evidence to reconstruct who accessed what and why.
Why AI agents reading from Supabase face a governance problem that RLS alone cannot solve
Having row-level security policies does not establish that an agent is constrained by them. Supabase’s auto-generated REST API creates an exposure surface that grows with the schema, while RLS applicability depends on table creation and credential choices. Since October 30, 2026, new tables on all projects also require an explicit Postgres GRANT before the Data API can reach them. That adds a gate, but not a complete guarantee.
Tables created outside the dashboard Table Editor have RLS off by default, including those created through raw SQL or the SQL editor. The SQL editor warns about CREATE TABLE statements missing RLS, while raw SQL outside the dashboard provides no visible warning. Without RLS, reachable tables expose every row to callers. Policies elsewhere do not close that opening.
The service_role key, commonly handed to agents and backend services, has BYPASSRLS and skips every RLS policy. Postgres views run with their creator’s permissions by default, so a privileged owner’s view can bypass policies on underlying tables. The query simply travels through a path where the expected control does not apply.
Why model-level guardrails and policy documents do not constitute audit-defensible controls
Better prompts cannot repair a bypassed database policy. Safety filters, system prompts, and fine-tuning operate at the output layer, where prompt injection, model updates, or indirect manipulation can defeat their intended restrictions. They may influence an agent’s behavior, but they do not establish an enforceable boundary around data retrieval. A restriction on what the model should disclose is not a restriction on what its credential can read.
A February 2026 red-team study by researchers from Northeastern University, Harvard, MIT, Stanford, Carnegie Mellon, and other institutions tested agents in a live environment. It found agents routinely exceeding authorization boundaries, taking irreversible actions, and disclosing sensitive data, with no effective kill switch available to operators. The study found that identity verification, authorization boundaries, and ways to hold agents accountable were missing. These are infrastructure properties.
Written policies leave the same gap when they never become query-time decisions. A pilot needs data quickly, someone supplies a working database credential, and its broad privileges become permanent when nobody revisits the setup. The policy may call for narrower access the whole time. The credential still determines what retrieval can reach. For auditable data access, controls must apply during inference, in the path the query actually travels, rather than depend on the agent remembering an instruction.
What scoped agent identity actually means and why shared credentials fail it
Scoped agent identity establishes which agent is requesting data, which user it represents, and which permissions apply to that request. Gravitee’s State of AI Agent Security 2026 report, as cited in Atlan’s guide to agent data access, found that only 21.9% of teams treat agents as independent, identity-bearing entities, and that 45.6% still rely on shared API keys. The shared key’s combined privileges replace the end user’s actual scope.
In Supabase, the consequence is especially direct when the shared credential is service_role. Every request using it bypasses RLS, regardless of who prompted the agent or which records that person should see. A shared account also weakens attribution because the database-facing identity does not distinguish the people behind its requests. A successful login proves too little by itself. It establishes possession of the credential while leaving the requesting user’s entitlement to the returned data unverified.
The prerequisite is a central identity provider using OAuth or SAML so queries inherit end-user identity. Each source also needs a named owner and sensitivity label before it is connected, because access policy is based on those choices. RBAC roles and row and column scope must then be defined at the source before the agent is wired in. The service_role key must never become the agent’s credential. Its dedicated credential needs the minimum required schema surface and no BYPASSRLS privilege.
Why direct agent queries against production Supabase create risks that go beyond access policy
Correct credentials do not make production access operationally safe. The first scaling barrier can be connection exhaustion rather than query performance, because agent traffic multiplies connections differently from human traffic. Supabase’s connection capacity varies substantially across compute tiers, but capacity alone does not resolve the traffic pattern. Access policy can authorize a query that consumes scarce production resources, leaving production’s capacity to withstand the combined workload unaddressed.
Serverless execution adds to this risk because each running edge-function instance has its own connection pool. Under load, concurrent instances can collectively request far more connections than the database supports. This turns an agent workload into a shared-service risk. When the pool is exhausted, human users lose access too. The incident is no longer confined to the agent’s task or the rows its credential permits it to read.
An agent that takes down the connection pool can leave an unattributable, unrecoverable state rather than a sequence that an auditor can reconstruct. Operational survival is therefore part of the evidence requirement. Keeping agent reads away from production is needed for governance as well as performance.
How can AI agents query Supabase data without direct database access?
Pre-modeled, pre-calculated datasets give agents approved data and metric definitions that last, without letting them build answers directly from production tables. The definition becomes an artifact the agent consumes. This resolves a problem that row permissions cannot address, namely what the returned numbers mean. Raw rows contain values, but they do not establish a canonical business calculation.
For example, one engineer writes SUM(revenue), another writes SUM(amount_captured), and an agent creates a third variant. All three can read the same underlying data and return different answers to the same business question. More access control does not reconcile those definitions. A modeled layer does, because the agent and dashboard consume the same approved calculation. The audit then has a definition against which to assess the result.
A governed protocol layer sits between the agent and those datasets, making an access decision for every request. It returns only the assets, rows, and columns the requesting identity may see, together with owner, certification status, and sensitivity classification. MCP standardizes how the agent requests that data. It does not supply governance by itself. For an MCP server serving Supabase data, the decisive criteria are enforced identity scope, canonical definitions, and reconstructable evidence underneath the interface.
The Supabase-specific architecture routes agent queries to a governed analytical copy, with pre-modeled data queryable through DuckDB over governed Parquet datasets. Agents remain off the production instance entirely. This removes the production service_role bypass route and agent-driven production connection exhaustion from the read path. The analytical layer still needs its own enforced permissions.
What an audit trail needs to contain to be reconstructable, not just present
The Decision Evidence Maturity Model paper names the “container fallacy,” the assumption that the presence of an evidence container establishes audit sufficiency. Its reproducible feasibility exercise found completeness as low as 53.6% across synthetic scenarios and public incidents. That result shows how the implementation behaved, without any external validation. The distinction is important when interpreting the figure. Existing logs can still lack the properties needed to answer a specific governance question.
The paper looks at public incidents in which coding agents took destructive actions, including the Replit agent that dropped a production database in July 2025. Each documents a destructive action, but no single record answers under what governance regime it was authorized. Reconstruction requires proof that the action occurred together with the authority and context behind it.
For agent reads, the record must identify what triggered the action, the agent, and the user it represented. It must also identify the queried dataset or metric definition, what the agent received, and what it did with that result. Without the definition, the result lacks semantic context. Without the initiating user or task, the query cannot establish who saw what or why.
The MCP tool server must capture user identity, permissions at request time, current task context, the approved dataset accessed, and an audit correlation identifier linking the action to its originating request. The Kiteworks 2026 Forecast Report identifies the audit trail gap as the strongest predictor of AI governance immaturity, stronger than industry, region, or organization size. Evidence quality is consequently a design requirement for the query path before deployment.
How to sequence the implementation — what to put in place before an agent connects, not after
Inventory every table and view in the Supabase schema, classify sensitivity, and assign a named owner to each source. Those decisions determine which roles and agents may reach the data at all. They also provide a basis for holding people accountable for later permission decisions. Connecting first reverses this dependency, because retrieval immediately inherits the source’s permissions and data quality.
With that inventory established, audit RLS on every table, paying particular attention to SQL editor, migration, and ORM-created tables where RLS is off by default. Enable RLS and attach a policy before provisioning an agent credential. Next, audit views for security definer versus security invoker behavior. Postgres 15 added security_invoker = true so underlying permissions can be checked against the caller. Apply it to any view your applications and any remaining non-agent consumers reach, so views do not undo the table-level work.
Only after those boundaries are defined should a dedicated, scoped agent credential be provisioned. Its access is limited to the governed analytical layer, and service_role is prohibited as its credential. The agent receives no connection string for the production database at all. Its only read path is DuckDB queries over the governed Parquet datasets described here.
Before any agent query runs, define the correlation identifier scheme, identity passthrough mechanism, and retention policy, and build the audit log before production deployment. Source lineage must also be defined before connection, together with identity, ownership, classification, and access policy. The evidence design depends on knowing which identity and approved dataset have already been set up. Governing afterward leaves the first queries outside the intended control regime.
What a governed data layer for Supabase teams looks like when it handles both human and agent consumers
Agents and dashboards read pre-modeled, governed datasets in place of production Postgres tables, which keeps agent traffic out of the production connection pool. A single MCP server exposes that analytical layer with scoped access and per-request attribution. Its value comes from the governed path underneath. The interface gives the agent context without permission to explore the operational database.
The same layer can send pre-calculated metrics to Slack, email, and dashboards for people to use. A weekly review and an agent’s nightly report then use identical definitions, avoiding independently written SQL. That consistency reduces the metric drift that complicates audit reconciliation. Human and agent access need not be identical. Their permissions can differ while the approved meaning of a metric remains the same.
For Supabase teams, this extends the existing Postgres project into analytical capability without ETL, production schema changes, or separate warehouse infrastructure. The operational boundary remains explicit throughout that extension. Normal requests produce evidence because the MCP server records identity and task context as part of serving governed datasets. An auditor can therefore examine the authorization and meaning of a particular answer, rather than infer them from a broad credential and a record that a query occurred.


