File size: 2,191 Bytes
4298f06
 
 
 
 
 
 
 
 
 
 
 
e49a771
 
 
 
 
 
9a85536
e49a771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a85536
e49a771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a85536
 
e49a771
9a85536
 
 
e49a771
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: MCP
emoji: 📈
colorFrom: green
colorTo: pink
sdk: gradio
sdk_version: 5.27.0
app_file: app.py
pinned: false
short_description: MCP Data Analyst Duo
---

# MCP: Data Analyst Duo

A lightweight two-agent pipeline using the **Model Context Protocol (MCP)** to load a CSV, compute statistics & correlations, interpret results with simple rule-based insights, and assemble a Markdown report—all powered by a Gradio interface.

---

## Features

- **ComputeAgent**  
  - Loads any publicly-accessible CSV into a pandas DataFrame  
  - Computes descriptive statistics (count, mean, std, min, quartiles, max)  
  - Computes a Pearson correlation matrix for all numeric columns  

- **InterpretAgent**  
  - Acknowledges each compute result  
  - Picks top 3 columns by range and top 3 strongest correlations  
  - Formats human-readable insights and a concise summary  
  - Assembles a final Markdown report combining preview, metrics, and insights  

- **Gradio UI**  
  1. **Input:** Paste your CSV URL  
  2. **Outputs (in order):**  
     - First five rows preview  
     - JSON statistics  
     - JSON correlation matrix  
     - ComputeAgent message history  
     - InterpretAgent message history  
     - Final Markdown report  

---

## Architecture

1. **MCPMessage**  
   - Typed messages (`request_*`, `*_result`, `ack`, `*_interpretation`, `report_result`)  
   - Ensures strict request–response semantics  

2. **ComputeAgent**  
   - Handlers for `request_data_load`, `request_statistics`, `request_correlation`  
   - Emits `data_load_result`, `statistics_result`, `correlation_result`  

3. **InterpretAgent**  
   - Receives compute results, replies with `ack`  
   - Runs `interpret_statistics` & `interpret_correlation` tools  
   - Emits `statistics_interpretation`, `correlation_interpretation`  
   - On `request_report`, emits `report_result` with assembled Markdown  

---

## Usage

1. Clone or fork this Space.  
2. Ensure your CSV is publicly accessible (e.g., hosted on GitHub, S3, etc.).  
3. In the Gradio UI, paste the CSV URL and click **Run**.  
4. Inspect each output panel—preview, raw metrics, histories, then read the final report summary.