Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

get_token_balance

Retrieve ERC-20 token balances for any wallet address across multiple blockchain networks using Grove's Pocket Network data access.

Instructions

Get ERC-20 token balance for an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockchainYesBlockchain name
tokenAddressYesToken contract address
walletAddressYesWallet address to check balance
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • MCP tool handler for 'get_token_balance': parses input arguments (blockchain, tokenAddress, walletAddress, network) and delegates to AdvancedBlockchainService.getTokenBalance, formats response as MCP content.
    case 'get_token_balance': {
      const blockchain = args?.blockchain as string;
      const tokenAddress = args?.tokenAddress as string;
      const walletAddress = args?.walletAddress as string;
      const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet';
    
      const result = await advancedBlockchain.getTokenBalance(
        blockchain,
        tokenAddress,
        walletAddress,
        network
      );
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
        isError: !result.success,
      };
    }
  • Core implementation: Retrieves ERC-20 token balance via eth_call to balanceOf(address) on EVM-compatible chains, processes hex result to decimal balance.
    async getTokenBalance(
      blockchain: string,
      tokenAddress: string,
      walletAddress: string,
      network: 'mainnet' | 'testnet' = 'mainnet'
    ): Promise<EndpointResponse> {
      const service = this.blockchainService.getServiceByBlockchain(blockchain, network);
    
      if (!service) {
        return {
          success: false,
          error: `Blockchain service not found: ${blockchain} (${network})`,
        };
      }
    
      // Encode balanceOf(address) call
      const paddedAddress = walletAddress.replace('0x', '').padStart(64, '0');
      const data = AdvancedBlockchainService.ERC20_BALANCE_OF + paddedAddress;
    
      const result = await this.blockchainService.callRPCMethod(
        service.id,
        'eth_call',
        [
          {
            to: tokenAddress,
            data: data,
          },
          'latest',
        ]
      );
    
      if (result.success && result.data) {
        // Convert hex to decimal
        const balance = BigInt(result.data).toString();
        return {
          success: true,
          data: {
            balance,
            balanceHex: result.data,
          },
          metadata: result.metadata,
        };
      }
    
      return result;
    }
  • Tool registration definition including name, description, and input schema for get_token_balance, returned by registerTokenHandlers for MCP server registration.
    {
      name: 'get_token_balance',
      description: 'Get ERC-20 token balance for an address',
      inputSchema: {
        type: 'object',
        properties: {
          blockchain: {
            type: 'string',
            description: 'Blockchain name',
          },
          tokenAddress: {
            type: 'string',
            description: 'Token contract address',
          },
          walletAddress: {
            type: 'string',
            description: 'Wallet address to check balance',
          },
          network: {
            type: 'string',
            enum: ['mainnet', 'testnet'],
            description: 'Network type (defaults to mainnet)',
          },
        },
        required: ['blockchain', 'tokenAddress', 'walletAddress'],
      },
    },
  • Input schema validation for get_token_balance tool: requires blockchain, tokenAddress, walletAddress; optional network.
    inputSchema: {
      type: 'object',
      properties: {
        blockchain: {
          type: 'string',
          description: 'Blockchain name',
        },
        tokenAddress: {
          type: 'string',
          description: 'Token contract address',
        },
        walletAddress: {
          type: 'string',
          description: 'Wallet address to check balance',
        },
        network: {
          type: 'string',
          enum: ['mainnet', 'testnet'],
          description: 'Network type (defaults to mainnet)',
        },
      },
      required: ['blockchain', 'tokenAddress', 'walletAddress'],
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool's function but doesn't cover critical aspects like rate limits, authentication needs, error handling, or return format. For a read operation with no annotation coverage, this is a significant gap in transparency.

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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

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?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimal but covers the core purpose. However, it lacks details on behavioral traits and usage context, making it incomplete for optimal agent decision-making without additional structured data.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add any additional meaning or context beyond what the schema provides, such as examples or edge cases, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('ERC-20 token balance for an address'), making the purpose immediately understandable. It distinguishes itself from siblings like 'get_historical_balance' or 'get_solana_token_balance' by specifying ERC-20 tokens, though it doesn't explicitly contrast with all similar tools.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_historical_balance', 'get_solana_token_balance', and 'compare_balances', the description lacks context on selection criteria, prerequisites, or exclusions, leaving usage ambiguous.

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