dune_query_update
Modify saved Dune Analytics queries by updating their name, SQL code, description, tags, or parameters to maintain accurate blockchain data analysis.
Instructions
Update fields of a saved Dune query (name/SQL/description/tags/parameters). Requires SPICE_DUNE_ALLOW_SAVES=true.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query_id | Yes | ||
| name | No | ||
| query_sql | No | ||
| description | No | ||
| tags | No | ||
| parameters | No |
Implementation Reference
- src/spice_mcp/mcp/server.py:843-848 (registration)Registers the 'dune_query_update' tool with FastMCP, specifying its metadata including name, title, description, and tags.@app.tool( name="dune_query_update", title="Update Saved Query", description="Update fields of a saved Dune query (name/SQL/description/tags/parameters). Requires SPICE_DUNE_ALLOW_SAVES=true.", tags={"dune", "admin"}, )
- src/spice_mcp/mcp/server.py:849-886 (handler)The handler function that executes the tool: ensures initialization, checks save permissions, calls QUERY_ADMIN_SERVICE.update(), logs the action to query history, and handles errors gracefully.def dune_query_update(query_id: int, name: str | None = None, query_sql: str | None = None, description: str | None = None, tags: list[str] | None = None, parameters: list[dict[str, Any]] | 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_update", "allow_saves": False} ) assert QUERY_ADMIN_SERVICE is not None try: result = dict(QUERY_ADMIN_SERVICE.update(query_id, name=name, query_sql=query_sql, description=description, tags=tags, parameters=parameters)) # Log admin action if QUERY_HISTORY is not None: QUERY_HISTORY.record( execution_id=f"update_{query_id}", query_type="query_id", query_preview=f"Updated query {query_id}", status="success", duration_ms=0, action_type="admin_action", query_id=query_id, action="update", ) return result except Exception as e: # Log error if QUERY_HISTORY is not None: QUERY_HISTORY.record( execution_id=f"update_{query_id}", query_type="query_id", query_preview=f"Failed to update query {query_id}", status="error", duration_ms=0, action_type="admin_action", query_id=query_id, action="update", error=str(e), ) return error_response(e, context={"tool": "dune_query_update", "query_id": query_id})