Skip to main content
Glama

get_address_balance

Retrieve Bitcoin address balance, transaction history, and activity timestamps to monitor wallet status and verify transactions.

Instructions

Get the total balance, transaction count, and first/last seen times for a Bitcoin address.

Uses the Satoshi API blockchain indexer when available, falls back to mempool.space. Returns total received, total sent, current balance, tx count, and timestamps.

Args: address: Bitcoin address (any format: legacy, P2SH, bech32, bech32m)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `get_address_balance` tool is defined here. It attempts to fetch balance data from a configured Satoshi API indexer, falling back to mempool.space if necessary.
    @mcp.tool()
    def get_address_balance(address: str) -> str:
        """Get the total balance, transaction count, and first/last seen times for a Bitcoin address.
    
        Uses the Satoshi API blockchain indexer when available, falls back to mempool.space.
        Returns total received, total sent, current balance, tx count, and timestamps.
    
        Args:
            address: Bitcoin address (any format: legacy, P2SH, bech32, bech32m)
        """
        result = _query_indexed_api(f"address/{address}/balance")
        if "error" not in result:
            return json.dumps(result)
        # Fallback to mempool.space
        data = _query_mempool_space(f"address/{address}")
        if "error" in data:
            return json.dumps(data)
        chain = data.get("chain_stats", {})
        mempool = data.get("mempool_stats", {})
        balance = {
            "source": "mempool.space",
            "address": address,
            "total_received": chain.get("funded_txo_sum", 0),
            "total_sent": chain.get("spent_txo_sum", 0),
            "balance": chain.get("funded_txo_sum", 0) - chain.get("spent_txo_sum", 0),
            "tx_count": chain.get("tx_count", 0),
            "unconfirmed_balance": mempool.get("funded_txo_sum", 0) - mempool.get("spent_txo_sum", 0),
            "unconfirmed_tx_count": mempool.get("tx_count", 0),
        }
        return json.dumps(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/Bortlesboat/bitcoin-mcp'

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