get_program_accounts
Query all accounts associated with a specific program Pubkey on the Solana blockchain using this tool. Retrieve account details to manage and analyze program interactions effectively.
Instructions
Returns all accounts owned by the provided program Pubkey.
Args: program_id (str): Pubkey of program to query
Returns: str: Program accounts in the format "Program accounts: {accounts}"
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| program_id | Yes |
Implementation Reference
- src/server.py:228-241 (handler)The handler function for the 'get_program_accounts' tool. It is registered via the @mcp.tool() decorator, includes input schema via type hints and docstring, and implements the logic by querying the Solana RPC client for accounts owned by the given program ID, formatting the result as a string.@mcp.tool() async def get_program_accounts(program_id: str) -> str: """Returns all accounts owned by the provided program Pubkey. Args: program_id (str): Pubkey of program to query Returns: str: Program accounts in the format "Program accounts: {accounts}" """ async with AsyncClient(rpc_url) as client: accounts = await client.get_program_accounts(Pubkey.from_string(program_id)) return f"Program accounts: {accounts}"