mcpField
1
1scan - Blockchain Explorer API Gateway & MCP Server

1scan - Blockchain Explorer API Gateway & MCP Server

远程服务
github.com/huahuayu开发工具981 周前更新
代码仓库

关于 1scan - Blockchain Explorer API Gateway & MCP Server

1scan 将多个类 Etherscan 区块链浏览器 API 汇集到统一网关,并提供 AI 助手查询链上数据的 MCP 服务。适合需要从多条网络读取账户、交易、区块和合约信息的开发者。

主要功能

  1. 01统一访问多个浏览器 API
  2. 02API 负载均衡
  3. 03管理 API 速率限制
  4. 04通过 URL 参数指定 API 密钥
  5. 05提供链上数据查询工具

适用场景

  1. 01查询多条网络上的账户余额
  2. 02检查交易详情与区块信息
  3. 03读取代币转账及合约资料

MCP 相关

MCP 服务将区块链浏览器数据工具提供给 MCP 客户端,包括余额、交易、区块、代币和合约查询。支持 SSE 或 stdio 传输。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址http://localhost:3000/mcp/sse
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

详细介绍

1scan - 区块链浏览器 API 网关与 MCP 服务

一个统一的 API 网关,可集成多个类似 etherscan 的区块链浏览器 API,并支持模型上下文协议(MCP),供 AI 助手使用。

概述

1scan 提供两个主要组件:

  1. API 网关:用于访问多个区块链浏览器 API 的统一端点
  2. MCP 服务:允许 AI 模型(例如 Cursor IDE 中的 Claude)直接查询区块链数据

支持的区块链网络

请向相应的区块链浏览器申请自己的 API 密钥

网络名称Chain ID浏览器链接浏览器 API 端点
Ethereum1https://etherscan.ioapi.etherscan.io
Binance Smart Chain56https://bscscan.comapi.bscscan.com
Arbitrum One42161https://arbiscan.ioapi.arbiscan.io
Polygon137https://polygonscan.comapi.polygonscan.com
Optimism10https://optimistic.etherscan.ioapi-optimistic.etherscan.io
Avalanche C-Chain43114https://snowtrace.ioapi.snowtrace.io
Base8453https://basescan.orgapi.basescan.org
zkSync Era324https://explorer.zksync.ioblock-explorer-api.mainnet.zksync.io
Gnosis100https://gnosisscan.ioapi.gnosisscan.io
Fantom250https://ftmscan.comapi.ftmscan.com
Mantle5000https://mantlescan.infoapi.mantlescan.info
Cronos25https://cronoscan.comapi.cronoscan.com
Polygon ZkEVM1101https://zkevm.polygonscan.comapi-zkevm.polygonscan.com
Linea59144https://lineascan.buildapi.lineascan.build
Moonbeam1284https://moonscan.ioapi.moonscan.io
Celo42220https://celoscan.ioapi.celoscan.io
Scroll534352https://scrollscan.comapi.scrollscan.com
OpBNB204https://opbnbscan.comapi.opbnbscan.com
Moonriver1285https://moonriver.moonscan.ioapi-moonriver.moonscan.io
Arbitrum Nova42170https://nova.arbiscan.ioapi-nova.arbiscan.io
Blast81457https://blastscan.ioapi.blastscan.io
Fraxtal252https://fraxscan.comapi.fraxscan.com
Wemix1111https://wemixscan.comapi.wemixscan.com
Xai660279https://xaiscan.ioapi.xaiscan.io
World Chain480https://worldscan.orgapi.worldscan.org
Ape33139https://apescan.io/api.apescan.io
Kroma255https://kromascan.comapi.kromascan.com
Taiko167000https://taikoscan.ioapi.taikoscan.io
Bittorrent199https://bttcscan.comapi.bttcscan.com
Xdc50https://xdcscan.ioapi.xdcscan.io

功能

  • 🔄 为多个区块链浏览器提供统一的 API 端点
  • ⚖️ API 负载均衡
  • 🔑 API 速率限制管理
  • 🎯 通过 URL 参数支持自定义 API 密钥
  • 🤖 MCP 服务,供 AI 助手查询区块链数据

安装

使用 Go 安装
go install github.com/huahuayu/1scan@latest
从源代码安装
# Clone the repository
git clone https://github.com/huahuayu/1scan.git
cd 1scan

# Build both 1scan API server and MCP server
make build

快速开始

1. 创建配置文件

创建一个 config.json 文件并填入你的 API 密钥:

{
  "1": {
    "endpoint": "api.etherscan.io",
    "keys": {
      "YOUR_ETHERSCAN_API_KEY_1": 5,
      "YOUR_ETHERSCAN_API_KEY_2": 10
    }
  },
  "56": {
    "endpoint": "api.bscscan.com",
    "keys": {
      "YOUR_BSCSCAN_API_KEY": 5
    }
  }
}

每个链条目包含:

  • chainID:区块链网络 ID
  • endpoint:区块链浏览器的 API 端点
  • keys:API 密钥及其速率限制(每秒请求数)的映射
2. 运行 API 服务
# Run with default settings
1scan -config /path/to/config.json

# Or using make
make run-1scan
3. 运行 MCP 服务
# Run with default settings
1scanmcp -config /path/to/config.json # default serve at port 3000

# Or using make
make run-1scanmcp

# With custom settings
1scanmcp -config /path/to/config.json -port 3000 -path /mcp

与 Cursor IDE 集成

要在 Cursor IDE 中使用 1scan MCP:

  1. 启动 API 服务和 MCP 服务

    # Terminal 1
    make run-1scan
    
    # Terminal 2
    make run-1scanmcp
    
  2. 在 Cursor IDE 中,前往 Settings → AI → MCP Servers

  3. 添加一个新的 MCP 服务,并使用以下 URL:

{
  "mcpServers": {
    "1scan": {
      "url": "http://localhost:3000/mcp/sse"
    }
  }
}
  1. 如有必要,重启 Cursor IDE

  2. 现在,你可以在 AI 对话中使用区块链数据:

    Can you check the balance of address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e on Ethereum?
    

MCP 服务配置

运行 MCP 服务时,可以使用以下参数进行自定义:

  • -port:MCP 服务运行的端口(默认值:"3000")
  • -path:MCP 服务端点的路径(默认值:"/mcp")
  • -config:配置文件的路径(默认值:"config.json")
  • -transport:传输类型(sse 或 stdio)(默认值:"sse")

示例:

1scanmcp -port 3000 -config /path/to/config.json

可用的 MCP 工具

MCP 服务向 AI 模型提供以下工具:

  • getAccountBalance - 获取特定区块链上某个账户的余额
  • getTokenBalance - 获取特定区块链上某个账户的代币余额
  • getTransactionByHash - 根据哈希获取交易详情
  • getBlockByNumber - 根据区块编号获取区块信息
  • getContractABI - 获取已验证合约的 ABI
  • getContractSourceCode - 获取已验证合约的源代码
  • getTokenInfo - 获取 ERC20 代币的信息
  • getGasPrice - 获取特定区块链上的当前 Gas 价格
  • getLogs - 获取符合指定参数的事件日志
  • getTransaction - 根据交易哈希获取交易详情
  • getTransactionCount - 获取从某个地址发出的交易数量
  • getTransactionReceipt - 根据交易哈希获取交易回执
  • getBlockTransactionCountByNumber - 获取某个区块中的交易数量
  • getBlockTransactionCountByHash - 根据区块哈希获取某个区块中的交易数量
  • getBlockByHash - 根据区块哈希获取区块信息
  • getNormalTransactions - 根据地址获取普通交易
  • getInternalTransactions - 根据地址或交易哈希获取内部交易
  • getERC20Transfers - 根据地址或合约获取 ERC-20 代币转账事件
  • getERC721Transfers - 根据地址或合约获取 ERC-721 NFT 转账事件
  • getValidators - 获取验证者信息(适用于设有验证者集合的网络)
  • getContractCreation - 获取合约创建信息
  • getContractVerificationStatus - 检查合约验证状态

MCP 交互示例

以下是通过 MCP 接口与区块链数据交互的示例:

# Get account balance
What's the ETH balance of vitalik.eth (0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045) on Ethereum?

# Check a token balance
What's the USDC balance of address 0x28C6c06298d514Db089934071355E5743bf21d60 on Ethereum?

# Examine a transaction
Can you analyze transaction 0xdd6d7f687c9821404ae8c2ea7de5cfb5a23fc4c01ef1e7f535748cb147aa76dd on Ethereum?

# Look up block information
What transactions were in Ethereum block 18700000?

# Get contract ABI
Can you show me the ABI for the USDC contract (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) on Ethereum?

# Analyze contract source code
I need to understand how the Uniswap V3 router works. Can you show me the source code for 0xE592427A0AEce92De3Edee1F18E0157C05861564 on Ethereum?

# Check multiple chains
What's the difference in gas fees between Ethereum and Arbitrum right now?

# Examine token information
Tell me about the tokenomics of the APE token on Ethereum.

MCP 工具完整列表

MCP 服务向 AI 模型提供以下工具:

  • getAccountBalance - 获取特定区块链上某个账户的余额
  • getTokenBalance - 获取特定区块链上某个账户的代币余额
  • getTransactionByHash - 根据哈希获取交易详情
  • getBlockByNumber - 根据区块编号获取区块信息
  • getContractABI - 获取已验证合约的 ABI
  • getContractSourceCode - 获取已验证合约的源代码
  • getTokenInfo - 获取 ERC20 代币信息
  • getGasPrice - 获取特定区块链上的当前 Gas 价格
  • getLogs - 获取符合指定参数的事件日志
  • getTransaction - 根据交易哈希获取交易详情
  • getTransactionCount - 获取从某个地址发送的交易数量
  • getTransactionReceipt - 根据交易哈希获取交易收据
  • getBlockTransactionCountByNumber - 获取区块中的交易数量
  • getBlockTransactionCountByHash - 根据区块哈希获取区块中的交易数量
  • getBlockByHash - 根据区块哈希获取区块信息
  • getNormalTransactions - 根据地址获取普通交易
  • getInternalTransactions - 根据地址或交易哈希获取内部交易
  • getERC20Transfers - 根据地址或合约获取 ERC-20 代币转账事件
  • getERC721Transfers - 根据地址或合约获取 ERC-721 NFT 转账事件
  • getValidators - 获取验证者信息(适用于具有验证者集的网络)
  • getContractCreation - 获取合约创建信息
  • getContractVerificationStatus - 检查合约验证状态

MCP 集成故障排除

如果你在从 Cursor 连接 MCP 服务时遇到问题:

  1. 确认两个服务都在运行:

    # Check if servers are running
    ps aux | grep 1scanmcp
    
  2. 确保在 Cursor 中配置了正确的 URL

许可证

MIT 许可证

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。