Using US Trade Data to Analyze Tariff Impacts with AI Agents
Tariffs change trade flows. That much is obvious. What’s harder is quantifying the actual impact — how much volume shifted, which countries absorbed the redirected trade, and which commodity categories were most affected. The Census Bureau tracks all of this in its International Trade database, and AgentPatch’s Trade Data tool makes it queryable by any AI agent over MCP.
Why This Matters
Trade policy moves fast. New tariffs get announced, modified, and retaliated against on a timeline measured in weeks. Analysts, journalists, logistics companies, and policy researchers all need to measure the downstream effects, but the workflow is painful: navigate the Census Bureau portal, select the right HS codes, download monthly data, and manually compare periods.
The Trade Data tool collapses that into structured API calls. You specify imports or exports, a commodity level (HS2 for sectors, HS4 for product groups, HS6 for specific items), and a month in YYYY-MM format. Optional filters let you isolate a specific country (e.g., 5700 for China, 2900 for Mexico) or commodity code. Results return sorted by value, with commodity descriptions, country names, monthly totals, and year-to-date figures. At 75 credits per call, running a multi-month comparison is straightforward.
Setup
Add AgentPatch as an MCP server in your agent’s configuration:
{
"mcpServers": {
"agentpatch": {
"type": "url",
"url": "https://agentpatch.ai/mcp/?key=YOUR_API_KEY"
}
}
}
This works with Claude Code, Codex, OpenClaw, or any MCP-compatible agent. Once connected, the agent discovers the trade-data tool automatically.
Example
You want to measure how US imports from China changed after a tariff escalation. You ask your agent:
“Compare US imports from China at the HS2 level for January 2025 vs January 2026. Identify which sectors saw the biggest declines and which grew despite tariffs.”
The agent calls the Trade Data tool twice — once for each period, filtered to country code 5700 (China) — and produces a comparison:
Fetching HS2-level imports from China, 2025-01...
Fetching HS2-level imports from China, 2026-01...
Biggest declines (Jan 2025 -> Jan 2026):
85 - Electrical machinery: $12.4B -> $9.1B (-27%)
84 - Industrial machinery: $10.8B -> $8.3B (-23%)
94 - Furniture: $2.9B -> $2.1B (-28%)
Sectors that grew:
30 - Pharmaceutical products: $1.1B -> $1.4B (+27%)
29 - Organic chemicals: $0.9B -> $1.1B (+22%)
Total imports from China fell 18% year-over-year. Electrical and
industrial machinery drove most of the decline. Pharmaceutical and
chemical imports grew, suggesting those categories face lower
effective tariff rates or have fewer substitution options.
From here, you can drill deeper. Ask the agent to check where the lost volume went — pull the same HS2 codes for Vietnam, Mexico, or India to see which countries picked up share. Or go to HS6 level to isolate specific products within the declining categories.
Wrapping Up
Trade data turns tariff speculation into measurable impact. AgentPatch’s Trade Data tool gives any MCP-compatible agent direct access to the Census Bureau’s numbers, making it practical to run the kind of before-and-after analysis that used to require a dedicated research team. Pair it with FRED for exchange rate context or Google News for policy timeline correlation. Explore the full marketplace at agentpatch.ai.