Skip to main content
Glama

account_balance

Check HBAR and token balances for Hedera accounts using Mirror Node queries to monitor funds and verify holdings without transaction fees.

Instructions

Query HBAR and token balances for any Hedera account.

RETURNS: HBAR balance in ℏ format, list of all associated token balances FREE: No transaction fee (Mirror Node query)

USE FOR: Checking account balances, monitoring funds, verifying token holdings.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesAccount ID (format: 0.0.xxxxx)

Implementation Reference

  • The primary handler function that implements the core logic of the 'account_balance' tool. It invokes the hederaCLI service to fetch the account balance and handles errors appropriately.
    export async function getAccountBalance(args: { accountId: string }): Promise<ToolResult> {
      try {
        logger.info('Getting account balance', { accountId: args.accountId });
    
        const result = await hederaCLI.executeCommand({
          command: 'account balance',
          args: {
            accountId: args.accountId,
          },
        });
    
        return result;
      } catch (error) {
        logger.error('Failed to get account balance', { error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Input schema and metadata for the 'account_balance' tool, provided in the optimizedToolDefinitions array and returned by the MCP listTools handler.
        name: 'account_balance',
        description: `Query HBAR and token balances for any Hedera account.
    
    RETURNS: HBAR balance in ℏ format, list of all associated token balances
    FREE: No transaction fee (Mirror Node query)
    
    USE FOR: Checking account balances, monitoring funds, verifying token holdings.`,
        inputSchema: {
          type: 'object' as const,
          properties: {
            accountId: { type: 'string', description: 'Account ID (format: 0.0.xxxxx)' },
          },
          required: ['accountId'],
        },
      },
  • src/index.ts:569-571 (registration)
    Registration and dispatch logic in the main MCP tool execution switch statement, mapping incoming 'account_balance' calls to the handler function.
    case 'account_balance':
      result = await getAccountBalance(args as { accountId: string });
      break;
  • Modular tool schema definition within the exported accountTools array, matching the structure used in main index.
      name: 'account_balance',
      description:
        'Get the HBAR balance and token balances for a Hedera account. Returns the account balance in HBAR and a list of all associated token balances.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          accountId: {
            type: 'string',
            description: 'Hedera account ID (format: 0.0.xxxxx)',
            pattern: '^0\\.0\\.\\d+$',
          },
        },
        required: ['accountId'],
      },
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It successfully communicates key behavioral traits: that it's a query (not a mutation), that it's free (no transaction fee), that it uses Mirror Node infrastructure, and what format the HBAR balance returns in (ℏ format). However, it doesn't mention potential limitations like rate limits or error conditions.

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 efficiently structured with clear sections (purpose, returns, cost, usage) in just four sentences. Every sentence earns its place by providing distinct, valuable information without redundancy.

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?

For a single-parameter query tool with no output schema, the description provides excellent context about what the tool does, when to use it, cost implications, and return format. The only minor gap is the lack of output structure details, but given the tool's simplicity and clear return description, this is acceptable.

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 fully documents the single 'accountId' parameter with its format. The description doesn't add any additional parameter semantics beyond what's in the schema, making the baseline score of 3 appropriate.

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 ('Query'), resource ('HBAR and token balances'), and target ('any Hedera account'). It distinguishes itself from sibling tools like 'account_info' by focusing specifically on balance queries rather than general account information.

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

Usage Guidelines5/5

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

The 'USE FOR' section explicitly lists three specific use cases: 'Checking account balances, monitoring funds, verifying token holdings.' This provides clear guidance on when to use this tool versus alternatives like 'account_info' which might provide broader account details.

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/justmert/hashpilot'

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