get_job_results_summary
Retrieve a preview of Dune Analytics query results with statistics to quickly assess data insights before full analysis.
Instructions
Get result preview (5 rows) and stats.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes |
Implementation Reference
- src/main.py:240-264 (handler)The handler function for the get_job_results_summary tool. It is registered via the @mcp.tool() decorator. Fetches job status, retrieves results if complete, processes a preview of the first 5 rows using data_processor.process_results, and returns a formatted summary including row count, columns, preview, and stats.def get_job_results_summary(job_id: str) -> str: """ Get result preview (5 rows) and stats. """ try: # Check status first status_data = dune_service.get_status(job_id) state = status_data.get("state", "UNKNOWN") if state != "QUERY_STATE_COMPLETED" and state != "COMPLETED": return f"Job is not complete (Status: {state}). Please wait." raw_result = dune_service.get_result(job_id) processed = data_processor.process_results(raw_result, limit=5) return ( f"Row Count: {processed['row_count']}\n" f"Columns: {processed['columns']}\n" f"Preview (First 5 rows): {processed['preview']}\n" f"Stats: {processed.get('summary_stats', 'N/A')}\n" f"Tip: To see all data, use 'export_results_to_csv'." ) except Exception as e: return f"Error fetching results: {str(e)}"