AgenticLong read

Metric-Scoped Tool Definitions as the Governance Primitive That Replaces Raw SQL for Claude and GPT Agents on Supabase

Scoped MCP tools give agents one governed answer per metric.

· 8 min read
Cover illustration for “Metric-Scoped Tool Definitions as the Governance Primitive That Replaces Raw SQL for Claude and GPT Agents on Supabase”
Agentic · November 16, 2026 · 8 min read · 1,880 words

Claude and GPT agents can query Supabase business data without direct database access through metric-scoped MCP tools backed by governed Parquet datasets. Each tool fixes the canonical calculation, permitted rows, and caller access, while DuckDB serves analytical requests away from production Postgres. The tool definition is the governance primitive, a contract that enforces how business answers are calculated in place of agent-written SQL.

Why giving agents raw SQL access is structurally unsafe, not just risky in theory

Two agents answer the same question about Q2 revenue. One computes SUM(revenue), while the other computes SUM(amount_captured), producing figures that diverge by an observable margin without a record of why. Both queries can be valid SQL against permitted tables. Neither establishes which answer the business recognizes as revenue. The failure begins before query execution, because the agents have no shared metric definition against which to resolve the question.

A direct connection gives an agent the access granted to that connection. It does not, by itself, establish per-user scope, a caller-specific audit trail, or a canonical calculation. Better prompting cannot close that architectural gap. AtScale identifies metric governance as one of six required components of agent governance, distinct from access control and runtime oversight.

A human analyst’s incorrect definition may surface on a dashboard that someone eventually questions, while an agent can propagate the same error through connected workflows and automated decisions before anyone notices. Supabase also introduces a separate operational constraint. Supabase’s documentation states that Postgres cannot accept unlimited direct connections and recommends poolers for short-lived or horizontally scaled clients. A fleet of agents can therefore exhaust production connection capacity even when every query calculates the right result.

What metric-scoped tool definitions are and how they differ from prompt instructions or read-only credentials

A metric-scoped tool definition is a named, versioned MCP Tool or Resource that encodes a business metric’s calculation, row scope, and access rules. The agent requests that defined metric. Calculation determines what revenue, churn, ARR, or gross margin means. Row scope determines which data belongs in a particular caller’s answer, while access rules determine who may invoke the metric at all.

The distinction from a prompt is enforcement. An instruction such as “always use SUM(revenue) not SUM(amount_captured)” remains advisory and can be displaced by a long context or a conflicting tool result. A metric-scoped interface instead limits the available operation to the defined calculation. Within that interface, the agent cannot substitute another expression for the metric. Its choice is which permitted tool to call.

Read-only credentials and row-level security provide different protections. They restrict database access and visible data, but they do not decide which calculation an agent applies to the rows it can read. Metric scoping adds that missing semantic constraint without treating database controls as unnecessary. AtScale describes metric and semantic governance as requiring version-controlled business logic and centralized KPI definitions. Those definitions address metric drift, the gradual erosion of confidence that follows when nominally identical metrics acquire different meanings.

Why the tool definition, not the database, is the right control surface for agent governance

The database can enforce permissions without knowing whether a calculation it allows matches the business’s agreed ARR. The metric tool is where those concerns meet. A named, versioned definition binds the calculation to its permitted scope and callers, so governance applies when the business question is asked. The agent does not have to remember a policy and translate it into SQL correctly. The permitted operation already embodies that policy.

Agents that call get_monthly_arr for the same scope and dataset get the same calculation, whatever model they use or team deploys them. The MCP server logs the tool, the agent that calls it, and the parameters, so the audit trail shows the business operation behind the call. When the canonical definition changes, the calculations that use it change too, with no need to change a prompt or rotate credentials. Restricting agents to scoped tools also limits their reach, because tables outside those tools are not exposed.

A governed layer introduces maintenance, scheduled-data staleness, and potentially latency, while an early-stage team without a data function may consider a well-prompted, read-only agent sufficient. That approach can restrict writes, but it leaves metric consistency unresolved. Speed is not necessarily the price of governance, either. Pre-calculated datasets queried through DuckDB can answer faster than a cold Postgres query on a production instance under connection pressure.

Ampcome states that the platform, rather than the prompt, must enforce access. It also places thresholds and approval rules in business configuration so they apply consistently and can change in one place. A metric definition follows the same principle. Business logic becomes a control that the team maintains in place of an instruction that each agent must work out on its own.

How MCP structures the interface between agents and governed metric tools

MCP separates the interface into Tools, Resources, and Prompts. Each has a distinct role in metric governance. A Tool performs an action, making it appropriate for a calculation requested by name, such as get_monthly_churn_rate or get_ltv_by_cohort. A Resource supplies context, including a governed dataset or certified metric snapshot that an agent reads without triggering a live calculation. A Prompt supplies a reusable template for a workflow in which the same sequence of metric lookups recurs.

A Prompt can organize an analysis, but the Tools and Resources it references remain the governed access points. The July 28, 2026 specification revision removed protocol-level session tracking, so MCP is now stateless at the protocol layer. Anthropic Member of Technical Staff David Soria Parra described the revision as the most substantial changes to the specification probably since the addition of authorization. Metric servers must therefore keep their own state for governed datasets because they can no longer rely on protocol-level sessions.

The common interface also reduces integration work. MCP replaces N×M application-to-source connectors with N+M implementations of a shared protocol, allowing compliant hosts to discover and call an existing metric tool without a bespoke connector. Informatica announced native MCP support across its Intelligent Data Management Cloud at Informatica World 2026. Its servers were live or in preview across AWS, Microsoft Foundry, Databricks Agent Bricks, Snowflake Cortex AI, and Salesforce Agentforce. Those governed operations illustrate the architectural direction, though they do not establish a ranked choice of Supabase metric servers.

The safe data layer behind the MCP server: governed Parquet datasets instead of production Postgres queries

A scoped interface does not by itself remove production load. The backing data path determines that outcome. In this architecture, scheduled jobs pre-calculate metrics and write governed Parquet files, so the canonical answer is ready before an agent asks for it. The MCP server exposes those datasets through named Tools and Resources. DuckDB then executes analytical queries locally against Parquet rather than sending agent requests to the production Supabase database.

This separation addresses the two original failures independently. Pre-modeled calculations prevent agents from inventing competing definitions, while the analytical copy keeps agent queries out of the production connection pool. Scheduled preparation still originates from the source data, but answering an agent does not require a production query. The preparation schedule makes clear how fresh the data is. It is no longer implicitly tied to an agent’s ability to query live tables.

The MCP server also becomes the enforcement point for rate limits and per-agent quotas. Production Postgres never sees that analytical request traffic. The same governed datasets can serve agents, BI tools, and applications, allowing a dashboard and an agent to resolve against the same answer. Ampcome recommends governed datasets, explicit table boundaries, and read-only starting access enforced by the platform. The pre-modeled layer implements that separation without changing production schemas.

How do teams implement metric-scoped tools on a Supabase project?

For a Supabase team, the implementation starts with five or fewer actionable KPIs rather than a broad catalog of loosely defined measurements. Candidates for a B2B SaaS startup include CAC, LTV, monthly churn, ARR, and gross margin. Agreement comes before expanding the tool surface. Sales, finance, and product need shared definitions for the metrics that drive decisions. ARR provides a concrete path through the architecture, from the Supabase subscriptions table to governed Parquet and then to an MCP tool.

The first step is to prepare the analytical copy. A scheduled job transforms the subscriptions table into the Parquet dataset using the team’s agreed ARR calculation. The metric’s business definition belongs in plain-language documentation, along with the assumptions it uses about paid seats, cancellations, and exchange rates. Its lineage documentation identifies the source table, preparation job, schedule, and transformation. This makes the calculation and its freshness inspectable without asking an agent to reconstruct either from raw data.

The second step is to expose that dataset through get_monthly_arr. The definition includes a description that helps the agent choose the tool, an explicit input schema containing the time range, segment filter, and tenant ID, and a handler that resolves against governed Parquet. It does not issue a live Postgres query. The scope predicate determines which rows this caller may use for this metric. For analytical traffic, that predicate supplies row filtering without changing the production database’s RLS policies.

Versioning makes later business changes manageable. If the ARR definition changes to exclude a new revenue category, the governed calculation and tool definition can be updated so subsequent calls use the new logic. The old version remains in the audit log. Supabase observability complements this design by showing when connection pressure builds, while the separate analytical path prevents agent queries from causing that pressure. Observation and prevention serve different purposes.

The remaining documentation connects execution to ownership and policy. Atlan distinguishes logs that record what happened from governed context that explains what it meant. Linking each tool call to the relevant data assets, owners, and policies makes the event interpretable as a business operation. A record that an agent called get_monthly_arr is useful. A record connected to the definition and governed dataset behind that call explains which ARR answer the agent received.

What the governed metric layer makes possible for teams where agents are already in the loop

Once the same definitions serve both people and agents, delivery no longer has to depend on someone remembering to ask. Metrics can be pushed to Slack, email, or a mobile dashboard on a schedule. The calculation does not change with the delivery channel. Because the dataset is pre-modeled and the tool is versioned, the pushed number can match the answer an agent returns for the same scope and snapshot.

That consistency changes how teams use the result. When sales, finance, and product call the same ARR tool, executive discussion can move from competing spreadsheet definitions to decisions based on a shared figure. New agents inherit that foundation through MCP discovery. A sales forecasting agent or churn prediction agent can find the existing tools without a bespoke integration or a new prompt-engineering exercise to teach the metric’s meaning.

AtScale argues that governance protocols let more agents act on their own safely. The metric layer gives that principle a concrete boundary, allowing agents to act on certified business answers without granting them freedom to redefine those answers. Its significance extends beyond a technical artifact. The tool definition is a governance contract between the team, its data, and every agent authorized to ask a question about the business.

Sources

  1. AI Agent Observability: A Complete Guide for 2026 & Beyond
Filed underAgentic

More in Agentic