沙丘查询 MCP
通过模型控制协议 (MCP) 将 Dune Analytics 数据连接到智能代理的现代桥梁。
概述
dune-query-mcp 可将区块链数据分析无缝集成到您的 AI 应用程序中。通过利用 Dune Analytics 强大的查询功能和模型控制协议,该服务允许 LLM 和其他 AI 系统通过简单的自然语言交互访问链上数据。
Related MCP server: Bankless Onchain MCP Server
核心能力
数据检索工具
工具 | 描述 | 用例 |
| 检索预先计算的查询结果 | 快速访问现有数据 |
| 按需执行查询 | 实时数据分析 |
数据格式
所有数据均以 CSV 格式返回,提供:
通用兼容性
大多数数据分析工具都可以轻松解析
人类可读的输出
入门
系统要求
Python 3.10 或更高版本
有效的 Dune Analytics API 密钥(在此获取)
快速设置
克隆和导航
git clone https://github.com/olaxbt/dune-query-mcp-mcp.git cd dune-query-mcp环境设置
# Create virtual environment python -m venv .venv # Activate it source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows # Install dependencies pip install -r requirements.txt配置 API 访问
# Copy example config cp .env.example .env # Edit with your API key echo "DUNE_API_KEY=your_key_here" > .env
用法
运行服务
dune-query-mcp 提供两种运行方式:
作为 MCP 服务
python run.py这将在默认端口 8000 上启动 MCP 服务。
作为 Web 服务器
python flask_app.py这提供了对 Web 界面和 REST API 端点的访问。
与应用程序集成
MCP 客户端集成
from mcp.client import Client
# Connect to Dune-query-mcp
client = Client("http://localhost:8000")
# Get latest results for a query
csv_data = client.call("get_latest_result", query_id=1234567)
# Execute a query
query_results = client.call("run_query", query_id=1234567)REST API
端点 | 方法 | 描述 |
| 得到 | 服务健康检查 |
| 得到 | 检索最新结果 |
| 邮政 | 运行查询 |
REST 调用示例:
curl -X GET http://localhost:5000/dune/query/1234567/latest建筑学
dune-query-mcp/
├── app/ # Application core
│ ├── __init__.py # Flask & MCP setup
│ ├── routes/ # API endpoint definitions
│ │ └── dune_routes/ # Dune Analytics routes
│ │ └── templates/ # Web interface
│ └── templates/ # Web interface
├── config/ # Configuration files
├── logs/ # Runtime logs
├── flask_app.py # Web server entry point
├── run.py # MCP server entry point
└── requirements.txt # Dependencies高级配置
环境变量
多变的 | 目的 | 默认 |
DUNE_API_密钥 | Dune API 的身份验证 | 无(必填) |
港口 | 服务器端口 | 8000 |
性能调优
对于大容量查询执行:
# Set a higher timeout for long-running queries
export DUNE_QUERY_TIMEOUT=600 # 10 minutes in seconds故障排除
常见问题及解决方案:
问题 | 解决方案 |
API 密钥错误 | 确保 |
超时错误 | 增加复杂查询的超时时间 |
CSV解析问题 | 检查查询返回正确的表格数据 |
贡献
欢迎贡献!请按以下步骤操作:
分叉存储库
创建功能分支:
git checkout -b feature/amazing-feature提交您的更改:
git commit -am 'Add some amazing feature'推送到分支:
git push origin feature/amazing-feature打开拉取请求
执照
本项目遵循 MIT 许可证。详情请参阅LICENSE文件。
致谢
使用FastMCP构建
由Dune Analytics提供支持的查询功能
This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.