Skip to main content
Glama
blockscout

Blockscout MCP Server

Official

transaction_summary

Generate human-readable transaction summaries from blockchain data to classify transfers, swaps, NFT sales, and DeFi operations for rapid comprehension and analysis.

Instructions

Get human-readable transaction summaries from Blockscout Transaction Interpreter. Automatically classifies transactions into natural language descriptions (transfers, swaps, NFT sales, DeFi operations) Essential for rapid transaction comprehension, dashboard displays, and initial analysis. Note: Not all transactions can be summarized and accuracy is not guaranteed for complex patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYesThe ID of the blockchain
transaction_hashYesTransaction hash

Implementation Reference

  • The core handler function that executes the transaction_summary tool. It fetches the summary from Blockscout API, processes it, and returns a structured ToolResponse.
    @log_tool_invocation async def transaction_summary( chain_id: Annotated[str, Field(description="The ID of the blockchain")], transaction_hash: Annotated[str, Field(description="Transaction hash")], ctx: Context, ) -> ToolResponse[TransactionSummaryData]: """ Get human-readable transaction summaries from Blockscout Transaction Interpreter. Automatically classifies transactions into natural language descriptions (transfers, swaps, NFT sales, DeFi operations) Essential for rapid transaction comprehension, dashboard displays, and initial analysis. Note: Not all transactions can be summarized and accuracy is not guaranteed for complex patterns. """ # noqa: E501 api_path = f"/api/v2/transactions/{transaction_hash}/summary" await report_and_log_progress( ctx, progress=0.0, total=2.0, message=f"Starting to fetch transaction summary for {transaction_hash} on chain {chain_id}...", ) base_url = await get_blockscout_base_url(chain_id) await report_and_log_progress( ctx, progress=1.0, total=2.0, message="Resolved Blockscout instance URL. Fetching transaction summary..." ) response_data = await make_blockscout_request(base_url=base_url, api_path=api_path) await report_and_log_progress(ctx, progress=2.0, total=2.0, message="Successfully fetched transaction summary.") summary = response_data.get("data", {}).get("summaries") if summary is not None and not isinstance(summary, list): raise RuntimeError("Blockscout API returned an unexpected format for transaction summary") summary_data = TransactionSummaryData(summary=summary) return build_tool_response(data=summary_data)
  • Pydantic model defining the structure of the transaction summary data payload used in the tool response.
    class TransactionSummaryData(BaseModel): """A structured representation of a transaction summary.""" summary: list[dict] | None = Field( None, description=( "List of summary objects for generating human-readable transaction descriptions, " "or null if no summary data is available." ), )
  • MCP tool registration where the transaction_summary function is registered with the FastMCP server.
    structured_output=False, annotations=create_tool_annotations("Get Transaction Summary"), )(transaction_summary)
  • REST API wrapper and route registration for the transaction_summary tool.
    async def transaction_summary_rest(request: Request) -> Response: """REST wrapper for the transaction_summary tool.""" params = extract_and_validate_params(request, required=["chain_id", "transaction_hash"], optional=[]) tool_response = await transaction_summary(**params, ctx=get_mock_context(request)) return JSONResponse(tool_response.model_dump())

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