Skip to main content
Glama

un-comtrade-mcp-server

Server Details

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

If you are the author of this connector, you can claim ownership by verifying the domain or GitHub account it belongs to. Claimed connector authors can inspect health checks, view analytics, and manage their listing.
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 tools
comtrade_get_data_availabilityCheck Data Availability
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
freqNoFrequency: A=annual, M=monthly.A
periodNoPeriod to check: YYYY (annual) or YYYYMM (monthly). Omit to see all available periods for the reporter.
type_codeNoTrade type: C=commodities (goods), S=services.C
reporter_codeNoM49 reporter code to check. Omit to browse availability across all reporters.
classificationNoClassification code filter (e.g. "HS", "H6", "EB10"). Omitted or blank defaults to HS for goods and EB10 for services.

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
noticeNoRecovery hint when no availability records are found.
datasetsNoAvailable datasets matching the query.
totalDatasetsNoTotal number of available dataset records.
comtrade_get_services_tradeGet Services Trade Data
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
periodYesPeriods (YYYY or YYYYMM). Serves the first 12 and discloses the remainder; input ceiling 120. Preview makes one paced request per period.
flow_codeYesTrade flow: M=imports (credit received by reporter), X=exports (debit paid).
partner_codeNoM49 partner code. Use 0 for all partners combined. Omit for a disaggregated by-partner breakdown.
service_codeNoEBOPS 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_codeYesM49 numeric code of the reporting country.

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
shownNoNumber of records returned.
noticeNoRecovery hint when no records are returned.
recordsNoServices trade flow records.
truncatedNoTrue when any preview response reached 500 and may be incomplete.
totalCountNoSum of upstream response counts before local filtering; not a full match count when capped.
truncationHintNoQuery narrowing and authenticated access guidance when possibly incomplete.
unservedPeriodsNoPeriods beyond the 12-period work cap; query them separately.
comtrade_get_top_commoditiesGet Top Trade Commodities
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of top commodity categories to return; above 50 returns all retrieved categories.
periodYesSingle period: annual (YYYY) or monthly (YYYYMM).
flow_codeYesTrade flow: M=imports, X=exports.
aggr_levelNoHS aggregation level: 2 = chapter (broader), 4 = heading (more specific).
partner_codeNoM49 partner code to filter to a specific bilateral relationship. Omit to rank commodities across all partners.
reporter_codeYesM49 numeric code of the reporting country.

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
noticeNoRecovery hint when no data is returned.
periodNoPeriod queried.
flowCodeNoFlow direction queried.
aggrLevelNoHS aggregation level used.
truncatedNoTrue when API returned 500 records and results may be incomplete.
commoditiesNoTop commodity categories sorted by descending trade value.
reporterCodeNoM49 reporter code.
reporterDescNoReporter country name.
totalValueUsdNoSum of primary values across all returned categories (before limit).
totalCommoditiesNoTotal commodity categories returned by API.
comtrade_get_top_partnersGet Top Trading Partners
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of top partners to return; above 50 returns all retrieved partners.
periodYesSingle period: annual (YYYY) or monthly (YYYYMM).
cmd_codeNoSingle HS commodity code (e.g. "84", "8471"). Omit or pass "TOTAL" to rank partners for total merchandise trade.
flow_codeYesTrade flow: M=imports, X=exports.
reporter_codeYesM49 numeric code of the reporting country.

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
noticeNoRecovery hint when no data is returned.
periodNoPeriod queried.
cmdCodeNoCommodity code queried (TOTAL when omitted).
flowCodeNoFlow direction queried.
partnersNoTop partners sorted by descending trade value.
truncatedNoTrue when API returned 500 records and results may be incomplete.
reporterCodeNoM49 reporter code.
reporterDescNoReporter country name.
totalPartnersNoTotal partners with non-zero trade value returned by API.
totalValueUsdNoSum of primary values across all returned partners (before limit truncation).
comtrade_get_trade_balanceGet Trade Balance
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
freqNoFrequency: A=annual, M=monthly.A
periodYesAnnual periods (YYYY) or monthly periods (YYYYMM). Serves the first 12 and discloses the remainder; input ceiling 120.
cmd_codeNoHS 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_codeYesM49 numeric code of the reporting country.
classificationNoGoods classification: HS/H0–H6 or SITC S1–S4/SS.HS

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
noticeNoPossible incompleteness of the balance when a preview response reaches its cap.
periodsNoBalance computation per period.
cmdCodesNoCommodity codes used in the query (absent when querying all commodities).
mirrorCaveatNoStandard caveat about mirror asymmetry — balance reflects this country's reported values.
reporterCodeNoM49 reporter code used.
reporterDescNoReporter country name.
referenceNoticeNoReference descriptions unavailable; codes and trade values retained.
unservedPeriodsNoPeriods beyond the 12-period work cap; query them separately.
unservedCmdCodesNoCommodity codes beyond the 20-code work cap; query them separately.
comtrade_get_trade_flowsGet Trade Flow Records
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
freqNoFrequency: A=annual, M=monthly.A
periodYesOne 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_codeNoHS 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_codeYesTrade flow direction: M=imports, X=exports, RX=re-exports, RM=re-imports.
partner_codeNoM49 code of the trade partner. Use 0 to aggregate across all partners (World total). Omit to get a disaggregated breakdown by partner country.
reporter_codeYesM49 numeric code of the reporting country. Use comtrade_lookup_countries to resolve names to codes.
classificationNoGoods classification: HS/H0–H6 or SITC S1–S4/SS. Defaults to combined HS.HS

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
shownNoNumber of records returned in this response.
noticeNoRecovery hint when no records are returned. Absent on successful responses.
recordsNoTrade flow records.
truncatedNoTrue when any preview response reached 500 and may be incomplete.
totalCountNoSum of upstream response counts before local filtering; not a full match count when capped.
truncationHintNoQuery narrowing and authenticated access guidance when possibly incomplete.
referenceNoticeNoNotice when reference descriptions could not be loaded; codes and trade values remain available.
unservedPeriodsNoPeriods beyond the 12-period work cap; query them separately.
unservedCmdCodesNoCommodity codes beyond the 20-code work cap; query them separately.
comtrade_list_service_categoriesList Service Trade Categories (EBOPS)
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of categories to return; above 500 returns all matching categories.
queryNoKeyword or category code prefix to filter results. Examples: "transport", "SA", "financial services". Omit to list all EBOPS categories.
parent_codeNoReturn only sub-categories of this parent EBOPS code. Example: "SA" to see all transport service sub-categories.

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
shownNoNumber of categories returned.
noticeNoRecovery hint when no results found or results are truncated.
truncatedNoTrue when categories were capped at the limit (totalMatches exceeds shown).
categoriesNoEBOPS 2010 service categories matching the query.
totalMatchesNoTotal matching categories before limit truncation.
comtrade_lookup_countriesLookup Countries / Areas
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
roleNoFilter 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
queryYesCountry 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_groupsNoWhether to include regional and economic groupings (e.g. EU, ASEAN). Set to false to return only individual countries.

Output Schema

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
noticeNoRecovery hint when no matches are found — echoes the query and suggests alternatives. Absent when results are non-empty.
matchesNoCountry/area entries matching the query, sorted by name.
totalMatchesNoTotal number of matching entries.
comtrade_search_commoditiesSearch HS Commodity Codes
Read-only
Inspect

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results to return; above 200 returns all matching codes.
queryYesKeyword, partial description, or HS code prefix to search for. Examples: "motor vehicles", "8471", "coffee", "84" (chapter 84 = machinery).
aggr_levelNoAggregation level: 2 = HS chapter (most general), 4 = heading, 6 = subheading (most specific). Omit to return all matching levels.
classificationNoHS 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

ParametersJSON Schema
NameRequiredDescription
errorNoPresent when the call failed. Absent on success.
shownNoNumber of codes returned in this response.
noticeNoRecovery hint when no matches are found or results are truncated. Absent when results are non-empty and not truncated.
matchesNoHS codes matching the query.
truncatedNoTrue when matches were capped at the limit (totalMatches exceeds shown).
totalMatchesNoTotal matching codes (before limit truncation).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 9 tool updates
    • First observedcomtrade_get_data_availability
    • First observedcomtrade_get_services_trade
    • First observedcomtrade_get_top_commodities
    • First observedcomtrade_get_top_partners
    • First observedcomtrade_get_trade_balance
    • First observedcomtrade_get_trade_flows
    • First observedcomtrade_list_service_categories
    • First observedcomtrade_lookup_countries
    • First observedcomtrade_search_commodities

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides access to UN Comtrade international bilateral trade data via an MCP server, enabling AI agents to query trade statistics through natural language.
    32 npm
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    An 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.
    7
    Creative Commons Zero v1.0 Universal
  • F
    license
    A
    quality
    B
    maintenance
    Enables 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
    -
  • A
    license
    A
    quality
    A
    maintenance
    Brazilian 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.
    15
    1
    MIT
Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.