Scoping Claude and GPT Agent Permissions to Named Metrics Instead of Supabase Tables

Expose metrics, not tables, to limit agent access and boost trustworthiness.

· 8 min read
Cover illustration for “Scoping Claude and GPT Agent Permissions to Named Metrics Instead of Supabase Tables”
Agent-to-Data Access · November 7, 2026 · 8 min read · 1,870 words

Claude and GPT agents should query Supabase data through an MCP server that exposes only named, governed metrics. The server should enforce scoped permissions before returning results with provenance. This architecture closes the gap between what an agent can reach and what its task requires, while making analytical answers faster and more trustworthy.

Why giving agents table access instead of metric access is an architectural mistake

What an agent is assumed to reach and what it actually should reach are different boundaries. A task may require a business result, while the database connection supplied to complete it grants access to the underlying records. That mismatch is a design flaw with security implications. The connection makes the available tables the practical boundary of the task, even when the intended boundary is much narrower.

Table access controls an action. It establishes whether an agent may read data, but not whether the data it reads should leave the environment. Permission to answer a question thus lets the agent fetch data beyond what it needs for the answer. The flaw exists before the agent makes any mistake.

In Supabase, that mismatch also affects production capacity. An agent with a narrow business question can run queries against the same production database that serves the application, which risks connection-pool exhaustion. What appears to be a convenient connector is therefore a decision about both data exposure and production workload.

How MCP creates the access layer — and what it deliberately leaves ungoverned

MCP separates the AI client, such as Claude or ChatGPT, from the MCP server that supplies connector logic and the resource it reaches, such as a database or API. It standardizes the channel between those parts. It does not clean, transform, or govern the data moving through them. The caller has to do that work because the protocol does not.

The stateless MCP specification revision of July 28, 2026 made the protocol stateless at the protocol layer, so requests can reach any server instance behind a round-robin load balancer. This enables horizontal scaling of the access layer. Its architectural value is that a governed metric backend can scale independently of the production database, rather than tying agent access to one connector instance.

MCP does not provide metric definitions, query policy, or provenance, so an agent given table access through it still has to decide what the data means. Conversely, an agent supplied with definitions but no query access cannot produce a live answer. A governed metric layer gives the agent both query access and the definitions it needs to know what the data means.

What happens when agents write their own SQL against production tables

Raw schemas do not resolve disagreements about business definitions. If three analysts use different definitions of a conversion event, an agent cannot settle the disagreement by querying faster. It can choose the interpretation suggested by the tables and return an authoritative-looking number. The SQL may run without errors even when the answer is wrong.

Prompt injection adds a different route to unintended retrieval. An empirical study documented 15,387 validated instances of injected instructions on the public web, mostly hidden in markup, white text, or metadata and aimed at LLM-based agents. An agent that finds such content while it has open table access can be told to query and show data beyond what its task calls for. The operational consequence follows from the permission already granted.

Claude Managed Agents also illustrates why tool restrictions and credential scope must be distinguished. A single API key provides access to all agents, sessions, and event logs within the workspace, with no per-agent API key scoping. Per-agent tool and networking permissions can be configured at agent creation time, but those settings do not narrow the API key itself. One over-permissioned configuration therefore creates exposure that a task description cannot contain.

How to let AI agents query Supabase without direct database access

The architectural alternative is an MCP server that accepts a metric name, filters, and dimensions, enforces policy, and returns a result with provenance. The agent requests monthly_active_users rather than constructing SQL against users, sessions, and events. The server exposes an analytical contract. That contract defines both the question the agent may ask and the meaning of the answer.

For Supabase, the metric server sits in front of a governed copy, keeping agent queries off the production instance. Supabase Row Level Security makes token-scoped access enforceable at the database layer. The metric interface restricts the available analytical operations, while RLS enforces the data grant on queries that reach Supabase.

Onyinyechi Iwuchukwu’s Claude Agent Consent project on GitHub, published in 2026, demonstrates scoped consent at the Supabase layer. A user gives a Claude-powered agent read-only access through an OAuth-style consent screen, and RLS enforces that grant on every query. The agent fetches its grant from the server before calling Claude and registers only permitted tools. list_tasks requires tasks:read, while search_notes requires notes:read and is limited to granted folders. The example shows how permissions are enforced but does not include a complete governed metric implementation.

For the analytical backend, governed Parquet datasets queryable through DuckDB provide fast, cheap queries through a single MCP server without touching production. This approach avoids ETL, schema changes, and new infrastructure. A server that accepts arbitrary SQL does not become a metric boundary merely because it supports MCP.

What a governed metric definition actually requires

Each metric needs six machine-readable fields, namely its metric name, plain-English definition, version-pinned calculation logic, owner, lineage, and refresh cadence. Those fields establish what the result means, how it is calculated, who owns it, where it comes from, and when it is refreshed. The definition is a human artifact built before querying begins. Table structure alone cannot tell an agent what the business has agreed the data means.

Agents using an old calculation and agents using a new one can return different numbers for the same question unless the version is explicit. Internal consistency also does not guarantee that the definition answers the right business question. Governance must settle that question before the metric becomes an approved tool.

Start with 20 to 30 core KPIs. These should be the metrics used in board-level reporting, referenced by senior leaders, and most costly to interpret inconsistently. Governing that small set before expanding scope concentrates the work where disagreement is most visible. A larger catalogue offers little benefit if its definitions remain unsettled.

How to scope agent permissions step by step inside a Supabase project

Implementation should begin with a one-sentence charter for the agent’s task. Derive the minimum data set from that charter rather than surveying available tables and working backward. Then map the task to the named metrics it requires.

Next, configure Supabase RLS before connecting any agent. Grant access through scoped credentials or access tokens that expire after the task, rather than standing access to data the agent might eventually need. Keep read and write credentials separate. An agent that only reads metrics should not inherit write permissions through the same credential, even if other workflows require them.

CData’s 2026 guide provides four eligibility gates for AI access to production data. Federated SSO through OAuth or SAML should resolve every query to a named person, and the AI path should inherit source-system RBAC. Encryption in transit should cover every hop, including the MCP endpoint. A per-query audit record should also export to a SIEM. These gates supply a governance backbone.

For Claude Managed Agents, handle the configurations for agents as infrastructure-as-code. Review and version-control them under the same governance as production deployments because there is no org-wide default or admin-configured baseline to inherit. Tool and networking permissions must therefore be chosen with care when each agent is configured. Workspace-level credentials cannot stand in for that review.

Finally, track query patterns from the start and set limits for each session. Rate-limit sessions, cap how long commands can run, limit write operations per session, and set maximum steps so runaway loops cannot exhaust the connection pool. Connection counts and query patterns should show when agents try to bypass the governed metric layer to query production tables.

The objection that a metric layer trades capability for safety — and why it does not hold

The strongest objection is that arbitrary table access can answer questions the business has not anticipated, while a predefined metric catalogue cannot. That concern is legitimate. A narrow catalogue can omit an analysis the business needs, and no amount of consistent querying creates a missing model.

A metric-backed architecture permits custom analysis upstream of the MCP server. If multi-touch attribution is calculated before the server queries the data, the agent can retrieve the attribution result through the governed interface. Analytical depth is not the prohibited capability. The constraint is on ad hoc raw-table access, so new analysis expands the governed layer.

The alternative also has a cost beyond inconsistent answers. The “Attacker Moves Second” paper, published at USENIX Security 2026, examined twelve published defenses and found most were bypassed above 90 percent once attackers could iterate. That finding does not establish that every agent will be compromised. The finding does show why defensive instructions are no reason to give an agent access to more data than its task needs.

The architectural control is to expose only approved metric tools through the MCP server. Agents may try semantic bypass by calling raw query tools instead of metric tools, so raw table tools should not be registered at all. Scope must limit what the agent can reach. An instruction to prefer metrics leaves the alternative available, while an interface without raw query tools removes that route.

Why Supabase observability is the prerequisite that makes all of this enforceable

A team that believes its permission architecture works but cannot observe agent behavior has no basis for distinguishing that belief from an unprotected system. Query patterns, connection counts, and anomalous activity make the boundary testable. Without them, permission scoping remains an assertion. The team cannot tell whether agents are using the governed layer or reaching production tables.

Supabase launched a fully configured Grafana Cloud integration on July 23, 2026, available on any plan including free. Its pre-built dashboard tracks more than 200 metrics covering CPU and memory pressure, disk IO, network traffic, connection counts and pooler behavior, replication lag, scheduled and requested checkpoints, and query stats. Supabase Studio’s built-in metrics are too coarse to diagnose connection spikes, slow queries, and replication lag on their own.

Supabase’s Logs and Analytics feature, powered by Logflare, supplies the log instrumentation behind per-query audit records. It processes events from the API gateway, Postgres databases, Storage, Edge Functions, and more across a multi-node Elixir cluster. Those records complement the infrastructure metrics. Anomalous connection behavior and query patterns are the signals of agents querying production rather than the approved layer, and visibility is necessary to distinguish agent traffic from application traffic.

For a Supabase founder, those operational signals must connect to business results. Paid conversion, retention, completed customer outcomes, and support burden are the metrics to track in practice. Realtime feeds and attractive dashboards can show activity without demonstrating demand. A governed access architecture earns its place when answers people can trust help achieve those outcomes while keeping production data beyond the task out of reach.

Sources

  1. How Agents Ask for Permission: User Permissions for AI Agents, from Interfaces to Enforcement
  2. Securing the Model Context Protocol (MCP): Risks, Controls, and Governance
  3. SNARE: Adaptive Scenario Synthesis for Eliciting Overeager Behavior in Coding Agents

More in Agent-to-Data Access