mirror_query_account
Retrieve Hedera account details including balance, creation time, keys, and transaction history using the Mirror Node REST API without transaction fees.
Instructions
Query comprehensive account data from Hedera Mirror Node REST API.
RETURNS: Balance, EVM address, creation time, keys, memo, transactions (optional) FREE: No transaction fees (REST API query)
USE FOR: Account inspection, transaction history, state verification.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | Account ID (0.0.xxxxx) | |
| includeTransactions | No | Include recent transactions | |
| transactionLimit | No | Transaction count (default: 20) |
Implementation Reference
- src/tools/mirror-node.ts:14-63 (handler)Core handler function that executes the mirror_query_account tool logic by querying the Hedera Mirror Node for account details including balance, keys, staking info, etc.export async function mirrorQueryAccount(args: { accountId: string; timestamp?: string; }): Promise<ToolResult> { try { logger.info('Querying account from Mirror Node', { accountId: args.accountId }); const account = await mirrorNodeService.getAccount(args.accountId, { timestamp: args.timestamp, }); return { success: true, data: { accountId: account.account, evmAddress: account.evm_address, balance: { hbar: account.balance.balance / 100_000_000, // Convert tinybar to HBAR tokens: account.balance.tokens, }, alias: account.alias, memo: account.memo, createdTimestamp: account.created_timestamp, expiryTimestamp: account.expiry_timestamp, autoRenewPeriod: account.auto_renew_period, deleted: account.deleted, ethereumNonce: account.ethereum_nonce, maxAutoTokenAssociations: account.max_automatic_token_associations, stakedNodeId: account.staked_node_id, stakedAccountId: account.staked_account_id, pendingReward: account.pending_reward, declineReward: account.decline_reward, key: account.key, }, metadata: { network: mirrorNodeService.getCurrentNetwork(), executedVia: 'mirror_node_rest_api', }, }; } catch (error) { logger.error('Failed to query account', { error }); return { success: false, error: error instanceof Error ? error.message : 'Unknown error', metadata: { network: mirrorNodeService.getCurrentNetwork(), }, }; } }
- src/index.ts:504-521 (schema)Input schema definition for the mirror_query_account tool as registered in the MCP server's tool list.{ name: 'mirror_query_account', description: `Query comprehensive account data from Hedera Mirror Node REST API. RETURNS: Balance, EVM address, creation time, keys, memo, transactions (optional) FREE: No transaction fees (REST API query) USE FOR: Account inspection, transaction history, state verification.`, inputSchema: { type: 'object' as const, properties: { accountId: { type: 'string', description: 'Account ID (0.0.xxxxx)' }, includeTransactions: { type: 'boolean', description: 'Include recent transactions' }, transactionLimit: { type: 'number', description: 'Transaction count (default: 20)' }, }, required: ['accountId'], }, },
- src/index.ts:642-644 (registration)Registration and dispatch logic in the MCP server's tool execution switch statement.case 'mirror_query_account': result = await mirrorQueryAccount(args as any); break;
- src/tools/mirror-node.ts:882-900 (schema)Detailed input schema matching the handler function parameters in mirrorNodeTools export.{ name: 'mirror_query_account', description: 'Get comprehensive account information from Hedera Mirror Node REST API. Returns balance, EVM address, keys, memo, staking info, and more. No API key required.', inputSchema: { type: 'object' as const, properties: { accountId: { type: 'string', description: 'Hedera account ID (format: 0.0.xxxxx), alias, or EVM address', }, timestamp: { type: 'string', description: 'Optional: Query account state at specific timestamp', }, }, required: ['accountId'], }, },
- src/index.ts:61-61 (registration)Import statement registering the handler function into the main MCP server index.import { mirrorQueryAccount } from './tools/mirror-node.js';