Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

compare_balances

Compare native token balances for an address across multiple EVM chains to analyze cross-chain holdings and track assets on different blockchains.

Instructions

Compare native token balance for an address across multiple EVM chains

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesAddress to check
blockchainsNoList of blockchain names (optional, defaults to all EVM chains)
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • Core implementation of compare_balances tool: queries native token balances across multiple EVM chains using eth_getBalance RPC calls, converts to ETH, aggregates total and counts non-zero balances.
    async compareBalances(
      address: string,
      blockchains?: string[],
      network: 'mainnet' | 'testnet' = 'mainnet'
    ): Promise<EndpointResponse> {
      try {
        // Get all EVM chains if not specified
        const chainsToCheck = blockchains || this.getEVMChains();
    
        const results = await Promise.all(
          chainsToCheck.map(async (blockchain) => {
            const service = this.blockchainService.getServiceByBlockchain(blockchain, network);
            if (!service) {
              return { blockchain, error: 'Service not found', balance: null };
            }
    
            const result = await this.blockchainService.callRPCMethod(
              service.id,
              'eth_getBalance',
              [address, 'latest']
            );
    
            if (result.success && result.data) {
              const weiBalance = BigInt(result.data);
              const ethBalance = Number(weiBalance) / 1e18;
              return {
                blockchain,
                balance: ethBalance,
                balanceWei: weiBalance.toString(),
                balanceHex: result.data,
              };
            }
    
            return { blockchain, error: result.error, balance: null };
          })
        );
    
        const totalBalance = results
          .filter(r => r.balance !== null)
          .reduce((sum, r) => sum + (r.balance || 0), 0);
    
        return {
          success: true,
          data: {
            address,
            balances: results,
            totalBalance,
            chainsWithBalance: results.filter(r => r.balance && r.balance > 0).length,
          },
          metadata: {
            timestamp: new Date().toISOString(),
            endpoint: 'multi-chain',
          },
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Failed to compare balances',
        };
      }
    }
  • MCP tool handler wrapper: extracts parameters, calls the advanced blockchain service's compareBalances, formats response as MCP content with error flag.
    case 'compare_balances': {
      const address = args?.address as string;
      const blockchains = args?.blockchains as string[] | undefined;
      const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet';
    
      const result = await advancedBlockchain.compareBalances(address, blockchains, network);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
        isError: !result.success,
      };
    }
  • JSON schema defining input parameters for the compare_balances tool: address (required), optional blockchains array and network enum.
    inputSchema: {
      type: 'object',
      properties: {
        address: {
          type: 'string',
          description: 'Address to check',
        },
        blockchains: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of blockchain names (optional, defaults to all EVM chains)',
        },
        network: {
          type: 'string',
          enum: ['mainnet', 'testnet'],
          description: 'Network type (defaults to mainnet)',
        },
      },
      required: ['address'],
    },
  • Tool registration object including name, description, and input schema, returned by registerMultichainHandlers for inclusion in MCP server's tool list.
    {
      name: 'compare_balances',
      description: 'Compare native token balance for an address across multiple EVM chains',
      inputSchema: {
        type: 'object',
        properties: {
          address: {
            type: 'string',
            description: 'Address to check',
          },
          blockchains: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of blockchain names (optional, defaults to all EVM chains)',
          },
          network: {
            type: 'string',
            enum: ['mainnet', 'testnet'],
            description: 'Network type (defaults to mainnet)',
          },
        },
        required: ['address'],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool does, not how it behaves. It doesn't disclose rate limits, error conditions, authentication requirements, whether it's read-only (implied but not stated), or what format the comparison results take.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence efficiently conveys the core purpose with zero wasted words. Front-loaded with the main action and scope, making it immediately understandable without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, 100% schema coverage, and no output schema, the description adequately covers the what but lacks behavioral context. It doesn't explain what the comparison output looks like (structured data, formatted table, etc.) or any operational constraints, leaving gaps for an agent to understand full usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds value by clarifying that 'blockchains' parameter is optional and defaults to all EVM chains, and implies 'network' defaults to mainnet, providing useful context beyond the schema's technical specifications.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('compare native token balance') for a specific resource ('for an address across multiple EVM chains'), distinguishing it from sibling tools like get_historical_balance (single chain/time) or get_cosmos_balance (different blockchain type).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for multi-chain balance comparison, but provides no explicit guidance on when to choose this tool over alternatives like get_token_balance (single chain) or get_historical_balance (temporal focus). It mentions default behavior but lacks explicit when/when-not recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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