Retrieve on-chain information for EVM contracts locally using an Ethereum RPC node and Etherscan API.
基于 MCP 协议的本地以太坊合约信息获取工具,支持在 Cursor 等 AI 工具中使用。采用 uv 作为现代化的 Python 项目管理工具。
重要说明:这是一个本地 MCP 服务,Cursor 会自动管理服务的启动和停止,无需用户手动启动服务器。
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# 或使用 pip
pip install uv
# 克隆/进入项目目录
cd ContractInfoMCP
# 创建虚拟环境并安装所有依赖(一键搞定)
uv sync
# 复制环境变量模板
cp env.example .env
# 编辑 .env 文件,填入您的 API keys
# 需要配置:
# - RPC_URL:您的以太坊 RPC 节点地址(如 Infura、Alchemy 等)
# - ETHERSCAN_API_KEY:您的 Etherscan API 密钥
配置完成后,您只需要在 Cursor 中添加 MCP 配置即可。无需手动启动任何服务器,Cursor 会自动管理本地 MCP 服务的生命周期。
在 Cursor 的 MCP 设置中添加以下配置。Cursor 会根据此配置自动启动和管理 MCP 服务。
请将 <project_path>
替换为您项目的实际绝对路径:
macOS/Linux 用户:
{
"mcpServers": {
"contract-inspector": {
"command": "<project_path>/.venv/bin/python",
"args": ["-m", "contract_inspector.main"],
"cwd": "<project_path>"
}
}
}
Windows 用户:
{
"mcpServers": {
"contract-inspector": {
"command": "<project_path>/.venv/Scripts/python.exe",
"args": ["-m", "contract_inspector.main"],
"cwd": "<project_path>"
}
}
}
将 <project_path>
替换为您项目的实际绝对路径:
获取项目路径:
# 在项目目录中运行
pwd # macOS/Linux
echo %cd% # Windows CMD
echo $PWD # Windows PowerShell
配置示例:
/Users/username/Projects/ContractInfoMCP
C:\\Users\\username\\Projects\\ContractInfoMCP
配置完成后,当您在 Cursor 中首次使用 MCP 工具时,Cursor 会自动启动本地服务。您可以直接在 Cursor 聊天中输入:
查询 0xdac17f958d2ee523a2206206994597c13d831ec7 地址的基本信息
Cursor 会自动调用相应的 MCP 工具来处理您的请求。
contract_address
(合约地址)contract_address
(合约地址)contract_inspector/
├── main.py # MCP 服务器入口
├── contract_analyzer.py # 核心分析逻辑
├── etherscan_client.py # Etherscan API
├── web3_client.py # Web3 RPC 客户端
├── config.py # 配置管理
└── utils.py # 工具函数
"uv: command not found"
pip install uv
"No solution found when resolving dependencies"
uv --version
和 python --version
"ModuleNotFoundError: No module named 'contract_inspector'"
# 确保在项目目录中
cd <project_path>
# 以可编辑模式重新安装包
uv pip install -e .
# 验证模块可以正确导入
.venv/bin/python -c "import contract_inspector; print('模块导入成功')"
# 获取正确的项目路径
pwd # 将输出的路径用于Cursor配置
MCP 配置问题
cwd
路径正确指向项目根目录本地 MCP 服务无响应
.env
文件是否正确配置了 API 密钥uv sync
正确安装uv run python -c "import contract_inspector; print('模块可用')"
MIT License
An MCP server that integrates with Ollama to provide tools for file operations, calculations, and text processing. Requires a running Ollama instance.
Server for advanced AI-driven video editing, semantic search, multilingual transcription, generative media, voice cloning, and content moderation.
MCP Expr-Lang provides a seamless integration between Claude AI and the powerful expr-lang expression evaluation engine.
A TypeScript library for integrating MCP with tools like LangChain and Zod, providing helpers for schema conversion and event streaming.
A unified interface for various Large Language Model (LLM) providers, including OpenAI, Anthropic, Google Gemini, Groq, DeepSeek, and Ollama.
A terminal AI chat interface for any LLM model, with file context, MCP, and deployment support.
Interact with Azure DevOps for managing projects, pipelines, and repositories.
A server for automated provisioning, supporting both local and remote communication protocols.
A server for splitting and extracting parts of OpenAPI specifications using Redocly CLI.
An MCP server for managing the software development lifecycle, with support for an optional external SQLite database.