Skip to main content
Glama

stats

Compute count, sum, mean, median, min, max, and stddev for any measure across matching rows. Optionally group results by a dimension to get per-group statistics.

Instructions

Aggregate statistics (count, sum, mean, median, min, max, stddev) for one measure across all rows matching filters. Optionally grouped.

Without group_by: returns one stats payload over all matching rows. With group_by: returns per-group stats — much more powerful for "distribution X by Y" queries that would otherwise require N filtered calls.

Examples: # Single aggregate over NSW postcodes stats("IND_POSTCODE_MEDIAN", "median_taxable_income_2022_23", filters={"state": "nsw"}) # → {statistics: {count: 587, mean: 55017, median: 53484, ...}}

# Stats grouped by state — one call instead of 8
stats("IND_POSTCODE_MEDIAN", "median_taxable_income_2022_23",
      group_by="state")
# → {by: "state", groups: [
#     {key: "ACT", statistics: {...}},
#     {key: "NSW", statistics: {...}},
#     ...
# ]}

# Tax payable per income year across the corporate sector
stats("CORP_TRANSPARENCY", "tax_payable", group_by="income_year")

Returns: Without group_by: dict with statistics field. With group_by: dict with by and groups fields; each group carries key, statistics, plus the same envelope metadata (dataset_id, unit, attribution, etc.).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filtersNoOptional dimension filters — same shape as get_data.
measureYesThe measure key to aggregate over. Use describe_dataset() to see available measures.
group_byNoOptional dimension key to partition rows by. When set, returns per-group statistics instead of a single aggregate. Caps at 200 groups to keep responses bounded — exceeding the cap returns the first 200 groups by row order and sets a `groups_truncated` flag in the response.
dataset_idYesCurated dataset ID. Use search_datasets() / list_curated().

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

Despite no annotations, the description discloses key behaviors: return shape (with/without group_by), grouping cap at 200 groups with truncation flag, and metadata in response. It does not explicitly state idempotency or read-only nature, but the operation is clearly a read. Slight missing on side effects or auth needs, but adequate.

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?

The description is well-structured with an intro, bulleted examples, and a return section. It is fairly long but every part adds value. Slight redundancy in the example formatting, but overall good balance of detail and conciseness.

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?

Given the number of parameters and existence of output schema, the description covers main behavior, return types, and grouping semantics. It lacks error handling or edge cases like empty results, but these are minor. The output schema likely fills gaps. Adequate for effective use.

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 coverage is 100% with good descriptions. The description adds value beyond schema by providing concrete usage examples, clarifying group_by behavior and return structure. It explains what each parameter does in context, such as the meaning of group_by and the 'same envelope metadata' in returns.

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 clearly states 'Aggregate statistics (count, sum, mean, median, min, max, stddev) for one measure across all rows matching filters' with a specific verb and resource. It distinguishes itself from siblings like get_data (raw data) and top_n (top values) by focusing on aggregation and grouping.

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 explicit guidance on when to use group_by vs without, includes examples showing single aggregate vs per-group statistics, and mentions that group_by is 'much more powerful for distribution X by Y queries that would otherwise require N filtered calls.' It implicitly tells when not to use it (when raw data is needed) via sibling context.

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/Bigred97/ato-mcp'

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