Skip to main content
Glama
luizzzvictor

mcp-comexstat

by luizzzvictor

queryData

Retrieve detailed trade data for imports or exports, filtered by country, state, economic block, or product categories, and analyze metrics like FOB, KG, and CIF within specified periods.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailsYes
filtersNo
flowYes
languageNopt
metricsYes
monthDetailYes
periodYes

Implementation Reference

  • Core handler implementation of queryData that validates period format and performs POST request to Comexstat API '/general' endpoint with the provided parameters.
    async queryData( flow: "export" | "import", period: { from: string; to: string }, // Format: YYYY-MM (e.g., "2023-01") monthDetail: boolean, filters: Array<{ filter: | "country" | "state" | "economicBlock" | "section" | "chapter" | "position" | "subposition" | "ncm"; values: number[]; }> = [], details: Array< | "country" | "state" | "economicBlock" | "section" | "chapter" | "position" | "subposition" | "ncm" >, metrics: Array< | "metricFOB" | "metricKG" | "metricStatistic" | "metricFreight" | "metricInsurance" | "metricCIF" >, language: string = "pt" ): Promise<{ data: { list: any[]; }; success: boolean; message: string | null; processo_info: any; language: string; }> { // Validate date format const dateFormatRegex = /^\d{4}-\d{2}$/; if ( !dateFormatRegex.test(period.from) || !dateFormatRegex.test(period.to) ) { throw new Error( 'Period dates must be in YYYY-MM format (e.g., "2023-01")' ); } return this.post( "/general", { flow, monthDetail, period, filters, details, metrics, }, { language } ); }
  • Zod input schema for the queryData MCP tool defining parameters like flow, period, filters, details, metrics with validation.
    { flow: z.enum(["export", "import"]), monthDetail: z.boolean(), period: z.object({ from: z .string() .regex( /^\d{4}-\d{2}$/, "Must be in YYYY-MM format (e.g., '2023-01')" ), to: z .string() .regex( /^\d{4}-\d{2}$/, "Must be in YYYY-MM format (e.g., '2023-01')" ), }), filters: z .array( z.object({ filter: z.enum([ "country", "state", "economicBlock", "section", "chapter", "position", "subposition", "ncm", ]), values: z.array(z.number()), }) ) .optional(), details: z.array( z.enum([ "country", "state", "economicBlock", "section", "chapter", "position", "subposition", "ncm", ]) ), metrics: z.array( z.enum([ "metricFOB", "metricKG", "metricStatistic", "metricFreight", "metricInsurance", "metricCIF", ]) ), language: z.string().optional().default("pt"), },
  • MCP tool registration for 'queryData' using server.tool() with schema and wrapper handler that JSON.stringifies the client response.
    this.server.tool( "queryData", { flow: z.enum(["export", "import"]), monthDetail: z.boolean(), period: z.object({ from: z .string() .regex( /^\d{4}-\d{2}$/, "Must be in YYYY-MM format (e.g., '2023-01')" ), to: z .string() .regex( /^\d{4}-\d{2}$/, "Must be in YYYY-MM format (e.g., '2023-01')" ), }), filters: z .array( z.object({ filter: z.enum([ "country", "state", "economicBlock", "section", "chapter", "position", "subposition", "ncm", ]), values: z.array(z.number()), }) ) .optional(), details: z.array( z.enum([ "country", "state", "economicBlock", "section", "chapter", "position", "subposition", "ncm", ]) ), metrics: z.array( z.enum([ "metricFOB", "metricKG", "metricStatistic", "metricFreight", "metricInsurance", "metricCIF", ]) ), language: z.string().optional().default("pt"), }, async ({ flow, period, monthDetail, filters, details, metrics, language, }) => ({ content: [ { type: "text", text: JSON.stringify( await this.client.queryData( flow, period, monthDetail, filters || [], details, metrics, language ) ), }, ], }) );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/luizzzvictor/mcp-comexstat'

If you have feedback or need assistance with the MCP directory API, please join our Discord server