Skip to main content
Glama

get_all_balances

Retrieve all currency balances from your wallet, including USD and BTC, to monitor financial holdings across multiple supported currencies.

Instructions

Get all currency balances from your wallet (USD, BTC, etc.). Most useful with Strike wallet which supports multiple currencies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function 'get_all_balances' that implements the tool logic, including interactions with StrikeWallet or primary wallet balances.
    async def get_all_balances(
        wallet: "Union[NWCWallet, OpenNodeWallet, StrikeWallet, None]" = None,
        strike_wallet: "StrikeWallet | None" = None,
        budget_service: "BudgetService | None" = None,
    ) -> str:
        """
        Get all currency balances from your wallet (USD, BTC, etc.).
    
        Most useful with Strike wallet which supports multiple currencies.
        For NWC and OpenNode wallets, returns BTC balance only.
    
        Args:
            wallet: Primary wallet instance
            strike_wallet: Strike wallet instance (may be separate from primary wallet)
            budget_service: BudgetService for session stats
    
        Returns:
            JSON with all currency balances and session spending info
        """
        # Use strike_wallet if available, otherwise try primary wallet
        effective_strike = strike_wallet
        if effective_strike is None:
            from ..strike_wallet import StrikeWallet
            if isinstance(wallet, StrikeWallet):
                effective_strike = wallet
    
        if effective_strike is not None:
            try:
                result = await effective_strike.get_all_balances()
    
                if not result.success:
                    return json.dumps({
                        "success": False,
                        "error": result.error_message,
                        "errorCode": result.error_code,
                    })
    
                formatted_balances = []
                for b in result.balances:
                    entry = {
                        "currency": b.currency,
                        "available": float(b.available),
                        "total": float(b.total),
                        "pending": float(b.pending),
                    }
                    if b.currency == "BTC":
                        sats = int(b.available * 100_000_000)
                        entry["formatted"] = f"{b.available:.8f} BTC ({sats:,} sats)"
                    else:
                        entry["formatted"] = f"{b.available:,.2f} {b.currency}"
                    formatted_balances.append(entry)
    
                response: dict = {
                    "success": True,
                    "provider": "Strike",
                    "balances": formatted_balances,
                    "message": f"Retrieved {len(result.balances)} currency balance(s) from Strike",
                }
    
                # Add session info if budget service available
                if budget_service:
                    try:
                        status = budget_service.get_status()
                        session = status.get("session", {})
                        response["session"] = {
                            "spentSats": session.get("spentSats", 0),
                            "remainingBudgetSats": session.get("remainingSats", 0),
                            "requestCount": session.get("requestCount", 0),
                        }
                    except Exception:
                        pass
    
                return json.dumps(response, indent=2)
    
            except Exception as e:
                logger.exception("Error getting all balances from Strike")
                return json.dumps({
                    "success": False,
                    "error": sanitize_error(str(e))
                })
    
        # Fallback to regular balance for non-Strike wallets
        if wallet:
            try:
                balance_sats = await wallet.get_balance()
                provider_name = type(wallet).__name__.replace("Wallet", "")
    
                response = {
                    "success": True,
                    "provider": provider_name,
                    "balances": [{
                        "currency": "BTC",
                        "available": balance_sats / 100_000_000,
                        "total": balance_sats / 100_000_000,
                        "pending": 0,
                        "formatted": f"{balance_sats / 100_000_000:.8f} BTC ({balance_sats:,} sats)",
                    }],
                    "message": f"Retrieved BTC balance from {provider_name}. "
                               "For multi-currency balances, use Strike wallet.",
                }
    
                if budget_service:
                    try:
                        status = budget_service.get_status()
                        session = status.get("session", {})
                        response["session"] = {
                            "spentSats": session.get("spentSats", 0),
                            "remainingBudgetSats": session.get("remainingSats", 0),
                            "requestCount": session.get("requestCount", 0),
                        }
                    except Exception:
                        pass
    
                return json.dumps(response, indent=2)
    
            except Exception as e:
                logger.exception("Error getting balance")
                return json.dumps({
                    "success": False,
                    "error": sanitize_error(str(e))
                })
    
        return json.dumps({
            "success": False,
            "error": "Wallet not configured. Set STRIKE_API_KEY, OPENNODE_API_KEY, or NWC_CONNECTION_STRING environment variable.",
            "configured": False,
        })
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 of behavioral disclosure. It mentions the tool retrieves balances but doesn't cover critical aspects like authentication needs, rate limits, error handling, or whether it's a read-only operation. This leaves significant gaps in understanding how the tool behaves in practice.

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

Conciseness4/5

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

The description is concise with two sentences that directly state the purpose and a usage tip. It's front-loaded with the core functionality and avoids unnecessary details, though the second sentence could be slightly more integrated to enhance flow.

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

Completeness2/5

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

Given the tool's complexity (retrieving financial data) and lack of annotations and output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral traits like security requirements. For a tool handling sensitive wallet data, this leaves too many unknowns for effective use.

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 input schema has 0 parameters with 100% coverage, meaning no parameters are documented in the schema. The description doesn't add parameter details, which is acceptable since there are no parameters to describe. A baseline of 4 is appropriate as it doesn't need to compensate for missing schema information.

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

Purpose4/5

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

The description clearly states the action ('Get all currency balances') and resource ('from your wallet'), specifying the scope includes multiple currencies like USD and BTC. However, it doesn't explicitly differentiate from sibling tools like 'check_wallet_balance', which might have overlapping functionality, preventing a perfect score.

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 by mentioning it's 'Most useful with Strike wallet which supports multiple currencies,' suggesting a preferred context but not providing explicit guidance on when to use this tool versus alternatives like 'check_wallet_balance'. No exclusions or clear alternatives are stated, leaving some ambiguity.

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

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/refined-element/lightning-enable-mcp'

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