get_token_accounts_by_owner
Retrieve all SPL Token accounts associated with a specific owner and mint address using the Solana blockchain. This method simplifies token account management and querying.
Instructions
Returns all SPL Token accounts by token owner.
Args: owner (str): Public key of token owner mint (str): Token mint address
Returns: str: Token accounts information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mint | Yes | ||
| owner | Yes |
Implementation Reference
- src/server.py:589-604 (handler)The @mcp.tool() decorator registers this async handler function, which executes the core logic: connects to Solana RPC, fetches token accounts by owner and mint using solana-py library, and returns a formatted string result.@mcp.tool() async def get_token_accounts_by_owner(owner: str, mint: str) -> str: """Returns all SPL Token accounts by token owner. Args: owner (str): Public key of token owner mint (str): Token mint address Returns: str: Token accounts information """ async with AsyncClient(rpc_url) as client: accounts = await client.get_token_accounts_by_owner( Pubkey.from_string(owner), TokenAccountOpts(Pubkey.from_string(mint)) ) return f"Token accounts by owner: {accounts}"
- src/server.py:589-589 (registration)The @mcp.tool() decorator registers the get_token_accounts_by_owner tool with the MCP server.@mcp.tool()
- src/server.py:591-599 (schema)Docstring provides input parameter descriptions and return type for schema validation in MCP tools."""Returns all SPL Token accounts by token owner. Args: owner (str): Public key of token owner mint (str): Token mint address Returns: str: Token accounts information """