Query US Trade Data from Claude Code for Supply Chain Analysis

Supply chain decisions depend on trade flow data — which countries dominate imports of a given component, how volumes shift month to month, whether a particular corridor is growing or shrinking. That data lives in the Census Bureau’s International Trade database, and getting to it usually means navigating a clunky government portal. AgentPatch’s Trade Data tool lets Claude Code query it directly from the terminal.

Why This Matters

If you’re building logistics software, procurement tools, or anything that touches international sourcing, you need real trade data to make informed decisions. Hardcoded assumptions about where goods come from go stale fast — trade patterns shift with tariffs, supply disruptions, and currency moves.

The Trade Data tool queries the Census Bureau’s International Trade API and returns monthly and year-to-date values broken down by Harmonized System commodity codes and country. You specify the direction (imports or exports), the commodity granularity (HS2, HS4, or HS6), and the time period. Results come back sorted by value with commodity descriptions, country names, and both monthly and YTD figures. Each call costs 75 credits.

Setup

The AgentPatch CLI is designed for AI agents to use via shell access. Install it, and your agent can discover and invoke any tool on the marketplace.

Install (zero dependencies, Python 3.10+):

pip install agentpatch

Set your API key:

export AGENTPATCH_API_KEY=your_api_key

Example commands your agent will use:

ap search "web search"
ap run google-search --input '{"query": "test"}'

Get your API key from the AgentPatch dashboard.

Install the AgentPatch skill — it teaches Claude Code when to use AgentPatch and how to use the CLI:

/plugin marketplace add fullthom/agentpatch-claude-skill
/plugin install agentpatch@agentpatch

MCP Server (Alternative)

If you prefer raw MCP tool access instead of the skill:

claude mcp add -s user --transport http agentpatch https://agentpatch.ai/mcp \
  --header "Authorization: Bearer YOUR_API_KEY"

Replace YOUR_API_KEY with your actual key from the AgentPatch dashboard.

Example

You’re evaluating supply chain concentration risk for electronic components and want to see where US imports actually come from. You tell Claude Code:

“Pull HS4-level import data for January 2026, filtered to commodity code 8542 (electronic integrated circuits). Show me the top countries by import value.”

Claude Code calls the Trade Data tool and works through the results:

Fetching US import data...
Direction: imports
Commodity level: HS4
Time: 2026-01
Commodity code: 8542

Top countries by monthly import value (electronic integrated circuits):

1. China (5700):         $4.82B monthly,  $4.82B YTD
2. Malaysia:             $2.14B monthly,  $2.14B YTD
3. Taiwan:               $1.97B monthly,  $1.97B YTD
4. South Korea:          $1.63B monthly,  $1.63B YTD
5. Japan (5880):         $1.21B monthly,  $1.21B YTD

China accounts for roughly 41% of US integrated circuit imports by value.
The top 5 countries represent 87% of total volume. Writing concentration
analysis to analysis/ic-supply-chain.md.

From there, you can ask Claude Code to compare against the same month last year, drill into HS6 subcategories to see which specific chip types drive the concentration, or cross-reference with tariff schedules. All without leaving the terminal.

Wrapping Up

Connecting AgentPatch to Claude Code gives it live access to US trade flow data from the Census Bureau. Pair it with other marketplace tools — FRED for economic context, Google News for trade policy developments — to build a complete supply chain intelligence workflow. The same MCP connection unlocks every tool on the marketplace. See what’s available at agentpatch.ai.