Skip to main content
Glama
alanpcf

brasil-data-mcp

listar_bancos

List all Brazilian banks from BACEN: returns name, COMPE code, and ISPB for each institution to help identify bank codes by name.

Instructions

Lista TODOS os bancos brasileiros cadastrados no BACEN via BrasilAPI. Retorna em JSON um array com nome, código COMPE/Febraban e ISPB de cada instituição. Use quando o usuário quiser uma lista completa, buscar banco por nome (você filtra o resultado), ou descobrir o código de um banco específico cujo nome ele forneceu. NÃO use quando o usuário já forneceu o código numérico — nesse caso use consultar_banco que é mais barato. A lista tem ~250 entradas; cite só os relevantes na resposta.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Zod schema for listar_bancos (no input parameters needed).
    export const listarBancosSchema = z.object({});
  • Main handler function: fetches all banks from BrasilAPI /banks/v1 endpoint and returns the JSON result.
    export async function listarBancosHandler(
      _input: ListarBancosInput,
    ): Promise<CallToolResult> {
      try {
        const dados = await brasilApi.get<unknown>("/banks/v1");
        return {
          content: [{ type: "text", text: JSON.stringify(dados, null, 2) }],
        };
      } catch (err) {
        return {
          content: [
            {
              type: "text",
              text: traduzirErroBrasilApi(err, {
                // Não há "404" semântico pra lista — se a API errar, todos
                // caem no mesmo balde de "indisponível".
                notFound: "Lista de bancos não disponível no momento.",
                contextoErro: "Erro ao listar bancos",
              }),
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:108-115 (registration)
    Registration of the listar_bancos tool on the MCP server via server.registerTool().
    server.registerTool(
      listarBancosTool.name,
      {
        description: listarBancosTool.description,
        inputSchema: listarBancosSchema.shape,
      },
      wrapHandler(listarBancosTool.name, listarBancosHandler),
    );
  • Error translation utility used by the handler to produce user-friendly error messages.
    export function traduzirErroBrasilApi(
      err: unknown,
      mapa: MapeamentoErro,
    ): string {
      const ctx = mapa.contextoErro ?? "Erro ao consultar dados";
    
      if (err instanceof BrasilApiError) {
        if (err.status === 404) return mapa.notFound;
        if (err.status === 400) {
          return `${ctx}: dados inválidos enviados ao serviço.`;
        }
        if (err.status === 429) {
          return `${ctx}: limite de requisições temporariamente atingido. Tente novamente em alguns segundos.`;
        }
        if (err.status >= 500) {
          return `${ctx}: serviço temporariamente indisponível. Tente novamente em alguns instantes.`;
        }
        // status === 0 é o sinal que usamos no cliente pra erro de rede / abort.
        if (err.status === 0) {
          return `${ctx}: falha de rede ao alcançar o serviço.`;
        }
        return `${ctx}: o serviço retornou erro inesperado (${err.status}).`;
      }
    
      const msg = err instanceof Error ? err.message : String(err);
      return `${ctx}: ${msg}`;
    }
  • HTTP client's get method used by the handler to call the BrasilAPI /banks/v1 endpoint.
    export const brasilApi = {
      get<T>(path: string, opts: GetOptions = {}): Promise<T> {
        return getInterno<T>(path, opts);
      },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided; description compensates by stating output format (JSON array with nome, código COMPE/Febraban, ISPB) and size (~250 entries). It implies a read-only operation and gives usage behavior, though does not explicitly mention side effects or rate limits, which are minimal for a listing tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is structured with a clear opening, output details, usage scenarios, and a caution. Every sentence adds value, though it is slightly verbose. It is front-loaded with the main purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no parameters and no output schema, the description covers purpose, output format, use cases, alternatives, and a practical tip for handling results. No gaps identified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has zero parameters; description clarifies no input is needed and that the tool returns an unfiltered list. This adds value beyond the schema, achieving a score above the baseline of 4 for zero-param tools.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it lists all Brazilian banks registered at BACEN via BrasilAPI, with a specific verb (list) and resource (bancos brasileiros). It distinguishes from the sibling tool consultar_banco, which is for query by code, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance: when to use (user wants complete list, search by name, discover code from name) and when not to use (user already has numeric code, suggesting consultar_banco as a cheaper alternative). Also advises to cite only relevant entries from ~250 results.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/alanpcf/brasil-data-mcp'

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