Skip to main content
Glama
tywenk

Model Context Protocol Server for Solana Client

by tywenk

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
NameRequiredDescriptionDefault
mintYes
ownerYes

Implementation Reference

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

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