dune_health_check
Validate Dune API key configuration and logging setup to ensure proper integration with blockchain data workflows.
Instructions
Validate Dune API key presence and logging setup.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/spice_mcp/mcp/server.py:336-343 (handler)Handler function decorated with @app.tool, registering and implementing the dune_health_check tool. It calls compute_health_status() to perform the actual logic.@app.tool( name="dune_health_check", title="Health Check", description="Validate Dune API key presence and logging setup.", tags={"health"}, ) def dune_health_check() -> dict[str, Any]: return compute_health_status()
- src/spice_mcp/mcp/server.py:138-170 (helper)Supporting function that computes the health status dictionary, checking for Dune API key presence, query history path, logging setup, and optionally a template query.def compute_health_status() -> dict[str, Any]: """Compute a lightweight health status without requiring full init.""" if not os.getenv("DUNE_API_KEY"): _best_effort_load_dotenv() has_api_key = bool(os.getenv("DUNE_API_KEY") or (CONFIG and CONFIG.dune.api_key)) qh = QUERY_HISTORY if QUERY_HISTORY is not None else QueryHistory.from_env() history_path = getattr(qh, "history_path", None) status: dict[str, Any] = { "api_key_present": has_api_key, "query_history_path": str(history_path) if history_path else None, "logging_enabled": qh is not None, "status": "ok" if has_api_key else "degraded", } # Optional: check raw SQL template query health if configured try: tmpl = os.getenv("SPICE_RAW_SQL_QUERY_ID") if tmpl: tid = dune_urls.get_query_id(tmpl) url = dune_urls.url_templates["query"].format(query_id=tid) from ..adapters.dune.user_agent import get_user_agent as get_dune_user_agent headers = { "X-Dune-API-Key": os.getenv("DUNE_API_KEY", ""), "User-Agent": get_dune_user_agent(), } client = HTTP_CLIENT or HttpClient(Config.from_env().http) resp = client.request("GET", url, headers=headers, timeout=5.0) status["template_query_id"] = tid status["template_query_ok"] = resp.status_code == 200 except Exception: pass return status