# comtrade.trade.query

Query international merchandise trade statistics from the UN Comtrade database. Returns up to 500 records of imports and/or exports for a specific reporting country, reference period, commodity code, and partner country. Data covers 200+ reporter countries from 1962 (annual) and 2010 (monthly). Values in USD (primary value), CIF for imports, FOB for exports. Commodities classified by Harmonized System (HS) or SITC. Use reporter_code from comtrade.reporters, HS chapter codes (e.g. "84" for machinery, "27" for petroleum, "85" for electronics), and flow_code M=imports, X=exports. Source: UN Comtrade public preview API, no auth, 500 calls/day free.

Agent View of the PolicyLayer registry record for `comtrade.trade.query`. HTML page: https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/comtrade.trade.query

## Facts

- Tool: `comtrade.trade.query`
- Server: Apibase (`apibase-mcp-client`) — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase.md
- Install: `npx -y apibase-mcp-client`
- Homepage: https://github.com/whiteknightonhorse/APIbase
- Risk category: Read (Low risk)
- Registry record: grade F, identity unverified
- Server auth posture: open
- Server rate-limited: no
- Parameters: 12 (3 required)
- Recommended policy verdict: Allowed

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `period` | string | yes | Reference period to query. Annual: 4-digit year (e.g. "2022"). Monthly: YYYYMM (e.g. "202209" for Sep 2022). Comma-separated for multiple periods (e.g. "2020,20 |
| `cmd_code` | string | no | Commodity code filter. Use HS codes (e.g. "84" for machinery, "27" for petroleum, "TOTAL" for aggregate totals, "AG2" for all 2-digit chapters). Omit to return |
| `flow_code` | string | yes | Trade flow direction. M=Imports, X=Exports, MX=Both imports and exports, RM=Re-imports, RX=Re-exports. |
| `freq_code` | string | no | Frequency. A=Annual (default), M=Monthly. |
| `type_code` | string | no | Trade data type. C=Commodities (default), S=Services. |
| `max_records` | integer | no | Maximum number of records to return (1–500). Default 100. The public preview API is capped at 500 records per request. |
| `aggregate_by` | string | no | Aggregate results by a dimension. Valid values: "cmdCode", "flowCode", "partnerCode", "reporterCode", "period". Omit to return unaggregated records. |
| `customs_code` | string | no | Customs procedure code filter (e.g. "C00"=all procedures, "C03"=outright export, "C04"=warehousing). Omit for all procedures. |
| `partner_code` | integer | no | UN numeric code for the partner country. 0=World aggregate (all partners combined). Omit to return all individual partners. |
| `partner2_code` | integer | no | Secondary partner code for extended trade flow tracking (consignment country). 0=World aggregate. Omit to use the default world aggregate. |
| `reporter_code` | integer | yes | UN numeric code for the reporting country (e.g. 276=Germany, 840=USA, 156=China, 826=UK). Use comtrade.reporters to look up codes. |
| `classification` | string | no | Commodity classification system. HS=Harmonized System (default, most common). B4/B5=BEC, EB=EBOPS services, S1-S4/SS=SITC revisions. |

Parameters from the server's own tool schema.

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "comtrade.trade.query",
    "arguments": {
      "period": "<period>",
      "flow_code": "<flow_code>",
      "reporter_code": 0
    }
  }
}
```

## Why comtrade.trade.query is rated Low

Tool retrieves historical trade data from public UN database with no side effects or modifications.

From the tool's own definition: "Query international merchandise trade statistics, returns up to 500 records, retrieves data"

Risk signals: High parameter count (12 properties)

## Use case

AI agents call comtrade.trade.query to retrieve information from Apibase without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.

## Recommended policy (PolicyLayer)

Verdict: **Allowed**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Apibase:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "comtrade.trade.query": {}
  }
}
```

## Other tools on Apibase (1383)

- `infra.cloudflare.dns_delete` — Destructive — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/infra.cloudflare.dns-delete.md
- `infra.cloudflare.purge_cache` — Destructive — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/infra.cloudflare.purge-cache.md
- `polymarket.trading.cancel_order` — Destructive — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/polymarket.trading.cancel-order.md
- `ai.image.generate` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/ai.image.generate.md
- `aipush.market.report` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/aipush.market.report.md
- `audio.transcribe.submit` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/audio.transcribe.submit.md
- `dev.code.execute` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/dev.code.execute.md
- `device.registry.command` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/device.registry.command.md
- `document.convert.from_pdf` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/document.convert.from-pdf.md
- `document.convert.to_pdf` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/document.convert.to-pdf.md
- `document.convert.web_to_pdf` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/document.convert.web-to-pdf.md
- `hf_inference.nlp.translate` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/hf-inference.nlp.translate.md
- `infra.browser.create_session` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/infra.browser.create-session.md
- `phone.telnyx.sms_world` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/phone.telnyx.sms-world.md
- `phone.twilio.sms` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/phone.twilio.sms.md
- `platform.batch.call` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/platform.batch.call.md
- `scb.tables.query` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/scb.tables.query.md
- `socrata.datasets.query` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/socrata.datasets.query.md
- `web.screenshot.capture` — Execute — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/web.screenshot.capture.md
- `domain.namesilo.register` — Financial — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/domain.namesilo.register.md
- `phone.telnyx.sms_premium` — Financial — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/phone.telnyx.sms-premium.md
- `polymarket.trading.place_order` — Financial — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/polymarket.trading.place-order.md
- `abr.business.abn_lookup` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abr.business.abn-lookup.md
- `abr.business.acn_lookup` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abr.business.acn-lookup.md
- `abr.business.name_search` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abr.business.name-search.md
- `abs.demographics.population` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abs.demographics.population.md
- `abs.economy.cpi` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abs.economy.cpi.md
- `abs.economy.gdp` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abs.economy.gdp.md
- `abs.economy.labour_force` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abs.economy.labour-force.md
- `abs.economy.trade` — Read — https://policylayer.com/tools/io-github-whiteknightonhorse-apibase/abs.economy.trade.md
- …and 1353 more: https://policylayer.com/tools/io-github-whiteknightonhorse-apibase.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=io-github-whiteknightonhorse-apibase · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/io-github-whiteknightonhorse-apibase
