Skip to main content
Glama
kukapay

bitcoin-utxo-mcp

get_block_stats

Retrieve transaction statistics for a specific Bitcoin block, including block height, hash, transaction count, total BTC value, and block time.

Instructions

Get transaction statistics for a specific Bitcoin block.

Args:
    block_height (int): The height of the block

Returns:
    A string containing:
    - Block height
    - Block hash
    - Number of transactions
    - Total transaction value in BTC
    - Block time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
block_heightYes

Implementation Reference

  • main.py:45-76 (handler)
    The 'get_block_stats' tool handler, registered with @mcp.tool(). Fetches Bitcoin block details (height, hash, tx count, total value, time) from blockchain.info API using the provided block_height.
    @mcp.tool()
    async def get_block_stats(block_height: int) -> str:
        """Get transaction statistics for a specific Bitcoin block.
        
        Args:
            block_height (int): The height of the block
        
        Returns:
            A string containing:
            - Block height
            - Block hash
            - Number of transactions
            - Total transaction value in BTC
            - Block time
        """
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(f"https://blockchain.info/block-height/{block_height}?format=json")
                response.raise_for_status()
                data = response.json()["blocks"][0]
                tx_count = len(data["tx"])
                total_value = sum(tx["out"][0]["value"] for tx in data["tx"] if tx["out"]) / 1e8
                block_time = data["time"]
                return (
                    f"Block Height: {block_height}\n"
                    f"Block Hash: {data['hash']}\n"
                    f"Transactions: {tx_count}\n"
                    f"Total Value: {total_value:.8f} BTC\n"
                    f"Block Time: {block_time}"
                )
            except Exception as e:
                return f"Error fetching block stats: {str(e)}"
  • main.py:45-45 (registration)
    Registration of the 'get_block_stats' tool via the FastMCP @mcp.tool() decorator.
    @mcp.tool()
  • main.py:46-46 (schema)
    Type annotations and docstring define the input schema (block_height: int) and output (str with formatted block stats).
    async def get_block_stats(block_height: int) -> str:
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/kukapay/bitcoin-utxo-mcp'

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