Skip to main content
Glama

top_n

Retrieve top or bottom N records from a dataset ranked by a selected measure, with server-side sorting to avoid downloading full table.

Instructions

Return the N rows with the largest (or smallest) value of a measure.

This is the most common agent workflow: "show me the top 10 X by Y". Without this tool, an agent would call get_data, receive the full table, and then sort/slice locally — wasting tokens and turns. top_n does the rank server-side and returns only the requested rows.

Examples: # Top 10 corporate taxpayers in 2023-24 top_n("CORP_TRANSPARENCY", "tax_payable", n=10)

# 20 NSW postcodes with the highest median income (2022-23)
top_n("IND_POSTCODE_MEDIAN", "median_taxable_income_2022_23",
      filters={"state": "nsw"}, n=20)

# 5 lowest-income postcodes in QLD
top_n("IND_POSTCODE_MEDIAN", "median_taxable_income_2022_23",
      filters={"state": "qld"}, n=5, direction="bottom")

Returns: DataResponse with at most n records, sorted by measure value in the requested direction. Other fields (period, unit, attribution) match a regular get_data call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nNoHow many top (or bottom) rows to return.
filtersNoOptional dimension filters, same shape as get_data.
measureYesPlain-English measure key to rank by. Use describe_dataset() to see available measures.
directionNo'top' returns the N rows with the LARGEST measure values (highest tax payable, biggest population, etc.). 'bottom' returns the SMALLEST.top
dataset_idYesCurated dataset ID. Use search_datasets() / list_curated().

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
csvNo
unitNo
queryNo
staleNo
periodNo
sourceNoAustralian Taxation Office
ato_urlYesClick-through URL for this dataset's source page. ato-mcp legacy name — prefer source_url (canonical) for new code. Both fields are populated identically.
recordsNo
row_countNo
dataset_idYes
source_urlYesCanonical click-through URL. Same value as ato_url; both populated for backward compat.
attributionNoData sourced from the Australian Taxation Office (and, for charity data, the Australian Charities and Not-for-profits Commission) via data.gov.au. Licensed under Creative Commons Attribution 3.0 Australia (CC BY 3.0 AU). https://creativecommons.org/licenses/by/3.0/au/
dataset_nameYes
retrieved_atYes
stale_reasonNo
truncated_atNo
server_versionNo
Behavior5/5

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

With no annotations, the description fully discloses behavior: server-side ranking, returning only requested rows, sorted output, and return structure matching get_data. No contradictions.

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 well-structured with an intro, rationale, examples, and return explanation. Every sentence adds necessary context without redundancy.

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 100% schema coverage and an output schema, the description covers all necessary aspects: purpose, usage, parameters, examples, and return format. No gaps.

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%, baseline 3. The description adds value by explaining 'plain-English measure key', direction semantics, and providing detailed examples for each parameter.

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 it returns the top/bottom N rows by a measure, with explicit examples. It distinguishes itself from get_data by noting it avoids wasteful token usage.

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?

The description explicitly states when to use (most common agent workflow) and contrasts with get_data as an alternative. However, it does not explicitly list when not to use this tool.

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