un-comtrade-mcp-server
Server Details
UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.
- Status
- Healthy
- Last Tested
- Transport
- Streamable HTTP · MCP 2025-11-25
- URL
- Repository
- cyanheads/un-comtrade-mcp-server
- GitHub Stars
- 3
- Server Listing
- @cyanheads/un-comtrade-mcp-server
TDQS
Score is being calculated.
Available Tools
9 toolscomtrade_get_data_availabilityCheck Data AvailabilityRead-onlyInspect
Check which reporter/period/classification combinations have published data before constructing expensive trade queries. Returns dataset records with period, classification, record count, and first/latest release dates. Call this before querying recent periods — annual data is typically published 3–12 months after the reference year and not all countries report every year. Omit all parameters to browse the full availability index.
| Name | Required | Description | Default |
|---|---|---|---|
| freq | No | Frequency: A=annual, M=monthly. | A |
| period | No | Period to check: YYYY (annual) or YYYYMM (monthly). Omit to see all available periods for the reporter. | |
| type_code | No | Trade type: C=commodities (goods), S=services. | C |
| reporter_code | No | M49 reporter code to check. Omit to browse availability across all reporters. | |
| classification | No | Classification code filter (e.g. "HS", "H6", "EB10"). Omitted or blank defaults to HS for goods and EB10 for services. |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| notice | No | Recovery hint when no availability records are found. |
| datasets | No | Available datasets matching the query. |
| totalDatasets | No | Total number of available dataset records. |
comtrade_get_services_tradeGet Services Trade DataRead-onlyInspect
Fetch international trade-in-services data (EBOPS 2010 classification). Same bilateral structure as goods trade: returns flow value in USD, period, and reporter/partner/category metadata for each row. Use comtrade_list_service_categories to find the right service code before querying. Preview makes one paced request per served period, capped at 500 records per request. Services coverage is more limited than goods trade.
| Name | Required | Description | Default |
|---|---|---|---|
| period | Yes | Periods (YYYY or YYYYMM). Serves the first 12 and discloses the remainder; input ceiling 120. Preview makes one paced request per period. | |
| flow_code | Yes | Trade flow: M=imports (credit received by reporter), X=exports (debit paid). | |
| partner_code | No | M49 partner code. Use 0 for all partners combined. Omit for a disaggregated by-partner breakdown. | |
| service_code | No | EBOPS 2010 service category code (e.g. "SA" for transport). Use comtrade_list_service_categories to find available codes. Omit to get totals across all service categories. | |
| reporter_code | Yes | M49 numeric code of the reporting country. |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| shown | No | Number of records returned. |
| notice | No | Recovery hint when no records are returned. |
| records | No | Services trade flow records. |
| truncated | No | True when any preview response reached 500 and may be incomplete. |
| totalCount | No | Sum of upstream response counts before local filtering; not a full match count when capped. |
| truncationHint | No | Query narrowing and authenticated access guidance when possibly incomplete. |
| unservedPeriods | No | Periods beyond the 12-period work cap; query them separately. |
comtrade_get_top_commoditiesGet Top Trade CommoditiesRead-onlyInspect
Rank commodity categories for a reporter by trade value for a given flow direction and period. Returns the top N HS chapters (2-digit) or headings (4-digit) sorted by descending value — answers "what does country X mainly export?" or "what does country X mainly import?". Symmetric counterpart to comtrade_get_top_partners. Optionally filter to a single partner country.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of top commodity categories to return; above 50 returns all retrieved categories. | |
| period | Yes | Single period: annual (YYYY) or monthly (YYYYMM). | |
| flow_code | Yes | Trade flow: M=imports, X=exports. | |
| aggr_level | No | HS aggregation level: 2 = chapter (broader), 4 = heading (more specific). | |
| partner_code | No | M49 partner code to filter to a specific bilateral relationship. Omit to rank commodities across all partners. | |
| reporter_code | Yes | M49 numeric code of the reporting country. |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| notice | No | Recovery hint when no data is returned. |
| period | No | Period queried. |
| flowCode | No | Flow direction queried. |
| aggrLevel | No | HS aggregation level used. |
| truncated | No | True when API returned 500 records and results may be incomplete. |
| commodities | No | Top commodity categories sorted by descending trade value. |
| reporterCode | No | M49 reporter code. |
| reporterDesc | No | Reporter country name. |
| totalValueUsd | No | Sum of primary values across all returned categories (before limit). |
| totalCommodities | No | Total commodity categories returned by API. |
comtrade_get_top_partnersGet Top Trading PartnersRead-onlyInspect
Rank trading partners for a reporter by trade value for a given commodity and flow direction. Returns the top N partners sorted by descending value — answers "who does country X mainly export product Y to?" or "where does country X mainly import product Z from?" for a single period. Fetches a disaggregated breakdown across all partners then sorts locally. Omit cmd_code to rank partners for total trade.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of top partners to return; above 50 returns all retrieved partners. | |
| period | Yes | Single period: annual (YYYY) or monthly (YYYYMM). | |
| cmd_code | No | Single HS commodity code (e.g. "84", "8471"). Omit or pass "TOTAL" to rank partners for total merchandise trade. | |
| flow_code | Yes | Trade flow: M=imports, X=exports. | |
| reporter_code | Yes | M49 numeric code of the reporting country. |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| notice | No | Recovery hint when no data is returned. |
| period | No | Period queried. |
| cmdCode | No | Commodity code queried (TOTAL when omitted). |
| flowCode | No | Flow direction queried. |
| partners | No | Top partners sorted by descending trade value. |
| truncated | No | True when API returned 500 records and results may be incomplete. |
| reporterCode | No | M49 reporter code. |
| reporterDesc | No | Reporter country name. |
| totalPartners | No | Total partners with non-zero trade value returned by API. |
| totalValueUsd | No | Sum of primary values across all returned partners (before limit truncation). |
comtrade_get_trade_balanceGet Trade BalanceRead-onlyInspect
Compute the trade balance for a country over one or more periods — total exports minus total imports — with optional HS or SITC commodity filter. Preview makes two paced requests per served period; authenticated calls batch periods. Returns the signed balance (USD), export value, import value, and coverage ratio (exports / imports). Note: mirror asymmetry is common — balance reflects values as reported by this country; the same flow may be recorded differently by the partner. Uses comtrade_lookup_countries to resolve reporter codes.
| Name | Required | Description | Default |
|---|---|---|---|
| freq | No | Frequency: A=annual, M=monthly. | A |
| period | Yes | Annual periods (YYYY) or monthly periods (YYYYMM). Serves the first 12 and discloses the remainder; input ceiling 120. | |
| cmd_code | No | HS or SITC commodity codes to restrict the balance calculation. Serves the first 20 and discloses the remainder; input ceiling 200. Omit to compute the overall trade balance across all commodities. | |
| reporter_code | Yes | M49 numeric code of the reporting country. | |
| classification | No | Goods classification: HS/H0–H6 or SITC S1–S4/SS. | HS |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| notice | No | Possible incompleteness of the balance when a preview response reaches its cap. |
| periods | No | Balance computation per period. |
| cmdCodes | No | Commodity codes used in the query (absent when querying all commodities). |
| mirrorCaveat | No | Standard caveat about mirror asymmetry — balance reflects this country's reported values. |
| reporterCode | No | M49 reporter code used. |
| reporterDesc | No | Reporter country name. |
| referenceNotice | No | Reference descriptions unavailable; codes and trade values retained. |
| unservedPeriods | No | Periods beyond the 12-period work cap; query them separately. |
| unservedCmdCodes | No | Commodity codes beyond the 20-code work cap; query them separately. |
comtrade_get_trade_flowsGet Trade Flow RecordsRead-onlyInspect
Fetch bilateral trade flow records — the primary data retrieval tool. Returns trade value in USD (primaryValue — FOB for exports, CIF for imports), quantity, net weight, and period/commodity/partner metadata for each row. Accepts multiple periods and commodity codes per call; pass partner_code 0 to get totals aggregated across all partners. Omit cmd_code or pass "TOTAL" to aggregate all commodities. Preview makes one paced request per served period, with a 500-record cap per request. Use comtrade_lookup_countries to resolve reporter/partner codes and comtrade_search_commodities to resolve HS codes. For SITC, supply codes from the selected SITC revision.
| Name | Required | Description | Default |
|---|---|---|---|
| freq | No | Frequency: A=annual, M=monthly. | A |
| period | Yes | One or more periods to query. Annual: "YYYY" (e.g. ["2022", "2023"]). Monthly: "YYYYMM" (e.g. ["202201", "202202"]). Serves the first 12 periods and discloses the remainder; input ceiling 120. | |
| cmd_code | No | HS or SITC commodity codes to query. Serves the first 20 codes and discloses the remainder; input ceiling 200. Pass ["TOTAL"] or omit to aggregate all commodities. Use comtrade_search_commodities for HS codes only. | |
| flow_code | Yes | Trade flow direction: M=imports, X=exports, RX=re-exports, RM=re-imports. | |
| partner_code | No | M49 code of the trade partner. Use 0 to aggregate across all partners (World total). Omit to get a disaggregated breakdown by partner country. | |
| reporter_code | Yes | M49 numeric code of the reporting country. Use comtrade_lookup_countries to resolve names to codes. | |
| classification | No | Goods classification: HS/H0–H6 or SITC S1–S4/SS. Defaults to combined HS. | HS |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| shown | No | Number of records returned in this response. |
| notice | No | Recovery hint when no records are returned. Absent on successful responses. |
| records | No | Trade flow records. |
| truncated | No | True when any preview response reached 500 and may be incomplete. |
| totalCount | No | Sum of upstream response counts before local filtering; not a full match count when capped. |
| truncationHint | No | Query narrowing and authenticated access guidance when possibly incomplete. |
| referenceNotice | No | Notice when reference descriptions could not be loaded; codes and trade values remain available. |
| unservedPeriods | No | Periods beyond the 12-period work cap; query them separately. |
| unservedCmdCodes | No | Commodity codes beyond the 20-code work cap; query them separately. |
comtrade_list_service_categoriesList Service Trade Categories (EBOPS)Read-onlyInspect
List EBOPS 2010 service trade categories — the equivalent of comtrade_search_commodities for the services domain. Returns category codes, descriptions, and parent codes. Filter by keyword to find a specific service type (e.g. "transport", "financial", "travel"), or browse from a parent category code. Use the returned id as service_code in comtrade_get_services_trade.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of categories to return; above 500 returns all matching categories. | |
| query | No | Keyword or category code prefix to filter results. Examples: "transport", "SA", "financial services". Omit to list all EBOPS categories. | |
| parent_code | No | Return only sub-categories of this parent EBOPS code. Example: "SA" to see all transport service sub-categories. |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| shown | No | Number of categories returned. |
| notice | No | Recovery hint when no results found or results are truncated. |
| truncated | No | True when categories were capped at the limit (totalMatches exceeds shown). |
| categories | No | EBOPS 2010 service categories matching the query. |
| totalMatches | No | Total matching categories before limit truncation. |
comtrade_lookup_countriesLookup Countries / AreasRead-onlyInspect
Resolve country and area names to Comtrade M49 numeric codes used in all data queries. Accepts a partial name, full name, or ISO alpha-2/alpha-3 code (e.g. "United States", "USA", "US"). Returns matching entries with their numeric code, ISO identifiers, and a validAsReporter flag — regional groupings like "World" (code 0) are valid partners but not valid reporters. Use this before any trade data tool that requires reporter_code or partner_code. To aggregate across all partners, use partner code 0 (World) — no lookup needed.
| Name | Required | Description | Default |
|---|---|---|---|
| role | No | Filter by role: "reporter" returns only codes valid for the reporterCode parameter, "partner" returns only partner areas (includes regional groupings), "any" returns all matches regardless of role. | any |
| query | Yes | Country or area name fragment, full name, or ISO alpha-2/alpha-3 code to search for. Case-insensitive. Examples: "Germany", "DEU", "DE", "united states", "china". | |
| include_groups | No | Whether to include regional and economic groupings (e.g. EU, ASEAN). Set to false to return only individual countries. |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| notice | No | Recovery hint when no matches are found — echoes the query and suggests alternatives. Absent when results are non-empty. |
| matches | No | Country/area entries matching the query, sorted by name. |
| totalMatches | No | Total number of matching entries. |
comtrade_search_commoditiesSearch HS Commodity CodesRead-onlyInspect
Find HS commodity codes by keyword, partial description, or known code prefix. Returns matched codes at the requested aggregation level (2-, 4-, or 6-digit) with full descriptions, parent code, leaf status, and a recommended_query_code field indicating the best code level for subsequent trade queries (2-digit chapter for broad analysis, 4- or 6-digit for specific products). This is the critical resolution step — agents cannot derive HS codes from product names without this tool. Use aggr_level 2 to start broad; narrow with aggr_level 4 or 6 once you have a chapter. To get all commodities for an entire chapter, pass the 2-digit code as cmd_code in trade tools.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results to return; above 200 returns all matching codes. | |
| query | Yes | Keyword, partial description, or HS code prefix to search for. Examples: "motor vehicles", "8471", "coffee", "84" (chapter 84 = machinery). | |
| aggr_level | No | Aggregation level: 2 = HS chapter (most general), 4 = heading, 6 = subheading (most specific). Omit to return all matching levels. | |
| classification | No | HS classification version. "HS" covers the combined dataset across all editions (H0–H6). Use a specific edition (e.g. "H6") for version-specific lookups. | HS |
Output Schema
| Name | Required | Description |
|---|---|---|
| error | No | Present when the call failed. Absent on success. |
| shown | No | Number of codes returned in this response. |
| notice | No | Recovery hint when no matches are found or results are truncated. Absent when results are non-empty and not truncated. |
| matches | No | HS codes matching the query. |
| truncated | No | True when matches were capped at the limit (totalMatches exceeds shown). |
| totalMatches | No | Total matching codes (before limit truncation). |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
9 tool updates
- First observed
comtrade_get_data_availability - First observed
comtrade_get_services_trade - First observed
comtrade_get_top_commodities - First observed
comtrade_get_top_partners - First observed
comtrade_get_trade_balance - First observed
comtrade_get_trade_flows - First observed
comtrade_list_service_categories - First observed
comtrade_lookup_countries - First observed
comtrade_search_commodities
Related MCP Connectors
Comtrade MCP — UN Comtrade API for international bilateral trade data
Trade Intel MCP — Compound tools that chain Comtrade, Census, Treasury,
Census Trade MCP — US Census Bureau International Trade data
World Bank MCP — wraps the World Bank Data API v2 (free, no auth)
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides access to UN Comtrade international bilateral trade data via an MCP server, enabling AI agents to query trade statistics through natural language.32 npmMIT
- AlicenseAqualityCmaintenanceAn MCP server for the U.S. Census Bureau's International Trade Data API, enabling queries of monthly export and import statistics by HS, NAICS, end-use, and other classifications, with tools for trade balance, top partners, and country code lookup.7Creative Commons Zero v1.0 Universal
- FlicenseAqualityBmaintenanceEnables querying Brazilian foreign trade data through MCP tools for trade flows, freight costs, code resolution, and dataset caveats, with known data defects corrected in responses.4-
- AlicenseAqualityAmaintenanceBrazilian foreign trade from MDIC/ComexStat -- exports and imports since 2000 by HS code (SH4/SH6/NCM) and partner country, in USD FOB and kilograms -- plus crop production, supply-and-demand balances, climate readings and commodity forecasts for hubs such as soybean, coffee and beef. 15 read-only tools, remote at https://mcp.kyrodata.com/mcp; official registry com.kyrodata/kyrodata.151MIT
Glama MCP Gateway
Add one secure layer between your agents and this server.