Skip to main content
Glama

helius_get_token_accounts_by_owner

Retrieve Solana token accounts associated with a specific address using the Helius API to interact with blockchain data and manage token operations.

Instructions

Get token accounts owned by a Solana address

Input Schema

NameRequiredDescriptionDefault
programIdYes
publicKeyYes

Input Schema (JSON Schema)

{ "properties": { "programId": { "type": "string" }, "publicKey": { "type": "string" } }, "required": [ "publicKey", "programId" ], "type": "object" }

Implementation Reference

  • The handler function that validates the owner and programId public keys, then calls the Solana RPC method getTokenAccountsByOwner via the Helius client.
    export const getTokenAccountsByOwnerHandler = async (input: GetTokenAccountsByOwnerInput): Promise<ToolResultSchema> => { const ownerPublicKeyResult = validatePublicKey(input.publicKey); if (!(ownerPublicKeyResult instanceof PublicKey)) { return ownerPublicKeyResult; } const programIdResult = validatePublicKey(input.programId); if (!(programIdResult instanceof PublicKey)) { return programIdResult; } try { const tokenAccounts = await (helius as any as Helius).connection.getTokenAccountsByOwner(ownerPublicKeyResult, { programId: programIdResult, }); return createSuccessResponse(` Context: ${tokenAccounts.context.slot} Token accounts: ${tokenAccounts.value.map((tokenAccount) => tokenAccount.pubkey.toString()).join("\n")}`); } catch (error) { return createErrorResponse(`Error getting token accounts: ${error instanceof Error ? error.message : String(error)}`); } }
  • The input schema defining the parameters: publicKey (owner) and programId for the tool.
    { name: "helius_get_token_accounts_by_owner", description: "Get token accounts owned by a Solana address", inputSchema: { type: "object", properties: { publicKey: { type: "string" }, programId: { type: "string" } }, required: ["publicKey", "programId"] } },
  • src/tools.ts:552-552 (registration)
    Registration mapping the tool name to its handler function in the handlers dictionary.
    "helius_get_token_accounts_by_owner": getTokenAccountsByOwnerHandler,

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