Skip to main content
Glama

helius_get_program_accounts

Retrieve all accounts owned by a specific program on the Solana blockchain to analyze program data and interactions.

Instructions

Get all accounts owned by a program

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
programIdYes
commitmentNo

Implementation Reference

  • The handler function that executes the tool logic: validates the programId public key, fetches program accounts using Helius RPC connection.getProgramAccounts, and returns a success or error response.
    export const getProgramAccountsHandler = async (input: GetProgramAccountsInput): Promise<ToolResultSchema> => {
      const programIdResult = validatePublicKey(input.programId);
      if (!(programIdResult instanceof PublicKey)) {
        return programIdResult;
      }
      
      try {
        const programAccounts = await (helius as any as Helius).connection.getProgramAccounts(programIdResult, input.commitment);
        return createSuccessResponse(`Program accounts: ${JSON.stringify(programAccounts, null, 2)}`);
      } catch (error) {
        return createErrorResponse(`Error getting program accounts: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • The tool schema definition in the tools array, including name, description, and inputSchema for programId (required) and optional commitment level.
    {
      name: "helius_get_program_accounts",
      description: "Get all accounts owned by a program",
      inputSchema: {
        type: "object",
        properties: {
          programId: { type: "string" },
          commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] }
        },
        required: ["programId"]
      }
    },
  • src/tools.ts:561-561 (registration)
    The registration of the tool name to its handler function in the handlers dictionary.
    "helius_get_program_accounts": getProgramAccountsHandler,

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