Skip to main content
Glama

Comtrade Trade Data

comtrade_trade_data
Read-onlyIdempotent

AUTHORITATIVE bilateral trade data between two countries from UN Comtrade — the official international-trade statistics database (every country's customs filings, harmonized). Returns trade values USD, quantities, and HS commodity-level detail for imports and exports between reporter + partner. Use for "how much X did US import from China in 2024", "what does Germany export to Brazil", "Mexico's top trade partners by commodity". UN Comtrade reporter/partner codes (842=US — Comtrade uses 842, NOT the ISO 840; 156=China, 276=Germany, 0=World — see comtrade_country_codes). Annual data, lags ~3 months from reporting period.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
flowNoTrade flow: "M" for imports, "X" for exports. Optional — defaults to both "M,X".
yearYesTrade year (e.g., "2024")
hs_codeNoHS commodity code at 2/4/6 digit level (e.g., "8471" for computers). Optional — omit for all commodities.
partner_codeYesPartner country name (e.g. "China") or UN code (156=China, 0=World). Optional — defaults to World (0). Names resolved automatically.
reporter_codeYesCountry name (e.g. "USA", "China", "Germany") or UN numeric code (US=842, China=156). Names are resolved automatically.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNoTrade year queried
countNoNumber of trade records returned
recordsNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed4 schema fields changed
    • changedOutput schema / properties / records / items / properties / net_weight_kg / type
      Previous value: -"number"New value: +[
      +  "number",
      +  "null"
      +]
    • changedOutput schema / properties / records / items / properties / quantity / type
      Previous value: -"number"New value: +[
      +  "number",
      +  "null"
      +]
    • changedOutput schema / properties / records / items / properties / quantity_unit / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / required
      Removed value: -[
      -  "count",
      -  "year",
      -  "records"
      -]
  2. Changed2 schema fields changed
    • changedInput schema / properties / partner_code / description
      Previous value: -"ISO numeric country code for the partner country (e.g., \"156\" for China, \"0\" for World)"New value: +"Partner country name (e.g. \"China\") or UN code (156=China, 0=World). Optional — defaults to World (0). Names resolved automatically."
    • changedInput schema / properties / reporter_code / description
      Previous value: -"ISO numeric country code for the reporting country (e.g., \"842\" for US, \"156\" for China)"New value: +"Country name (e.g. \"USA\", \"China\", \"Germany\") or UN numeric code (US=842, China=156). Names are resolved automatically."
  3. Changed1 schema field changed
    • changedInput schema / examples
      Previous value: -[
      -  {
      -    "partner_code": "156",
      -    "reporter_code": "840",
      -    "year": "2024"
      -  },
      -  {
      -    "flow": "M",
      -    "hs_code": "8471",
      -    "partner_code": "156",
      -    "reporter_code": "840",
      -    "year": "2023"
      -  }
      -]New value: +[
      +  {
      +    "partner_code": "156",
      +    "reporter_code": "842",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "hs_code": "8471",
      +    "partner_code": "156",
      +    "reporter_code": "842",
      +    "year": "2023"
      +  }
      +]
  4. Changed3 schema fields changed
    • removedOutput schema / properties / records / description
      Removed value: -"Array of bilateral trade records"
    • changedOutput schema / properties / records / items / properties / commodity / description
      Previous value: -"Commodity description"New value: +"Commodity description or code"
    • changedOutput schema / properties / records / items / properties / quantity / description
      Previous value: -"Quantity traded"New value: +"Trade quantity"
  5. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "count": {
      +      "description": "Number of trade records returned",
      +      "type": "number"
      +    },
      +    "records": {
      +      "description": "Array of bilateral trade records",
      +      "items": {
      +        "properties": {
      +          "commodity": {
      +            "description": "Commodity description",
      +            "type": "string"
      +          },
      +          "commodity_code": {
      +            "description": "HS commodity code",
      +            "type": "string"
      +          },
      +          "flow": {
      +            "description": "Trade flow type (Imports, Exports, Re-exports, Re-imports)",
      +            "type": "string"
      +          },
      +          "net_weight_kg": {
      +            "description": "Net weight in kilograms",
      +            "type": "number"
      +          },
      +          "partner": {
      +            "description": "Partner country name",
      +            "type": "string"
      +          },
      +          "quantity": {
      +            "description": "Quantity traded",
      +            "type": "number"
      +          },
      +          "quantity_unit": {
      +            "description": "Unit of quantity measurement",
      +            "type": "string"
      +          },
      +          "reporter": {
      +            "description": "Reporting country name",
      +            "type": "string"
      +          },
      +          "trade_value_usd": {
      +            "description": "Trade value in USD",
      +            "type": "number"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "year": {
      +      "description": "Trade year queried",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "count",
      +    "year",
      +    "records"
      +  ],
      +  "type": "object"
      +}
  6. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "partner_code": "156",
      +    "reporter_code": "840",
      +    "year": "2024"
      +  },
      +  {
      +    "flow": "M",
      +    "hs_code": "8471",
      +    "partner_code": "156",
      +    "reporter_code": "840",
      +    "year": "2023"
      +  }
      +]
  7. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already guarantee read-only and non-destructive behavior, so the description's additional context is valuable: it discloses data lags (~3 months), the critical code discrepancy (Comtrade uses 842 not 840 for US), and the data source's authority. No contradictions with annotations.

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 description is dense but not bloated, packing authority, return values, examples, a code caveat, and data lag into a few sentences. Minor repetition ('AUTHORITATIVE' + 'official international-trade statistics database') prevents a perfect score.

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?

The description is thorough for a data-retrieval tool: it covers the data source, scope, output types, example questions, and important caveats (codes, annual data, lag). With an output schema present and rich annotations, no critical information is missing.

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 covers 100% of parameter descriptions, but the description adds essential nuance beyond the schema by explaining the Comtrade-specific country codes and warning against common ISO code mistakes. This directly aids correct parameter values.

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?

Clearly states the tool retrieves authoritative bilateral trade data from UN Comtrade, with specific details on what it returns (values USD, quantities, HS detail). The phrase 'bilateral trade data between two countries' distinguishes it from sibling tools like comtrade_top_partners and comtrade_top_commodities.

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?

Provides concrete usage examples ('how much X did US import from China in 2024', 'what does Germany export to Brazil') that convey when to use the tool. It does not explicitly state when not to use it or name alternative sibling tools, though the 'see comtrade_country_codes' reference hints at a related resource.

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.

TDQS

A3.8/5.0
Disambiguation3/5

Some tools have near-identical purposes (ask_pipeworx vs ask_pipeworx_beta are currently identical; polymarket_arbitrage vs polymarket_edges both find opportunities), but detailed descriptions and distinct input patterns mostly help an agent choose. A few discovery/verification tools (suggest_questions vs discover_tools, validate_claim vs ask_pipeworx_grounded) also overlap, creating residual ambiguity.

Naming Consistency3/5

All names are snake_case and many use domain prefixes (comtrade_, polymarket_, pipeworx_), but the set mixes verb_noun (compare_entities, discover_tools), bare verbs (remember, forget, subscribe), and noun phrases (entity_profile, recent_changes). This inconsistency, plus the use of domain-specific prefixes as a substitute for a uniform verb_noun style, makes the naming pattern only moderately predictable.

Tool Count2/5

35 tools is well beyond the typical well-scoped range, and the vast majority (prediction markets, memory, subscriptions, feedback, npm dependency checks) have nothing to do with the server's apparent Comtrade trade-data purpose. This bloat makes the set feel unfocused, even though some meta-tools serve a general data-access mission.

Completeness4/5

For the Comtrade trade-data domain, the four comtrade_* tools cover country codes, top commodities, top partners, and detailed bilateral trade values — enough for most queries, with minor gaps like time-series trends or tariff lookups. For the broader Pipeworx data-access scope, the set is extensive (ask_pipeworx, deep_research, entity_profile, validate_claim, subscriptions), so no severe dead ends are apparent.