helius_get_token_accounts
Retrieve token accounts by mint or owner. Provide mint address or owner public key, with optional page and limit for paginated results.
Instructions
Get token accounts by mint or owner
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mint | No | ||
| owner | No | ||
| page | No | ||
| limit | No |
Implementation Reference
- src/handlers/helius.ts:453-460 (handler)The actual handler function `getTokenAccountsHandler` that executes the tool logic. It calls `helius.rpc.getTokenAccounts(input)` with mint, owner, page, and limit parameters.
export const getTokenAccountsHandler = async (input: { mint?: string, owner?: string, page?: number, limit?: number }): Promise<ToolResultSchema> => { try { const accounts = await (helius as any as Helius).rpc.getTokenAccounts(input); return createSuccessResponse(`Token accounts: ${JSON.stringify(accounts, null, 2)}`); } catch (error) { return createErrorResponse(`Error getting token accounts: ${error instanceof Error ? error.message : String(error)}`); } } - src/handlers/helius.types.ts:238-243 (schema)The `GetTokenAccountsInput` type definition for the tool's input schema (mint, owner, page, limit).
export type GetTokenAccountsInput = { mint?: string; owner?: string; page?: number; limit?: number; } - src/tools.ts:436-448 (registration)Tool registration in the `tools` array with name 'helius_get_token_accounts', description 'Get token accounts by mint or owner', and inputSchema.
{ name: 'helius_get_token_accounts', description: 'Get token accounts by mint or owner', inputSchema: { type: 'object', properties: { mint: { type: 'string' }, owner: { type: 'string' }, page: { type: 'number' }, limit: { type: 'number' } } } }, - src/tools.ts:583-583 (registration)Handler mapping in the `handlers` object: 'helius_get_token_accounts' maps to `helius.getTokenAccountsHandler`.
"helius_get_token_accounts": helius.getTokenAccountsHandler, - src/handlers/helius-mock.ts:648-667 (helper)Mock implementation of `getTokenAccounts` in `MockHeliusClient` for testing purposes.
getTokenAccounts: async (params: { mint?: string, owner?: string, page?: number, limit?: number }) => { const limit = params.limit || 10; return { total: 100, limit, page: params.page || 1, items: Array(limit).fill(0).map((_, i) => ({ address: `MockTokenAccount${i}`, mint: params.mint || `MockMint${i}`, owner: params.owner || `MockOwner${i}`, amount: 1000000000 + i, delegateOption: 0, delegate: null, state: "initialized", isNative: false, rentExemptReserve: null, closeAuthority: null })) }; },