Skip to main content
Glama

top_n

Fetch the top or bottom N records from an ATO dataset, ranked by a chosen measure, using server-side sorting to save tokens and time.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataset_idYes
dataset_nameYes
queryNo
periodNo
unitNo
row_countNo
recordsNo
csvNo
sourceNoAustralian Taxation Office
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/
retrieved_atYes
ato_urlYes
server_versionNo
Behavior4/5

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

Describes return structure (DataResponse, at most n records, sorted by measure, other fields match get_data). Mentions server-side execution. No annotations present, so description carries burden; covers safety (no mutation implied) but could mention read-only or auth requirements.

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?

Well-structured with clear sections: purpose, rationale, examples, returns. Every sentence adds value. Concise yet comprehensive.

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?

Covers main behavior, examples, and parameter usage. Output schema exists, so return details are handled. Could mention edge cases like no results or invalid dataset, but overall sufficient for the tool's simplicity.

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%, so baseline is 3. Description adds valuable examples for each parameter and explains the direction parameter clearly. The examples provide context beyond schema definitions.

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?

Clearly states 'Return the N rows with the largest (or smallest) value of a measure' using specific verbs and resource. Distinguishes from get_data by explaining server-side ranking saves tokens and turns.

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?

Explicitly identifies this as the most common agent workflow and explains when to use (ranking queries). Provides multiple examples. Could strengthen by naming alternatives like get_data or stats, but examples implicitly cover usage.

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