Skip to main content
Glama

usda_psd_get_top_countries

Read-onlyIdempotent

Rank the top n countries by a selected USDA PSD commodity attribute for a given market year, optionally limiting results to a region or excluding aggregate groupings.

Instructions

The n countries with the largest value of one PSD attribute for a commodity and year.

One request to PSDData_GetCommodityDataByYear (every country); its records with attribute_id are sorted by value, largest first, and the first n kept, each exactly as upstream sent it. Equal values keep upstream's order. Values are compared as sent, with no unit check: each record carries its own unit_id, the unit of its value (in the recorded answers, wheat and corn 2023, every country reports an attribute in the same unit). By default nothing is excluded: PSD's country list holds groupings that rank alongside countries, above all the European Union ("E4", second in wheat production for 2023), and residual aggregates such as "T3" (Africa, NEC), "X8" (Southern Asia NEC) and "Z7" (Other Pacific Islands, NEC); exclude_groupings=True leaves those out, and region_code keeps the countries of one PSD region. The data records carry no region, so each record's country is looked up in the packaged country list; a country it lacks has no region and is left out when region_code is given. meta.vintage is the latest release among every record that was ranked, after region_code and exclude_groupings apply, not only the n returned, since each of them could have changed the order; for wheat 2023 that is "2026-10", and None when nothing was ranked. meta.published_at stays empty. Codes and arguments are checked before the call; a market year without data raises NotFoundError.

Args: commodity_code: PSD commodity code, seven digits, e.g. "0410000" (Wheat), "0440000" (Corn), "2222000" (Oilseed, Soybean). market_year: PSD market year, e.g. 2023, 2022, 2021. attribute_id: PSD attribute id to rank by, e.g. 28 (Production), 88 (Exports), 57 (Imports), 176 (Ending Stocks); list_commodity_attributes lists them. n: How many records to keep, at least 1, e.g. 5, 10 (the default); more than the countries reporting the attribute returns them all. region_code: Rank only the countries of this PSD region, as list_countries gives it, e.g. "R04" (South America), "R18" (East Asia), "R15" (Africa, NEC and three more, a region list_regions lacks). A code no packaged country carries is refused; "R00" (World) is one, and the world total is get_world_data's. Omit (None) for every region. exclude_groupings: True leaves PSD's aggregates out of the ranking: "E4" European Union, "E2" EU-15, "E3" EU-25, "C1" Caribbean Basin, "T3" Africa, NEC, "X8" Southern Asia NEC, "Z7" Other Pacific Islands, NEC and "ZZ" Other. False, the default, ranks them like countries.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "commodity_code": "<commodity_code>",
      "market_year": "<market_year>",
      "attribute_id": "<attribute_id>"
    },
    "name": "usda_psd_get_top_countries"
  }
}

Input Schema

NameRequiredDescriptionDefault
nNo
market_yearYes
region_codeNo
attribute_idYes
commodity_codeYes
exclude_groupingsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior3/5

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

Annotations already declare read-only, idempotent, open-world, non-destructive behavior, and the description goes well beyond them: sort order, tie-breaking by upstream order, no unit normalization, inclusion of EU/aggregate groupings by default, meta.vintage computed over all ranked records, meta.published_at empty, and NotFoundError on a year without data. It does not explain the shape of each returned record beyond 'exactly as upstream sent it', leaving the payload structure undocumented.

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

Conciseness3/5

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

Purpose is front-loaded, but the body is a single dense paragraph mixing ranking semantics, unit caveats, grouping codes, region lookup internals, and metadata rules. Specific trivia (the '2026-10' vintage example, the wheat/corn 2023 unit aside) adds length without helping an agent invoke the tool.

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?

With no output schema, the description does explain meta.vintage and meta.published_at and that records are returned verbatim, though it never enumerates the record fields an agent would receive. Combined with full parameter coverage and error behavior, it is nearly complete for a six-parameter ranking 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 coverage is 0%, so the description must carry all parameter meaning, and it largely does: every parameter is illustrated with example codes, the default for n and exclude_groupings, region_code refusal rules, and the edge case that n larger than the country count returns all. All six parameters are addressed with more than schema-level detail.

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?

Opens with a precise statement of the operation: the top n countries by value of one PSD attribute for a given commodity and year. It also distinguishes itself from siblings by naming get_world_data for world totals and pointing to list_commodity_attributes and list_countries/list_regions for code lookup.

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?

Gives concrete guidance on when to set region_code versus omitting it, when to set exclude_groupings, and redirects world-total queries to get_world_data. It never explicitly contrasts itself with the general usda_psd_get_data sibling, so the selection guidance is strong but not exhaustive.

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