consultar_estabelecimentos_credenciados
Query the number of establishments authorized to accept electronic payment methods by quarter using Brazil's Central Bank data.
Instructions
Consulta quantidade de estabelecimentos credenciados para aceitar meios de pagamento eletrônico 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) | |
| ordenar_por | No | Campo para ordenação | |
| filtro | No | Filtro OData para refinar a consulta |
Implementation Reference
- src/index.ts:350-373 (handler)Handler logic for the 'consultar_estabelecimentos_credenciados' tool. Extracts trimestre and optional parameters, fetches data from the BCB 'EstabCredTransDA' OData endpoint, and returns the JSON response.case "consultar_estabelecimentos_credenciados": { const { trimestre, top = 100, ordenar_por, filtro } = args as { trimestre: string; top?: number; ordenar_por?: string; filtro?: string; }; const data = await fetchBCBData(`EstabCredTransDA(trimestre=@trimestre)?@trimestre='${trimestre}'`, { formato: "json", top, orderby: ordenar_por, filter: filtro, }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:149-170 (schema)Input schema definition for the tool, specifying parameters like trimestre (required), top, ordenar_por, and filtro.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)", }, ordenar_por: { type: "string", description: "Campo para ordenação", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"], },
- src/index.ts:146-171 (registration)Tool registration in the tools array used for ListToolsRequestHandler, includes name, description, and inputSchema.{ name: "consultar_estabelecimentos_credenciados", description: "Consulta quantidade de estabelecimentos credenciados para aceitar meios de pagamento eletrônico 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)", }, ordenar_por: { type: "string", description: "Campo para ordenação", }, filtro: { type: "string", description: "Filtro OData para refinar a consulta", }, }, required: ["trimestre"], }, },
- src/index.ts:37-52 (helper)Helper function to fetch data from BCB API, builds URL with OData params and handles axios request. Used by all tools including this one.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:354-377 (handler)Handler logic for the tool in the HTTP/SSE MCP server version (createMCPServer). Identical to stdio version.case "consultar_estabelecimentos_credenciados": { const { trimestre, top = 100, ordenar_por, filtro } = args as { trimestre: string; top?: number; ordenar_por?: string; filtro?: string; }; const data = await fetchBCBData(`EstabCredTransDA(trimestre=@trimestre)?@trimestre='${trimestre}'`, { formato: "json", top, orderby: ordenar_por, filter: filtro, }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }