Pre-Aggregated Metric Vaults as the Architecture That Makes Supabase Production Unreachable by Design for AI Agents
Isolate production by serving AI agents pre-aggregated metrics through a separate governed vault.

To give AI agents governed access to Supabase data without direct database access, use MCP to expose a separate, pre-aggregated metric vault. Metric contracts define the answers, while the MCP interface applies the requesting user’s permissions against the governed artifact. Production Supabase stays outside the agent’s execution path, making isolation a structural property.
Why AI agents break on raw Supabase production data
A human analyst writing SQL already knows that revenue means recognized revenue, that test accounts are excluded, and that the fiscal year starts in February. An agent sees tables, columns, and the joins it could make. The analyst supplies meaning that the schema omits. The agent instead selects a plausible table, makes a plausible join, and can return a confident, well-formatted answer that does not match the business definition. Better SQL generation does not resolve that difference.
An agent can choose the wrong fact table, multiply rows through a join, use gross revenue in place of net revenue, or sum a non-additive measure. Time introduces another source of ambiguity. A query can use the wrong date dimension while remaining syntactically valid, and exclusions can disappear because nothing in the schema identifies them as required. An answer built this way can reach a board pack or customer email before anyone challenges its premise.
For Supabase teams, the same access path also creates operational exposure. Direct queries use production connections, while the wrong credentials or security configuration can expose restricted rows. These are distinct failures with a shared entry point. Giving an agent raw access asks it to infer business meaning while allowing its attempts to reach the database that serves the application.
What metric contracts actually encode, and why agents need them before access
A metric contract specifies business rules, exclusions, time logic, ownership, and the conditions under which a measure can be trusted. It is not merely a saved query. “Retention last quarter” requires a choice between logo and revenue retention, a decision about trials, a governing date field, and an explicit calendar or fiscal period. Internal accounts may also need exclusion. Those choices must be in machine-readable form before the agent answers the question.
The same requirement applies to apparently simple terms such as active users. That label might refer to daily actives, monthly actives, paid accounts, or users who performed a qualifying product event. Column names cannot settle the approved meaning. Nor can they reliably identify an obsolete table, a superseded dashboard definition, or a dimension that creates double-counting. A contract puts what people know into a clear specification that everyone who uses the data can share.
That specification must also describe lifecycle state and refusal conditions. Gross revenue, for example, is not valid for customer-level churn analysis when it includes one-time fees. A governed system needs to distinguish an approved calculation from an invalid use of that calculation, rather than treating every executable query as a legitimate answer. Once those boundaries are explicit, a pre-calculated artifact becomes a way to preserve them before access begins.
The pre-aggregated metric vault as a structural boundary, not a runtime policy
A pre-aggregated metric vault is a pre-modeled artifact that is kept separate from the production database. It is not a cache placed in front of a live production connection. The agent’s query resolves against that artifact alone. Because production is absent from this execution path, changing a query or widening permissions on the vault does not turn the request into a production database query.
Read-only credentials, row-level security, and network rules serve a different purpose. They restrict an access path, but they do not replace that path with a separate dataset. If a production connection is still available, even queries that are allowed can use up production capacity. Access controls remain necessary for the governed data, but protecting that data and isolating production are no longer the same boundary.
Incremental refresh keeps the artifact up to date without a production query for each agent request. Above the vault, the semantic layer identifies certified definitions, allowed dimensions, and refusal conditions, while the vault holds the pre-computed values those definitions govern. Serving those values also avoids repeated analytical work on production, but performance is the secondary benefit. The decisive property is that the production connection pool, row-level security configuration, and write path are outside the agent’s call chain.
Why Supabase production is the pressure point this design is built to protect
Postgres connections or Realtime channel quotas can become the constraint before an LLM rate limit does. More model capacity does not relieve that pressure. Agents that open connections on demand can exhaust a production pool, while an agent using a service role or an inadequately restricted anon configuration can reach data the application was intended to protect.
Without pg_stat_statements, slow query logging, and connection and pool metrics, a team may first encounter saturation as timeouts before recognizing the approaching limit. The application then shares the cost of analytical demand. This is why production isolation is not simply a question of whether an agent is allowed to write. Read workloads still compete for database resources.
Supabase Pipelines addresses part of this problem by streaming Postgres data to external analytical targets in near real time. Multigres addresses scaling through connection pooling and automated multi-node failover. Neither capability supplies the missing business definitions. Multigres v0.1 was released as an alpha in June 2026 and was not production-ready at that point, but even greater database capacity would not tell an agent which revenue definition is approved. The vault pattern meets a different need by sending analytical requests to a governed copy and keeping production out of the agent’s execution path.
How an MCP server gives agents governed Supabase access without a production connection
MCP provides the access interface between consumers and the governed artifact. In this headless analytics pattern, an agent calls the MCP server, and the server queries the vault under the semantic contract. Human interfaces use the same governed definitions. Neither consumer needs a direct production database connection, so adding an interface does not require reopening the boundary the vault established.
The MCP specification’s July 28, 2026 revision made the protocol core stateless. Requests can consequently reach any server instance behind a plain round-robin load balancer without session affinity. This supports horizontal scaling of the access layer. It does not, however, make the underlying data governed. A well-implemented MCP server over raw tables inherits their ambiguity, and a server connected to production leaves production in the execution path.
For a Supabase team selecting an MCP server, the relevant criteria are therefore its data target, semantic controls, and permission model. The server should query the separate governed artifact, expose certified metric definitions, and apply the requesting user’s permissions at query time. Databricks’ Unity Catalog Business Semantics, announced as generally available and open-sourced in April 2026, shows how definitions can be shared at the warehouse layer.
The real cost of skipping the vault: metric drift, agent disagreement, and lost trust
When departments use different rules for the same label, their answers can differ even when the calculations are correct. Consider net sales defined differently across three departments. Finance includes deferred revenue, Sales excludes mid-quarter cancellations, and Marketing replaces invoice date with booking date. Each number follows its own internal logic. The leadership review then becomes a dispute over which number is real rather than a discussion of what the business should do.
Agents can multiply that disagreement when each vendor builds a private model of the business. One model resolves entities one way, another defines active customer differently, and each develops its own context layer. There is no shared arbiter when they disagree. If that knowledge belongs to the vendor’s private layer, it also leaves when the contract ends. The organization must then get back definitions it should have owned all along.
Metric drift is more corrosive than a single visible error because it can be chronic and defensible. Each department can explain its number without resolving the disagreement. One metric contract for each measure clears up that ambiguity for those using the governed vault, as long as agents and dashboards use the same contract. A disputed answer has an agreed definition against which it can be assessed.
What a vault-first data architecture looks like for a Supabase team in practice
For a Supabase team without a dedicated data function, the practical starting point is a small set of decision-driving metrics, without a warehouse migration or an ETL build. The recommended scope is five or fewer metrics. For most B2B SaaS teams, the brief identifies CAC, LTV, monthly churn, ARR, and gross margin as that starting set. Each requires a single owner, a single calculation, and a certified grain. The grain sets what each result stands for, so those who use it downstream do not silently change the level of analysis.
This approach keeps Postgres as the analytical home without making production the agent’s query endpoint. Business metrics are pre-modeled into governed datasets, and the separate vault serves agents and dashboards from those definitions. Incremental refresh maintains the artifact, the semantic layer constrains valid questions, and MCP exposes the results under the requesting user’s permissions. None of those consumer requests needs to open a production connection.
Reconciliation gives those contracts a business anchor. Every metric on the CEO dashboard should reconcile to a single source, including ARR from the billing system, cash from the bank, and product usage from the analytics layer. Agreement must extend beyond the presentation layer. Two interfaces that display the same label but calculate it independently have not established a single source of truth. When the governed definitions reconcile to their sources and serve both interfaces, the executive discussion can turn from competing numbers to decisions.
Why the vault pattern is the durable answer even as agent tooling keeps changing
If the semantic model exists only inside a proprietary context layer, centralization can exchange departmental drift for dependence on one supplier. Portability changes that trade-off. A pre-aggregated artifact stored in Parquet, queryable with DuckDB, and exposed through MCP need not bind access to a single agent vendor. The metric definitions must travel with the data independently of a subscription.
Apache Ossie is incubating as a vendor-neutral specification for semantic model exchange across analytics, AI, and BI platforms. That effort treats portability as a shared requirement. It also separates the need for consistent business meaning from the choice of a particular consumer. An organization can change its agent or model without asking the replacement to reconstruct what revenue, retention, or active customer means from raw tables.
The isolation guarantee follows the same logic. Whichever agent consumes the governed artifact, production remains unreachable through that interface because no production connection exists in its execution path. Business rules, exclusions, and ownership still need durable, machine-readable definitions, while production still needs separation from autonomous analytical demand. The lasting design principle is to give agents a governed artifact they can use, rather than a production connection they are instructed not to misuse.


