Skip to main content
Glama
tywenk

Model Context Protocol Server for Solana Client

by tywenk

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
NameRequiredDescriptionDefault
token_accountYes

Implementation Reference

  • 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()

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/tywenk/mcp-sol'

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