get_cosmos_all_balances
Retrieve all token balances for any Cosmos SDK blockchain address across multiple networks. Query balances on chains like Osmosis, Juno, and Kava to monitor portfolio holdings.
Instructions
Get all token balances for a Cosmos SDK address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Cosmos address | |
| blockchain | Yes | Blockchain name (e.g., "osmosis", "juno", "kava") | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- src/handlers/cosmos-handlers.ts:404-420 (handler)Handler logic for get_cosmos_all_balances tool: extracts parameters, calls cosmosService.getAllBalances, and formats response.case 'get_cosmos_all_balances': { const blockchain = args?.blockchain as string; const address = args?.address as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await cosmosService.getAllBalances(blockchain, address, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- Tool schema definition including name, description, and input schema for validation.{ name: 'get_cosmos_all_balances', description: 'Get all token balances for a Cosmos SDK address', inputSchema: { type: 'object', properties: { blockchain: { type: 'string', description: 'Blockchain name (e.g., "osmosis", "juno", "kava")', }, address: { type: 'string', description: 'Cosmos address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['blockchain', 'address'], }, },
- Core implementation: constructs REST API URL for all balances endpoint and fetches data using internal fetchRest method.async getAllBalances( blockchain: string, address: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { try { const baseUrl = this.getRestUrl(blockchain, network); const url = `${baseUrl}/cosmos/bank/v1beta1/balances/${address}`; return this.fetchRest(url); } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get Cosmos balances', }; } }