Skip to main content
Glama
guilhermelirio

Brasil API MCP

bank-search

Search for Brazilian bank details using official bank codes to identify financial institutions and access their information.

Instructions

Find information about a Brazilian bank by its code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesBank code to search for

Implementation Reference

  • The handler function for the "bank-search" tool. It takes a bank code, fetches data from the Brasil API, handles errors, and formats the response with bank details including code, name, full name, and ISPB.
        async ({ code }) => {
          console.error(`Finding bank by code: ${code}`);
          
          const result = await getBrasilApiData(`/banks/v1/${code}`);
          
          if (!result.success) {
            return formatErrorResponse(`Error finding bank: ${result.message}`);
          }
          
          // Format the response data
          const bank = result.data;
          return {
            content: [{ 
              type: "text" as const, 
              text: `
    Bank Information:
    Code: ${bank.code}
    Name: ${bank.name}
    Full Name: ${bank.fullName}
    ISPB: ${bank.ispb}
    ` 
            }]
          };
        }
  • Zod input schema defining the 'code' parameter as a string for the bank-search tool.
      code: z.string()
        .describe("Bank code to search for")
    },
  • Registers the "bank-search" tool on the MCP server inside the registerBankTools function, specifying name, description, schema, and handler.
      server.tool(
        "bank-search",  
        "Find information about a Brazilian bank by its code",
        {
          code: z.string()
            .describe("Bank code to search for")
        },
        async ({ code }) => {
          console.error(`Finding bank by code: ${code}`);
          
          const result = await getBrasilApiData(`/banks/v1/${code}`);
          
          if (!result.success) {
            return formatErrorResponse(`Error finding bank: ${result.message}`);
          }
          
          // Format the response data
          const bank = result.data;
          return {
            content: [{ 
              type: "text" as const, 
              text: `
    Bank Information:
    Code: ${bank.code}
    Name: ${bank.name}
    Full Name: ${bank.fullName}
    ISPB: ${bank.ispb}
    ` 
            }]
          };
        }
      );
  • Helper function used by bank-search to fetch bank data from https://brasilapi.com.br/api/banks/v1/{code}, returning structured success or error response.
    export async function getBrasilApiData(endpoint: string, params: Record<string, any> = {}) {
      try {
        const url = `${BASE_URL}${endpoint}`;
        console.error(`Making request to: ${url}`);
        
        const response = await axios.get(url, { params });
        return { 
          data: response.data,
          success: true
        };
      } catch (error: any) {
        console.error(`Error in API request: ${error.message}`);
        
        // Handle API errors in a structured format
        if (error.response) {
          return {
            success: false,
            statusCode: error.response.status,
            message: error.response.data?.message || error.message,
            error: error.response.data
          };
        }
        
        return {
          success: false,
          message: error.message,
          error
        };
      }
    }
  • Helper function used by bank-search to format error responses in MCP-compatible format.
    export function formatErrorResponse(message: string) {
      return {
        content: [{ 
          type: "text" as const, 
          text: message 
        }],
        isError: true
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects like what information is returned, whether it's a read-only operation, error handling, or any rate limits. The description is functional but lacks operational context.

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

Conciseness5/5

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

The description is a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately sized for a simple search tool and front-loads the essential information.

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

Completeness2/5

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

For a search tool with no annotations and no output schema, the description is insufficient. It doesn't explain what information is returned about Brazilian banks, what format the response takes, or any limitations. Given the lack of structured metadata, the description should provide more operational context.

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

Parameters3/5

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

The schema has 100% description coverage with the 'code' parameter clearly documented. The description adds minimal value beyond the schema by specifying this is for Brazilian banks, but doesn't provide additional context about code format, validation, or examples. Baseline 3 is appropriate given the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Find information') and resource ('Brazilian bank'), specifying the scope as Brazilian banks. However, it doesn't distinguish this tool from potential sibling 'bank-list' which might list banks rather than search by code, leaving some ambiguity about sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'bank-list' or other search tools in the sibling list. It mentions searching by code but doesn't specify when this is appropriate or what alternatives exist for different search criteria.

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/guilhermelirio/brasil-api-mcp'

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