Allows configuration of API keys and RPC URLs through environment variables for secure credential management.
Enables retrieval of Ethereum contract information, executing view functions without parameters, and obtaining contract data by combining Etherscan and RPC data sources.
Contract Inspector MCP Service
基于 MCP 协议的本地以太坊合约信息获取工具,支持在 Cursor 等 AI 工具中使用。采用 uv 作为现代化的 Python 项目管理工具。
重要说明:这是一个本地 MCP 服务,Cursor 会自动管理服务的启动和停止,无需用户手动启动服务器。
功能
- 🔍 获取 EVM 合约链上信息
- 📊 调用所有无参数 view 函数
- 🌐 整合 Etherscan 和 RPC 数据
- ⚡ 并发处理,性能优化
- 📋 标准 JSON 格式输出
环境要求
- Python 3.10+
- uv 包管理器
快速开始
1. 安装 uv(如果尚未安装)
2. 设置项目
3. 配置环境
4. 完成配置
配置完成后,您只需要在 Cursor 中添加 MCP 配置即可。无需手动启动任何服务器,Cursor 会自动管理本地 MCP 服务的生命周期。
在 Cursor 中配置
在 Cursor 的 MCP 设置中添加以下配置。Cursor 会根据此配置自动启动和管理 MCP 服务。
请将 <project_path>
替换为您项目的实际绝对路径:
macOS/Linux 用户:
Windows 用户:
路径配置说明
将 <project_path>
替换为您项目的实际绝对路径:
获取项目路径:
配置示例:
- macOS/Linux:
/Users/username/Projects/ContractInfoMCP
- Windows:
C:\\Users\\username\\Projects\\ContractInfoMCP
使用示例
配置完成后,当您在 Cursor 中首次使用 MCP 工具时,Cursor 会自动启动本地服务。您可以直接在 Cursor 聊天中输入:
Cursor 会自动调用相应的 MCP 工具来处理您的请求。
MCP 工具
ContractInfo
- 功能:获取合约完整信息,调用所有不需要参数的 view 函数
- 参数:
contract_address
(合约地址) - 输出:JSON 格式的合约信息和函数调用结果
ContractSummary
- 功能:获取合约基本摘要,不调用函数
- 参数:
contract_address
(合约地址) - 输出:合约基本信息
项目结构
故障排除
常见问题
- "uv: command not found"
- 安装 uv:
pip install uv
- 或访问:https://github.com/astral-sh/uv
- 安装 uv:
- "No solution found when resolving dependencies"
- 检查 Python 版本是否 >= 3.10
- 运行:
uv --version
和python --version
- "ModuleNotFoundError: No module named 'contract_inspector'"
- 这通常是Cursor没有使用正确的虚拟环境导致的,请执行以下步骤:
- MCP 配置问题
- 确保 Cursor 配置文件中的
cwd
路径正确指向项目根目录 - 确保使用绝对路径而不是相对路径
- 检查虚拟环境中的Python可执行文件是否存在
- 如果 Cursor 无法启动 MCP 服务,检查配置文件语法是否正确
- 确保 Cursor 配置文件中的
- 本地 MCP 服务无响应
- 检查
.env
文件是否正确配置了 API 密钥 - 查看 Cursor 的 MCP 日志获取详细错误信息
- 确认项目依赖已通过
uv sync
正确安装
- 检查
如何检查 MCP 服务状态
- 在 Cursor 中查看 MCP 连接状态(通常在设置或状态栏中显示)
- 如果需要调试,可以手动测试:
uv run python -c "import contract_inspector; print('模块可用')"
- 查看 Cursor 的 MCP 日志文件以获取详细的错误信息
许可证
MIT License
A local Ethereum contract analysis tool that retrieves on-chain information, integrates Etherscan and RPC data, and automatically executes view functions to provide comprehensive contract insights.
Related MCP Servers
- AsecurityAlicenseAqualityFacilitates interaction with Ethereum blockchain data via Etherscan's API, providing real-time access to balances, transactions, token transfers, contract ABIs, gas prices, and ENS name resolutions.Last updated -6313TypeScriptMIT License
- AsecurityAlicenseAqualityProvides Ethereum blockchain data tools via Etherscan's API, enabling users to check ETH balances, view transactions, track token transfers, fetch contract ABIs, monitor gas prices, and resolve ENS names.Last updated -63TypeScriptMIT License
- AsecurityAlicenseAqualityProvides tools for AI assistants to interact with the Ethereum blockchain through standard JSON-RPC methods, enabling queries for account balances, gas prices, and smart contract code.Last updated -63JavaScriptMIT License
- -securityFlicense-qualityA comprehensive toolkit for Ethereum blockchain analysis within Claude AI, enabling contract auditing, wallet analysis, profitability tracking, and on-chain data retrieval.Last updated -2JavaScript