Skip to main content
Glama

analyze_results

Detect outliers and identify trends in Dune Analytics query results to reveal data patterns and anomalies.

Instructions

Detect outliers (Z-score > 3) and trends in query results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYes

Implementation Reference

  • The handler and registration for the 'analyze_results' MCP tool. This function checks the job status, fetches analysis from dune_service.analyze_result, and returns a formatted summary of numeric columns including means, standard deviations, outliers (Z-score >3), and trend heuristics.
    @mcp.tool()
    def analyze_results(job_id: str) -> str:
        """
        Detect outliers (Z-score > 3) and trends in query results.
        """
        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}). Cannot analyze."
    
            analysis = dune_service.analyze_result(job_id, data_processor)
            
            if "error" in analysis:
                return f"Analysis Failed: {analysis['error']}"
                
            summary = [f"Analysis for Job {job_id} ({analysis['row_count']} rows):"]
            
            for col, stats in analysis.get("numeric_analysis", {}).items():
                summary.append(f"\nColumn: {col}")
                summary.append(f"  Mean: {stats.get('mean'):.2f} | StdDev: {stats.get('std_dev'):.2f}")
                
                outliers = stats.get("outlier_count", 0)
                if outliers > 0:
                    summary.append(f"  Outliers detected: {outliers} values (>3 sigma)")
                    summary.append(f"  Sample outliers: {stats.get('top_outliers')}")
                else:
                    summary.append("  No significant outliers.")
                    
                if "trend_heuristic" in stats:
                    summary.append(f"  Trend: {stats['trend_heuristic']}")
                    
            return "\n".join(summary)
        except Exception as e:
            return f"Error analyzing results: {str(e)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nice-bills/dune-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server