helius_get_program_accounts
Retrieve all accounts associated with a specific program on the Solana blockchain using MCP Helius. Input the program ID and commitment level to access detailed account data for efficient blockchain analysis and interaction.
Instructions
Get all accounts owned by a program
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commitment | No | ||
| programId | Yes |
Input Schema (JSON Schema)
{
"properties": {
"commitment": {
"enum": [
"confirmed",
"finalized",
"processed"
],
"type": "string"
},
"programId": {
"type": "string"
}
},
"required": [
"programId"
],
"type": "object"
}
Implementation Reference
- src/handlers/helius.ts:193-205 (handler)The main handler function getProgramAccountsHandler that executes the tool logic. It validates the programId, calls helius.connection.getProgramAccounts, and returns the result or error.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)}`); } }
- src/tools.ts:150-161 (schema)Tool schema definition including name, description, and inputSchema for validation.{ 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)Registration of the tool name to its handler function in the handlers dictionary."helius_get_program_accounts": getProgramAccountsHandler,
- src/tools.ts:14-14 (registration)Import of the getProgramAccountsHandler from helius.tsgetProgramAccountsHandler,
- src/handlers/helius.ts:12-12 (schema)Import of the input type GetProgramAccountsInput used in the handler signature.GetProgramAccountsInput,