Skip to main content
Glama
tywenk

Model Context Protocol Server for Solana Client

by tywenk

get_balance

Query the Solana blockchain to retrieve the balance of a specific account using its Pubkey. Provides the balance in a clear response format for easy integration and verification.

Instructions

Returns the balance of the account of provided Pubkey.

Args: address (str): Pubkey of account to query

Returns: str: Account balance response in the format "Balance of {address}: {balance}"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes

Implementation Reference

  • The handler function for the 'get_balance' tool, decorated with @mcp.tool() which registers it in the MCP server. It queries the Solana RPC for the balance of the given address pubkey.
    @mcp.tool()
    async def get_balance(address: str) -> str:
        """Returns the balance of the account of provided Pubkey.
    
        Args:
            address (str): Pubkey of account to query
    
        Returns:
            str: Account balance response in the format "Balance of {address}: {balance}"
        """
        async with AsyncClient(rpc_url) as client:
            balance = await client.get_balance(Pubkey.from_string(address))
            return f"Balance of {address}: {balance}"

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