Why the Safest Agentic Analytics Stack Interposes a Metric Contract Layer Between Supabase and Every Agent Consumer
A governed metric layer keeps agents off production and consistent.

The safest agentic analytics stack puts a metric contract layer between every agent consumer and Supabase, so agents get governed analytical datasets through MCP. That architecture separates analytical traffic from production, enforces shared metric definitions, and scopes access to the user behind each request. Pre-action authorization completes that boundary by checking each tool call before it runs.
Why agents querying production Postgres directly is an architectural problem, not a policy one
Supabase Postgres serves transactional work built around fast, random, row-level reads and writes. Agent analytics asks the same instance to run aggregations, multi-table joins, and time-series rollups that work best with sequential full-table scans. Those scans can occupy I/O for seconds or minutes while customer-facing transactions need the same resources. Both workloads share the connection pool and lock surface. A read-only credential does not separate those demands.
Small datasets can conceal the conflict for a while. Postgres handles the combination gracefully at low volumes, so a successful pilot can give little warning of the contention that arrives at scale. Agents amplify that contention because they can issue many queries in rapid succession. Adding MCP server instances cannot remove a bottleneck at the database connection layer. The architecture therefore needs workload separation as well as a policy that tells agents to query carefully.
What the authorization gap looks like when agents call databases without a policy layer
A working credential establishes whether a connection can reach data, while permission for a particular agent action requires a separate decision. Model alignment and post-hoc evaluation leave that distinction unresolved. Alignment is probabilistic and comes from training, while retrospective evaluation looks at behavior after execution. Neither supplies a deterministic policy decision at the individual tool call. Access can therefore exceed the authority of the task.
Before the Tool Call: Deterministic Pre-Action Authorization for Autonomous AI Agents names this gap the “pre-action authorization problem.” The OAP paper reports that social engineering succeeded against a model under a permissive policy in 74.6% of attempts in its live adversarial testbed. Under a restrictive pre-action policy, the same attack class had zero successes across hundreds of attempts. The finding’s scope is limited to that testbed.
Atlan’s governed access pattern addresses how a broad database credential can unblock a pilot and then become permanent because nobody revisits its scope once the immediate pressure passes. With a shared credential, each request inherits everything the connection can reach, with access decided at the connection level. For Supabase, credentials that bypass row-level security can also bypass a protection already built into the platform. The agent’s permissions must therefore be narrower than the reach of an expedient connection string.
Why analytical inconsistency is the third failure mode that security framing alone misses
An agent can respect access controls and connection limits yet still return an analytically wrong answer. Consider three agents asked to find revenue from raw order tables. Each constructs its own SQL, and each returns a different number because no shared contract specifies the expression, grain, filter, time semantics, or additivity rules. The database schema alone does not encode that intent.
The same gap lets “monthly active users” diverge between a product dashboard, an investor report, and a growth agent’s query. As departments lose trust in shared numbers, they maintain separate definitions, which accelerates the divergence. An LLM cannot know that “churned” means 90 days without a purchase rather than 60 unless that definition is encoded somewhere the agent must consult. If every consumer needs a shared, authoritative definition that it cannot bypass, what does that layer actually look like?
What a metric contract specifies and how it differs from a SQL view or a prompt definition
A metric contract is a machine-readable specification of what a metric means and how consumers may use it. It defines the expression, grain, allowed dimensions, filter, time semantics, and additivity. These constraints make the number deterministic across human and agent consumers, regardless of their access interface. The formula is only part of the definition. The contract also establishes the conditions under which that formula produces a meaningful result.
A named SQL view encodes a formula, leaving the definition and enforcement of allowed grouping, filtering, and additivity rules for every downstream use to other mechanisms. Two agents can join the same view with different GROUP BY clauses and obtain different numbers that are both technically valid against it. A prompt definition has a different weakness. Repeating definitions in every agent’s system prompt incurs per-request token cost, permits drift as prompts change, and provides no enforcement when another agent lacks the same instructions.
The contract approach uses fetch-on-demand discovery instead, so agents read the current certified definition when they choose a tool. A tool description can state “do not compute revenue from raw order amounts — use the certified revenue metric tool” at that decision point. The description helps agents choose, while access controls and pre-action policy enforce the rules. A genuine contract includes an owner, tests, lineage, and access rules, without which “certified” is only a label.
How do agents query Supabase data without direct database access?
Pre-calculated datasets, stored as governed Parquet files and queried through DuckDB, supply analytical context without making agent requests compete for production connections. Agents discover available datasets and request them by name instead of constructing ad hoc SQL against transactional tables. Their queries stay off the production Supabase instance. The copy is both a workload boundary and the place where metric contracts become consumable.
That separation also narrows what an agent can reach. The governed layer exposes approved datasets rather than the full production schema, with row-level and column-level permissions tied to the identity on whose behalf the agent acts. A generic service account with broad access cannot substitute for that identity. Atlan’s pattern establishes the sequence for this arrangement. Policy is defined against the governed layer first, and data is then exposed through an MCP server that preserves that policy.
Supabase’s acquisition of Hydra, the team that co-developed pg_duckdb, supports its work on Supabase Warehouse. That direction does not make pg_duckdb available on managed Supabase Cloud. Custom extensions that embed another execution engine cannot be installed there, so governed pre-calculated datasets remain an accessible analytical path for most managed Supabase teams. The architecture must fit the environment in which the team can actually run it.
Why the MCP server is the right delivery mechanism for the contract layer, not an optional integration
MCP gives every agent one governed interface to metric contracts and analytical datasets, regardless of the model behind it. Without that interface, each link between an agent and a source needs its own authentication, error handling, and monitoring. A common protocol prevents that integration work from multiplying as agents and model providers change. In this architecture, MCP is the delivery boundary. A separate raw database connector would create a route around the contract.
The protocol alone does not make that boundary secure. An MCP server that delivers everything its underlying credential can reach is still only a pipe. The governed layer behind it must decide what this agent, acting for this user on this task, may read. Identity passthrough is therefore a selection criterion, together with row-level and column-level enforcement and access to certified definitions. A Supabase connection by itself is not enough.
The MCP project’s move under the Agentic AI Foundation within the Linux Foundation gives the protocol vendor-neutral governance. MCP’s maintainers finalized the July 28, 2026 revision with protocol-level session tracking removed. The protocol version, client identity, and capabilities go with each request in a _meta parameter. This makes the protocol layer stateless. A governed MCP server can consequently scale like a REST API without session affinity or shared storage for protocol context.
Dremio’s MCP Server demonstrates the governed-interface pattern through semantic layer views and fixed tools, including RunSqlQuery, GetSchemaOfTable, and RunSemanticSearch. Role-based access controls scope those tools and restrict raw-table visibility to authorized roles. For Supabase teams, the decisive comparison is between servers that preserve governed access and servers that merely expose a database credential.
What pre-action authorization adds on top of governed data access, and why both are necessary
A governed analytical copy limits the reach of a bad action, but it does not establish that every action within that boundary is authorized. An agent permitted to access a dataset may still request a tool operation that its current task does not allow. Pre-action authorization checks that distinction synchronously before execution. It is a separate implementation concern from metric modeling. Together, the two layers constrain both the available data and the permitted use.
The OAP paper distinguishes sandboxed execution, model-based screening, and pre-action authorization. Sandboxing contains the blast radius, screening remains probabilistic, and pre-action authorization enforces a deterministic policy before a tool runs. The governed metric layer supplies isolation from raw production data, while the per-call policy check can enforce which metric tools an agent may invoke and in what sequence.
Pre-action authorization also produces a cryptographically signed audit record of the tool call, the policy applied, and the result, letting people check the authorization decision. For certified revenue, the tool description and the policy check form independent barriers. The description steers the agent toward the approved metric, while enforcement blocks a call that breaks the rules even if prompt injection or a jailbreak gets past that guidance.
Why Supabase teams need observability infrastructure in place before the metric contract layer can work reliably
A contract cannot make source data that is unreliable safe to trust. Supabase teams need query-level observability from day one to detect regressions, permission mistakes, and workload saturation before they appear as wrong agent answers. Slow query logging makes a regression inspectable before it prompts a customer complaint. Connection and pool metrics expose pressure before saturation becomes timeouts. Without those signals, the production contention that drove the need for workload separation can stay hidden until users feel it.
A use of auth.uid() that is re-evaluated for every row of a large table can turn an access-control check into a substantial query cost. Wrapping the call as a scalar subquery lets the planner evaluate it once instead. The difference can be a millisecond versus a timeout. Query-level observability exposes the execution behavior behind an otherwise reasonable-looking access rule.
Those signals also help establish whether pre-modeled datasets are refreshing on the right cadence and whether the production instance is drifting from the governed copy. A consistent metric definition is insufficient if the data behind it is unreliable. For founders and growing teams without a dedicated data engineer, a data partner can accelerate the path to a trustworthy metric layer. The investment should fit how complex the work is now instead of paying for enterprise requirements years before they are needed. Engineering effort belongs in the boundaries, definitions, and instrumentation the workload actually needs, with the remaining time available for product development.


