Skip to main content
Glama

bank-search

Retrieve details about Brazilian banks using their unique code. The tool provides accurate bank information through the Brasil API MCP server, streamlining access to essential financial data.

Instructions

Find information about a Brazilian bank by its code

Input Schema

NameRequiredDescriptionDefault
codeYesBank code to search for

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "code": { "description": "Bank code to search for", "type": "string" } }, "required": [ "code" ], "type": "object" }

Implementation Reference

  • The handler function that implements the core logic of the 'bank-search' tool: fetches Brazilian bank information by code from BrasilAPI, handles errors, and formats a text response.
    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 for the 'bank-search' tool, defining the required 'code' parameter as a string.
    { code: z.string() .describe("Bank code to search for") },
  • Registers the 'bank-search' tool with the MCP server, specifying name, description, input schema, and handler function.
    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} ` }] }; } );
  • src/index.ts:27-27 (registration)
    Calls registerBankTools on the main MCP server instance to register bank-related tools including 'bank-search'.
    registerBankTools(server);
  • Utility function getBrasilApiData used by the 'bank-search' handler to fetch data from the BrasilAPI and handle API responses and errors.
    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 }; }

Other Tools

Related 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