Skip to main content
Glama

search_blocks

Retrieve Bitcoin block statistics for a specific height range, allowing analysis of up to 10 consecutive blocks at once.

Instructions

Get block statistics for a range of heights. Max 10 blocks.

Args: start_height: Starting block height (inclusive) end_height: Ending block height (inclusive)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_heightYes
end_heightYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The implementation of the `search_blocks` tool, which queries statistics for a block range via the RPC `getblockstats` method.
    def search_blocks(start_height: int, end_height: int) -> str:
        """Get block statistics for a range of heights. Max 10 blocks.
    
        Args:
            start_height: Starting block height (inclusive)
            end_height: Ending block height (inclusive)
        """
        if end_height - start_height + 1 > 10:
            return json.dumps({"error": "Maximum range is 10 blocks. Narrow your search."})
        if start_height > end_height:
            return json.dumps({"error": "start_height must be <= end_height"})
        results = []
        for h in range(start_height, end_height + 1):
            stats = get_rpc().getblockstats(h)
            results.append({
                "height": h,
                "time": stats.get("time"),
                "txs": stats.get("txs"),
                "total_fee": stats.get("totalfee"),
                "avg_fee_rate": stats.get("avgfeerate"),
                "median_fee_rate": stats.get("feerate_percentiles", [None, None, None])[2] if "feerate_percentiles" in stats else stats.get("medianfee"),
                "total_weight": stats.get("total_weight"),
                "total_size": stats.get("total_size"),
            })
        return json.dumps(results)

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