Un MCP Server

UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.

Local serverstdio

What is the Un MCP Server?

UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.

What you get

Configuration and credentials

  • Bun v1.3.0 or higher (or Node.js v24+). - Optional: a UN Comtrade subscription key for full API access. Without one, all tools fall back to the public preview endpoint (500 records/call). Reference/lookup tools (comtrade_lookup_countries, comtrade_search_commodities, comtrade_list_service_categories) never require a key — they query

More MCP options

Compare MCP servers by category, or browse hosted MCP servers if you prefer an endpoint over a local process.

Maintainer setup documentation.

Recorded tools

Check the linked publisher documentation and your connected client's tool list. Names and availability can vary with the server version and account permissions.

ToolWhat it does
comtrade_lookup_countriesResolve 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_commoditiesFind 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_categoriesList 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_flowsFetch 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_balanceCompute 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_partnersRank 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_commoditiesRank 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_tradeFetch 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_availabilityCheck which reporter/period/classification combinations have published data before constructing expensive queries. Returns record count and publication date per dataset.

How to install the Un MCP 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.

Configuration

  • Bun v1.3.0 or higher (or Node.js v24+). - Optional: a UN Comtrade subscription key for full API access. Without one, all tools fall back to the public preview endpoint (500 records/call). Reference/lookup tools (comtrade_lookup_countries, comtrade_search_commodities, comtrade_list_service_categories) never require a key — they query
VariableDescriptionRequired
MCP_TRANSPORT_TYPEConfiguration value read at startup.Optional
MCP_LOG_LEVELConfiguration value read at startup.Optional
COMTRADE_SUBSCRIPTION_KEYCredential the server authenticates with.Yes
COMTRADE_API_BASE_URLEndpoint or connection string the server talks to.Yes
MCP_HTTP_ENDPOINT_PATHFilesystem location the server is allowed to use.Optional
MCP_PUBLIC_URLEndpoint or connection string the server talks to.Yes

Example prompts to try

  • “Use Un to comtrade lookup countries.”
  • “Use Un to comtrade search commodities.”
  • “Use Un to comtrade list service categories.”

Frequently asked questions

UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings. Confirm the tools offered by your installed version in the connected client. Tool availability and permissions depend on the server and account configuration.