Skip to main content
Glama

helius_get_token_account_balance

Retrieve the balance of a token account on the Solana blockchain by specifying the token address and commitment level using the MCP Helius server.

Instructions

Get the balance of a token account

Input Schema

NameRequiredDescriptionDefault
commitmentNo
tokenAddressYes

Input Schema (JSON Schema)

{ "properties": { "commitment": { "enum": [ "confirmed", "finalized", "processed" ], "type": "string" }, "tokenAddress": { "type": "string" } }, "required": [ "tokenAddress" ], "type": "object" }

Implementation Reference

  • The handler function that implements the core logic for retrieving the token account balance using the Helius SDK's connection.getTokenAccountBalance method, including input validation and error handling.
    export const getTokenAccountBalanceHandler = async (input: GetTokenAccountBalanceInput): Promise<ToolResultSchema> => { const tokenAddressResult = validatePublicKey(input.tokenAddress); if (!(tokenAddressResult instanceof PublicKey)) { return tokenAddressResult; } try { const tokenBalance = await (helius as any as Helius).connection.getTokenAccountBalance(tokenAddressResult, input.commitment); return createSuccessResponse(`Token balance: ${JSON.stringify(tokenBalance.value)}`); } catch (error) { return createErrorResponse(`Error getting token account balance: ${error instanceof Error ? error.message : String(error)}`); } }
  • The input schema definition for the 'helius_get_token_account_balance' tool, defining the expected input parameters including tokenAddress (required) and optional commitment level.
    { name: "helius_get_token_account_balance", description: "Get the balance of a token account", inputSchema: { type: "object", properties: { tokenAddress: { type: "string" }, commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] } }, required: ["tokenAddress"] } },
  • src/tools.ts:556-556 (registration)
    The registration mapping in the handlers dictionary that associates the tool name 'helius_get_token_account_balance' with its handler function getTokenAccountBalanceHandler.
    "helius_get_token_account_balance": getTokenAccountBalanceHandler,
  • TypeScript type definition for the input of getTokenAccountBalanceHandler, matching the tool's inputSchema.
    export type GetTokenAccountBalanceInput = { tokenAddress: string; commitment?: "confirmed" | "finalized" | "processed"; }

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/dcSpark/mcp-server-helius'

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