Skip to main content
Glama
blockscout

Blockscout MCP Server

Official

get_block_info

Read-only

Retrieve blockchain block details including timestamp, gas usage, transaction count, and burnt fees. Optionally fetch transaction hashes for deeper analysis.

Instructions

Get block information like timestamp, gas used, burnt fees, transaction count etc. Can optionally include the list of transaction hashes contained in the block. Transaction hashes are omitted by default; request them only when you truly need them, because on high-traffic chains the list may exhaust the context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYesThe ID of the blockchain
number_or_hashYesBlock number or hash
include_transactionsNoIf true, includes a list of transaction hashes from the block.

Implementation Reference

  • The core handler function implementing the get_block_info tool. Fetches block details and optionally transaction hashes from Blockscout API, reports progress, and returns structured ToolResponse.
    @log_tool_invocation
    async def get_block_info(
        chain_id: Annotated[str, Field(description="The ID of the blockchain")],
        number_or_hash: Annotated[str, Field(description="Block number or hash")],
        ctx: Context,
        include_transactions: Annotated[
            bool | None, Field(description="If true, includes a list of transaction hashes from the block.")
        ] = False,
    ) -> ToolResponse[BlockInfoData]:
        """
        Get block information like timestamp, gas used, burnt fees, transaction count etc.
        Can optionally include the list of transaction hashes contained in the block. Transaction hashes are omitted by default; request them only when you truly need them, because on high-traffic chains the list may exhaust the context.
        """  # noqa: E501
        total_steps = 3.0 if include_transactions else 2.0
    
        await report_and_log_progress(
            ctx,
            progress=0.0,
            total=total_steps,
            message=f"Starting to fetch block info for {number_or_hash} on chain {chain_id}...",
        )
    
        base_url = await get_blockscout_base_url(chain_id)
    
        await report_and_log_progress(
            ctx,
            progress=1.0,
            total=total_steps,
            message="Resolved Blockscout instance URL. Fetching block data...",
        )
    
        if not include_transactions:
            response_data = await make_blockscout_request(base_url=base_url, api_path=f"/api/v2/blocks/{number_or_hash}")
            await report_and_log_progress(
                ctx,
                progress=2.0,
                total=total_steps,
                message="Successfully fetched block data.",
            )
            block_data = BlockInfoData(block_details=response_data)
            return build_tool_response(data=block_data)
    
        block_api_path = f"/api/v2/blocks/{number_or_hash}"
        txs_api_path = f"/api/v2/blocks/{number_or_hash}/transactions"
    
        results = await asyncio.gather(
            make_blockscout_request(base_url=base_url, api_path=block_api_path),
            make_blockscout_request(base_url=base_url, api_path=txs_api_path),
            return_exceptions=True,
        )
        await report_and_log_progress(
            ctx,
            progress=2.0,
            total=total_steps,
            message="Fetched block and transaction data.",
        )
    
        block_info_result, txs_result = results
        notes = None
    
        if isinstance(block_info_result, Exception):
            raise block_info_result
    
        tx_hashes = None
        if isinstance(txs_result, Exception):
            notes = [f"Could not retrieve the list of transactions for this block. Error: {txs_result}"]
        else:
            tx_items = txs_result.get("items", [])
            tx_hashes = [tx.get("hash") for tx in tx_items if tx.get("hash")]
    
        await report_and_log_progress(
            ctx,
            progress=3.0,
            total=total_steps,
            message="Successfully fetched all block data.",
        )
    
        # The block details are added to the response as they are returned by the API.
        # Where as for transactions only the hashes are added. AI agents can use the hashes
        # to get the full transaction details using the `get_transaction_info` tool.
        block_data = BlockInfoData(block_details=block_info_result, transaction_hashes=tx_hashes)
        return build_tool_response(data=block_data, notes=notes)
  • MCP server registration of the get_block_info tool using FastMCP.tool decorator.
    mcp.tool(
        structured_output=False,
        annotations=create_tool_annotations("Get Block Information"),
    )(get_block_info)
  • Pydantic model BlockInfoData defining the structure of the block information returned by the tool.
    # --- Model for get_block_info Data Payload ---
    class BlockInfoData(BaseModel):
        """A structured representation of a block's information."""
    
        model_config = ConfigDict(extra="allow")  # External APIs may add new fields; allow them to avoid validation errors
    
        block_details: dict[str, Any] = Field(description="A dictionary containing the detailed properties of the block.")
        transaction_hashes: list[str] | None = Field(
            None, description="A list of transaction hashes included in the block."
        )
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, and openWorldHint=true, covering safety and scope. The description adds valuable behavioral context about the performance impact of including transactions ('may exhaust the context'), which goes beyond what annotations provide. No contradiction with annotations.

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

Conciseness5/5

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

Two well-structured sentences: first states the core purpose with examples, second provides crucial usage guidance about the transactions parameter. Every word earns its place with no redundancy or fluff.

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

Completeness4/5

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

For a read-only tool with good annotations and full schema coverage, the description provides excellent context about the key performance consideration (transaction list exhausting context). The main gap is lack of output format details, but with no output schema, this would be helpful to include.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds some context about the include_transactions parameter's default behavior and performance implications, but doesn't provide additional semantic meaning beyond what's in the schema descriptions.

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

Purpose5/5

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

The description clearly states the verb 'Get' and the resource 'block information', then provides specific examples of what information is retrieved (timestamp, gas used, burnt fees, transaction count). It distinguishes this tool from siblings like get_latest_block by focusing on specific block retrieval rather than latest block.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use the include_transactions parameter: 'request them only when you truly need them, because on high-traffic chains the list may exhaust the context.' This gives clear context about performance implications and when to avoid using this feature.

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

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