get_bank_by_code
Retrieve detailed information about a specific Brazilian bank using its unique code, sourced from the Brasil API. Simplify banking data integration for applications and AI systems.
Instructions
Get information from a specific bank given its code. The code from each bank is returned by get_all_banks tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"code": {
"type": "number"
}
},
"required": [
"code"
],
"type": "object"
}
Implementation Reference
- src/tools/banks.ts:38-52 (handler)The async handler function that fetches specific bank information by code using the Brasil API client, formats the response as pretty JSON, and handles errors.handler: async ({ code }) => { try { const result = await brasilApiClient.bank.getBy(code); const content: McpTextContent = { type: "text", text: prettifyJson(result.data), }; return { content: [content], }; } catch (error: any) { console.error(error); throw new Error(`Failed to fetch bank with code ${code}`); } },
- src/tools/banks.ts:27-29 (schema)Zod schema defining the single required input parameter 'code' as a number.const GetBankByCodeToolParams = { code: z.number(), };
- src/index.ts:30-41 (registration)The getBankByCodeTool is included in the array of tools and registered to the MCP server via registerTool in a loop.const tools = [ getCepTool, getCepV2Tool, getBookByISBNTool, getCNPJTool, getAllBanksTool, getBankByCodeTool, ]; tools.forEach((tool) => { registerTool(server, tool); });
- src/tools/banks.ts:31-53 (registration)Export of the McpToolDefinition for 'get_bank_by_code', including name, description, params schema reference, and handler function.export const getBankByCodeTool: McpToolDefinition< typeof GetBankByCodeToolParams > = { name: "get_bank_by_code", description: "Get information from a specific bank given its code. The code from each bank is returned by get_all_banks tool.", params: GetBankByCodeToolParams, handler: async ({ code }) => { try { const result = await brasilApiClient.bank.getBy(code); const content: McpTextContent = { type: "text", text: prettifyJson(result.data), }; return { content: [content], }; } catch (error: any) { console.error(error); throw new Error(`Failed to fetch bank with code ${code}`); } }, };