Scoping AI Agent Data Access to Approved Metric Sets Instead of Raw Supabase Queries
Govern AI agent access through pre-approved metrics instead of raw database credentials.

With governed data access for AI agents on Supabase via MCP, agents get approved, pre-calculated metric sets through an MCP server and have no production database credentials. The governed dataset is the architectural boundary because it removes the agent’s ability to formulate raw production queries. That boundary must be defined before the connection is wired.
Why the default agent-to-database connection is an authorization failure, not a configuration detail
A developer unblocks a pilot in five minutes by giving an agent a working database credential. The connection succeeds, the agent returns an answer, and access scope becomes a cleanup task. Under that sequence, whatever access was provisioned under deadline pressure becomes the agent’s standing authority. The pilot has proved connectivity alone. No separate decision has established which actions the agent may take, for which task, or on whose behalf.
Uchi Uchibeke’s Before the Tool Call: Deterministic Pre-Action Authorization for Autonomous AI Agents distinguishes this gap from alignment and sandboxing. The paper describes the absence of a standard mechanism for enforcing policy before a tool call executes. It also notes that 27.2% of engineering teams have abandoned framework-provided authorization for custom, hardcoded logic. This is a missing authorization layer between the agent’s proposed action and the system that executes it.
That omission becomes dangerous at machine speed. An agent can issue thousands of queries in the time a person writes one, while a shared static credential supplies no identity context. The query log shows what happened but cannot trace it to a principal. Halil Burak Noyan’s Dynamic Capability Scoping for Enterprise AI Agents identifies the lethal trifecta of private data access, exposure to untrusted content, and an external send path. A broadly credentialed production agent can have all three simultaneously.
What over-permissioned agents actually do to a production Supabase database
For Supabase teams, direct agent queries put analytical demand on the same Postgres instance that serves transactional work. Connection-pool exhaustion is one consequence. Analytical workloads also compete with writes and cause lock contention, so getting connected says little about how much performance will suffer later. The damage becomes visible when latency spikes. Scoping what a credential may read does not, by itself, separate those workloads.
The exposure extends beyond database performance. An agent with a broad credential can read rows it should never see where row-level security policies have gaps. The pre-action authorization paper documents a red-teaming study in which six autonomous agents with persistent memory and shell access leaked SSNs over 14 days when a single verb in a prompt was reframed. In that study, which did not test Supabase, the relevant mechanism was credential use without a technical exploit.
The same credential can support both an intended task and an unintended one because agent behavior adapts to input. Read-only access also leaves analytical traffic on the production path. These problems require removing the agent’s raw production connection entirely.
Why scoping to pre-approved metric sets eliminates the risk class, not just individual risks
A credential that does not exist in an agent’s context cannot be misused, regardless of how the agent reasons or is prompted. The capability-scoping paper makes this the basis for prevention before detection. The architecture shifts the question from whether a monitor can spot every improper query to whether the agent has the capability to issue one against production at all.
Detection has a structural limit when an agent can reason about monitoring, because an attacker needs only one phrasing that the monitor misses. The pre-action authorization paper reports a 0% attacker success rate when it used a restrictive policy in its adversarial testbed. The result from withholding the capability is specific to the testbed.
Approved metric sets apply that distinction at the data boundary. The agent receives only defined columns with known semantics. If its only available tool returns a governed Parquet file with five columns, prompt injection can still distort its reasoning, but its data access remains bounded by that file. This removes the raw-production-query risk class as a whole. Atlan’s governed access pattern draws the corresponding distinction for MCP, which can deliver either everything a credential reaches or only what policy permits. The protocol alone does not choose between them.
How do AI agents query Supabase data through MCP without direct database access?
An MCP server can give agents governed, pre-modeled datasets while keeping them away from the production instance entirely. In this pattern, approved metrics are pre-calculated and served as Parquet files queryable through DuckDB. Analytical queries run outside the transactional query path. DuckDB’s columnar execution suits analytical workloads, while the files are exposed read-only to the agent. No live Postgres connection is available for the agent to use.
MCP provides more than a retrieval action. Its three primitives are Tools, which expose actions such as running a query, Resources, which expose governed datasets and schemas, and Prompts, which provide reusable analytical templates. Together, they can supply the data, context, and workflow needed to answer a question without directing the agent into raw tables. The choice of server therefore starts with how it governs the data it exposes, scopes access to the task, and keeps queries off production. Support for MCP is necessary for this pattern, but it does not establish row-level authorization.
Supabase’s acquisition of Hydra, co-developers of pg_duckdb, and the resulting Supabase Warehouse capability point toward separate analytical execution becoming first-class in the ecosystem. The architectural principle is the same, though the MCP boundary still needs its own governance. The U.S. National Security Agency noted in a May 2026 Cybersecurity Information Sheet that MCP’s rapid proliferation had outpaced development of its security model. A production connection wrapped in MCP reproduces the original authorization problem. The governed dataset, rather than the protocol wrapper, supplies the boundary.
Why connectivity alone does not produce consistent metrics — the semantic layer problem
The governed dataset can resolve both access scope and metric consistency, but only if definitions are settled before modeling begins. Secure retrieval does not settle competing definitions. An agent that queries faster cannot resolve a disagreement between two engineers about what “revenue” means. If one query sums one field and another sums a different field, the agent can return different Q2 revenue figures depending on which table it reaches first.
This is the familiar startup metrics problem applied to a faster consumer. Without an owned definition, each consumer invents one. A data dictionary must establish a single agreed meaning for each metric, so “Churn” and “Active User” each mean one thing before an agent uses them. Pre-calculation then turns that agreement into an enforceable choice. The agent does not choose between competing definitions of ARR because only the approved definition exists in the dataset it can reach.
Metadata gives that choice an accountable source. Atlan’s pattern returns an owner, certification status, and sensitivity classification with the data. These details help show whether the returned dataset is fit to act on. They do not replace the prior work of agreeing on the calculation. Without that work, even a tightly secured interface can give out numbers that disagree. Metric drift is insidious precisely because it can remain unnoticed until an external party asks for audited numbers.
What metric sets to approve before any agent connection is wired
Start with a narrow set of metrics whose definitions can be defended. Scope must precede connectivity. Retrofitting governance after an agent has broad access requires revoking capabilities that people may already depend on. Breadth is useful only when the definitions behind it are settled.
Each approved metric needs a single source of truth, an agreed calculation, and an owner who can resolve disputes. ARR should come from the billing system. Its calculation must specify the relevant fields, filters, and exclusions before it enters the governed dataset. The same discipline applies to revenue, churn, engagement, Active User, and gross margin. Each agent’s access to a metric category requires approval for its task.
The capability-scoping paper proposes a task-context classifier that narrows permissions to the current task. At the metric layer, an agent answering a retention question receives only churn and engagement datasets, leaving gross margin data outside its access scope. The paper’s policy-derived combination prohibitions add a further constraint. A metric that combines PII-adjacent fields with an external send path should be kept out of datasets that agents can access, even if either field would be allowed on its own.
Observability as the enforcement layer that makes the boundary real over time
A governed dataset without observability is a launch-time boundary that can degrade invisibly. Once agent query traffic enters an opaque system, there is no reliable signal separating misuse from ordinary load growth. For Supabase teams, the baseline covers the database, API layer, authentication flows, and Edge Functions from the start. Monitoring is a precondition for informed access and scaling decisions. It is not a later enhancement to an already complete architecture.
Agent-facing observability must go beyond p95 latency. Each query against the governed layer should produce an audit record identifying the metric set accessed, on whose behalf it was accessed, and what was returned. That record connects activity to authority. The pre-action authorization paper describes enforcement that creates cryptographically signed per-call audit records and takes a measured median of 53 ms to make authorization decisions. The enforcement happens before execution, while the resulting record helps distinguish authorized use from policy drift.
Supabase provides performance advisors, Index Advisor dashboard observability, and log drains to external systems. Those capabilities cover the database foundation, but they do not substitute for an audit trail at the agent-facing governed layer. A production instance can be healthy even when some metric access is inappropriate. A team that cannot see what its agents are querying cannot claim its metric sets are actually governed, because the boundary is only as strong as the signal monitoring it.
How to staff and maintain a governed metric layer without a dedicated data team
The strongest operational objection to a separate governed layer is that a maintained copy introduces synchronization concerns and another system to secure. For a very small team, that work can appear more expensive than granting a tightly scoped read-only credential on the primary. The objection deserves a direct answer. Removing the raw connection leaves the team with the work of keeping the dataset up to date.
But the build-cost argument assumes the team must build and maintain the layer in-house. The fractional model established in CFO and CTO hiring also applies to data, and a pre-built governed layer eliminates most of the build cost. An outsourced or product-based analytics function can cover metric definitions, recurring reporting, and the governed datasets that agents query. It can also give non-technical team members a way to get answers without making up competing definitions. That scope resembles the responsibility a fractional CFO takes for financial reporting.
An external data partner can therefore own the work that must precede the agent connection. The partner establishes definitions, models the approved datasets, and maintains the single source of truth. The founding team retains a basis for discussing decisions with agreed numbers. External ownership provides a staffing model for addressing synchronization and security concerns without a dedicated data team. The team must choose who maintains the governed boundary.


