Comtrade
v0.2.1Comtrade MCP — UN Comtrade API for international bilateral trade data
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
comtrade_trade_data
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", or "how did Saudi–Egypt trade move this year" (pass frequency="monthly" for month-by-month, not just last year's annual total). UN Comtrade reporter/partner codes…
| Parameter | Type | Description |
|---|---|---|
partner_code * | string | Partner country name (e.g. "China") or UN code (156=China, 0=World). Optional — defaults to World (0). Names resolved automatically. |
reporter_code * | string | Country name (e.g. "USA", "China", "Germany") or UN numeric code (US=842, China=156). Names are resolved automatically. |
year * | string | Trade period. For frequency="annual" (default): a year, e.g. "2024". For frequency="monthly": year+month as YYYYMM, e.g. "202401" for January 2024. |
cmd_code | string | Alias for hs_code — HS commodity code. Use this OR hs_code, not both. |
commodity | string | Alias for hs_code — HS commodity code. Use this OR hs_code, not both. |
commodity_code | string | Alias for hs_code — HS commodity code (e.g. "2603" for copper ores). Use this OR hs_code, not both. |
flow | string | Trade flow: "M" for imports, "X" for exports. Optional — defaults to both "M,X". |
frequency | string | Data frequency: "annual" (default) for yearly totals, or "monthly" for month-level data. Monthly coverage is thinner than annual — not every reporter files monthly, and recent months lag by reporter… |
hs | string | Alias for hs_code — HS commodity code. Use this OR hs_code, not both. |
hs_code | string | HS commodity code at 2/4/6 digit level (e.g., "8471" for computers, "2603" for copper ores). Optional — omit for all commodities. Aliases accepted: commodity_code, commodity, hs, cmd_code (pass exac… |
comtrade_top_partners
Find a country's top trading partners ranked by trade volume. Returns partner countries and total trade values. Defaults to ANNUAL; pass frequency="monthly" for a single month's ranking instead of the last full year's.
| Parameter | Type | Description |
|---|---|---|
flow * | string | Trade flow: "M" for imports, "X" for exports |
reporter_code * | string | Country name (e.g. "USA", "China") or UN numeric code (842=US). Names resolved automatically. |
year * | string | Trade period. For frequency="annual" (default): a year, e.g. "2024". For frequency="monthly": year+month as YYYYMM, e.g. "202401". |
cmd_code | string | Alias for hs_code — HS commodity code. Use this OR hs_code, not both. |
commodity | string | Alias for hs_code — HS commodity code. Use this OR hs_code, not both. |
commodity_code | string | Alias for hs_code — HS commodity code (e.g. "2603" for copper ores). Use this OR hs_code, not both. |
frequency | string | 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 fr… |
hs | string | Alias for hs_code — HS commodity code. Use this OR hs_code, not both. |
hs_code | string | 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… |
limit | number | Number of top partners to return (default 20) |
comtrade_top_commodities
Rank the products two countries actually trade, largest value first — "what does the US import most from China". 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.
| Parameter | Type | Description |
|---|---|---|
flow * | string | 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 — guessi… |
reporter_code * | string | Country name (e.g. "USA", "China") or UN numeric code (842=US). Names resolved automatically. |
year * | string | Trade period. For frequency="annual" (default): a year, e.g. "2024". For frequency="monthly": year+month as YYYYMM, e.g. "202401". |
frequency | string | 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. |
hs_level | number | 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. |
limit | number | Number of top commodities to return (default 20) |
partner_code | string | Partner country name or UN code (0=World). Optional — defaults to World. Names resolved automatically. |
comtrade_country_codes
Look up UN Comtrade reporter/partner codes for trade queries (e.g., "842" = US, "156" = China). Note Comtrade uses 842 for the US, not the ISO 840. Returns code and country name pairs.