Skip to main content
Glama

get_wallet_balance

Retrieve wallet balance details for specified account types (UNIFIED, CONTRACT, SPOT) and optional coin on Bybit. Provides accurate balance information for better account management.

Instructions

Get wallet balance Args: accountType (str): Account type (UNIFIED, CONTRACT, SPOT) coin (Optional[str]): Coin symbol Returns: Dict: Wallet balance information Example: get_wallet_balance("UNIFIED", "BTC") Reference: https://bybit-exchange.github.io/docs/v5/account/wallet-balance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountTypeYesAccount type (UNIFIED, CONTRACT, SPOT)
coinNoCoin symbol

Implementation Reference

  • The primary MCP tool handler for 'get_wallet_balance', decorated with @mcp.tool(). It validates inputs using Pydantic Field, calls the BybitService, handles errors, and returns the balance information.
    @mcp.tool() def get_wallet_balance( accountType: str = Field(description="Account type (UNIFIED, CONTRACT, SPOT)"), coin: Optional[str] = Field(default=None, description="Coin symbol") ) -> Dict: """ Get wallet balance Args: accountType (str): Account type (UNIFIED, CONTRACT, SPOT) coin (Optional[str]): Coin symbol Returns: Dict: Wallet balance information Example: get_wallet_balance("UNIFIED", "BTC") Reference: https://bybit-exchange.github.io/docs/v5/account/wallet-balance """ try: result = bybit_service.get_wallet_balance(accountType, coin) if result.get("retCode") != 0: logger.error(f"Failed to get wallet balance: {result.get('retMsg')}") return {"error": result.get("retMsg")} return result except Exception as e: logger.error(f"Failed to get wallet balance: {e}", exc_info=True) return {"error": str(e)}
  • Helper method in BybitService class that proxies the get_wallet_balance call to the underlying HTTP client (likely pybit).
    def get_wallet_balance(self, accountType: str, coin: Optional[str] = None) -> Dict: """ Get wallet balance Args: accountType (str): Account type (UNIFIED, CONTRACT, SPOT) coin (Optional[str]): Coin symbol Returns: Dict: Wallet balance information """ return self.client.get_wallet_balance( accountType=accountType, coin=coin )
  • Input schema definition using Pydantic Field annotations for MCP tool parameters, providing descriptions and defaults for validation and documentation.
    def get_wallet_balance( accountType: str = Field(description="Account type (UNIFIED, CONTRACT, SPOT)"), coin: Optional[str] = Field(default=None, description="Coin symbol") ) -> Dict:
  • src/server.py:163-163 (registration)
    The @mcp.tool() decorator registers this function as an MCP tool, making it available via mcp.run().
    @mcp.tool()
  • Tool description in the @mcp.prompt() function used for AI context, listing available tools.
    - get_wallet_balance(accountType, coin) - Get wallet balance: Retrieve wallet balance information for a specific account type and coin.

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/dlwjdtn535/mcp-bybit-server'

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