Blocknative MCP 服务器
一个MCP服务器,提供跨多个区块链的实时天然气价格预测,由Blocknative提供支持。
特性
- 工具:
- predict_gas_price:获取指定链的天然气价格预测(默认值:以太坊主网, chain_id=1),包括基本费用和一个包含置信水平、价格、最高优先级费用和最高费用的表格。 - estimate_gas_cost:根据气体限制、置信水平和链ID估算交易成本,以Gwei和ETH返回成本。 - get_supported_chains:在表中列出支持的区块链,包括链ID、系统和网络。
- 提示:
- gas_price_query:用于查询特定置信水平和链ID的天然气价格的提示模板。
- 异步:用途
httpx用于向Blocknative的Gas Price和Chains API发送非阻塞HTTP请求。 - 可选API密钥:支持低频访问,无需Blocknative API密钥;高频使用需要设置
BLOCKNATIVE_API_KEY.
先决条件
- python:版本3.10
- 紫外线:用于依赖关系管理和运行项目(安装指南)
- 区块本机API密钥 (可选):用于高频API访问。注册地址: Blocknative 的 以获得免费的API密钥。
安装
- 克隆存储库:
git clone https://github.com/kukapay/blocknative-mcp.git
cd blocknative-mcp- 通过以下方式设置项目
uv:
uv sync- 设置Blocknative API密钥(可选):
- 对于高频访问,设置环境变量:
export BLOCKNATIVE_API_KEY="your-api-key-here"- 对于低频访问,跳过此步骤。
用法
服务器提供三个工具和一个提示,可通过FastMCP框架访问。您可以在开发模式下运行服务器,直接执行它,或将其与Claude Desktop集成。
运行服务器
- MCP Inspector开发模式:
uv run mcp dev blocknative-mcp这将打开MCP检查器,这是一个用于交互式测试工具和提示的web界面。
- 直接执行:
uv run blocknative-mcp- Claude桌面集成:
uv run mcp install blocknative-mcp --name "Blocknative MCP Server"这将安装服务器以与Claude Desktop一起使用。
工具
predict_gas_price(chain_id: int = 1) -> str:
获取链的天然气价格预测(默认:以太坊主网)。返回基本费用和一个包含置信度、价格、最大优先级费用和最大费用的Markdown表。
- 例子:
Gas Price Predictions for Chain ID 1 (ethereum/main):
- Base Fee Per Gas: 0.382910791 Gwei
| Confidence | Price (Gwei) | Max Priority Fee (Gwei) | Max Fee (Gwei) |
|------------|--------------|-------------------------|----------------|
| 99% | 0.52 | 0.14 | 0.9 |
| 95% | 0.48 | 0.094 | 0.86 |
| 90% | 0.47 | 0.089 | 0.85 |
| 80% | 0.46 | 0.079 | 0.84 |
| 70% | 0.45 | 0.069 | 0.83 |estimate_gas_cost(gas_limit: int, confidence: int = 99, chain_id: int = 1) -> str:
根据气体限制、置信水平和链ID估算交易成本。返回Gwei和ETH的成本。
- 例子:
Estimated Gas Cost (Confidence 90%, Chain ID 1):
- Gas Limit: 21000
- Max Fee Per Gas: 0.85 Gwei
- Total Cost: 17850 Gwei (0.00001785 ETH)get_supported_chains(ctx: Optional[Context] = None) -> str:
在Markdown表中列出支持的链,包括链ID、系统和网络。
- 例子:
Supported Chains:
| Chain ID | System | Network |
|------------|----------|-----------|
| 1 | ethereum | main |
| 137 | polygon | mainnet |
| 8453 | base | mainnet |
| 11155111 | ethereum | sepolia |鼓励
gas_price_query(confidence: int, chain_id: int = 1) -> List[base.Message]:
用于查询特定置信水平和链ID的天然气价格的提示模板。 - 例子:
- User: What is the current gas price for chain ID 1 transactions with 90% confidence?
- Assistant: Let me fetch the gas price predictions for chain ID 1.许可证
该项目根据MIT许可证获得许可。请参阅 许可证 文件以获取详细信息。
