Skip to main content
Glama

helius_get_token_accounts_by_owner

Retrieve token accounts associated with a Solana wallet address to view holdings and manage assets on the blockchain.

Instructions

Get token accounts owned by a Solana address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
publicKeyYes
programIdYes

Implementation Reference

  • The handler function that validates inputs, calls the Solana RPC getTokenAccountsByOwner via Helius connection, and formats the response with token account pubkeys.
    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)}`);
      }
    }
  • Tool schema definition including name, description, and input schema requiring publicKey (owner) and programId.
    {
      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)
    Maps the tool name to its handler function in the handlers dictionary for tool dispatching.
    "helius_get_token_accounts_by_owner": getTokenAccountsByOwnerHandler,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe how it behaves: no information on rate limits, authentication needs, error handling, response format, or whether it's read-only/destructive. For a tool with zero annotation coverage, this leaves significant gaps in understanding its operational characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a simple lookup tool and front-loads the essential information. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't explain parameter meanings, behavioral traits, return values, or how this tool differs from similar siblings. For a tool in this context (blockchain data query with specific parameters), more information would be needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning neither parameter (publicKey, programId) is documented in the schema. The description mentions 'Solana address' which hints at publicKey but doesn't explain format or validation. It doesn't mention programId at all, leaving half the parameters completely unexplained. The description adds minimal value beyond the parameter names themselves.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('token accounts owned by a Solana address'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'helius_get_token_accounts' or 'helius_get_assets_by_owner', but the specificity of 'token accounts' and 'by owner' provides reasonable distinction. The description avoids tautology and isn't misleading.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'helius_get_token_accounts' (which might have different parameters) or 'helius_get_assets_by_owner' (which might handle different asset types). There's no context about prerequisites, constraints, or typical use cases, leaving the agent with minimal usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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