get_token_account_balance
Retrieve the balance of an SPL Token account on the Solana blockchain by specifying the account's Pubkey. Returns the balance in a clear, formatted string.
Instructions
Returns the token balance of an SPL Token account.
Args: token_account (str): Pubkey of Token account to query
Returns: str: Token account balance in the format "Token account balance: {balance}"
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_account | Yes |
Implementation Reference
- src/server.py:310-325 (handler)The handler function for the 'get_token_account_balance' tool. It is decorated with @mcp.tool(), which registers it with the MCP server. The function queries the Solana RPC for the token account balance using the solana library's AsyncClient.@mcp.tool() async def get_token_account_balance(token_account: str) -> str: """Returns the token balance of an SPL Token account. Args: token_account (str): Pubkey of Token account to query Returns: str: Token account balance in the format "Token account balance: {balance}" """ async with AsyncClient(rpc_url) as client: balance = await client.get_token_account_balance( Pubkey.from_string(token_account) ) return f"Token account balance: {balance}"
- src/server.py:310-310 (registration)The @mcp.tool() decorator registers the get_token_account_balance function as an MCP tool.@mcp.tool()