Skip to main content
Glama
mcp-comexstat

mcp-comexstat

by luizzzvictor

MCP Server for Comexstat API

This project implements an MCP (Model Context Protocol) server for the Comexstat API, allowing AI models like Claude to interact directly with Brazil's foreign trade data.

Overview

The MCP Comexstat server provides tools to query Brazilian export and import statistics, including:

  • General export and import data

  • Data by municipalities

  • Historical data (1989-1996)

  • Auxiliary tables with codes and descriptions

Related MCP server: br-eli-mcp

Features

  • Implemented using @modelcontextprotocol/sdk

  • Typing with TypeScript

  • Data validation with Zod

  • Support for communication via stdin/stdout (MCP standard)

  • Robust API error handling and responses

Installation

# Clone o repositório
git clone https://github.com/luizzzvictor/mcp-comexstat-easy.git
cd mcp-comexstat-easy

# Instale as dependências
npm install

# Compile o código TypeScript
npm run build

Quick Use

# Execute o servidor MCP
npm start

Available Tools

The MCP server provides the following tools:

General Data

  • getLastUpdate() - Gets the date the data was last updated

  • getAvailableYears() - Lists the years available for query

  • getAvailableFilters() - Lists available filters

  • getFilterValues(filter, language?) - Gets values for a specific filter

  • getAvailableFields() - Lists the fields available for detailing

  • getAvailableMetrics() - Lists available metrics

  • queryData(options) - Performs detailed queries with the following parameters:

    • flow : "export" | "import"

    • period : { from: "YYYY-MM", to: "YYYY-MM" }

    • monthDetail : boolean

    • filters : Array of filters (optional)

    • details : Array of fields for detailing

    • metrics : Array of metrics

    • language : string (optional, default: "pt")

Data by Municipalities

  • queryMunicipalitiesData(options) - Query data focusing on municipalities

Historical Data

  • queryHistoricalData(options) - Query historical data (1989-1996)

Auxiliary Tables

  • getStates() - List Brazilian states

  • getStateDetails(ufId) - Details of a specific state

  • getCities() - List of cities

  • getCityDetails(cityId) - Details of a specific city

  • getCountries(search?) - List countries

  • getCountryDetails(countryId) - Details of a specific country

  • getEconomicBlocks(options?) - List economic blocks

  • getHarmonizedSystem(options?) - Harmonized System (HS)

  • getNBM(options?) - Brazilian Nomenclature of Goods

  • getNBMDetails(coNbm) - Details of a specific NBM code

Usage Example

// Consultar exportações para os EUA em 2023
const result = await queryData({
  flow: "export",
  period: { from: "2023-01", to: "2023-12" },
  monthDetail: false,
  filters: [{ filter: "country", values: [105] }],
  details: ["country", "month"],
  metrics: ["metricFOB", "metricKG"],
});

Integration with Claude

To use the MCP server with Claude Desktop:

  1. Add the configuration to the claude_desktop_config.json file:

    {
      "mcpServers": {
        "comexstat": {
          "command": "node",
          "args": ["/caminho/completo/para/mcp-comexstat-easy/dist/index.js"]
        }
      }
    }
  2. On Claude Desktop, use the command:

    /mcp comexstat

Development

# Executar em modo de desenvolvimento
npm run dev

# Executar testes
npm test

# Verificar cobertura de testes
npm test -- --coverage

License

MIT

Available Tools

20 tools
getAuxiliaryTableD

Inputs: table (required), page, pageSize, search.

getAvailableFieldsD

Inputs: no named parameters.

getAvailableFiltersD

Inputs: no named parameters.

getAvailableMetricsD

Inputs: no named parameters.

getAvailableYearsD

Inputs: no named parameters.

getCitiesD

Inputs: no named parameters.

getCityDetailsD

Inputs: cityId (required).

getCountriesD

Inputs: search.

getCountryDetailsD

Inputs: countryId (required).

getEconomicBlocksD

Inputs: add, language, search.

getFilterValuesD

Inputs: filter (required), language.

getHarmonizedSystemD

Inputs: add, language, page, perPage.

getLastUpdateD

Inputs: no named parameters.

getNBMD

Inputs: add, language, page, perPage, +1 more.

getNBMDetailsD

Inputs: coNbm (required).

getStateDetailsD

Inputs: ufId (required).

getStatesD

Inputs: no named parameters.

queryDataD

Inputs: details (required), flow (required), metrics (required), monthDetail (required), +3 more.

queryHistoricalDataD

Inputs: details (required), flow (required), metrics (required), period (required), +3 more.

queryMunicipalitiesDataD

Inputs: details (required), flow (required), metrics (required), period (required), +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    D1.9/5.0

    Scored across 20 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes targeting different data entities (countries, states, cities, NBM, etc.) or metadata (available fields, filters, metrics). However, some pairs like getCities/getMunicipalitiesData and getNBM/getNBMDetails have potential overlap that could cause confusion without descriptions to clarify their boundaries.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with 'get' or 'query' prefixes, using camelCase uniformly throughout. The naming is highly predictable and readable, with clear conventions for different types of operations (get for metadata/entities, query for data retrieval).

    Tool Count3/5

    With 20 tools, this is borderline heavy for a trade statistics server. While the domain appears broad (covering countries, states, cities, NBM codes, auxiliary tables, etc.), the count feels somewhat inflated with multiple similar metadata tools (getAvailableFields/Filters/Metrics/Years) that might be consolidated.

    Completeness4/5

    The tool set appears to provide comprehensive coverage for trade data exploration and retrieval, including metadata discovery, entity lookups, and data querying across different dimensions (current, historical, municipal). Minor gaps might exist in data modification capabilities, but for a read-only statistical service, the surface seems reasonably complete.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      MCP Server do SEI Pro para o SEI (Sistema Eletrônico de Informações) via API REST mod-wssei v2 + scraper do frontend web (modo híbrido).
      100
      20
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for the Brazilian Chamber of Deputies open-data API, enabling search and retrieval of federal legislative bills and their status.
      15
      69 PyPI
      2
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for the Omie API to list products, consult clients, and create budgets
      19 npm
      MIT