transaction_summary
Generate human-readable transaction summaries with natural language descriptions for transfers, swaps, NFT sales, and DeFi operations using the Blockscout MCP Server, enhancing rapid comprehension and dashboard displays.
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
| Name | Required | Description | Default |
|---|---|---|---|
| chain_id | Yes | The ID of the blockchain | |
| transaction_hash | Yes | Transaction hash |
Implementation Reference
- The main handler function that executes the transaction_summary tool logic by fetching data from the Blockscout API and returning 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 data returned by the transaction_summary tool.# --- Model for transaction_summary Data Payload --- 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." ), )
- blockscout_mcp_server/server.py:194-196 (registration)MCP tool registration for the transaction_summary function.structured_output=False, annotations=create_tool_annotations("Get Transaction Summary"), )(transaction_summary)
- blockscout_mcp_server/api/routes.py:235-241 (registration)REST API wrapper and route registration for the transaction_summary tool.@handle_rest_errors 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())