Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

get_solana_program_accounts

Retrieve accounts owned by a Solana program using program ID with optional filters for data size or memory comparison. Access blockchain data through Grove's MCP Server for Pocket Network.

Instructions

Get accounts owned by a Solana program with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
programIdYesProgram ID (public key)
filtersNoOptional RPC filters (memcmp, dataSize, etc.)
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • Tool definition and schema registration in the array returned by registerSolanaHandlers
    {
      name: 'get_solana_program_accounts',
      description: 'Get accounts owned by a Solana program with optional filters',
      inputSchema: {
        type: 'object',
        properties: {
          programId: {
            type: 'string',
            description: 'Program ID (public key)',
          },
          filters: {
            type: 'array',
            description: 'Optional RPC filters (memcmp, dataSize, etc.)',
            items: { type: 'object' },
          },
          network: {
            type: 'string',
            enum: ['mainnet', 'testnet'],
            description: 'Network type (defaults to mainnet)',
          },
        },
        required: ['programId'],
      },
    },
  • Execution handler in handleSolanaTool function that processes tool arguments and calls SolanaService
    case 'get_solana_program_accounts': {
      const programId = args?.programId as string;
      const filters = args?.filters as any[] | undefined;
      const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet';
    
      const result = await solanaService.getProgramAccounts(programId, filters, network);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
        isError: !result.success,
      };
    }
  • Core implementation of get_solana_program_accounts tool logic in SolanaService, preparing RPC parameters and calling the RPC method
    async getProgramAccounts(
      programId: string,
      filters?: any[],
      network: 'mainnet' | 'testnet' = 'mainnet'
    ): Promise<EndpointResponse> {
      const service = this.blockchainService.getServiceByBlockchain('solana', network);
    
      if (!service) {
        return {
          success: false,
          error: `Solana service not found for ${network}`,
        };
      }
    
      const params: any = [
        programId,
        {
          encoding: 'jsonParsed',
        },
      ];
    
      if (filters && filters.length > 0) {
        params[1].filters = filters;
      }
    
      return this.blockchainService.callRPCMethod(service.id, 'getProgramAccounts', params);
    }

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/buildwithgrove/mcp-pocket'

If you have feedback or need assistance with the MCP directory API, please join our Discord server