Skip to main content
Glama

query_metric

Compute governed business metrics with optional grouping, filters, and time buckets, returning the SQL and models used for provenance instead of relying on ad hoc SQL.

Instructions

Compute a governed metric, optionally grouped, filtered and bucketed by time.

Prefer this over run_sql: the metric definition is the agreed business logic. The result includes the SQL that ran and the models it read, for provenance.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "metric": "<metric>"
    },
    "name": "query_metric"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum rows, up to the server's row cap.
metricYesMetric name from list_metrics, e.g. 'on_time_rate'.
filtersNoFilters on dimensions.
end_dateNoInclusive end date, YYYY-MM-DD.
group_byNoDimensions to group by, as 'model.column' or a bare column name.
order_byNoOutput column to sort by; defaults to the metric.
descendingNo
start_dateNoInclusive start date, YYYY-MM-DD.
time_grainNoBucket the metric by the base model's time column.

Output Schema

NameRequiredDescriptionDefault
sqlYes
rowsYes
modelsYes
columnsYes
query_idYes
warningsNo
row_countYes
truncatedYes
elapsed_msYes
catalog_versionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.1

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full behavioral burden. It usefully discloses provenance (the response includes the executed SQL and the models read) and that results are governed, but it says nothing about permission/auth requirements, behavior on an unknown metric name, or that results are capped server-side (that fact lives only in the limit param text).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences, front-loaded with the action and immediately followed by the routing rule. Every clause earns its place; only the split into a separate provenance sentence slightly dilutes the opening.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return-value detail is not required, and the description still adds the provenance note that the schema can't convey. For a 9-parameter governed query tool the gaps (error behavior, row caps, permissions) are real but modest given the strong schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 89%, so the schema already documents metric, filters, group_by, order_by, dates, limit and time_grain. The description's "grouped, filtered and bucketed by time" merely echoes those fields and adds no syntax, default, or interaction detail beyond the schema; baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

"Compute a governed metric, optionally grouped, filtered and bucketed by time" names a specific verb (compute) and resource (a governed metric) plus its scope modifiers. Combined with the explicit "prefer this over run_sql", an agent can distinguish it from the closest sibling without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly names the alternative (run_sql) and the condition that selects this tool: the metric definition is the agreed business logic. What's missing is the inverse case — when raw SQL is the right call (e.g. ad-hoc joins the metric layer doesn't model) — so the routing is one-directional.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.