The Read-Only Metric Bus That Routes AI Agent Queries Away From Your Supabase Production Schema
Serving agents modeled Parquet data keeps analytics off production.

A read-only metric bus lets AI agents answer analytical questions about a Supabase project without giving them credentials for the production database. It exposes pre-modeled datasets through a governed MCP interface rather than opening raw tables to agent-generated queries. This is the correct default because it separates agent traffic from production workloads and gives agents the same metric definitions that people use.
Why AI agents querying your production Supabase database is a structural problem, not just a risk
Supabase’s connection pooling puts agent access in the context of a shared production resource. An agent querying the live Postgres instance competes with application traffic for connection pool slots, even when its credentials permit only reads. Read-only does not mean free of operational consequences. A poorly written analytical query can cause full table scans, while a long-running query can pin old snapshots and keep VACUUM from reclaiming dead tuples. That last mechanism is MVCC pressure.
These effects follow from where the query runs. Restricting writes removes the agent’s ability to change data, but it does not separate analytical work from the database serving the application. Advice to be careful with credentials therefore addresses only part of the problem. The credential still grants access to a live resource, and the work performed through it still consumes production capacity. Whether a query is well intentioned has no bearing on that competition.
The same access pattern also creates a semantic dependency. An agent sees column names, table relationships, and business logic hinted at by naming conventions, rather than a fixed definition of what each metric means. Those are not equivalent sources of meaning. A renamed column or a split table can disrupt the agent’s reasoning, including cases where a query still succeeds but returns results that no longer match the intended analysis. A successful database response is not proof of a correct analytical answer.
For example, an agent counting active users from raw events can return a different number from a dashboard applying the team’s agreed definition of active. Both calculations may execute without error. The disagreement comes from the architecture giving two consumers different ways to define the same term. As a result, the blast radius extends beyond database performance to the reliability of the answers. When people repeatedly receive numbers that conflict with their dashboards, trust in the agent can deteriorate before the investment in it delivers value.
How do you let AI agents query Supabase data without direct database access?
A metric bus replaces that dependency on raw tables with a governed, read-only interface to modeled outputs. It sits between the data producers and the consumers, which can include agents, dashboards, and reports. The boundary is defined by the available metrics. Instead of exposing the tables from which revenue or churn might be calculated, the bus exposes datasets in which the agreed business logic has already been applied.
The word “bus” describes this separation of responsibilities. Like a message bus, it decouples producers from consumers so that neither side has to depend on the other’s internals. In this case, Postgres tables produce the source data, while downstream consumers use the modeled results. The interface is closer to a public API than a database connection. Its contract concerns the answers it makes available.
Concretely, those answers can include revenue by cohort, churn rate, and active users calculated according to the team’s definition. The bus holds these outputs as materialized datasets in a format suited to reads, with Parquet a natural fit. DuckDB can then query those datasets without contacting the live Postgres instance at query time. Only the controlled process that prepares the data gets production access.
Governance here has a specific meaning. Humans define the metrics and encode their business logic before the agent consumes them, so the agent does not invent an alternative definition by composing raw columns. A database connection can restrict access through permissions, but access permissions do not themselves define active users or recognized revenue. The bus makes those definitions part of the interface contract. Where a connection grants a capability to query available data, the bus supplies a vocabulary whose terms have already been settled.
That vocabulary deliberately limits what the agent can answer. A question outside the modeled outputs is not a reason to infer a new metric from production tables. This design constraint makes the distinction between a defined analytical question and an unsupported one visible at the data boundary.
How the bus is structured: Parquet datasets, DuckDB queries, and the MCP interface layer

The modeling layer reads the Supabase Postgres tables on a schedule or on change, applies the agreed business logic, and writes the results as Parquet files. Its work includes deciding what counts as an active user, how revenue is recognized, and which events are excluded from funnel analysis. This is where human judgment becomes executable logic. Agents receive the result of those decisions rather than responsibility for reconstructing them from the schema.
Within this architecture, that controlled modeling process is the point at which the production schema is accessed. An agent can ask a question without starting another production query. Preparation still reads production data, but consumption takes place elsewhere. Consequently, the bus separates the frequency and shape of agent questions from the process that reads the source tables.
The modeling layer also absorbs changes in those tables. When the production schema changes, the model can be updated to preserve the meaning and shape of the downstream datasets. That protection depends on updating the modeling logic so that it continues to express the agreed definitions against the changed source. With that work contained at the modeling boundary, agents do not need to reinterpret the production schema themselves.
The storage and query layer serves the resulting Parquet files from object storage. Supabase Storage is a natural home for a team already using Supabase, while DuckDB provides an in-process analytical engine for querying the files without loading them into memory in full. Its columnar, vectorized execution suits analytical reads over large datasets. The relevant workload is many small questions. This arrangement provides a read path designed for that workload rather than sending it through the transactional database.
In this serving pattern, DuckDB runs in-process and statelessly, so there is no additional database server or database connection pool to operate for these queries. The query work happens against the materialized files. That placement is the operational boundary separating agent analysis from production Postgres. Parquet supplies the modeled data, while DuckDB supplies the means to ask questions of it.
The interface layer exposes those datasets through the Model Context Protocol, or MCP. MCP is an open standard for connecting AI applications to external tools, data sources, and systems, allowing compatible agents to use the bus without bespoke integration. Metric definitions come from the modeling layer, and the MCP server exposes them through the governed interface.
For example, an agent can ask what MRR was last month, broken down by plan tier. The MCP server translates that request into a DuckDB query against the governed Parquet dataset. The agent never formulates SQL against raw production tables.
Why routing agent queries through the bus rather than Postgres is the correct default, not an optional optimization
The strongest objection is that this appears to add infrastructure to a problem that read-only credentials and trusted queries should already solve. Why add a layer if the agent cannot write and its SQL looks reasonable? Because reasonable SQL does not establish a shared metric definition. Trust depends on the agent’s vocabulary.
An agent reasoning from a raw schema maintains an inferred interpretation of the business. The team maintains another interpretation in its dashboard logic or in its understanding of the data. These are parallel semantic layers. A schema change can shift the agent’s interpretation, and a prompt change can alter how it constructs the calculation, even while the dashboard’s definition stays fixed. The resulting divergence can compound without producing a database error.
The bus concentrates that semantic work in one place. When the agent, dashboard, weekly email report, and investor update all consume the same pre-calculated datasets, they no longer need to reconstruct the metric independently. This is the answer to the over-engineering objection. Direct access avoids building the shared layer initially, but it leaves each consumer responsible for deriving meaning from the source.
Security reinforces the case without being its primary justification. An MCP credential exposing only named metrics grants a much narrower capability than a live Postgres credential, even a read-only one. If that MCP credential is compromised, the exposed surface is limited to the governed summaries. The boundary follows what the server actually exposes. MCP alone is not a substitute for restricting that surface to the modeled outputs.
Each new agent, dashboard consumer, or report sends its queries to the serving layer. The controlled modeling process still accesses Postgres, but agent query volume does not directly add analytical work there. This makes the bus an architectural default rather than a performance adjustment to postpone until queries become slow.
What teams building with AI agents on Supabase should put in place now
Teams adopting this pattern should start by writing down in prose what counts as a user, how revenue is recognized, and what an event must look like to enter the funnel before modeling a dataset. These definitions are the substance of governance. Parquet files and an MCP server cannot resolve a disagreement that the team has never settled. Without explicit business logic, the bus would simply give an undefined calculation a new delivery path.
The next step is to identify the read path agents actually need. Most agent use cases require a small, stable set of metrics, including MRR, active users, churn, funnel conversion, and error rate. Teams should model those first instead of trying to put the full production schema behind a different interface. A narrow vocabulary supports higher trust. It also keeps the initial implementation focused on the questions agents are expected to answer.
For the interface, the relevant criterion is an MCP server that exposes the governed datasets rather than passing agent requests through to production tables. Protocol compatibility is necessary for interoperability, but it does not establish the data boundary. The bus pattern also does not, by itself, specify row-level access controls. A team requiring those controls cannot infer their presence merely because an interface uses MCP or serves modeled data.
Once the bus can answer the questions an agent used to answer directly, teams should revoke direct Postgres credentials or stop giving them to systems that agents use. An existing Postgres connection string is the credential to rotate out at that transition. Otherwise, agents can still use the old route despite the new boundary. Adopting the pattern before agent usage scales is cheaper than retrofitting it after months of production access and accumulated distrust in conflicting outputs.
Finally, changes to modeled Supabase tables should trigger a review of the modeling layer. The purpose is not to assume that every schema change breaks the bus, but to check that the encoded business logic still matches the new shape of the source data. That review belongs where the definitions are implemented. Production can then evolve without requiring each agent and report to rediscover what the team means by its metrics.


