get_wallet_token_balance
Retrieve token balances for specified wallet and token pairs. Input WalletTokenPairsContainer to receive a list of WalletTokenBalance, enabling efficient crypto asset tracking and management.
Instructions
Get the balance for a list of wallet/token pairs.
Expects a WalletTokenPairsContainer, returns a list of WalletTokenBalance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet_token_pairs | Yes |
Implementation Reference
- armor_crypto_mcp/armor_mcp.py:112-126 (handler)Handler function for the MCP tool 'get_wallet_token_balance'. Registered via @mcp.tool() decorator. Delegates to armor_client.get_wallet_token_balance.@mcp.tool() async def get_wallet_token_balance(wallet_token_pairs: WalletTokenPairsContainer) -> List[WalletTokenBalance]: """ Get the balance for a list of wallet/token pairs. Expects a WalletTokenPairsContainer, returns a list of WalletTokenBalance. """ if not armor_client: return [{"error": "Not logged in"}] try: result: List[WalletTokenBalance] = await armor_client.get_wallet_token_balance(wallet_token_pairs) return result except Exception as e: return [{"error": str(e)}]
- Core helper method in ArmorWalletAPIClient that performs the actual API call to fetch wallet token balances.async def get_wallet_token_balance(self, data: WalletTokenPairsContainer) -> List[WalletTokenBalance]: """Get balances from a list of wallet and token pairs.""" # payload = [v.model_dump() for v in data.wallet_token_pairs] payload = data.model_dump(exclude_none=True)['wallet_token_pairs'] return await self._api_call("POST", "tokens/wallet-token-balance/", payload)
- Pydantic models for input (WalletTokenPairs) and output (WalletTokenBalance) data structures.class WalletTokenPairs(BaseModel): wallet: str = Field(description="The name of wallet. To get wallet names use `get_user_wallets_and_groups_list`") token: str = Field(description="public address of token. To get the address from a token symbol use `get_token_details`") class WalletTokenBalance(BaseModel): wallet: str = Field(description="name of wallet") token: str = Field(description="public address of token") balance: float = Field(description="balance of token")
- Container model for input list of wallet-token pairs used in the tool.class WalletTokenPairsContainer(BaseModel): wallet_token_pairs: List[WalletTokenPairs]
- armor_crypto_mcp/armor_mcp.py:10-112 (registration)Imports the necessary models and client from armor_client.py, enabling the handler.from .armor_client import ( ArmorWalletAPIClient, calculate, WalletTokenBalance, ConversionResponse, SwapQuoteResponse, SwapTransactionResponse, Wallet, TokenDetailsResponseContainer, GroupInfo, SingleGroupInfo, WalletInfo, WalletArchiveOrUnarchiveResponse, CreateGroupResponse, AddWalletToGroupResponse, GroupArchiveOrUnarchiveResponse, RemoveWalletFromGroupResponse, TransferTokenResponse, DCAOrderResponse, CancelDCAOrderResponse, ListSingleGroupRequest, TopTrendingTokensRequest, CandleStickRequest, StakeBalanceResponse, ListWalletsRequest, ListDCAOrderRequest, ListOrderRequest, PrivateKeyRequest, WalletTokenPairsContainer, ConversionRequestContainer, SwapQuoteRequestContainer, SwapTransactionRequestContainer, TokenDetailsRequestContainer, TokenSearchRequest, TokenSearchResponseContainer, TransferTokensRequestContainer, DCAOrderRequestContainer, CancelDCAOrderRequestContainer, CreateWalletRequestContainer, ArchiveWalletsRequestContainer, UnarchiveWalletRequestContainer, CreateGroupsRequestContainer, AddWalletToGroupRequestContainer, ArchiveWalletGroupRequestContainer, UnarchiveWalletGroupRequestContainer, RemoveWalletsFromGroupRequestContainer, CreateOrderRequestContainer, CancelOrderRequestContainer, CreateOrderResponseContainer, CancelOrderResponseContainer, StakeQuoteRequestContainer, UnstakeQuoteRequestContainer, StakeTransactionRequestContainer, UnstakeTransactionRequestContainer, RenameWalletRequestContainer, ListDCAOrderResponseContainer, ListOrderResponseContainer, ) # Load environment variables (e.g. BASE_API_URL, etc.) load_dotenv() # Create an MCP server instance with FastMCP mcp = FastMCP("Armor Crypto MCP") # Global variable to hold the authenticated Armor API client ACCESS_TOKEN = os.getenv('ARMOR_API_KEY') or os.getenv('ARMOR_ACCESS_TOKEN') BASE_API_URL = os.getenv('ARMOR_API_URL') or 'https://app.armorwallet.ai/api/v1' armor_client = ArmorWalletAPIClient(ACCESS_TOKEN, base_api_url=BASE_API_URL) #, log_path='armor_client.log') # Include version endpoint from armor_crypto_mcp import __version__ @mcp.tool() async def get_armor_mcp_version(): """Get the current Armor Wallet version""" return {'armor_version': __version__} @mcp.tool() async def wait_a_moment(seconds:float): """Wait for some short amount of time, no more than 10 seconds""" await asyncio.sleep(seconds) return {"waited": seconds} from datetime import datetime, timezone @mcp.tool() async def get_current_time() -> Dict: """Gets the current time and date""" return {"current_time": datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")} @mcp.tool() async def calculator(expression:str, variables:dict[str, Any]): """ Safely evaluates a mathematical or statistical expression string using Python syntax. Supports arithmetic operations (+, -, *, /, **, %, //), list expressions, and a range of math and statistics functions: abs, round, min, max, len, sum, mean, median, stdev, variance, sin, cos, tan, sqrt, log, exp, floor, ceil, etc. Custom variables can be passed via the 'variables' dict, including lists for time series data. """ return {'result': calculate(expression, variables)} @mcp.tool()