MCP Etherscan 服务器
一个 MCP(模型上下文协议)服务器,通过 Etherscan 的 API 提供以太坊区块链数据工具。功能包括查询 ETH 余额、查看交易历史记录、追踪 ERC20 转账、获取合约 ABI、监控 Gas 价格以及解析 ENS 域名。
特征
- 余额查询:获取任意以太坊地址的 ETH 余额
- 交易历史:查看最近交易的详细信息
- 代币转移:通过代币详细信息跟踪 ERC20 代币转移
- 合约 ABI :获取智能合约 ABI 以供开发
- 天然气价格:监控当前天然气价格(安全低、标准、快速)
- ENS 解析:将以太坊地址解析为 ENS 名称
先决条件
- Node.js >= 18
- Etherscan API 密钥(从https://etherscan.io/apis获取)
安装
- 克隆存储库:
- 安装依赖项:
- 在根目录中创建一个
.env
文件:
- 构建项目:
运行服务器
启动服务器:
该服务器将在 stdio 上运行,使其与 Claude Desktop 等 MCP 客户端兼容。
工作原理
该服务器实现了模型上下文协议 (MCP),以提供通过 Etherscan 的 API 与以太坊区块链数据交互的工具。每个工具都以 MCP 端点的形式公开,可供兼容的客户端调用。
可用工具
check-balance
- 输入:以太坊地址
- 输出:以 Wei 和 ETH 为单位的 ETH 余额
get-transactions
- 输入:以太坊地址,可选限制
- 输出:带有时间戳、值和地址的近期交易
get-token-transfers
- 输入:以太坊地址,可选限制
- 输出:最近的 ERC20 代币转移及代币详细信息
get-contract-abi
- 输入:合约地址
- 输出:JSON 格式的合约 ABI
get-gas-prices
- 输入:无
- 输出:当前 Gwei 中的 gas 价格
get-ens-name
- 输入:以太坊地址
- 输出:关联的 ENS 名称(如果可用)
与 Claude Desktop 一起使用
要将此服务器添加到 Claude Desktop:
- 使用
npm start
启动服务器 - 在 Claude Desktop 中:
- 前往“设置”
- 导航至 MCP 服务器部分
- 点击“添加服务器”
- 输入以下配置:
- 保存配置
- Etherscan 工具现在将在您的 Claude 对话中可用
Claude 中的示例用法
您可以使用如下命令:
或者
发展
要添加新功能或修改现有功能:
- 主服务器逻辑位于
src/server.ts
- Etherscan API 交互在
src/services/etherscanService.ts
中处理 - 更改后构建:
npm run build
执照
MIT 许可证 - 详情请参阅许可证文件
You must be authenticated.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
通过 Etherscan 的 API 提供以太坊区块链数据工具,使用户能够检查 ETH 余额、查看交易、跟踪代币转移、获取合约 ABI、监控 gas 价格以及解析 ENS 名称。
Related Resources
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 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
- AsecurityAlicenseAqualityA tool that enables users to interact with blockchain data to retrieve token total supply, chain IDs, and filtered RPC endpoints across different blockchain networks.Last updated -69JavaScriptMIT License