Auditing Every Metric Request an AI Agent Makes Against Your Supabase Backend
A governed MCP layer logs who asked, for what, and why.

Governed data access for AI agents on Supabase should run through an MCP server backed by a governed semantic layer. That layer must check who the agent is and whose authority it uses, find the named metric definition, and log the request before running the query.
Why agents querying Supabase directly is an audit problem, not just a performance one
A human analyst writes one query while an agent can issue thousands. That asymmetry breaks assumptions built around human-paced access, where someone can notice a mistake before repeating it across many requests. An unattended agent can trigger a gap in access policy repeatedly before anyone reviews its output. When agents run faster, it is harder to rein in excessive access and expensive queries once they start.
Atlan’s governed access guide identifies a common starting point for this problem. A pilot receives a working database credential to unblock development, but its access is never scoped afterward. The agent then inherits everything that credential can reach, permanently. A successful connection is not evidence of appropriate access. In a Supabase backend, the resulting concern is not simply whether Postgres can serve the traffic, but whether each request has an identifiable caller and a justified scope.
Database policy can also become a performance pressure point. Per-row auth.uid() re-evaluation in row-level security, or RLS, can turn a query expected to run in milliseconds into one that reaches timeout-level execution times under agent-frequency load. Agents can also put stress on production through connection surges. Neither symptom answers the underlying authorization question. Query logs added afterward may show the load, but they cannot tell who the agent was or whose authority allowed an earlier request.
Governance added after an agent begins running unattended leaves the original credential’s reach in place until that access is changed. Performance tuning can reduce the cost of requests. It cannot decide whether those requests should have been allowed.
What a complete audit trail for agent-originated metric requests must capture
A complete audit record identifies who asked, on whose authority, for which metric, against which definition, and when. It also records the shape of what was returned. These fields describe different parts of the same event. The agent identity identifies the caller, while the user or workflow identity explains the authority under which it acted. A shared service account does not preserve that distinction.
The minimum record therefore includes an independent agent identity, the requested metric or dataset name, the on-behalf-of user or workflow, a timestamp, and the result shape. Atlan distinguishes a direct credential’s generic query log from a governed access record that ties each decision to the requesting identity. Identity is often the weakest link. The guide notes that only a small minority of teams treat agents as independent, identity-bearing entities.
The governing metric definition must also be recorded, including its version. A metric name alone is not enough. If the calculation behind that name changes, an auditor needs to know which definition produced the result at the time of the request. Otherwise, a log can identify the requested metric without establishing what the returned number meant.
For regulated or audit-heavy applications, these records belong in an append-only audit table rather than a query log that can be rotated or overwritten. An audit trail that disappears cannot support a later review, even if it originally contained the right fields.
How do AI agents access Supabase metrics through MCP without direct database access?
An MCP server provides the interception point between an agent and the governed data layer. At that boundary, agent identity, access policy, and metric definition can converge on one request before a query runs. The agent requests a metric through the interface rather than receiving production database credentials. This makes enforcement possible at the request level. However, the protocol alone does not provide it.
MCP replaces separate application-to-source connectors with a common protocol that agents and sources can speak. CData’s 2026 integration architecture guide describes this governed MCP pattern as a way to avoid custom integration for every agent-source pairing. That distinction becomes important as teams add agents or change LLM vendors. A common interface keeps access decisions from depending on which connector happens to serve a request. It also gives audits the same place to start each time.
MCP’s three relevant primitives expose different kinds of auditable activity. Tools carry out actions such as running a query, so each tool call is a separate event. Resources provide context, including governed datasets and schemas, so a resource request can identify a named artifact. Prompts supply reusable templates for repeatable analytical workflows. A named prompt reduces ambiguity compared with a freeform query, although it does not replace authorization.
The July 28, 2026 MCP specification revision places method and tool names in the Mcp-Method and Mcp-Name HTTP headers. Gateways, rate limiters, and WAFs can therefore route and authorize requests without parsing JSON bodies. The revision also makes the protocol stateless, with protocol version, client identity, and capabilities supplied through a _meta parameter on each request. Each request is independently auditable without reconstructing session state. Those properties support interception, but they do not establish which data a caller may see.
The selection criterion for an MCP server is therefore its governed backing layer. That layer must decide access based on identity, keep metric access read-only, and keep records tied to governed definitions. MCP is necessary to this architecture but insufficient for its security. A server that merely exposes everything an underlying credential can reach remains a conduit.
How a governed semantic layer makes agent metric requests auditable by construction
If an agent chooses the wrong “revenue” column, the log may show exactly what it requested without establishing that the calculation was authoritative. More detailed records of arbitrary queries do not remove the ambiguity in the data those queries use.
One engineer writes SUM(revenue) while another writes SUM(amount_captured), and Q2 revenue then depends on who asks. An agent can repeat either calculation with total confidence. Starburst’s agentic AI infrastructure analysis identifies unresolved semantic ambiguity as a core failure mode because small errors in meaning become incorrect answers. The infrastructure must resolve that ambiguity before the agent reasons over the result.
A unified semantic layer gives each metric one definition with a name. When an agent asks for that metric through MCP, the audit record can show exactly which governed definition was used as well as the query text. Pre-modeling is therefore not just an optimization. It establishes what the answer claims to measure and gives the audit record a stable reference. The definition version connects that reference to the calculation in force at the time.
Pre-calculated, named datasets give agents a defined set of data they can access. Governed Parquet files queryable through DuckDB let agents discover available datasets and request them by name through Resources and Tools. Each request then maps to a versioned, defined artifact rather than an improvised interpretation of production tables. Access remains explicitly read-only. The governed layer must prevent writes, updates, and deletes through the metric interface.
Permissions must be just as precise as definitions. Atlan recommends basing fine-grained access on whose behalf the agent acts, instead of using a generic service account to set what it can reach. That makes row-level access an enforced entitlement. The same metric definitions can serve human dashboards and agent requests. Updating a definition once then propagates to both kinds of consumer without maintaining a separate agent version.
What the Postgres observability layer must track to surface agent-driven anomalies
Postgres observability supplies the database-side evidence that the access boundary is working. The semantic audit record explains a governed request, while database telemetry shows when something unexpected happens in production or puts pressure on resources. An access log alone cannot show whether agent traffic is bypassing the intended path and reaching the production connection pool.
At the query level, pg_stat_statements records mean execution time, total execution time, and call count. Those signals show when the number of production queries is unexpected or queries cost much more to run than usual. The RLS volatility cliff is a specific pattern to watch. A query expected to finish in milliseconds appearing at timeout-level execution times is the fingerprint of per-row auth.uid() re-evaluation under agent-frequency load.
At the connection level, active connections must be tracked relative to max_connections. Supabase’s infrastructure guidance says that usage past 80% of max_connections is a warning threshold at which the system needs to scale. Alerts for agents should also cover Realtime channel count thresholds, which require partition at scale, and Edge Function cold start latency, which shows when there is too little worker capacity for agent-driven load. These signals extend the feedback loop beyond individual SQL statements.
Administrative actions, permission changes, and sensitive workflow events also belong in an append-only audit table that cannot be rotated. The request trail explains who obtained a result. The surrounding records show what governance was in place when that access took place.
Putting it together: what audit-first agent metric access looks like end to end

The end-to-end path begins when an agent requests a named metric through MCP. Method and tool headers make the call loggable at the gateway without parsing its JSON body. The governed layer then checks both the agent identity and the on-behalf-of user against access policy. No anonymous service account substitutes for those identities. Authorization takes place before the metric query runs.
Once authorized, the request resolves against a named, pre-calculated metric definition, such as a governed Parquet dataset or a pre-modeled view. It does not become an ad-hoc query against production tables. The append-only audit record ties the request to the agent ID, metric name, governing definition version, timestamp, and result shape. Database telemetry closes the loop. pg_stat_statements and connection metrics provide evidence that direct agent traffic has not reached the production connection pool.
This arrangement is achievable because it shares definitions. Small teams do not need one revenue calculation for dashboards and another for agents. Both consumers use the same governed interface and metric definitions. Starburst says the broader need is for an agentic control plane that gives agents shared business meaning, including table definitions, ownership, and freshness. In a Supabase architecture, the governed access layer gives that requirement a concrete place to operate.
The system does not promise to stop every agent error. Its value is that an incorrect number remains traceable to a specific request instead of becoming an unexplained output from a shared credential. Reviewers can establish which agent asked, whose authority it used, which definition governed the calculation, and when the request occurred.


