Skip to main content
Glama

un-comtrade-mcp-server

Search Commodity Codes

comtrade_search_commodities
Read-only

Find HS or SITC commodity codes by keyword, description, or code prefix. A code written with dots, spaces, or hyphens ("0901.11") matches 090111. Exact codes, code prefixes and contiguous description matches rank first, followed by descriptions containing every query term in any order. Default HS searches include historical codes and report which edition catalogs list each code. Use a trade row’s classificationCode or comtrade_get_data_availability to identify the edition, then search that edition for its descriptions. Keyless goods queries use HS for as-reported data. Continue with nextOffset using the same query, classification, and aggr_level.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "comtrade_search_commodities"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum matching codes returned per page; defaults to 50.
queryYesKeyword, partial description, or commodity code prefix. Dots, spaces, and hyphens in a code are ignored, so "0901.11" finds 090111. Examples: "motor vehicles", "8471", "coffee", "84" (HS chapter 84 = machinery).
offsetNoNumber of matching codes to skip; use nextOffset to continue.
aggr_levelNoNative aggregation level: HS uses 2 (chapter), 4 (heading), 6 (subheading); SITC uses 1–5. Omit to return all matching levels.
classificationNoGoods reference catalog, case-insensitive: HS uses the default HS.json discovery catalog, whose total identifies H6; it is not an authoritative historical-edition reference. Select H0–H6 for an explicit HS edition, or SS/S1–S4 for SITC.HS

Output Schema

NameRequiredDescriptionDefault
errorNoPresent when the call failed. Absent on success.
shownNoNumber of codes returned on this page.
noticeNoRecovery hint when no codes match, matches remain past this page, or the offset is past the end. Absent otherwise.
offsetNoNumber of matching codes skipped for this page.
matchesNoCommodity codes on this page matching the query in the selected classification, ranked exact code, code prefix, whole-word description match, then other description matches for the contiguous query, then descriptions containing every term in any order. Ties keep catalog order.
truncatedNoWhether this page holds only part of the matching codes (shown < totalMatches).
nextOffsetNoOffset for the next page; absent when no matching codes remain.
totalMatchesNoTotal matching codes across all pages.
classificationNoReference catalog used for the search.
referenceNoticeNoUnavailable HS edition catalog names when the discovery page is returned without edition enrichment.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedOutput schema / properties / matches / description
      Previous value: -"Commodity codes on this page matching the query in the selected classification, ranked exact code, code prefix, whole-word description match, then other description matches; ties keep catalog order."New value: +"Commodity codes on this page matching the query in the selected classification, ranked exact code, code prefix, whole-word description match, then other description matches for the contiguous query, then descriptions containing every term in any order. Ties keep catalog order."
    • addedOutput schema / properties / matches / items / properties / editions
      Added value: +{
      +  "description": "H0–H6 catalogs listing this code in edition order. Definitions may differ across editions. Available for default HS searches when edition catalogs load.",
      +  "items": {
      +    "enum": [
      +      "H0",
      +      "H1",
      +      "H2",
      +      "H3",
      +      "H4",
      +      "H5",
      +      "H6"
      +    ],
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / matches / items / properties / parentDescription
      Added value: +{
      +  "description": "Immediate parent description from the default HS discovery catalog, when the code is absent from H6 and the parent exists in the discovery catalog.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / referenceNotice
      Added value: +{
      +  "description": "Unavailable HS edition catalog names when the discovery page is returned without edition enrichment.",
      +  "type": "string"
      +}
  2. Changed2 schema fields changed
    • changedInput schema / properties / query / description
      Previous value: -"Keyword, partial description, or commodity code prefix. Examples: \"motor vehicles\", \"8471\", \"coffee\", \"84\" (HS chapter 84 = machinery)."New value: +"Keyword, partial description, or commodity code prefix. Dots, spaces, and hyphens in a code are ignored, so \"0901.11\" finds 090111. Examples: \"motor vehicles\", \"8471\", \"coffee\", \"84\" (HS chapter 84 = machinery)."
    • changedOutput schema / properties / matches / description
      Previous value: -"Commodity codes on this page matching the query in the selected classification, in catalog order."New value: +"Commodity codes on this page matching the query in the selected classification, ranked exact code, code prefix, whole-word description match, then other description matches; ties keep catalog order."
  3. Changed13 schema fields changed
    • changedInput schema / properties / classification / description
      Previous value: -"Goods reference catalog: HS uses the default HS.json discovery catalog, whose total identifies H6; it is not an authoritative historical-edition reference. Select H0–H6 for an explicit HS edition, or SS/S1–S4 for SITC."New value: +"Goods reference catalog, case-insensitive: HS uses the default HS.json discovery catalog, whose total identifies H6; it is not an authoritative historical-edition reference. Select H0–H6 for an explicit HS edition, or SS/S1–S4 for SITC."
    • removedInput schema / properties / classification / enum
      Removed value: -[
      -  "HS",
      -  "H0",
      -  "H1",
      -  "H2",
      -  "H3",
      -  "H4",
      -  "H5",
      -  "H6",
      -  "SS",
      -  "S1",
      -  "S2",
      -  "S3",
      -  "S4"
      -]
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of results to return; above 200 returns all matching codes."New value: +"Maximum matching codes returned per page; defaults to 50."
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Number of matching codes to skip; use nextOffset to continue.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • changedOutput schema / anyOf
      Previous value: -[
      -  {
      -    "not": {
      -      "required": [
      -        "error"
      -      ]
      -    },
      -    "required": [
      -      "classification",
      -      "matches",
      -      "totalMatches",
      -      "shown",
      -      "truncated"
      -    ]
      -  },
      -  {
      -    "required": [
      -      "error"
      -    ]
      -  }
      -]New value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "classification",
      +      "matches",
      +      "totalMatches",
      +      "shown",
      +      "truncated",
      +      "offset"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • changedOutput schema / properties / matches / description
      Previous value: -"Commodity codes matching the query in the selected classification."New value: +"Commodity codes on this page matching the query in the selected classification, in catalog order."
    • changedOutput schema / properties / matches / items / properties / aggrLevel / description
      Previous value: -"Native aggregation level in the selected HS or SITC catalog."New value: +"Native aggregation level in the selected HS or SITC catalog; 0 is the all-commodities TOTAL, which no aggr_level filter returns."
    • addedOutput schema / properties / nextOffset
      Added value: +{
      +  "description": "Offset for the next page; absent when no matching codes remain.",
      +  "type": "number"
      +}
    • changedOutput schema / properties / notice / description
      Previous value: -"Recovery hint when no matches are found or results are truncated. Absent when results are non-empty and not truncated."New value: +"Recovery hint when no codes match, matches remain past this page, or the offset is past the end. Absent otherwise."
    • addedOutput schema / properties / offset
      Added value: +{
      +  "description": "Number of matching codes skipped for this page.",
      +  "type": "number"
      +}
    • changedOutput schema / properties / shown / description
      Previous value: -"Number of codes returned in this response."New value: +"Number of codes returned on this page."
    • changedOutput schema / properties / totalMatches / description
      Previous value: -"Total matching codes (before limit truncation)."New value: +"Total matching codes across all pages."
    • changedOutput schema / properties / truncated / description
      Previous value: -"True when matches were capped at the limit (totalMatches exceeds shown)."New value: +"Whether this page holds only part of the matching codes (shown < totalMatches)."
  4. Changed15 schema fields changed
    • changedInput schema / properties / aggr_level / anyOf
      Previous value: -[
      -  {
      -    "const": 2,
      -    "type": "number"
      -  },
      -  {
      -    "const": 4,
      -    "type": "number"
      -  },
      -  {
      -    "const": 6,
      -    "type": "number"
      -  }
      -]New value: +[
      +  {
      +    "const": 1,
      +    "type": "number"
      +  },
      +  {
      +    "const": 2,
      +    "type": "number"
      +  },
      +  {
      +    "const": 3,
      +    "type": "number"
      +  },
      +  {
      +    "const": 4,
      +    "type": "number"
      +  },
      +  {
      +    "const": 5,
      +    "type": "number"
      +  },
      +  {
      +    "const": 6,
      +    "type": "number"
      +  }
      +]
    • changedInput schema / properties / aggr_level / description
      Previous value: -"Aggregation level: 2 = HS chapter (most general), 4 = heading, 6 = subheading (most specific). Omit to return all matching levels."New value: +"Native aggregation level: HS uses 2 (chapter), 4 (heading), 6 (subheading); SITC uses 1–5. Omit to return all matching levels."
    • changedInput schema / properties / classification / description
      Previous value: -"HS classification version. \"HS\" covers the combined dataset across all editions (H0–H6). Use a specific edition (e.g. \"H6\") for version-specific lookups."New value: +"Goods reference catalog: HS uses the default HS.json discovery catalog, whose total identifies H6; it is not an authoritative historical-edition reference. Select H0–H6 for an explicit HS edition, or SS/S1–S4 for SITC."
    • changedInput schema / properties / classification / enum
      Previous value: -[
      -  "HS",
      -  "H0",
      -  "H1",
      -  "H2",
      -  "H3",
      -  "H4",
      -  "H5",
      -  "H6"
      -]New value: +[
      +  "HS",
      +  "H0",
      +  "H1",
      +  "H2",
      +  "H3",
      +  "H4",
      +  "H5",
      +  "H6",
      +  "SS",
      +  "S1",
      +  "S2",
      +  "S3",
      +  "S4"
      +]
    • changedInput schema / properties / query / description
      Previous value: -"Keyword, partial description, or HS code prefix to search for. Examples: \"motor vehicles\", \"8471\", \"coffee\", \"84\" (chapter 84 = machinery)."New value: +"Keyword, partial description, or commodity code prefix. Examples: \"motor vehicles\", \"8471\", \"coffee\", \"84\" (HS chapter 84 = machinery)."
    • changedOutput schema / anyOf
      Previous value: -[
      -  {
      -    "not": {
      -      "required": [
      -        "error"
      -      ]
      -    },
      -    "required": [
      -      "matches",
      -      "totalMatches",
      -      "shown",
      -      "truncated"
      -    ]
      -  },
      -  {
      -    "required": [
      -      "error"
      -    ]
      -  }
      -]New value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "classification",
      +      "matches",
      +      "totalMatches",
      +      "shown",
      +      "truncated"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / classification
      Added value: +{
      +  "description": "Reference catalog used for the search.",
      +  "type": "string"
      +}
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode."New value: +"Machine-readable failure mode. Declared by this tool: `invalid_aggregation_level`: The requested level does not belong to the selected classification family. Other values are possible when a failure originates below the handler."
    • addedOutput schema / properties / error / properties / data / properties / reason / examples
      Added value: +[
      +  "invalid_aggregation_level"
      +]
    • changedOutput schema / properties / matches / description
      Previous value: -"HS codes matching the query."New value: +"Commodity codes matching the query in the selected classification."
    • changedOutput schema / properties / matches / items / description
      Previous value: -"A single HS commodity code entry."New value: +"A commodity entry from the selected catalog."
    • changedOutput schema / properties / matches / items / properties / aggrLevel / description
      Previous value: -"Aggregation level: 2 (chapter), 4 (heading), 6 (subheading)."New value: +"Native aggregation level in the selected HS or SITC catalog."
    • changedOutput schema / properties / matches / items / properties / id / description
      Previous value: -"HS code string (e.g. \"84\", \"8471\", \"847130\")."New value: +"Commodity code in the selected classification, preserving leading zeros."
    • changedOutput schema / properties / matches / items / properties / parent / description
      Previous value: -"Parent HS code (chapter for headings; heading for subheadings)."New value: +"Parent commodity code in the selected classification."
    • changedOutput schema / properties / matches / items / properties / recommendedQueryCode / description
      Previous value: -"Best code to pass as cmd_code in trade data queries for this commodity. Uses the most specific level that returns meaningful data."New value: +"Code to pass as cmd_code with the same classification in trade data queries."
  5. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnly and closed-world; the description adds real behavior: result ranking order (exact code, prefix, contiguous description, then all-terms matches), that default HS searches include historical codes and report cataloging editions, and the nextOffset continuation contract.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded in the first sentence and every subsequent sentence adds operational information (ranking, editions, pagination). Slightly dense run-on phrasing around the classification guidance, but no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter search tool with an output schema and annotations, the description covers matching semantics, ranking, defaults, edition selection, and continuation. An agent could invoke and paginate it correctly without further reference.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds value beyond it: it explains the normalization rule applies to codes and, importantly, that pagination must reuse the same query, classification, and aggr_level — a constraint the schema does not state. The classification/edition relationship is also clarified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource ('Find HS or SITC commodity codes') and enumerates the three matching modes (keyword, description, code prefix). It is also clearly distinguishable from the retrieval siblings, which return trade values rather than code catalogs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a concrete workflow: take the classificationCode from a trade row or call comtrade_get_data_availability to identify the edition, then search that edition. Also states the keyless-query default of HS. It stops short of explicit when-not-to-use conditions, but the routing context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.