Skip to main content
Glama
Arun-kc

schemabrain

get_metric

Read-onlyIdempotent

Retrieve metric data with grouping, ordering, and filtering. Returns ranked rows and parameterized SQL, resolving multi-table joins automatically.

Instructions

Use this when you have a metric name + want ranked/sliced rows (top-N, most/highest/lowest). Returns rows + parameterised SQL. Compiler chains multi-hop joins automatically (anchor order_item + group_by user.email + order_by total_items_sold descorder_item → order → user). Pass order_by= for deterministic ranking; without it, limit is non-deterministic (envelope flags missing_order_by_with_limit). Use list_metrics instead when you don't know the metric name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe metric name to compute (e.g. `total_revenue`). Call `list_metrics` to enumerate every declared metric with its anchor entity, aggregation, and time-bucketing capabilities.
group_byNoTuple of `entity.column` references to slice by (e.g. `('product_category.name',)`). Each entity must be reachable from the metric's anchor via a chain of one or more canonical joins. Multi-hop chains (e.g. `order_item → order → user`) resolve automatically; if 2+ paths exist, the call refuses with `ambiguous_path` and the agent disambiguates via the `via` arg. Empty tuple = no slicing.
filtersNoTuple of `(column, op, value)` predicates. Column is `entity.column` form. Ops: eq, ne, lt, lte, gt, gte, in, not_in, is_null, not_null. Values bind as parameters — never inlined into SQL.
time_grainNoOne of the metric's declared time_grains (day, week, month, quarter, year). Defaults null = no time bucketing.
time_dimensionNoDisambiguates time-dimension inheritance when a metric carries no local `time_dimension` and 2+ timestamp columns are reachable via canonical joins. Pass `<entity>.<column>` form chosen from the `ambiguous_time_dimension` error's candidate list (also visible in the error message). Silently ignored when the metric has its own declared `time_dimension` — that always wins. Defaults null (no disambiguation).
limitNoMax rows returned. Defaults 1000, valid range 1-10000. Out-of-range values refuse with a typed `malformed_name` envelope (not a transport error). The compiler always emits LIMIT regardless of group_by complexity.
viaNoCanonical-join names the chain MUST traverse, used to disambiguate `ambiguous_path` (multiple paths between anchor and a group_by entity) or `ambiguous_join` (parallel canonical joins on a single hop). Pass one or more join names returned by `list_joins` or by the prior error's `candidate_paths` / `candidate_join_names`. Each name must appear on a valid chain; otherwise the call refuses with `unknown_via_join`. Defaults to empty (no constraint) — only set when an ambiguity error tells you to.
order_byNoORDER BY clauses applied to the result. Each entry's `column` must be EITHER the metric's `name` (the measure aggregate's SELECT alias) OR one of the `group_by` columns in `entity.column` form. Anything else refuses with `unknown_order_by_column`. `direction` is `asc` (default) or `desc`. Pass this when you want deterministic ranking (e.g. "top 5 users by total_items_sold" → `order_by=[{column:'total_items_sold', direction:'desc'}]`). The compiler auto-appends a tie-breaking secondary key (first group_by column ASC) so equal measure values produce identical row order across runs. Empty tuple + non-empty `group_by` defaults to ASC on every group column so the LIMIT N slice stays deterministic without the caller having to construct one; override by passing any explicit clause.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYes
dataNo
errorNo
confidenceNo
provenanceNo
follow_up_hintsNo
degradation_reasonNo
charter_versionNo1.2
Behavior5/5

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

Annotations already declare the tool as readOnly, destructive=False, idempotent, and openWorld. The description adds significant behavioral context: automatic multi-hop join chaining, the impact of `order_by` on determinism and the `missing_order_by_with_limit` flag, limit enforcement, error handling (e.g., `ambiguous_path`, `unknown_order_by_column`), and the `via` disambiguation mechanism. No contradiction with annotations.

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

Conciseness5/5

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

The description is concise but informative. It starts with the core purpose in the first sentence, then adds essential details about auto-joins, determinism, `order_by`, and error handling. Every sentence adds value, and there is no redundancy or fluff. The structure is logical and front-loaded.

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

Completeness5/5

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

Given the tool's complexity (8 parameters, output schema present, rich annotations), the description covers all necessary aspects: when to use, automated behavior, error conditions, and parameter guidance. The existence of an output schema reduces the need to describe return values. The description is complete for an AI agent to correctly select and invoke the tool.

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

Parameters4/5

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

Schema description coverage is 100%, so baseline is 3. The description adds value beyond the schema by explaining high-level usage patterns: e.g., how `order_by` enables deterministic ranking and that the compiler auto-appends a tie-breaking key, how `via` resolves ambiguity, and the effect of missing `order_by`. These contexts are not explicitly in the per-parameter descriptions.

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?

The description explicitly states the tool is for when you have a metric name and want ranked/sliced rows (top-N, most/highest/lowest). It distinguishes from the sibling `list_metrics` by noting that `list_metrics` is for when you don't know the metric name. The purpose is clear, specific, and actionable.

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

Usage Guidelines5/5

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

The description provides clear when-to-use guidance (when you have a metric name and want ranked/sliced rows) and when-not-to-use (use `list_metrics` if you don't know the metric name). It also details behavior with and without `order_by`, error cases like `ambiguous_path`, and the `via` parameter for disambiguation, offering comprehensive contextual guidance.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arun-kc/schemabrain'

If you have feedback or need assistance with the MCP directory API, please join our Discord server