Skip to main content
Glama

get_balance

Read-onlyIdempotent

Retrieve native token balances (like ETH or MATIC) for any wallet address across EVM-compatible blockchain networks to monitor account holdings.

Instructions

Get the native token balance (ETH, MATIC, etc.) for an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe wallet address or ENS name
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.

Implementation Reference

  • Primary registration of the 'get_balance' MCP tool. Includes inline Zod schema for input validation (address and optional network), description, and handler function that resolves the address via ENS if needed, fetches balance using services.getETHBalance, formats wei/ether, and returns structured JSON response or error.
      'get_balance',
      'Get the native token balance (ETH, MATIC, etc.) for an address',
      {
        address: z
          .string()
          .describe(
            "The wallet address or ENS name (e.g., '0x1234...' or 'vitalik.eth') to check the balance for"
          ),
        network: z
          .string()
          .optional()
          .describe(
            "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet."
          )
      },
      async ({ address, network = 'ethereum' }) => {
        try {
          const balance = await services.getETHBalance(address, network);
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(
                  {
                    address,
                    network,
                    wei: balance.wei.toString(),
                    ether: balance.ether
                  },
                  null,
                  2
                )
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error fetching balance: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Core handler logic for fetching native token (ETH) balance. Resolves ENS names to addresses, uses viem's public client to call getBalance, and formats the result into wei bigint and human-readable ether string.
    export async function getETHBalance(
      addressOrEns: string, 
      network = 'ethereum'
    ): Promise<{ wei: bigint; ether: string }> {
      // Resolve ENS name to address if needed
      const address = await resolveAddress(addressOrEns, network);
      
      const client = getPublicClient(network);
      const balance = await client.getBalance({ address });
      
      return {
        wei: balance,
        ether: formatEther(balance)
      };
    }
  • Server initialization where registerEVMTools(server) is called, which registers the get_balance tool among other EVM tools.
    registerEVMResources(server);
    registerEVMTools(server);
    registerEVMPrompts(server);
  • Re-export of balance service functions (including getETHBalance) as 'services' namespace used by the tool handler.
    export * from './clients.js';
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=true, covering safety and idempotency. The description adds no additional behavioral context (e.g., rate limits, auth needs, or return format), but it does not contradict annotations.

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 front-loads the core purpose without unnecessary words. Every part of the sentence contributes to clarifying the tool's function.

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

Completeness4/5

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

Given the tool's low complexity, rich annotations, and 100% schema coverage, the description is mostly complete. However, with no output schema, it could benefit from mentioning the return value format (e.g., balance in wei or ether), but this is a minor gap.

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%, with clear parameter descriptions in the schema. The description adds no extra parameter details beyond what the schema provides, such as format examples or constraints, so it meets the baseline for high schema coverage.

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 ('Get') and resource ('native token balance for an address'), distinguishing it from siblings like get_token_balance (ERC20 tokens) or get_erc1155_balance (NFTs). It explicitly mentions the token types (ETH, MATIC, etc.) to clarify scope.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'native token balance' and listing examples (ETH, MATIC), which helps differentiate it from get_token_balance for ERC20 tokens. However, it does not explicitly state when not to use it or mention alternatives like get_erc1155_balance for NFTs.

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/chulanpro5/evm-mcp-server'

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