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.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "flow": "M",
      "year": "2024",
      "limit": 15,
      "partner_code": "156",
      "reporter_code": "842"
    },
    "name": "comtrade_top_commodities"
  }
}

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. Changed3 schema fields changed
    • changedInput schema / properties / flow / description
      Previous 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."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 / properties / frequency / description
      Previous value: -"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."New value: +"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."
    • changedInput schema / properties / partner_code / description
      Previous value: -"Partner country name or UN code (0=World). Optional — defaults to World. Names resolved automatically."New value: +"Partner country name or UN code (0=World). Optional, defaults to World. Names resolved automatically."
  2. 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\"."
  3. 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"
      +]
  4. 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"
      +}
  5. 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."
  6. 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"
      +  }
      +]
  7. 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"
  8. 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"
      +}
  9. 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"
      +  }
      +]
  10. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnly/openWorld/idempotent/non-destructive, so the safety profile is covered. The description adds genuine behavioral context beyond that: what is returned (HS categories with trade value and net weight), the default granularity (~97 chapters at HS 2-digit) and the fact that finer levels produce "many more rows".

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?

The core action is front-loaded, then routing examples, then return shape and defaults — a sensible order. The quoted example questions cost some space but do real routing work; only the parenthetical chapter example borders on optional.

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?

With an output schema covering return values and annotations covering safety, the description supplies everything else an agent needs: reporter/partner semantics, the World default, default granularity and the cost of raising hs_level. Nothing material is missing 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?

Schema coverage is 100%, so the baseline is 3; the description still earns extra by restating the partner-defaults-to-World behavior and explaining what hs_level actually changes (2-digit chapters vs finer headings with far more rows). It adds meaning rather than echoing the schema.

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 specific verb+resource+ordering ("Rank the products a country actually trades, largest value first") and reinforces it with concrete natural-language questions ("what are Thailand's biggest exports"). An agent can immediately tell this ranks commodities by value, as distinct from the partner-ranking sibling.

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 situational triggers via three example questions, and explicitly resolves the main ambiguity: "the partner is optional and defaults to World ... so a one-country question needs no second country." It does not name a sibling alternative for cases where the agent actually wants partner breakdown, which keeps it short of a 5.

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.