update_query
Modify SQL code and description for existing Dune Analytics queries to update data analysis workflows.
Instructions
Update SQL/description of an existing query. (Requires Paid Plan)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query_id | Yes | ||
| sql | Yes | ||
| description | No |
Implementation Reference
- src/main.py:165-174 (handler)MCP tool handler for 'update_query'. Decorated with @mcp.tool(), which registers it and infers schema from type hints. Executes by delegating to dune_service.update_query and returns user-friendly status.@mcp.tool() def update_query(query_id: int, sql: str, description: str = None) -> str: """ Update SQL/description of an existing query. (Requires Paid Plan) """ try: dune_service.update_query(query_id, sql, description) return f"Successfully updated Query {query_id}." except Exception as e: return f"Error updating query: {str(e)}"
- src/services/dune_client.py:399-410 (helper)Supporting utility in DuneClient service that wraps the Dune SDK's update_query API call, handling the low-level update operation.def update_query(self, query_id: int, sql: str, description: str = None, name: str = None) -> int: """ Updates an existing query. Returns the Query ID. """ try: # client.update_query takes query_id and optional fields # Removed 'description' arg as it's not supported in current SDK version self.client.update_query(query_id, query_sql=sql, name=name) return query_id except Exception as e: logger.error(f"Error updating query {query_id}: {e}") raise