Skip to main content
Glama

Comtrade Top Commodities

comtrade_top_commodities
Read-onlyIdempotent

Rank the products a country actually trades, largest value first — "what are Thailand's biggest exports", "what does Brazil import most", "what does the US import most from China". Works for any country as reporter (a name or UN code); the partner is optional and defaults to World (all trading partners), so a one-country question needs no second country. Returns HS categories with trade value and net weight. Defaults to HS 2-digit chapters (~97 categories, e.g. 85 Electrical machinery); pass hs_level 4 or 6 for finer product detail.

Input Schema

NameRequiredDescriptionDefault
flowYesTrade flow, REQUIRED because it decides what the answer MEANS: "X" for exports (what a country SELLS / ships abroad) or "M" for imports (what it BUYS / receives). Deliberately not defaulted — guessing returns imports for an export question, which reads as a confident wrong answer instead of an error.
yearYesTrade period. For frequency="annual" (default): a year, e.g. "2024". For frequency="monthly": year+month as YYYYMM, e.g. "202401".
limitNoNumber of top commodities to return (default 20)
hs_levelNoHS aggregation level: 2 for chapters (default, ~97 broad categories), 4 for headings, 6 for subheadings. Higher numbers give finer product detail and many more rows.
frequencyNoData frequency: "annual" (default) or "monthly". Monthly coverage is thinner — not every reporter files monthly, and recent months lag. When "monthly", pass `year` as YYYYMM.
partner_codeNoPartner country name or UN code (0=World). Optional — defaults to World. Names resolved automatically.
reporter_codeYesCountry name (e.g. "USA", "China") or UN numeric code (842=US). Names resolved automatically.

Output Schema

NameRequiredDescriptionDefault
flowYesTrade flow type (Imports or Exports)
yearYesTrade year queried
partnerYesPartner country name
reporterYesReporting country name
top_commoditiesYes
total_commoditiesYesTotal number of top commodities returned

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / frequency
      Added value: +{
      +  "description": "Data frequency: \"annual\" (default) or \"monthly\". Monthly coverage is thinner — not every reporter files monthly, and recent months lag. When \"monthly\", pass `year` as YYYYMM.",
      +  "type": "string"
      +}
    • changedInput schema / properties / year / description
      Previous value: -"Trade year (e.g., \"2024\")"New value: +"Trade period. For frequency=\"annual\" (default): a year, e.g. \"2024\". For frequency=\"monthly\": year+month as YYYYMM, e.g. \"202401\"."
  2. Changed2 schema fields changed
    • changedInput schema / properties / flow / description
      Previous value: -"Trade flow: \"M\" for imports, \"X\" for exports"New value: +"Trade flow, REQUIRED because it decides what the answer MEANS: \"X\" for exports (what a country SELLS / ships abroad) or \"M\" for imports (what it BUYS / receives). Deliberately not defaulted — guessing returns imports for an export question, which reads as a confident wrong answer instead of an error."
    • changedInput schema / required
      Previous value: -[
      -  "reporter_code",
      -  "partner_code",
      -  "year",
      -  "flow"
      -]New value: +[
      +  "reporter_code",
      +  "year",
      +  "flow"
      +]
  3. Changed1 schema field changed
    • addedInput schema / properties / hs_level
      Added value: +{
      +  "description": "HS aggregation level: 2 for chapters (default, ~97 broad categories), 4 for headings, 6 for subheadings. Higher numbers give finer product detail and many more rows.",
      +  "type": "number"
      +}
  4. Changed2 schema fields changed
    • changedInput schema / properties / partner_code / description
      Previous value: -"ISO numeric country code for the partner country"New value: +"Partner country name or UN code (0=World). Optional — defaults to World. Names resolved automatically."
    • changedInput schema / properties / reporter_code / description
      Previous value: -"ISO numeric country code for the reporting country"New value: +"Country name (e.g. \"USA\", \"China\") or UN numeric code (842=US). Names resolved automatically."
  5. Changed1 schema field changed
    • changedInput schema / examples
      Previous value: -[
      -  {
      -    "flow": "M",
      -    "limit": 15,
      -    "partner_code": "156",
      -    "reporter_code": "840",
      -    "year": "2024"
      -  },
      -  {
      -    "flow": "X",
      -    "partner_code": "840",
      -    "reporter_code": "392",
      -    "year": "2023"
      -  }
      -]New value: +[
      +  {
      +    "flow": "M",
      +    "limit": 15,
      +    "partner_code": "156",
      +    "reporter_code": "842",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "X",
      +    "partner_code": "842",
      +    "reporter_code": "392",
      +    "year": "2023"
      +  }
      +]
  6. Changed3 schema fields changed
    • removedOutput schema / properties / top_commodities / description
      Removed value: -"List of top traded commodities ranked by value"
    • changedOutput schema / properties / top_commodities / items / properties / commodity / description
      Previous value: -"Commodity description"New value: +"Commodity description or code"
    • changedOutput schema / properties / top_commodities / items / properties / trade_value_usd / description
      Previous value: -"Trade value for this commodity in USD"New value: +"Trade value in USD"
  7. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "flow": {
      +      "description": "Trade flow type (Imports or Exports)",
      +      "type": "string"
      +    },
      +    "partner": {
      +      "description": "Partner country name",
      +      "type": "string"
      +    },
      +    "reporter": {
      +      "description": "Reporting country name",
      +      "type": "string"
      +    },
      +    "top_commodities": {
      +      "description": "List of top traded commodities ranked by value",
      +      "items": {
      +        "properties": {
      +          "commodity": {
      +            "description": "Commodity description",
      +            "type": "string"
      +          },
      +          "hs_code": {
      +            "description": "HS commodity code",
      +            "type": "string"
      +          },
      +          "net_weight_kg": {
      +            "description": "Net weight in kilograms",
      +            "type": "number"
      +          },
      +          "rank": {
      +            "description": "Commodity rank by trade value",
      +            "type": "number"
      +          },
      +          "trade_value_usd": {
      +            "description": "Trade value for this commodity in USD",
      +            "type": "number"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "total_commodities": {
      +      "description": "Total number of top commodities returned",
      +      "type": "number"
      +    },
      +    "year": {
      +      "description": "Trade year queried",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "reporter",
      +    "partner",
      +    "year",
      +    "flow",
      +    "total_commodities",
      +    "top_commodities"
      +  ],
      +  "type": "object"
      +}
  8. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "flow": "M",
      +    "limit": 15,
      +    "partner_code": "156",
      +    "reporter_code": "840",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "X",
      +    "partner_code": "840",
      +    "reporter_code": "392",
      +    "year": "2023"
      +  }
      +]
  9. First observed

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnly, idempotent, openWorld and non-destructive, so the safety profile is covered. The description adds useful operational context — World default for partner, ~97 categories at HS 2, and thinner monthly coverage with reporting lag — but does not discuss rate limits or result size behavior beyond row counts.

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?

Front-loaded with the action and example questions, then defaults and caveats in a sensible order. Mostly efficient, though the HS-level and World-default material duplicates the schema's own parameter descriptions.

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?

An output schema exists, so return-value explanation is not required, and the description still previews the payload (HS categories, trade value, net weight). Combined with the defaults and monthly-coverage caveat, an agent has enough to call this correctly; only explicit sibling routing is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all seven parameters, including flow, hs_level and frequency. The description repeats the hs_level defaults (~97 chapters) and the World partner default without adding new syntax or value semantics beyond what the schema states, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a concrete verb and resource ('Rank the products a country actually trades, largest value first') and grounds it with three example questions plus the return shape (HS categories with trade value and net weight). It differentiates implicitly from comtrade_top_partners by being about products rather than partners, but never names the sibling explicitly, so it falls short of a 5.

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 clear usage context — one-country questions need no second country because partner_code defaults to World, and hs_level 4/6 is signposted for finer detail. It does not state when to prefer comtrade_trade_data or comtrade_top_partners instead, so there are no explicit exclusions.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.