Tenant-Scoped Metric Identities as the Row-Level Guarantee AI Agents Inherit From Supabase Through MCP
Tenant-scoped datasets let AI agents query metrics without production database access.

Governed data access for AI agents on Supabase through MCP should expose tenant-scoped metric datasets. Row Level Security limits which rows queries can reach when they run under a tenant-bound identity to which its policies apply. Pre-modeling preserves that scope while removing sensitive fields, and a read-only MCP surface gives agents access to governed metrics without giving them direct production database access.
Why MCP changes what agents can reach inside a Supabase project
MCP gives agents a live path into other systems through standard Resources, Tools, and Prompts. For Supabase, that path can include schema inspection, queries, migrations, logs, configuration, and Edge Functions. This is operational access. Depending on the tools and permissions exposed, an agent can take several actions within a conversation turn without a human authorizing each step.
Supabase’s AI tools documentation lists integrations with Cursor, Claude Code, GitHub Copilot, Gemini CLI, and Codex. Instead of relying on copied schemas or periodically synchronized context, these clients can request current information on demand. That saves much of the work of connecting systems for tasks that would otherwise need retrieval pipelines and sync jobs. The boundary between what an agent should see and what its connection permits must be an explicit engineering decision.
What Row Level Security actually enforces, and what it does not
Postgres Row Level Security, or RLS, governs which rows a role may access. Grants authorize table access for the role, while policies constrain operations within it. For qualifying reads, the useful mental model is an implicit WHERE clause. Multi-tenant applications commonly place an org_id or tenant_id on each data table and define policies separately for SELECT, INSERT, UPDATE, and DELETE. The database enforces these conditions rather than depending on application code to append a filter.
The tenant identity can come from JWT claims checked through auth.jwt() -> 'app_metadata' -> 'org_id'. This lets the database check the policy without a membership-table join. A membership-table approach offers more flexibility, but its lookup can itself be subject to RLS, requiring a security definer function to bypass that restriction. Views need separate scrutiny as well. An analytics view can bypass underlying RLS unless it is explicitly configured with security invoker behavior.
Row scope is not field-level protection. A permitted row can still expose emails, payment references, internal flags, or other sensitive content to an agent. RLS does not redact those fields merely because the consumer is an AI system. Its guarantees concern which tenant’s rows an identity can read and which rows its permitted operations can affect. Field-level redaction requires a separate boundary.
How agents inherit tenant-scoped identities through MCP
When an agent’s query reaches Postgres under a tenant-bound identity subject to RLS, the database evaluates the applicable policies before returning results. The agent does not supply the security guarantee. Its effective database identity does. A prompt asking the agent to omit an org_id filter cannot remove a restriction that Postgres independently enforces.
This is the precise meaning of inheritance through MCP. MCP transports the request, while tenant policies apply according to the credential and query execution context. But connecting an MCP client alone does not give it a tenant-scoped database identity. The query path must actually operate under that identity rather than a privileged credential that bypasses RLS.
Supabase’s MCP server uses OAuth by default, with a personal access token available for non-interactive environments. Those connection credentials should not be confused with proof of tenant-bound query execution. Supabase’s guide also documents read_only=true and feature selection such as features=database,docs to narrow the available tools. These controls reduce capabilities, while RLS determines row scope. The inheritance depends on a correctly authored policy and a tenant claim the user cannot rewrite.
What breaks the inheritance — and the real shape of the threat
The guarantee has three distinct failure modes. An integration can use the wrong credential, enforce an incorrect policy, or disclose data the agent is legitimately allowed to read. These failures require different responses because only the first two concern whether the database boundary holds.
The service_role key bypasses RLS by design. A documented proof-of-concept involved attacker-supplied text in a support ticket manipulating an agent with the full key into exfiltrating secrets. No database permission had to be defeated. This was a confused-deputy failure, in which an authorized agent acted on instructions it should not have trusted.
Enabling RLS is not enough without appropriate policies for each operation and tenant checks based on claims the user cannot write. A client-writable tenant claim lets a user assign themselves another tenant without a database exploit. Even after those flaws are fixed, an agent can still leak sensitive fields from rows it is allowed to read. So prompt resistance cannot take the place of limits on the data the agent can reach.
How to expose governed metrics without letting agents touch production Supabase tables
The appropriate analytics unit is a pre-calculated, tenant-scoped dataset exposed through a governed MCP server. Its production rows are selected under RLS during modeling, so the resulting artifact preserves that tenant scope. The agent queries the artifact produced from production Postgres. This moves enforcement of source-row selection to model time, while access controls on the dataset determine which tenant artifact the agent can reach.
An agent querying a Parquet dataset does not need access to the production auth schema or migration tools. Pre-modeling provides a smaller, deliberately selected exposure, though prompt injection can still threaten information present in the dataset. Sensitive production data left out of the artifact cannot be read from it.
A headless BI architecture supplies the corresponding definition boundary. Metrics, business rules, calculations, and access policies are defined once in a centralized semantic layer and exposed to dashboards, internal tools, and agents through open interfaces. This gives “active user” a common meaning across consumers. An MCP interface can then expose the same certified definitions that dashboards use, rather than asking agents to reconstruct business logic from tables.
DuckDB-queryable Parquet datasets support agent analytics without using the production connection pool. That avoids the connection-exhaustion risk of direct agent workloads on Supabase projects without a pooler configured. The architecture therefore addresses two different pressures. It narrows data exposure while keeping repeated analytical queries away from the transactional database.
Designing metric identities that agents can consume safely at scale
The design begins with tenant scope at model time. A modeling job runs against production under the RLS policies that apply and makes a separate artifact for each tenant. The agent’s credential determines which artifact it can reach. A later error in a production policy cannot change an existing artifact, but it can affect later modeling runs.
The second property closes the field-level gap left by RLS. Datasets for agents should contain pre-aggregated or column-masked fields, with metrics such as MRR, churn rate, and activation rate in place of raw events with emails and payment references. Those fields are excluded from the dataset. This distinction is important because a valid tenant identity may otherwise authorize access to every sensitive column in a permitted row.
The third property is a declared schema version. Breaking changes to metric definitions require a new version rather than an in-place mutation that silently changes what a running agent measures. Versioning closes the definitional gap in the semantic layer. A centralized “active user” definition can still produce inconsistent results over time if its meaning changes without a visible schema change.
The fourth property is a governed MCP surface. Dataset access should be read-only and limited to the resources needed for analytics, without production schema introspection, migration tools, or auth schema access. Supabase’s documentation describes how to choose feature groups through --features and use a read-only flag. These controls complement tenant identity. The decisive criterion for an analytics MCP server is whether it exposes the governed artifacts without reopening the production capabilities the architecture removed.
The monitoring boundary: why the security perimeter and the observability perimeter should be the same
A monitoring agent needs the same tenant boundary as an analytics agent. When operational signals are shared through the tenant’s metric identity, the agent cannot see another tenant’s performance data by accident through that surface. Security and observability then share a scope. This alignment depends on the monitoring dataset being tenant-scoped, rather than assuming that all project-level signals are appropriate for every tenant.
Supabase announced a change to default API exposure on April 28, 2026. Under the change, new tables in the public schema are no longer automatically exposed through the data API, with existing projects following on 30 October 2026. Access requires explicit grants. For teams affected by the transition, integrations that depended on implicit exposure need an audit and reconfiguration. The change makes the API surface easier to reason about because access follows what has been opened deliberately.
That default-deny boundary helps control what is exposed, but it does not replace RLS or control every way of connecting to the database. Supabase’s monitoring tooling covers API and Auth error rates, connection pressure, slow queries, replication lag, and request-volume trends through a pre-built dashboard. These categories can guide the choice of operational metrics. The agent still needs access limited to the signals appropriate to its identity.
For early-stage projects, useful signals include pressure around the built-in mailer’s two-email-per-hour Auth limit, connection exhaustion without a pooler, and egress costs in media-heavy applications. Proactive alerting requires a data layer that pre-calculates the relevant signals and sends them to a messaging platform, an inbox, or a phone. Tenant scope should hold through that delivery path as well as at the analytics query.
What founding teams should actually build, in what order
For a founding team, the implementation sequence starts with credentials. Replace service_role usage in agent integrations with a read-only execution path that uses a tenant-bound identity subject to RLS. Supabase documents --read-only and --project-ref for narrowing capabilities and project scope. Neither flag alone establishes tenant isolation. The essential test is whether the agent’s actual queries execute under the intended RLS-constrained identity.
Policy completeness comes next because the modeled data inherits the policy’s decisions. Audit each table for enabled RLS, appropriate policies covering SELECT, INSERT, UPDATE, and DELETE, and tenant checks based on claims users cannot rewrite. Audit views separately for security invoker behavior. A protected table does not automatically make every analytics view safe.
The third step is a small pre-modeled metric layer. Pre-seed teams can focus on MRR, churn rate, signups, activation rate, and burn rate. Even that limited set needs tenant-scoped artifacts, safe fields, and versioned definitions. This is where database permissions become an agent-ready analytical contract. The agent gets the measures it needs without getting the raw production records used to calculate them.
Governed MCP exposure comes last, once those dependencies are in place. Only the read-only dataset surface and the tools required to consume it should be open. For existing projects affected on 30 October 2026, verify explicit grants for new public-schema tables where the Data API is part of the intended path. Direct production access and governed metric access are different products of this design. Founding teams should give analytical agents the latter, with the tenant boundary established below the agent.


