Skip to main content
Glama

Comtrade Top Partners

comtrade_top_partners
Read-onlyIdempotent

Rank the partner COUNTRIES a country trades with, largest value first: "which countries does the US import the most electrical machinery from", "who supplies Japan with crude oil", "Germany's biggest export markets for cars", "Brazil's top soybean buyers", "the US's top trading partners". Pass hs_code (an HS chapter or heading, e.g. "85" electrical machinery and electronics, "84" machinery, "27" mineral fuels and oil, "30" pharmaceuticals, "87" vehicles, "8542" integrated circuits) to rank the partners for ONE product; omit it to rank them on all goods. flow "M" ranks the countries the reporter imports from (its suppliers), "X" the countries it exports to (its markets). Returns each partner country with its UN code and trade value in USD. Defaults to ANNUAL; pass frequency="monthly" for a single month's ranking instead of the last full year's.

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": "X",
      "year": "2024",
      "limit": 10,
      "reporter_code": "842"
    },
    "name": "comtrade_top_partners"
  }
}

Input Schema

NameRequiredDescriptionDefault
hsNoAlias for hs_code, HS commodity code. Use this OR hs_code, not both.
flowYesTrade flow: "M" for imports, "X" for exports
yearYesTrade period. For frequency="annual" (default): a year, e.g. "2024". For frequency="monthly": year+month as YYYYMM, e.g. "202401".
limitNoNumber of top partners to return (default 20)
hs_codeNoOptional HS commodity code to filter by specific product (e.g. "2603" for copper ores), omit for all commodities (TOTAL). Aliases accepted: commodity_code, commodity, hs, cmd_code (pass exactly one).
cmd_codeNoAlias for hs_code, HS commodity code. Use this OR hs_code, not both.
commodityNoAlias for hs_code, HS commodity code. Use this OR hs_code, not both.
frequencyNoData frequency: "annual" (default) or "monthly". Monthly coverage is thinner, not every reporter files monthly, and recent months lag; a reporter with no filing for the requested month is absent from the ranking, not shown at zero. When "monthly", pass `year` as YYYYMM.
reporter_codeYesCountry name (e.g. "USA", "China") or UN numeric code (842=US). Names resolved automatically.
commodity_codeNoAlias for hs_code, HS commodity code (e.g. "2603" for copper ores). Use this OR hs_code, not both.

Output Schema

NameRequiredDescriptionDefault
flowYesTrade flow type (Imports or Exports)
yearYesTrade year queried
reporterYesReporting country name
top_partnersYes
total_partnersYesTotal number of top partners returned

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / examples
      Previous value: -[
      -  {
      -    "flow": "X",
      -    "limit": 10,
      -    "reporter_code": "842",
      -    "year": "2024"
      -  },
      -  {
      -    "flow": "M",
      -    "reporter_code": "156",
      -    "year": "2023"
      -  },
      -  {
      -    "flow": "X",
      -    "frequency": "monthly",
      -    "limit": 5,
      -    "reporter_code": "682",
      -    "year": "202401"
      -  },
      -  {
      -    "commodity_code": "2603",
      -    "flow": "M",
      -    "limit": 5,
      -    "reporter_code": "China",
      -    "year": "2024"
      -  }
      -]New value: +[
      +  {
      +    "flow": "X",
      +    "limit": 10,
      +    "reporter_code": "842",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "reporter_code": "156",
      +    "year": "2023"
      +  },
      +  {
      +    "flow": "X",
      +    "frequency": "monthly",
      +    "limit": 5,
      +    "reporter_code": "682",
      +    "year": "202401"
      +  },
      +  {
      +    "commodity_code": "2603",
      +    "flow": "M",
      +    "limit": 5,
      +    "reporter_code": "China",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "hs_code": "85",
      +    "limit": 5,
      +    "reporter_code": "842",
      +    "year": "2024"
      +  }
      +]
  2. Changed6 schema fields changed
    • changedInput schema / properties / cmd_code / description
      Previous value: -"Alias for hs_code — HS commodity code. Use this OR hs_code, not both."New value: +"Alias for hs_code, HS commodity code. Use this OR hs_code, not both."
    • changedInput schema / properties / commodity / description
      Previous value: -"Alias for hs_code — HS commodity code. Use this OR hs_code, not both."New value: +"Alias for hs_code, HS commodity code. Use this OR hs_code, not both."
    • changedInput schema / properties / commodity_code / description
      Previous value: -"Alias for hs_code — HS commodity code (e.g. \"2603\" for copper ores). Use this OR hs_code, not both."New value: +"Alias for hs_code, HS commodity code (e.g. \"2603\" for copper ores). Use this OR hs_code, not both."
    • 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; a reporter with no filing for the requested month is absent from the ranking, not shown at zero. 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; a reporter with no filing for the requested month is absent from the ranking, not shown at zero. When \"monthly\", pass `year` as YYYYMM."
    • changedInput schema / properties / hs / description
      Previous value: -"Alias for hs_code — HS commodity code. Use this OR hs_code, not both."New value: +"Alias for hs_code, HS commodity code. Use this OR hs_code, not both."
    • changedInput schema / properties / hs_code / description
      Previous value: -"Optional HS commodity code to filter by specific product (e.g. \"2603\" for copper ores) — omit for all commodities (TOTAL). Aliases accepted: commodity_code, commodity, hs, cmd_code (pass exactly one)."New value: +"Optional HS commodity code to filter by specific product (e.g. \"2603\" for copper ores), omit for all commodities (TOTAL). Aliases accepted: commodity_code, commodity, hs, cmd_code (pass exactly one)."
  3. Changed6 schema fields changed
    • changedInput schema / examples
      Previous value: -[
      -  {
      -    "flow": "X",
      -    "limit": 10,
      -    "reporter_code": "842",
      -    "year": "2024"
      -  },
      -  {
      -    "flow": "M",
      -    "reporter_code": "156",
      -    "year": "2023"
      -  },
      -  {
      -    "flow": "X",
      -    "frequency": "monthly",
      -    "limit": 5,
      -    "reporter_code": "682",
      -    "year": "202401"
      -  }
      -]New value: +[
      +  {
      +    "flow": "X",
      +    "limit": 10,
      +    "reporter_code": "842",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "reporter_code": "156",
      +    "year": "2023"
      +  },
      +  {
      +    "flow": "X",
      +    "frequency": "monthly",
      +    "limit": 5,
      +    "reporter_code": "682",
      +    "year": "202401"
      +  },
      +  {
      +    "commodity_code": "2603",
      +    "flow": "M",
      +    "limit": 5,
      +    "reporter_code": "China",
      +    "year": "2024"
      +  }
      +]
    • addedInput schema / properties / cmd_code
      Added value: +{
      +  "description": "Alias for hs_code — HS commodity code. Use this OR hs_code, not both.",
      +  "type": "string"
      +}
    • addedInput schema / properties / commodity
      Added value: +{
      +  "description": "Alias for hs_code — HS commodity code. Use this OR hs_code, not both.",
      +  "type": "string"
      +}
    • addedInput schema / properties / commodity_code
      Added value: +{
      +  "description": "Alias for hs_code — HS commodity code (e.g. \"2603\" for copper ores). Use this OR hs_code, not both.",
      +  "type": "string"
      +}
    • addedInput schema / properties / hs
      Added value: +{
      +  "description": "Alias for hs_code — HS commodity code. Use this OR hs_code, not both.",
      +  "type": "string"
      +}
    • changedInput schema / properties / hs_code / description
      Previous value: -"Optional HS commodity code to filter by specific product"New value: +"Optional HS commodity code to filter by specific product (e.g. \"2603\" for copper ores) — omit for all commodities (TOTAL). Aliases accepted: commodity_code, commodity, hs, cmd_code (pass exactly one)."
  4. Changed3 schema fields changed
    • changedInput schema / examples
      Previous value: -[
      -  {
      -    "flow": "X",
      -    "limit": 10,
      -    "reporter_code": "842",
      -    "year": "2024"
      -  },
      -  {
      -    "flow": "M",
      -    "reporter_code": "156",
      -    "year": "2023"
      -  }
      -]New value: +[
      +  {
      +    "flow": "X",
      +    "limit": 10,
      +    "reporter_code": "842",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "reporter_code": "156",
      +    "year": "2023"
      +  },
      +  {
      +    "flow": "X",
      +    "frequency": "monthly",
      +    "limit": 5,
      +    "reporter_code": "682",
      +    "year": "202401"
      +  }
      +]
    • 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; a reporter with no filing for the requested month is absent from the ranking, not shown at zero. 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\"."
  5. Changed1 schema field changed
    • changedInput schema / properties / reporter_code / description
      Previous value: -"ISO numeric country code (e.g., \"842\" for US)"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": "X",
      -    "limit": 10,
      -    "reporter_code": "840",
      -    "year": "2024"
      -  },
      -  {
      -    "flow": "M",
      -    "reporter_code": "156",
      -    "year": "2023"
      -  }
      -]New value: +[
      +  {
      +    "flow": "X",
      +    "limit": 10,
      +    "reporter_code": "842",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "reporter_code": "156",
      +    "year": "2023"
      +  }
      +]
  7. Changed3 schema fields changed
    • removedOutput schema / properties / top_partners / description
      Removed value: -"List of top trading partners ranked by trade value"
    • changedOutput schema / properties / top_partners / items / properties / partner_code / description
      Previous value: -"ISO numeric country code"New value: +"Partner ISO numeric country code"
    • changedOutput schema / properties / top_partners / items / properties / trade_value_usd / description
      Previous value: -"Trade value with this partner 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"
      +    },
      +    "reporter": {
      +      "description": "Reporting country name",
      +      "type": "string"
      +    },
      +    "top_partners": {
      +      "description": "List of top trading partners ranked by trade value",
      +      "items": {
      +        "properties": {
      +          "commodity": {
      +            "description": "Commodity code or description",
      +            "type": "string"
      +          },
      +          "partner": {
      +            "description": "Partner country name",
      +            "type": "string"
      +          },
      +          "partner_code": {
      +            "description": "ISO numeric country code",
      +            "type": "number"
      +          },
      +          "rank": {
      +            "description": "Partner rank by trade value",
      +            "type": "number"
      +          },
      +          "trade_value_usd": {
      +            "description": "Trade value with this partner in USD",
      +            "type": "number"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "total_partners": {
      +      "description": "Total number of top partners returned",
      +      "type": "number"
      +    },
      +    "year": {
      +      "description": "Trade year queried",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "reporter",
      +    "year",
      +    "flow",
      +    "total_partners",
      +    "top_partners"
      +  ],
      +  "type": "object"
      +}
  9. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "flow": "X",
      +    "limit": 10,
      +    "reporter_code": "840",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "reporter_code": "156",
      +    "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 cover the safety profile (readOnly, idempotent, openWorld, non-destructive), and the description adds real behavior: results are ordered largest value first, each partner comes back with a UN code and USD value, and monthly coverage is thin with non-filing reporters absent rather than zero. That last point is the kind of caveat an agent could not infer from structured fields.

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 core action and ranking order, then parameters, then defaults. The parenthetical HS code list is long and partly redundant with the schema examples, but each item genuinely helps an agent without HS knowledge pick a code.

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?

For a 10-parameter tool with an output schema, everything an agent needs to call it correctly is present: required inputs, the alias caveat, flow semantics, frequency defaults and their data caveats, and what the ranking contains. Nothing material is left to inference.

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 3 is the baseline, but the description adds meaning beyond it by glossing flow from the analytical angle ("M" = the countries the reporter imports from, i.e. its suppliers) and by giving hs_code with concrete code-to-product mappings ("85" electronics, "27" fuels, "8542" integrated circuits). The annual/monthly year-format distinction is also restated usefully.

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?

Specific verb+resource: "Rank the partner COUNTRIES a country trades with, largest value first," with five concrete query examples that pin down the shape of the answer. It is clearly differentiated from the implied inverse tool (ranking commodities) by stating it ranks partners for one product or all goods.

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 explicit usage branches: pass hs_code to rank for ONE product, omit it to rank on all goods; flow "M" for suppliers vs "X" for markets; default annual vs frequency="monthly". It does not name the sibling comtrade_top_commodities as the alternative for the inverse question, which is the only gap.

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.