UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
We haven't yet run this listing's install command through our automated sandbox check. This isn't a red flag β we're steadily working through the catalog.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Access UN Comtrade international merchandise and services trade statistics β country lookups, HS commodity search, bilateral trade flows, balances, rankings, and data availability β via MCP. STDIO or Streamable HTTP.
Note: The UN Comtrade license agreement (Β§5) prohibits redistributing data without prior written UN permission. Connect with your own Comtrade subscription key.
9 tools covering the full UN Comtrade workflow β reference resolution, trade data retrieval, aggregated rankings, and coverage checking:
| Tool | Description |
|---|---|
comtrade_lookup_countries | Resolve country and area names to Comtrade M49 numeric codes. Accepts partial names or ISO alpha-2/alpha-3 codes. Returns matching entries with validAsReporter flag β regional groupings are valid partner codes but not reporter codes. |
comtrade_search_commodities | Find HS commodity codes by keyword, partial description, or code prefix. Returns codes at 2-, 4-, or 6-digit aggregation with descriptions, parent code, leaf status, and a recommended_query_code field. |
comtrade_list_service_categories | List EBOPS 2010 service trade categories β the services-domain equivalent of comtrade_search_commodities. Returns codes, descriptions, and parent codes. Filter by keyword or browse from a parent code. |
comtrade_get_trade_flows | Fetch bilateral trade flow records. Returns primaryValue (USD, FOB for exports / CIF for imports), quantity, net weight, and period/commodity/partner metadata per row. Accepts multiple periods and commodity codes in one call. |
comtrade_get_trade_balance | Compute trade balance (exports minus imports) for a country over one or more periods with optional commodity filter. Fetches export and import totals in parallel; returns signed balance, component values, and coverage ratio. |
comtrade_get_top_partners | Rank trading partners for a reporter by trade value for a given commodity and flow direction. Returns top N partners sorted by descending value for a single period. |
comtrade_get_top_commodities | Rank commodity categories for a reporter by trade value for a given flow direction and period. Returns top N HS chapters (2-digit) or headings (4-digit) sorted by descending value. |
comtrade_get_services_trade | Fetch international trade-in-services data (EBOPS 2010). Same bilateral structure as goods trade: returns flow value, period, and reporter/partner/category metadata. |
comtrade_get_data_availability | Check which reporter/period/classification combinations have published data before constructing expensive queries. Returns record count and publication date per dataset. |
comtrade_lookup_countriesResolve reporter and partner codes from natural-language names or ISO identifiers.
US), or ISO alpha-3 (USA)role filter: "reporter", "partner", or "any" β narrows results to only valid reporters or all partner areasvalidAsReporter flag on each result β regional groupings (e.g., Africa, ASEAN) are valid as partners but cannot be used as reporter_codeinclude_groups to surface regional aggregate codescomtrade_search_commoditiesFind the HS code for any product before querying trade flows.
"semiconductors", "crude oil")"8471" returns the matching chapter and all descendantsaggr_level: 2 (chapters) to scope a sector, then narrow to 4 or 6 for specific headings or subheadingsrecommended_query_code field on each result β the best level for downstream comtrade_get_trade_flows callscomtrade_get_trade_flowsFetch bilateral trade records β the primary data retrieval tool.
reporter_code + flow_code (M import / X export / RX re-export / RM re-import) + period[] requiredperiod accepts annual (YYYY) or monthly (YYYYMM); pass multiple years as an array for time-series in one request (avoids multiple API calls against the 500-req/day free limit)partner_code: 0 aggregates across all partners (World total) β no partner lookup neededcmd_code[] accepts comma-separated HS codes; omit or use TOTAL for cross-commodity totalstruncated: true + hint when the cap is hit*Desc fieldscomtrade_get_trade_balanceCompute signed trade balance from parallel export + import fetches.
flowCode=X) and import (flowCode=M) requests in parallel, then computes locallybalance (USD, signed), exports, imports, and coverageRatio (exports / imports)cmd_code filter for commodity-specific balance (e.g., energy trade balance)comtrade_get_top_partnersRank trading partners by value for a single period.
limit controls N returned (default 10)comtrade_get_top_commoditiesRank commodity chapters or headings by value for a single period.
aggr_level: 2 for HS chapter ranking (21 sections), 4 for heading rankingpartner_code to scope the ranking to a specific bilateral relationshipcomtrade_get_top_partnerscomtrade_get_data_availabilityCheck data coverage before querying.
reporter_code, period, freq (A annual / M monthly), and classification filterscomtrade_get_services_tradeFetch services trade data (EBOPS 2010 classification).
comtrade_get_trade_flowsservice_code accepts an EBOPS category code β use comtrade_list_service_categories to find the right code| Type | Name | Description |
|---|---|---|
| Resource | comtrade://countries | Complete country/area code list β M49 numeric codes, ISO identifiers, validAsReporter flag, and group membership. Loaded from UN reference data at startup. |
| Resource | comtrade://hs-classification/{level} | Top-level HS commodity hierarchy at aggregation level 2 (chapters), 4 (headings), or 6 (top ~1 200 subheadings). Full leaf enumeration is too large to inject β use comtrade_search_commodities for keyword search. |
All resource data is also reachable via tools. comtrade://hs-classification/{level} provides a browsable hierarchy; for keyword resolution use comtrade_search_commodities instead.
Built on @cyanheads/mcp-ts-core:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/un-comtrade-mcp-server)<a href="https://allmcps.com/mcp/un-comtrade-mcp-server"><img src="https://allmcps.com/api/badge/un-comtrade-mcp-server?style=directory" alt="Un Comtrade MCP Server on AllMCPs" /></a>