Agentic AutoML Data Scientist MCP
README.md
# Agentic AutoML Data Scientist using MCP
An advanced, production-ready AI platform that automates the complete machine learning workflow (data analysis, cleaning, EDA, feature engineering, model selection, hyperparameter tuning, evaluation, explainability, and PDF report compilation) using multiple AI agents orchestrated with **LangGraph** and integrated with **Model Context Protocol (MCP)**.
The platform mimics a junior data scientist, logging every step, comparing standard Scikit-learn models (SVM, Random Forests, KNN, Linear/Logistic regression, Gradient Boosting), and producing interactive dashboards and downloadable models/PDF reports.
---
## Architecture Diagram
```mermaid
flowchart TD
UI["Web Dashboard (HTML5 / CSS3 / JS)"] <-->|REST API| FastAPI["FastAPI Server (:8000)"]
subgraph Orchestrator ["FastAPI Backend (LangGraph Orchestrator)"]
Planner["Planner Agent"]
Analyzer["Dataset Analysis Agent"]
EDA["EDA Agent"]
Cleaner["Data Cleaning Agent"]
FE["Feature Engineering Agent"]
Selector["Model Selection Agent"]
Tuner["Hyperparameter Tuning Agent"]
Evaluator["Evaluation Agent"]
Explain["Explainability Agent"]
Reporter["Report Generation Agent"]
end
FastAPI <-->|MCP Protocol / stdio| FS_MCP["Filesystem MCP Server"]
FastAPI <-->|MCP Protocol / stdio| PY_MCP["Python MCP Server"]
FastAPI <-->|MCP Protocol / stdio| DB_MCP["SQLite MCP Server"]
FS_MCP <-->|Read / Write| Disk[("Local Filesystem")]
PY_MCP <-->|Execute ML| ML["Scikit-Learn / Pandas"]
DB_MCP <-->|Log History| SQLite[("SQLite DB")]
```
---
## Core Components
### 1. LangGraph Agents
- **Planner Agent**: Understands the user's optimization request, analyses the dataset preview, selects the target column, and sets the regression/classification type.
- **Dataset Analysis Agent**: Summarizes the columns, null counts, shapes, and types.
- **EDA Agent**: Generates figures (missingness, correlations, target distribution) and writes findings.
- **Data Cleaning Agent**: Configures and executes missing values imputation, encoding, and scaling.
- **Feature Engineering Agent**: Writes custom python pandas statements to drop useless columns (like IDs) and generate derived features.
- **Model Selection Agent**: Iterates and trains candidate models to compare performance.
- **Hyperparameter Tuning Agent**: Fine-tunes the best model using cv grid/randomized search.
- **Evaluation Agent**: Finalizes metrics (Accuracy/F1/ROC AUC or MAE/RMSE/R2) and generates fit curves.
- **Explainability Agent**: Generates textual model explanations and identifies top feature importances.
- **Report Generation Agent**: Compiles findings into a PDF and logs metrics to SQLite history.
### 2. MCP Server Integrations
Rather than tightly coupling operations, all file, compute, and database actions go through standard **Model Context Protocol** tool calls:
1. **Filesystem MCP Server**: Manages disk files (CSV datasets, serialized model binaries, and PDF reports).
2. **Python MCP Server**: Executes isolated Pandas preprocessing, trains Scikit-learn models, tunes hyperparameters, and outputs Matplotlib figures. It also has a code interpreter tool (`execute_python_code`) to run dynamic feature engineering code.
3. **SQLite MCP Server**: Logs and retrieves historical experiment statistics.
---
## Tech Stack
- **Python 3.11**
- **FastAPI** (Backend REST API & Static File Server)
- **LangGraph** (Agent flow graph)
- **LangChain & Google Gemini 2.5 Flash** (LLM brains)
- **Model Context Protocol (MCP)** (SDK for client-server tool calls)
- **Scikit-learn, Pandas, NumPy** (Machine Learning & Data Processing)
- **Plotly, Matplotlib, Seaborn** (Data Visualizations)
- **ReportLab** (PDF document compilation)
- **HTML5 / CSS3 / JavaScript** (Responsive Single-Page Web App)
- **SQLite3** (Historical experiment logging database)
- **Docker & Docker Compose** (Containerization)
---
## Local Setup
### Prerequisites
- Python 3.11 installed.
- A **Google Gemini API Key**. Get one from [Google AI Studio](https://aistudio.google.com/).
### Installation
1. Clone this repository to your workspace.
2. Initialize virtual environment and install packages:
```bash
python -m venv .venv
.venv\Scripts\activate
pip install --upgrade pip
pip install -r requirements.txt
```
3. Set your API Key in your `.env` file or environment:
- **Windows (PowerShell):**
```powershell
$env:GEMINI_API_KEY="your-api-key-here"
```
- **Linux/macOS:**
```bash
export GEMINI_API_KEY="your-api-key-here"
```
4. Generate example datasets:
```bash
.venv\Scripts\python backend\datasets\generate_sample_data.py
```
5. Run server:
```bash
.venv\Scripts\python run_dev.py
```
- Single-Page Web Dashboard & API: http://localhost:8000
- Swagger API Documentation: http://localhost:8000/docs
---
## Docker Deployment
You can run the entire platform with a single command using Docker:
1. Create a `.env` file in the root directory:
```env
GEMINI_API_KEY=your_actual_gemini_api_key_here
```
2. Build and launch:
```bash
docker-compose up --build
```
3. Access the web dashboard at http://localhost:8000.
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues