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
| Name | Required | Description | Default |
|---|---|---|---|
| commitment | No | ||
| tokenAddress | Yes |
Input Schema (JSON Schema)
{
"properties": {
"commitment": {
"enum": [
"confirmed",
"finalized",
"processed"
],
"type": "string"
},
"tokenAddress": {
"type": "string"
}
},
"required": [
"tokenAddress"
],
"type": "object"
}
Implementation Reference
- src/handlers/helius.ts:137-148 (handler)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)}`); } }
- src/tools.ts:102-113 (schema)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,
- src/handlers/helius.types.ts:65-68 (schema)TypeScript type definition for the input of getTokenAccountBalanceHandler, matching the tool's inputSchema.export type GetTokenAccountBalanceInput = { tokenAddress: string; commitment?: "confirmed" | "finalized" | "processed"; }