bank-list
Access a comprehensive list of Brazilian banks through the Brasil API MCP server, enabling retrieval of essential banking data for integration or analysis.
Instructions
List all Brazilian banks
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/bank/index.ts:51-72 (handler)Handler function that lists all Brazilian banks by fetching data from BrasilAPI, formatting as 'code - name (ISPB)' list, and returning as MCP text content response.const result = await getBrasilApiData(`/banks/v1`); if (!result.success) { return formatErrorResponse(`Error listing banks: ${result.message}`); } // Format the response data const banks = result.data; const formattedBanks = banks.map((bank: any) => `${bank.code} - ${bank.name} (${bank.ispb})` ).join("\n"); return { content: [{ type: "text" as const, text: `Banks in Brazil:\n${formattedBanks}` }] }; } ); }
- src/tools/bank/index.ts:47-73 (registration)MCP server tool registration for 'bank-list': provides description, empty input schema (no params), and references the handler function."List all Brazilian banks", {}, async () => { console.error("Listing all banks"); const result = await getBrasilApiData(`/banks/v1`); if (!result.success) { return formatErrorResponse(`Error listing banks: ${result.message}`); } // Format the response data const banks = result.data; const formattedBanks = banks.map((bank: any) => `${bank.code} - ${bank.name} (${bank.ispb})` ).join("\n"); return { content: [{ type: "text" as const, text: `Banks in Brazil:\n${formattedBanks}` }] }; } ); }
- src/tools/bank/index.ts:50-50 (schema)Input schema for bank-list tool: empty object indicating no input parameters required.console.error("Listing all banks");
- src/utils/api.ts:11-40 (helper)API client helper used by bank-list handler to fetch bank list from https://brasilapi.com.br/api/banks/v1 with error handling.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 }; } }
- src/utils/api.ts:47-55 (helper)Utility to format error messages into MCP-compatible error responses, used when API call fails in bank-list handler.export function formatErrorResponse(message: string) { return { content: [{ type: "text" as const, text: message }], isError: true }; }