Skip to main content
Glama
olaxbt
by olaxbt

沙丘查询 MCP

版本Python

通过模型控制协议 (MCP) 将 Dune Analytics 数据连接到智能代理的现代桥梁。

概述

dune-query-mcp 可将区块链数据分析无缝集成到您的 AI 应用程序中。通过利用 Dune Analytics 强大的查询功能和模型控制协议,该服务允许 LLM 和其他 AI 系统通过简单的自然语言交互访问链上数据。

Related MCP server: Bankless Onchain MCP Server

核心能力

数据检索工具

工具

描述

用例

get_latest_result

检索预先计算的查询结果

快速访问现有数据

run_query

按需执行查询

实时数据分析

数据格式

所有数据均以 CSV 格式返回,提供:

  • 通用兼容性

  • 大多数数据分析工具都可以轻松解析

  • 人类可读的输出

入门

系统要求

  • Python 3.10 或更高版本

  • 有效的 Dune Analytics API 密钥(在此获取

快速设置

  1. 克隆和导航

    git clone https://github.com/olaxbt/dune-query-mcp-mcp.git cd dune-query-mcp
  2. 环境设置

    # 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
  3. 配置 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

端点

方法

描述

/dune/health

得到

服务健康检查

/dune/query/{query_id}/latest

得到

检索最新结果

/dune/query/{query_id}/execute

邮政

运行查询

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 密钥错误

确保

.env

文件存在且密钥有效

超时错误

增加复杂查询的超时时间

CSV解析问题

检查查询返回正确的表格数据

贡献

欢迎贡献!请按以下步骤操作:

  1. 分叉存储库

  2. 创建功能分支: git checkout -b feature/amazing-feature

  3. 提交您的更改: git commit -am 'Add some amazing feature'

  4. 推送到分支: git push origin feature/amazing-feature

  5. 打开拉取请求

执照

本项目遵循 MIT 许可证。详情请参阅LICENSE文件。

致谢

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/olaxbt/dune-query-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server