comtrade-mcp
Provides access to UN Comtrade trade statistics, enabling country and HS code lookup, market indicators, importer/exporter rankings, mirror imports, top partners, trend analysis, and raw trade flow queries.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
comtrade-mcp
An MCP server that gives AI assistants (Claude Desktop, Claude Code, Cursor and others) direct access to UN Comtrade trade statistics.
It is built for the question export advisors ask every day: "For this HS code, which countries should we target?"
Works without an API key (Comtrade's public preview endpoint). A free key raises the limits.
Returns decision-ready numbers: rankings, market share, USD/kg unit values and CAGR, not raw dumps.
Lightweight: two dependencies (
mcp,httpx), runs locally.
Tools
Tool | What it answers |
| Comtrade code for "Germany", "DE", "TUR"... (common names like "Turkey" and "Vietnam" work too) |
| HS codes by prefix ( |
| TradeMap-style target-market table seen from one exporter (default Türkiye): imports, world share, USD/kg, value and quantity CAGR, last-year growth, trade balance, the exporter's shipments, market share and destination rank; supplier concentration (HHI) with a key |
| The world's largest importers of an HS code: share, USD/kg, CAGR; optional mirror fill |
| The world's largest exporters (the competitor list): share, USD/kg, CAGR |
| A country's reported imports next to what its partners say they shipped to it |
| A country's export destinations or import sources for an HS code |
| Year-by-year values and CAGR for a reporter/partner/HS combination |
| Raw value and weight for a specific query |
Related MCP server: mcp-sputnikx-market
Install
git clone https://github.com/rawfuncdev/comtrade-mcp.git
cd comtrade-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -e .Connect to Claude Desktop
Add to claude_desktop_config.json (use the absolute path of your clone):
{
"mcpServers": {
"comtrade": {
"command": "/path/to/comtrade-mcp/.venv/bin/comtrade-mcp",
"env": { "COMTRADE_API_KEY": "" }
}
}
}Restart Claude Desktop, then ask things like:
Who are the top 10 importers of HS 080222 in 2023, and what do they pay per kg?
Where does Türkiye export shelled hazelnuts, and how has Germany's import demand grown since 2019?
Build a target-market table for HS 080222 from Türkiye's side. Flag markets that look under-reported.
API key (optional)
Without a key, each call uses the public preview endpoint: one period per request, at most 500 rows, and a short-term rate limit (the server retries automatically). For heavier use, get a free subscription key at comtradeplus.un.org and set COMTRADE_API_KEY. Never commit the key.
Mirror data
Some countries report late, partially or not at all. Their real imports can be estimated from what their partners report exporting to them, the method TradeMap uses. Example, HS 080222 (shelled hazelnuts), 2024:
Country | Own report | Partners' exports to it |
Iraq | $0.14M | $2.43M |
Poland | $43.0M | $192.1M |
Germany | $584.6M | $555.2M (normal CIF/FOB gap) |
mirror_imports works without a key. A world-wide mirror scan (mirror=True) needs every bilateral row, so it requires COMTRADE_API_KEY.
Notes on the data
Values are as reported to UN Comtrade (imports are usually CIF, exports FOB). Recent years fill in gradually as countries report.
top_importersexcludes country groups (EU, ASEAN) to avoid double counting.Out of scope: tariffs (see ITC MacMap), national tariff lines beyond HS6, and company-level data.
Without a key, a query that would return more than 500 rows stops with an error instead of returning silently truncated totals.
Development
pip install -e ".[dev]"
pytestTests run offline against fixtures.
License
MIT. Trade data © United Nations, subject to the UN Comtrade terms of use.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
UN Comtrade international trade statistics via MCP. Country/HS lookups, flows, balances, rankings.
TradeStats gives AI agents official customs trade statistics: monthly imports and exports by HS product code and by partner country, for Japan, the United States, the United Kingdom and the European Union. What you can ask - Product overview and time series for an HS code, with year-on-year change and unit prices. - Top partner countries, rankings, seasonality and new markets for a product. - Cross-country comparison and mirror trade (one country's exports against its partner's imports). - Named indicators and finance tools: price and volume decomposition, breadth of a rise or fall, supplier dependency. Why use it - Every answer states its source agency, the value basis (CIF or FOB) and the latest published month, so a figure can be traced. - Figures are the agencies' own published numbers; calculated fields (unit price, shares, growth) are labelled as derived. - HS6 and above for all four reporters, plus national codes for Japan. - Streamable HTTP MCP endpoint and a matching Web API (OpenAPI). No sign-up: a free API key is optional. Not for: company-level shipment records, trade in services, or forecasts. Operated by Washu Trading LLC. Data: Japan MOF (e-Stat), U.S. Census Bureau, HMRC (OGL v3.0), Eurostat (Comext). Not endorsed by these agencies.
Comtrade MCP — UN Comtrade API for international bilateral trade data
Trade Intel MCP — Compound tools that chain Comtrade, Census, Treasury,
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides access to UN Comtrade international bilateral trade data via an MCP server, enabling AI agents to query trade statistics through natural language.88 npmMIT
- AlicenseBqualityDmaintenanceProvides AI assistants with access to 22 tools for EU trade intelligence, customs analytics, salary data, agent identity, and commerce, integrating over 63M Eurostat records and other sources.1964 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to perform international trade operations such as calculating landed costs, classifying goods, explaining trade terms, estimating shipping, and converting currencies for Kazakhstan/EAEU/Central Asia trade routes.MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI assistants to query hosted critical-mineral and rare-earth trade intelligence, including trade flows, commodity snapshots, supply-concentration and China-exposure risk, counterparty screening, sourcing briefs, research reports, sourced evidence, and CM-PATRA patent and funded-R&D tracking.-