Skip to main content
Glama
ACaiSec
by ACaiSec

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
NameRequiredDescriptionDefault
contract_addressYes

Implementation Reference

  • 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 
  • The @mcp.tool() decorator registers the contract_summary function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a read operation that doesn't call contract functions, which is helpful. However, it doesn't disclose important behavioral traits like whether this requires specific permissions, rate limits, error conditions, or what format the summary information will be returned in. For a tool with zero annotation coverage, this leaves significant gaps.

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

Conciseness4/5

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

The description is appropriately concise with clear sections (purpose, Args, Returns). The first sentence states the core purpose, and subsequent sections efficiently document parameters and returns. There's minimal wasted text, though the structure could be slightly more polished.

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

Completeness3/5

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

Given the tool has no annotations, no output schema, and only one parameter, the description provides adequate basic information but has clear gaps. It explains the purpose and parameter format well, but doesn't describe what '合约的基本摘要信息' (basic contract summary information) actually contains or provide behavioral context about permissions, errors, or limitations. For a read-only tool, this is minimally viable but incomplete.

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

Parameters4/5

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

The description adds meaningful semantic context for the single parameter beyond what the schema provides. While the schema only shows 'contract_address' as a string, the description specifies it must be 'EVM 合约地址 (0x开头的42位十六进制字符串)' - an EVM contract address starting with 0x and 42 hexadecimal characters. This provides crucial format requirements not captured in the schema's 0% description coverage.

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

Purpose4/5

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

The description clearly states what the tool does ('获取合约基本摘要信息' - get basic contract summary information) with a specific verb and resource. It distinguishes from potential sibling operations by stating '不调用合约函数' (does not call contract functions), though it doesn't explicitly differentiate from the sibling 'contract_info' tool. The purpose is clear but lacks explicit sibling differentiation.

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

Usage Guidelines3/5

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

The description provides some usage context by stating this is for '快速获取合约概况' (quickly get contract overview) and that it doesn't call contract functions. However, it doesn't explicitly state when to use this tool versus the sibling 'contract_info' tool or provide clear alternatives. The guidance is implied rather than explicit.

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/ACaiSec/ContractInfoMCP'

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