dune_query_fork
Create a copy of an existing Dune Analytics query to modify and customize for your blockchain data analysis needs without starting from scratch.
Instructions
Fork an existing saved Dune query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_query_id | Yes | ||
| name | No |
Implementation Reference
- src/spice_mcp/mcp/server.py:895-935 (handler)Main execution logic for the dune_query_fork tool: initializes services, checks save permissions, calls QUERY_ADMIN_SERVICE.fork to create a fork of the source query, logs the action to query history, and handles errors.def dune_query_fork(source_query_id: int, name: str | None = None) -> dict[str, Any]: _ensure_initialized() if CONFIG is None or not CONFIG.allow_saves: return error_response( ValueError("Saving queries is disabled. Set SPICE_DUNE_ALLOW_SAVES=true to enable."), context={"tool": "dune_query_fork", "allow_saves": False} ) assert QUERY_ADMIN_SERVICE is not None try: result = dict(QUERY_ADMIN_SERVICE.fork(source_query_id, name=name)) # Log admin action if QUERY_HISTORY is not None: query_id = result.get("query_id") or source_query_id QUERY_HISTORY.record( execution_id=f"fork_{source_query_id}", query_type="query_id", query_preview=f"Forked query {source_query_id}", status="success", duration_ms=0, action_type="admin_action", query_id=query_id, action="fork", source_query_id=source_query_id, ) return result except Exception as e: # Log error if QUERY_HISTORY is not None: QUERY_HISTORY.record( execution_id=f"fork_{source_query_id}", query_type="query_id", query_preview=f"Failed to fork query {source_query_id}", status="error", duration_ms=0, action_type="admin_action", query_id=source_query_id, action="fork", error=str(e), ) return error_response(e, context={"tool": "dune_query_fork", "source_query_id": source_query_id})
- src/spice_mcp/mcp/server.py:889-894 (registration)Registers the dune_query_fork tool in FastMCP with metadata: title, description, and tags.@app.tool( name="dune_query_fork", title="Fork Saved Query", description="Fork an existing saved Dune query. Requires SPICE_DUNE_ALLOW_SAVES=true.", tags={"dune", "admin"}, )