mcp-comexstat
The MCP Server for API Comexstat provides access to Brazilian foreign trade statistics and related auxiliary data. With this server, you can:
Query Trade Data: Retrieve export/import statistics with detailed filters, fields, and metrics
Access Municipal Data: Get trade information specific to Brazilian municipalities
Examine Historical Records: View historical trade data from 1989-1996
Check Update Status: Get the date of the last data update
Retrieve Auxiliary Tables: Access lists and details for states, cities, countries, economic blocks, and trade codes (Harmonized System, NBM)
Perform Custom Queries: Create detailed queries with various parameters including flow type, period, filters, and metrics
List Available Parameters: View available years, filters, fields, and metrics for constructing queries
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-comexstat show me Brazil's top 5 export partners in 2023"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 buildQuick Use
# Execute o servidor MCP
npm startAvailable Tools
The MCP server provides the following tools:
General Data
getLastUpdate()- Gets the date the data was last updatedgetAvailableYears()- Lists the years available for querygetAvailableFilters()- Lists available filtersgetFilterValues(filter, language?)- Gets values for a specific filtergetAvailableFields()- Lists the fields available for detailinggetAvailableMetrics()- Lists available metricsqueryData(options)- Performs detailed queries with the following parameters:flow: "export" | "import"period: { from: "YYYY-MM", to: "YYYY-MM" }monthDetail: booleanfilters: Array of filters (optional)details: Array of fields for detailingmetrics: Array of metricslanguage: 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 statesgetStateDetails(ufId)- Details of a specific stategetCities()- List of citiesgetCityDetails(cityId)- Details of a specific citygetCountries(search?)- List countriesgetCountryDetails(countryId)- Details of a specific countrygetEconomicBlocks(options?)- List economic blocksgetHarmonizedSystem(options?)- Harmonized System (HS)getNBM(options?)- Brazilian Nomenclature of GoodsgetNBMDetails(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:
Add the configuration to the
claude_desktop_config.jsonfile:{ "mcpServers": { "comexstat": { "command": "node", "args": ["/caminho/completo/para/mcp-comexstat-easy/dist/index.js"] } } }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 -- --coverageLicense
MIT
Available Tools
20 toolsgetAuxiliaryTableD
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
Scored across 20 tools
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.
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).
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.
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
Related MCP Connectors
Brazil Comex Stat MCP — Brazilian foreign trade statistics from MDIC (Ministério do…
MCP server for Brazilian Federal Senate open data (legislative, administrative, e-Cidadania).
Comtrade MCP — UN Comtrade API for international bilateral trade data
# MCP DadosBR Servidor MCP focado em dados públicos do Brasil. Oferece duas ferramentas simples e…
Related MCP Servers
- AlicenseBqualityCmaintenanceMCP 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).10020MIT
- AlicenseAqualityBmaintenanceMCP server for the Brazilian Chamber of Deputies open-data API, enabling search and retrieval of federal legislative bills and their status.1569 PyPI2Apache 2.0
- AlicenseNot gradedqualityDmaintenanceMCP server for the Omie API to list products, consult clients, and create budgets19 npmMIT
- FlicenseNot gradedqualityDmaintenanceMCP server that provides access to UK trade data from the ONS Trade Data API, enabling queries for trade statistics, metadata, and raw data.-