Skip to main content
Glama

top_n

Retrieve the top or bottom N records from a WGEA dataset ranked by a numeric measure, such as number of employees or responses. Supports filtering by dimensions and reporting year for targeted analysis.

Instructions

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

Ranks across one WGEA reporting year (the latest by default, or a specific year via reporting_year=). This is the most common agent workflow — "show me the top 10 X by Y" — collapsed into a single server-side call: rank-and-slice happens on the server so the agent never has to fetch a full table just to take the top of it.

Examples: # 10 employers with the most women managers (latest reporting year) top_n("WORKFORCE_COMPOSITION", "n_employees", n=10, filters={"gender": "Women", "manager_category": "Manager"})

# 5 ANZSIC divisions with the fewest Yes responses on Gender Pay Gap
top_n("GENDER_EQUALITY_ACTIONS", "n_responses", n=5, direction="bottom",
      filters={"section": "Gender Pay Gap", "response": "Yes"})

# Top 5 employers in Mining by total workforce in 2023-24
top_n("WORKFORCE_COMPOSITION", "n_employees", n=5,
      filters={"anzsic_division": "Mining"},
      reporting_year="2023-24")

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataset_idYesCurated dataset ID. Use search_datasets() / list_curated().
measureYesNumeric measure column to rank by. WGEA measures are `n_employees` (WORKFORCE_COMPOSITION, WORKFORCE_MANAGEMENT) or `n_responses` (the other five questionnaire datasets). Use describe_dataset() to confirm.
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 n_employees, biggest n_responses, etc.). 'bottom' returns the SMALLEST.top
reporting_yearNoOptional single WGEA reporting year to restrict the ranking to. Format: 'YYYY-YY' (e.g. '2024-25') or 'YYYY' (e.g. '2024'). Defaults to the latest reporting year present in the data so the rank is a clean 'top N at the current reporting year' view.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataset_idYes
dataset_nameYes
queryNo
reporting_yearNo
periodNoCanonical period bounds {start, end} for cross-sister consumers. Populated alongside the wgea-specific reporting_year. For a single reporting year both bounds match; for multi-year spans they bracket the range.
unitNo
row_countNo
recordsNo
csvNo
sourceNoWorkplace Gender Equality Agency
attributionNoSource: Workplace Gender Equality Agency. Licensed under Creative Commons Attribution 3.0 Australia (https://creativecommons.org/licenses/by/3.0/au/). Original dataset: https://data.gov.au/data/dataset/wgea-dataset
retrieved_atYes
source_urlYes
download_urlNo
did_you_meanNo
staleNo
stale_reasonNo
truncated_atNo
server_versionNo
Behavior4/5

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

No annotations are provided, so description carries full burden. It clearly describes the tool as a query returning sorted data, with examples showing data retrieval. It does not explicitly state it's read-only, but the behavior is evident from context. Could be more explicit about no side effects.

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: core functionality, contextual explanation, then examples. Each sentence adds value. No wasted words, and it is front-loaded with the key purpose.

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 6 parameters (2 required) and presence of output schema, the description covers purpose, parameter details, usage context, and examples comprehensively. No additional information is needed for correct invocation.

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?

With 100% schema description coverage, baseline is 3. The description adds value by explaining measure types, default reporting year, and providing detailed examples that demonstrate parameter combinations, going beyond schema 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 clearly states the tool returns the N rows with largest/smallest value of a measure. It uses specific verb 'return' and resource 'N rows', distinguishes from siblings by noting it's a single server-side call avoiding full table fetch, and provides multiple examples.

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 notes this is the most common agent workflow for 'top 10 X by Y' and explains the advantage of server-side rank-and-slice. It implies get_data is the alternative for full data but does not explicitly state when not to use top_n, earning a 4.

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/wgea-mcp'

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