dune_query_fork
Create a copy of an existing Dune Analytics query to modify and analyze blockchain data with Polars-optimized workflows.
Instructions
Fork an existing saved Dune query. Requires SPICE_DUNE_ALLOW_SAVES=true.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_query_id | Yes | ||
| name | No |
Implementation Reference
- src/spice_mcp/mcp/server.py:889-894 (registration)Registration of the dune_query_fork tool using FastMCP @app.tool decorator, which also defines metadata like 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"}, )
- src/spice_mcp/mcp/server.py:895-934 (handler)The handler function for dune_query_fork tool. Initializes services, checks permissions, forks the query via QueryAdminService, logs to 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})