Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

get_cosmos_all_balances

Retrieve all token balances for a Cosmos SDK address across multiple blockchains using Grove's MCP Server for Pocket Network.

Instructions

Get all token balances for a Cosmos SDK address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockchainYesBlockchain name (e.g., "osmosis", "juno", "kava")
addressYesCosmos address
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • MCP tool handler case that parses input arguments, calls the service method, and formats the 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 registration definition including name, description, and input schema used by registerCosmosHandlers.
    {
      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'],
      },
    },
  • Service method implementing the core logic: constructs Cosmos REST API URL for all balances and fetches data.
    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',
        };
      }
    }

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/buildwithgrove/mcp-pocket'

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