consultar_portadores_cartao
Query payment card holder information by quarter from Brazil's Central Bank data to analyze card ownership statistics and trends.
Instructions
Consulta informações sobre portadores de cartões de pagamento por trimestre.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trimestre | Yes | Ano e trimestre no formato YYYYQ (exemplo: '20234') | |
| top | No | Número máximo de registros a retornar (padrão: 100) | |
| filtro | No | Filtro OData para refinar a consulta |
Implementation Reference
- src/index.ts:444-465 (handler)Primary MCP handler for the tool: destructures trimestre (required), top, filtro; fetches from BCB API endpoint PortadoresCartaoDA; formats and returns JSON response as text content.case "consultar_portadores_cartao": { const { trimestre, top = 100, filtro } = args as { trimestre: string; top?: number; filtro?: string; }; const data = await fetchBCBData(`PortadoresCartaoDA(trimestre=@trimestre)?@trimestre='${trimestre}'`, { formato: "json", top, filter: filtro, }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:238-260 (registration)Tool registration in the tools array provided to ListToolsRequestHandler, includes name, description, and input schema.{ name: "consultar_portadores_cartao", description: "Consulta informações sobre portadores de cartões de pagamento por trimestre.", inputSchema: { type: "object", properties: { trimestre: { type: "string", description: "Ano e trimestre no formato YYYYQ (exemplo: '20234')", }, top: { type: "number", description: "Número máximo de registros a retornar (padrão: 100)", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"], }, }, ];
- src/index.ts:37-52 (helper)Core helper function used by the handler to query the BCB Olinda API with OData parameters and error handling.async function fetchBCBData(endpoint: string, params: QueryParams = {}) { try { const url = buildUrl(endpoint, params); const response = await axios.get(url, { headers: { "Accept": "application/json" } }); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Erro ao consultar API do BCB: ${error.message}`); } throw error; } }
- src/http-server.ts:448-469 (handler)Duplicate MCP handler implementation in the HTTP/SSE server for the same tool logic.case "consultar_portadores_cartao": { const { trimestre, top = 100, filtro } = args as { trimestre: string; top?: number; filtro?: string; }; const data = await fetchBCBData(`PortadoresCartaoDA(trimestre=@trimestre)?@trimestre='${trimestre}'`, { formato: "json", top, filter: filtro, }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/http-server.ts:228-249 (registration)Tool registration in the tools array for the HTTP/SSE MCP server.{ name: "consultar_portadores_cartao", description: "Consulta informações sobre portadores de cartões de pagamento por trimestre.", inputSchema: { type: "object", properties: { trimestre: { type: "string", description: "Ano e trimestre no formato YYYYQ (exemplo: '20234')", }, top: { type: "number", description: "Número máximo de registros a retornar (padrão: 100)", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"], }, },