Skip to main content
Glama

get_balance

Retrieve the native token balance (ETH, MATIC, etc.) for a wallet address or ENS name across 30+ EVM-compatible networks using the EVM MCP Server.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe wallet address or ENS name (e.g., '0x1234...' or 'vitalik.eth') to check the balance for
networkNoNetwork name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet.

Implementation Reference

  • Registration of the 'get_balance' tool, including input schema, annotations, and the handler function that fetches and formats the balance using services.getETHBalance
    server.registerTool(
      "get_balance",
      {
        description: "Get the native token balance (ETH, MATIC, etc.) for an address",
        inputSchema: {
          address: z.string().describe("The wallet address or ENS name"),
          network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
        },
        annotations: {
          title: "Get Native Token Balance",
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true
        }
      },
      async ({ address, network = "ethereum" }) => {
        try {
          const balance = await services.getETHBalance(address as Address, network);
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                network,
                address,
                balance: { 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
          };
        }
      }
    );
  • Handler function for 'get_balance' tool that calls the service, formats the response as JSON, and handles errors
    async ({ address, network = "ethereum" }) => {
      try {
        const balance = await services.getETHBalance(address as Address, network);
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              network,
              address,
              balance: { 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
        };
      }
    }
  • Input schema for 'get_balance' tool using Zod validation for address and optional network
      address: z.string().describe("The wallet address or ENS name"),
      network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
    },
  • Core helper function getETHBalance that resolves ENS if needed, fetches balance using viem client.getBalance, and formats it to wei and ether units
    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)
      };
    }
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. It mentions the tool retrieves balances but doesn't disclose behavioral traits like rate limits, authentication needs, error handling, or response format. For a read operation with no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 key information ('Get the native token balance') without any wasted words. It's appropriately sized for the tool's simplicity and gets straight to the point.

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 low complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the purpose but lacks details on behavioral aspects like return values or error cases. Without annotations or output schema, the description should do more to compensate, but it's minimally viable for a simple read tool.

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 fully documents the parameters (address and network). The description adds no additional parameter semantics beyond what's in the schema, such as examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't need to.

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 action ('Get') and resource ('native token balance for an address'), specifying it's for native tokens like ETH or MATIC. It distinguishes from siblings like get_erc20_balance or get_nft_balance by focusing on native tokens, making the purpose specific and well-differentiated.

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 checking native token balances, but doesn't explicitly state when to use this tool versus alternatives like get_erc20_balance or get_token_balance. It provides some context by mentioning token types, but lacks explicit guidance on exclusions or comparisons with sibling tools.

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

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

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