Skip to main content
Glama

un-comtrade-mcp-server

Get Services Trade Data

comtrade_get_services_trade
Read-only

Fetch annual international trade-in-services data. Classification EB (default) serves each reporter-period as reported, in its own scheme (EB10, EB10S or EB02 codes); EB10 or EB02 selects UN Comtrade's conversion of other schemes into that one. Each row names its classification and whether it is original or converted. Same bilateral structure as goods trade: returns flow value in USD, period, and reporter/partner/category metadata for each row. Follow nextOffset for remaining records; each page repeats the upstream period requests. Use comtrade_list_service_categories to find a service code and its scheme before querying. Keyless preview makes one request per served period, at least 4 seconds apart, capped at 500 records per request. Services coverage is more limited than goods trade.

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": {
      "reporter_code": "<reporter_code>",
      "flow_code": "<flow_code>",
      "period": "<period>"
    },
    "name": "comtrade_get_services_trade"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoRecords per page (default 25). Larger requests are limited to 1000 with a notice.
offsetNoNumber of retrieved records to skip.
periodYesAnnual periods YYYY. Serves the first 8 distinct periods keyless (12 with authenticated access); the rest, and any period whose request is rate limited, fails on a UN Comtrade server error or network failure, or runs out of time, are listed in unservedPeriods. Input ceiling 120.
flow_codeYesTrade flow: M=imports (debits), X=exports (credits).
partner_codeNoM49 partner code. Use 0 for all partners combined (World). Omitting it can return World alongside the partner breakdown.
service_codeNoService category code in one scheme: "7" (EB10), "SG" (EB10S) and "260" (EB02) are each financial services. Under EB a code returns rows only for periods reported in its scheme; comtrade_list_service_categories lists codes with their schemes. Omit to get every category the reporter reported, at mixed levels: totals (200 for EB10 and EB02, S for EB10S) beside their components, so do not sum the rows.
reporter_codeYesM49 numeric code of the reporting country (0–999).
classificationNoServices classification. EB (default): each reporter-period as reported, in its own scheme (EB10, EB10S or EB02 codes). EB10 or EB02: UN Comtrade's conversion of reports from other schemes into that one; reports made in it stay under EB. EB10S has no converted series; its rows are served only under EB. Case-insensitive; blank means EB.EB

Output Schema

NameRequiredDescriptionDefault
errorNoPresent when the call failed. Absent on success.
shownNoNumber of records on this page.
noticeNoWorld overlap warnings, period failures, and guidance for empty results, including EB scheme coverage, ISO-3 counterpart codes, or partner_code 158 for Taiwan services.
offsetNoNumber of retrieved records skipped for this page.
recordsNoServices trade flow records.
truncatedNoTrue when any preview response reached 500 and may be incomplete.
limitClampNoRequested and applied page sizes when the limit was clamped.
nextOffsetNoOffset for the next page when more records remain.
totalCountNoSum of upstream response counts before local filtering; not a full match count when capped.
truncationHintNoQuery narrowing and authenticated access guidance when possibly incomplete.
referenceNoticeNoReference descriptions unavailable; codes and values retained.
unservedPeriodsNoPeriods not served: past the period cap (8 keyless, 12 authenticated) or whose requests were rate limited, failed on a UN Comtrade server error or network failure, or ran out of time; query them separately.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • addedInput schema / properties / limit
      Added value: +{
      +  "default": 25,
      +  "description": "Records per page (default 25). Larger requests are limited to 1000 with a notice.",
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Number of retrieved records to skip.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • changedOutput schema / anyOf
      Previous value: -[
      -  {
      -    "not": {
      -      "required": [
      -        "error"
      -      ]
      -    },
      -    "required": [
      -      "records",
      -      "totalCount",
      -      "shown",
      -      "truncated"
      -    ]
      -  },
      -  {
      -    "required": [
      -      "error"
      -    ]
      -  }
      -]New value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "records",
      +      "totalCount",
      +      "offset",
      +      "shown",
      +      "truncated"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / limitClamp
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Requested and applied page sizes when the limit was clamped.",
      +  "properties": {
      +    "applied": {
      +      "description": "Applied records per page.",
      +      "type": "number"
      +    },
      +    "requested": {
      +      "description": "Requested records per page.",
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "requested",
      +    "applied"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / nextOffset
      Added value: +{
      +  "description": "Offset for the next page when more records remain.",
      +  "type": "number"
      +}
    • addedOutput schema / properties / offset
      Added value: +{
      +  "description": "Number of retrieved records skipped for this page.",
      +  "type": "number"
      +}
    • changedOutput schema / properties / shown / description
      Previous value: -"Number of records returned."New value: +"Number of records on this page."
  2. Changed2 schema fields changed
    • changedInput schema / properties / partner_code / description
      Previous value: -"M49 partner code. Use 0 for all partners combined. Omit for a disaggregated by-partner breakdown."New value: +"M49 partner code. Use 0 for all partners combined (World). Omitting it can return World alongside the partner breakdown."
    • changedOutput schema / properties / notice / description
      Previous value: -"Why data is missing: periods that were rate limited (with the wait), failed on a UN Comtrade server error (with the HTTP status) or network failure, or ran out of time, and, when no records are returned, the requested code's EB scheme or the code to query instead of a partner-only reporter_code (250 → 251, 158 → 490) or of a partner_code with a reporter-valid counterpart (840 → 842, 158 → 490), with the next call to make."New value: +"World overlap warnings, period failures, and guidance for empty results, including EB scheme coverage, ISO-3 counterpart codes, or partner_code 158 for Taiwan services."
  3. Changed5 schema fields changed
    • changedInput schema / properties / period / description
      Previous value: -"Annual periods YYYY. Serves the first 8 keyless (12 with authenticated access); the rest, and any period whose request is rate limited or runs out of time, are listed in unservedPeriods. Input ceiling 120."New value: +"Annual periods YYYY. Serves the first 8 distinct periods keyless (12 with authenticated access); the rest, and any period whose request is rate limited, fails on a UN Comtrade server error or network failure, or runs out of time, are listed in unservedPeriods. Input ceiling 120."
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode. Declared by this tool: `invalid_reporter_filter`: Reporter omission lacks an explicit partner. `upstream_validation`: UN Comtrade rejects the query dimensions. `invalid_upstream_response`: UN Comtrade returns malformed services data. `rate_limited`: No served period completed and UN Comtrade rate-limited at least one through its retries. `deadline_exceeded`: No served period completed within the call's time budget. Other values are possible when a failure originates below the handler."New value: +"Machine-readable failure mode. Declared by this tool: `invalid_reporter_filter`: Reporter omission lacks an explicit partner. `upstream_validation`: UN Comtrade rejects the query dimensions. `invalid_upstream_response`: UN Comtrade returns malformed services data. `rate_limited`: No served period completed and UN Comtrade rate-limited at least one through its retries. `upstream_unavailable`: No requested period completed and at least one request failed on a UN Comtrade server error or network failure after retries. `deadline_exceeded`: No served period completed within the call's time budget. Other values are possible when a failure originates below the handler."
    • changedOutput schema / properties / error / properties / data / properties / reason / examples
      Previous value: -[
      -  "invalid_reporter_filter",
      -  "upstream_validation",
      -  "invalid_upstream_response",
      -  "rate_limited",
      -  "deadline_exceeded"
      -]New value: +[
      +  "invalid_reporter_filter",
      +  "upstream_validation",
      +  "invalid_upstream_response",
      +  "rate_limited",
      +  "upstream_unavailable",
      +  "deadline_exceeded"
      +]
    • changedOutput schema / properties / notice / description
      Previous value: -"Why data is missing: periods that were rate limited (with the wait) or ran out of time, and, when no records are returned, the requested code's EB scheme or a partner-only reporter's counterpart, with the next call to make."New value: +"Why data is missing: periods that were rate limited (with the wait), failed on a UN Comtrade server error (with the HTTP status) or network failure, or ran out of time, and, when no records are returned, the requested code's EB scheme or the code to query instead of a partner-only reporter_code (250 → 251, 158 → 490) or of a partner_code with a reporter-valid counterpart (840 → 842, 158 → 490), with the next call to make."
    • changedOutput schema / properties / unservedPeriods / description
      Previous value: -"Periods not served: past the period cap (8 keyless, 12 authenticated) or whose requests were rate limited or ran out of time; query them separately."New value: +"Periods not served: past the period cap (8 keyless, 12 authenticated) or whose requests were rate limited, failed on a UN Comtrade server error or network failure, or ran out of time; query them separately."
  4. Changed8 schema fields changed
    • addedInput schema / properties / classification
      Added value: +{
      +  "default": "EB",
      +  "description": "Services classification. EB (default): each reporter-period as reported, in its own scheme (EB10, EB10S or EB02 codes). EB10 or EB02: UN Comtrade's conversion of reports from other schemes into that one; reports made in it stay under EB. EB10S has no converted series; its rows are served only under EB. Case-insensitive; blank means EB.",
      +  "enum": [
      +    "EB",
      +    "EB10",
      +    "EB02"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / period / description
      Previous value: -"Annual periods YYYY. Serves the first 12 and discloses the remainder; input ceiling 120. Preview makes one paced request per period."New value: +"Annual periods YYYY. Serves the first 8 keyless (12 with authenticated access); the rest, and any period whose request is rate limited or runs out of time, are listed in unservedPeriods. Input ceiling 120."
    • changedInput schema / properties / service_code / description
      Previous value: -"EB service category code (e.g. \"SA\" for manufacturing services or \"3\" for transport). Use comtrade_list_service_categories to find available codes. Omit to get totals across all service categories."New value: +"Service category code in one scheme: \"7\" (EB10), \"SG\" (EB10S) and \"260\" (EB02) are each financial services. Under EB a code returns rows only for periods reported in its scheme; comtrade_list_service_categories lists codes with their schemes. Omit to get every category the reporter reported, at mixed levels: totals (200 for EB10 and EB02, S for EB10S) beside their components, so do not sum the rows."
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode. Declared by this tool: `invalid_reporter_filter`: Reporter omission lacks an explicit partner. `upstream_validation`: UN Comtrade rejects the query dimensions. `invalid_upstream_response`: UN Comtrade returns malformed services data. Other values are possible when a failure originates below the handler."New value: +"Machine-readable failure mode. Declared by this tool: `invalid_reporter_filter`: Reporter omission lacks an explicit partner. `upstream_validation`: UN Comtrade rejects the query dimensions. `invalid_upstream_response`: UN Comtrade returns malformed services data. `rate_limited`: No served period completed and UN Comtrade rate-limited at least one through its retries. `deadline_exceeded`: No served period completed within the call's time budget. Other values are possible when a failure originates below the handler."
    • changedOutput schema / properties / error / properties / data / properties / reason / examples
      Previous value: -[
      -  "invalid_reporter_filter",
      -  "upstream_validation",
      -  "invalid_upstream_response"
      -]New value: +[
      +  "invalid_reporter_filter",
      +  "upstream_validation",
      +  "invalid_upstream_response",
      +  "rate_limited",
      +  "deadline_exceeded"
      +]
    • changedOutput schema / properties / notice / description
      Previous value: -"Recovery hint when no records are returned."New value: +"Why data is missing: periods that were rate limited (with the wait) or ran out of time, and, when no records are returned, the requested code's EB scheme or a partner-only reporter's counterpart, with the next call to make."
    • addedOutput schema / properties / records / items / properties / isOriginalClassification
      Added value: +{
      +  "description": "True when the row is in the scheme the reporter used; false when UN Comtrade converted it into the requested classification.",
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / unservedPeriods / description
      Previous value: -"Periods beyond the 12-period work cap; query them separately."New value: +"Periods not served: past the period cap (8 keyless, 12 authenticated) or whose requests were rate limited or ran out of time; query them separately."
  5. Changed18 schema fields changed
    • changedInput schema / properties / flow_code / description
      Previous value: -"Trade flow: M=imports (credit received by reporter), X=exports (debit paid)."New value: +"Trade flow: M=imports (debits), X=exports (credits)."
    • removedInput schema / properties / flow_code / enum
      Removed value: -[
      -  "M",
      -  "X"
      -]
    • changedInput schema / properties / partner_code / maximum
      Previous value: -9007199254740991New value: +999
    • changedInput schema / properties / partner_code / minimum
      Previous value: --9007199254740991New value: +0
    • changedInput schema / properties / period / description
      Previous value: -"Periods (YYYY or YYYYMM). Serves the first 12 and discloses the remainder; input ceiling 120. Preview makes one paced request per period."New value: +"Annual periods YYYY. Serves the first 12 and discloses the remainder; input ceiling 120. Preview makes one paced request per period."
    • removedInput schema / properties / period / items / minLength
      Removed value: -4
    • addedInput schema / properties / period / items / pattern
      Added value: +"^[0-9]{4}$"
    • changedInput schema / properties / reporter_code / description
      Previous value: -"M49 numeric code of the reporting country."New value: +"M49 numeric code of the reporting country (0–999)."
    • changedInput schema / properties / reporter_code / maximum
      Previous value: -9007199254740991New value: +999
    • changedInput schema / properties / reporter_code / minimum
      Previous value: --9007199254740991New value: +0
    • changedInput schema / properties / service_code / description
      Previous value: -"EBOPS 2010 service category code (e.g. \"SA\" for transport). Use comtrade_list_service_categories to find available codes. Omit to get totals across all service categories."New value: +"EB service category code (e.g. \"SA\" for manufacturing services or \"3\" for transport). Use comtrade_list_service_categories to find available codes. Omit to get totals across all service categories."
    • addedInput schema / properties / service_code / pattern
      Added value: +"^(?:[A-Z0-9]+(?:\\.[A-Z0-9]+)*)?$"
    • 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_reporter_filter`: Reporter omission lacks an explicit partner. `upstream_validation`: UN Comtrade rejects the query dimensions. `invalid_upstream_response`: UN Comtrade returns malformed services data. Other values are possible when a failure originates below the handler."
    • addedOutput schema / properties / error / properties / data / properties / reason / examples
      Added value: +[
      +  "invalid_reporter_filter",
      +  "upstream_validation",
      +  "invalid_upstream_response"
      +]
    • addedOutput schema / properties / records / items / properties / classificationCode
      Added value: +{
      +  "description": "Actual services classification edition on the returned row.",
      +  "type": "string"
      +}
    • changedOutput schema / properties / records / items / properties / flowCode / description
      Previous value: -"Trade flow: M=import (credit received), X=export (debit paid)."New value: +"Trade flow: M=imports (debits), X=exports (credits)."
    • changedOutput schema / properties / records / items / properties / period / description
      Previous value: -"Period (YYYY or YYYYMM)."New value: +"Annual period YYYY."
    • addedOutput schema / properties / referenceNotice
      Added value: +{
      +  "description": "Reference descriptions unavailable; codes and values retained.",
      +  "type": "string"
      +}
  6. 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 openWorld, so the description carries the real burden and does so: keyless preview rate (one request per served period, at least 4 seconds apart, 500-record cap), pagination via nextOffset with each page repeating upstream period requests, and the warning not to sum rows because totals sit beside components. It also explains that each row labels its own classification and whether it is original or converted.

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?

Front-loaded with purpose and return shape, then pagination, then the prerequisite tool, then rate limits and coverage caveat. Dense but mostly earned; the classification sentence partially restates the enum documentation, which keeps it from a 5.

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?

Covers purpose, return structure, pagination, rate-limit behavior, prerequisite lookup, and the aggregation pitfall, for an 8-parameter open-world query tool. Even though an output schema exists, the extra return-value context is accurate and not redundant filler.

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 the baseline is 3; the description goes further by explaining the cross-parameter interaction between classification and service_code (scheme-specific codes return rows only for periods reported in that scheme) and by warning about mixed aggregation levels when service_code is omitted. That is meaning the per-parameter schema text does not convey on its own.

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?

Opening sentence gives a specific verb and resource (annual international trade-in-services data) and the rest distinguishes it from goods trade and from comtrade_list_service_categories. An agent can tell this is the services counterpart to the goods flow tool without opening the schema.

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?

Explicitly routes the agent to comtrade_list_service_categories to resolve a service code and its scheme before querying, and warns that services coverage is more limited than goods trade. It lacks an explicit 'do not use this for X' exclusion naming the goods-trade sibling, so it falls short of a 5.

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.