UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.
Un MCP server exists for a simple reason — assistants are far more useful when they can act on Un directly instead of describing what you should do. UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.
Setup follows the usual MCP pattern — install or clone the server, register it in your client's configuration file, restart the client. The configuration blocks on this page cover the common clients.
Once Un is connected, these are the calls the assistant has available:
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 withcomtrade_search_commodities — Find HS commodity codes by keyword, partial description, or code prefix. Returns codes at 2-, 4-, or 6-digit aggregation with descriptions, parentcomtrade_list_service_categories — List EBOPS 2010 service trade categories — the services-domain equivalent of comtrade_search_commodities. Returns codes, descriptions, and parentcomtrade_get_trade_flows — Fetch bilateral trade flow records. Returns primaryValue (USD, FOB for exports / CIF for imports), quantity, net weight, and period/commodity/partnercomtrade_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 totalscomtrade_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 acomtrade_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 headingscomtrade_get_services_trade — Fetch international trade-in-services data (EBOPS 2010). Same bilateral structure as goods trade: returns flow value, period, andcomtrade_get_data_availability — Check which reporter/period/classification combinations have published data before constructing expensive queries. Returns record count andPrerequisites — The Prerequisites tool exposed by this serverInstallation — The Installation tool exposed by this serverYou will need 6 environment variables: MCP_TRANSPORT_TYPE, MCP_LOG_LEVEL, COMTRADE_SUBSCRIPTION_KEY, COMTRADE_API_BASE_URL, MCP_HTTP_ENDPOINT_PATH, MCP_PUBLIC_URL. The server will not start without them, which is usually why the tools fail to appear on a first run. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.
comtrade_lookup_countries, comtrade_search_commodities, comtrade_list_service_categories) never require a key — they queryAmong the developer tooling options, the useful question is rarely "what can it do" but "what does it cost you to run" — permissions, credentials, and how much of your context its toolset consumes. Un's toolset — comtrade_lookup_countries, comtrade_search_commodities, comtrade_list_service_categories and 8 more — is a fair guide to whether it matches your workflow. It is maintained by cyanheads; worth a glance at recent repository activity before you build anything load-bearing on it.
SyncDev reviews every entry in this directory against the project's own documentation before publishing, and revisits them as servers change.
| Tool | What it does |
|---|---|
| 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 re |
| 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 |
| 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 ra |
| 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. |
| Prerequisites | The Prerequisites tool exposed by this server. |
| Installation | The Installation tool exposed by this server. |
{
"mcpServers": {
"un-comtrade-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/un-comtrade-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"COMTRADE_SUBSCRIPTION_KEY": "your-key-here"
}
}
}
}Configuration as documented by the project. Restart the client after saving.
comtrade_lookup_countries, comtrade_search_commodities, comtrade_list_service_categories) never require a key — they query| Variable | Description | Required |
|---|---|---|
| MCP_TRANSPORT_TYPE | Configuration value read at startup. | Optional |
| MCP_LOG_LEVEL | Configuration value read at startup. | Optional |
| COMTRADE_SUBSCRIPTION_KEY | Credential the server authenticates with. | Yes |
| COMTRADE_API_BASE_URL | Endpoint or connection string the server talks to. | Yes |
| MCP_HTTP_ENDPOINT_PATH | Filesystem location the server is allowed to use. | Optional |
| MCP_PUBLIC_URL | Endpoint or connection string the server talks to. | Yes |
Kill hallucinated APIs — version-accurate, up-to-date library documentation injected straight into context.
Microsoft's official browser automation server — drive a real browser through the accessibility tree, no screenshots needed.
GitHub's official server — repos, issues, pull requests, Actions and code security, straight from your assistant.
Issue tracking at the speed of conversation — Linear's official hosted server with OAuth and zero install.
Local repository surgery — status, diffs, commits, branches and history for any repo on disk.
Timezone sanity for AI — current time anywhere and correct conversions, without the model doing date math.