contract_summary
Retrieve basic contract summary information from Ethereum blockchain addresses without executing contract functions to quickly understand contract overviews.
Instructions
获取合约基本摘要信息,不调用合约函数,快速获取合约概况
Args:
contract_address: EVM 合约地址 (0x开头的42位十六进制字符串)
Returns:
合约的基本摘要信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contract_address | Yes |
Implementation Reference
- contract_inspector/main.py:69-111 (handler)The MCP tool handler for 'contract_summary'. Decorated with @mcp.tool(), performs input validation, calls ContractAnalyzer.get_contract_summary(), formats result as JSON, handles errors.@mcp.tool() async def contract_summary(contract_address: str): """ 获取合约基本摘要信息,不调用合约函数,快速获取合约概况 Args: contract_address: EVM 合约地址 (0x开头的42位十六进制字符串) Returns: 合约的基本摘要信息 """ # 验证合约地址格式 if not contract_address or not isinstance(contract_address, str): raise ValueError("合约地址不能为空且必须是字符串") if not contract_address.startswith("0x") or len(contract_address) != 42: raise ValueError("合约地址格式无效,必须是0x开头的42位十六进制字符串") try: print(f"📋 获取合约摘要: {contract_address}") # 获取合约摘要 result = await analyzer.get_contract_summary(contract_address) # 格式化输出 formatted_result = json.dumps(result, ensure_ascii=False, indent=2) print(f"✅ 合约摘要获取完成: {contract_address}") return formatted_result except Exception as e: error_msg = f"获取合约摘要失败: {str(e)}" print(f"❌ {error_msg}") error_response = { "status": "error", "error": error_msg, "contract_address": contract_address, "tool": "contract_summary" } return json.dumps(error_response, ensure_ascii=False, indent=2)
- Core helper function in ContractAnalyzer that fetches basic contract summary: checksum address, checks if contract, verified on Etherscan, and contract name using web3 and etherscan clients.async def get_contract_summary(self, contract_address: str) -> Dict[str, Any]: """ 获取合约基本信息摘要 Args: contract_address: 合约地址 Returns: Dict: 合约摘要信息 """ if not is_valid_ethereum_address(contract_address): return {"error": "无效的地址格式"} checksum_address = to_checksum_address(contract_address) # 基本信息 summary = { "address": checksum_address, "is_contract": await self.web3_client.is_contract_address(checksum_address), "is_verified": await self.etherscan_client.is_contract_verified(checksum_address), "contract_name": await self.etherscan_client.get_contract_name(checksum_address) } return summary
- contract_inspector/main.py:69-69 (registration)The @mcp.tool() decorator registers the contract_summary function as an MCP tool.@mcp.tool()