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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states this is a read operation ('Returns'), but lacks details on permissions, rate limits, error conditions, or whether it's idempotent. For a query tool with zero annotation coverage, this leaves behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement, followed by Args and Returns sections. Every sentence adds value—no redundancy or fluff. It's appropriately sized for a simple query tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter query tool with no output schema, the description is reasonably complete: it explains the purpose, parameter, and return format. However, it lacks behavioral details (e.g., error handling) that would be helpful given no annotations, slightly reducing completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter: 'token_account (str): Pubkey of Token account to query.' With 0% schema description coverage, this compensates well by explaining the parameter's purpose and format (Pubkey). However, it doesn't specify validation rules or examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Returns the token balance of an SPL Token account.' It specifies the verb ('Returns'), resource ('token balance'), and target ('SPL Token account'), distinguishing it from siblings like get_balance (likely native SOL balance) and get_token_accounts_by_owner (list of accounts).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'SPL Token account,' suggesting it's for token balances rather than native SOL. However, it doesn't explicitly state when to use this vs. alternatives like get_balance or get_token_accounts_by_owner, nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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