AutoML Stat MCP
by u9401066
README.md
# AutoML Stat MCP
[](https://opensource.org/licenses/Apache-2.0)
[](https://www.python.org/downloads/)
[](https://docs.docker.com/compose/)
**AI-powered statistical analysis and AutoML platform using Model Context Protocol (MCP).**
AutoML Stat MCP provides 51+ statistical and machine learning tools through the MCP interface, enabling AI agents (Claude, GPT, etc.) to perform comprehensive clinical research analysis. Supports **real-time progress notifications** via SSE for long-running operations.
---
## โจ Features
### ๐ Statistical Analysis (51+ MCP Tools)
- **Descriptive Statistics**: Table One generation, correlation analysis, group comparisons
- **Survival Analysis**: Kaplan-Meier curves, Cox proportional hazards, log-rank tests
- **Propensity Score Analysis**: PSM matching, IPW weighting, treatment effect estimation
- **ROC Analysis**: AUC with CI, threshold optimization, DeLong test for model comparison
- **Power Analysis**: T-test, ANOVA, Chi-square, proportion, survival sample size calculation
### ๐ค Machine Learning (AutoGluon Backend)
- **AutoML Training**: Automatic model selection and hyperparameter tuning
- **Multi-Algorithm Support**: XGBoost, LightGBM, CatBoost, Random Forest, Neural Networks
- **Classification & Regression**: Binary, multiclass, and regression problems
### ๐ง Data Preparation
- **Missing Value Analysis**: MCAR/MAR/MNAR detection with imputation recommendations
- **Data Cleaning**: PII detection, outlier handling, encoding categorical variables
- **Quality Checks**: VIF multicollinearity, data validation, integrity checks
---
## ๐ Quick Start
### Prerequisites
- Docker & Docker Compose
- 8GB+ RAM recommended
- (Optional) GPU for accelerated ML training
### โก One-Line Install (ๆจ่ฆ)
```bash
# Clone and auto-install
git clone https://github.com/u9401066/automl-stat-mcp.git
cd automl-stat-mcp
./quick-install.sh
```
### ๐ฏ Quick Launch Scripts
```bash
# ๆนๅผ 1: ไฝฟ็จๅๅ่
ณๆฌ (ๆจ่ฆ)
./start.sh # ้ ่จญๆจกๅผ (็ตฑ่จๅๆ)
./start.sh ml # ML ๆจกๅผ (ๅซ่จ็ทด)
./start.sh full # ๅฎๆดๆจกๅผ (ๅซ MinIO)
# ๆนๅผ 2: ไฝฟ็จ Makefile (ๆๆนไพฟ)
make start # ๅๅ้ ่จญๆๅ
make start-ml # ๅๅ ML ๆๅ
make start-full # ๅๅๅฎๆดๆๅ
make logs # ๆฅ็ๆฅ่ช
make health # ๅฅๅบทๆชขๆฅ
make help # ๆๆๅฏ็จๆไปค
# ๆนๅผ 3: ไฝฟ็จ Docker Compose (้ฒ้)
docker compose up -d # ้ ่จญ
docker compose --profile ml up -d # ML
docker compose --profile full up -d # ๅฎๆด
```
### ๐ Stop Services
```bash
./stop.sh # ๆ make stop
```
### Verify Installation
```bash
# Check service health
curl http://localhost:8003/health # Stats service
curl http://localhost:8002/health # MCP server
# List available sample datasets
curl http://localhost:8003/api/files/list
```
### Connect to AI Agent
#### VS Code Copilot (ๆจ่ฆ)
ๅจไฝ ็ๅฐๆกๆ น็ฎ้ๅปบ็ซ `.vscode/mcp.json`๏ผ
```json
{
"servers": {
"automl-stat-mcp": {
"url": "http://localhost:8002/sse",
"type": "sse"
}
}
}
```
ๆไฝฟ็จๅฟซ้่จญๅฎ่
ณๆฌ๏ผๅจ็ฎๆจๅฐๆก็ฎ้ๅท่ก๏ผ
```bash
/path/to/automl-stat-mcp/scripts/setup-vscode-mcp.sh
```
#### Claude Desktop / Cursor
ๅจ MCP ่จญๅฎไธญๆฐๅข๏ผ
```json
{
"mcpServers": {
"automl-stat-mcp": {
"url": "http://localhost:8002/sse"
}
}
}
```
---
## ๐ Deployment Profiles
| Profile | Command | Components | Use Case |
|---------|---------|------------|----------|
| Default | `docker compose up -d` | Stats + MCP | Statistical analysis only |
| `ml` | `docker compose --profile ml up -d` | + AutoML API/Workers | ML training enabled |
| `full` | `docker compose --profile full up -d` | + MinIO | Full stack with object storage |
### Storage Modes
**Default**: Local file storage (no external dependencies)
| Mode | Environment Variable | Description | Requirements |
|------|---------------------|-------------|-------------|
| **Local** (Default) | `STORAGE_MODE=local` | Uses local `/data` directory for all storage operations | None |
| **MinIO** | `STORAGE_MODE=minio` | S3-compatible object storage for distributed deployment | Profile: `full` |
**Volume Mounts**:
```yaml
volumes:
- ./sample_data:/data/sample_data:ro # Sample datasets (read-only)
- ./projects:/data/projects # User projects
- local-results:/data/results # Analysis results
```
**Switching Storage Modes**:
```bash
# Local storage (default)
docker compose up -d
# MinIO storage (requires full profile)
STORAGE_MODE=minio docker compose --profile full up -d
```
**Path Resolution**:
- User input: `iris.csv` โ Container path: `/data/sample_data/iris.csv`
- User input: `projects/study1/data.csv` โ `/data/projects/study1/data.csv`
---
## ๐ ๏ธ Configuration
### Environment Variables
Copy `.env.example` to `.env` and customize:
```bash
cp .env.example .env
```
Key settings:
| Variable | Default | Description |
|----------|---------|-------------|
| `STORAGE_MODE` | `local` | Storage backend: `local` or `minio` |
| `LOG_LEVEL` | `INFO` | Logging level |
| `MINIO_ENDPOINT` | `minio:9000` | MinIO server address |
| `MINIO_ACCESS_KEY` | `minioadmin` | MinIO access key |
| `MINIO_SECRET_KEY` | `minioadmin` | MinIO secret key |
### Scaling Workers
```bash
# Scale stats workers
docker compose up -d --scale stats-worker=4
# Scale ML workers (requires ml profile)
docker compose --profile ml up -d --scale automl-worker=8 --scale stats-worker=4
```
---
## ๐ Sample Datasets
The `sample_data/` directory includes test datasets:
| Dataset | Type | Target | Records |
|---------|------|--------|---------|
| `iris.csv` | Classification | species | 150 |
| `titanic.csv` | Binary | survived | 891 |
| `heart_disease.csv` | Binary | target | 303 |
| `breast_cancer.csv` | Binary | diagnosis | 569 |
| `medical_study_200.csv` | RCT | treatment_group | 200 |
| `rossi_recidivism.csv` | Survival | arrest, week | 432 |
| `stanford_heart.csv` | Survival | status, time | 103 |
---
## ๐ง MCP Tools Reference
### Quick Start Tools (Recommended)
| Tool | Description |
|------|-------------|
| `smart_analyze` | One-stop analysis: stats + Table One + correlations |
| `quick_preview` | Fast data preview with auto path resolution |
| `compare_treatment_groups` | Simplified group comparison |
| `analyze_medical_study` | Complete RCT analysis pipeline |
### Statistical Analysis
| Category | Tools |
|----------|-------|
| **Descriptive** | `generate_tableone_directly`, `analyze_correlations`, `compare_groups`, `get_quick_stats` |
| **Survival** | `kaplan_meier_survival`, `cox_proportional_hazards` |
| **Propensity** | `run_propensity_analysis`, `estimate_treatment_effect` |
| **ROC** | `compute_roc_curve`, `compare_roc_curves`, `find_optimal_threshold`, `full_classifier_evaluation` |
| **Power** | `power_ttest`, `power_anova`, `power_chisquare`, `power_proportion`, `power_survival` |
### Data Preparation
| Category | Tools |
|----------|-------|
| **Quality** | `analyze_missing_values`, `check_multicollinearity`, `get_column_info` |
| **Cleaning** | `handle_missing_values`, `encode_categorical`, `convert_to_binary`, `filter_rows`, `remove_columns` |
| **Project** | `create_project_workspace`, `list_available_files`, `list_project_workspaces` |
### ML Training (Requires `ml` profile)
| Tool | Description |
|------|-------------|
| `train_and_wait` | One-shot AutoML training |
| `submit_automl_job` | Async training submission |
| `get_job_status` | Check training progress |
| `get_model_leaderboard` | View trained models ranking |
| `predict` | Make predictions |
---
## ๐๏ธ Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI Agent (Claude/GPT) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Protocol
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ automl-mcp (Port 8002) โ
โ 51+ MCP Tools Handlers โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ stats-service (8003) โ โ automl-api (8001) โ
โ Statistical Analysis โ โ ML Training API โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ stats-worker โ โ automl-worker โ
โ Background Analysis โ โ AutoGluon Training โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Redis โ
โ Job Queue & Cache โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ
โ Local Storage โ OR โ MinIO Storage โ
โ /data/... โ โ Object Storage โ
โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ
```
---
## ๐ Documentation
- [Architecture Overview](docs/ARCHITECTURE.md)
- [MCP Tools Inventory](docs/MCP_TOOLS_INVENTORY.md)
- [Deployment Guide](docs/deployment-guide.md)
- [Testing Strategy](docs/TESTING_STRATEGY.md)
- [Roadmap](docs/ROADMAP.md)
---
## ๐ค Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
### Development Setup
```bash
# Clone your fork or local mirror
git clone --recursive https://github.com/YOUR_USERNAME/automl-stat-mcp.git
cd automl-stat-mcp
# Sync the workspace environment
uv venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
uv sync --all-extras
# Install developer hooks
make hooks-install
# Run quality gates
make check
# Run tests (interactive mode)
./run_tests.sh
# Or use focused targets
make test # smoke tests
make test-all # full pytest collection
# Or run specific test suites
./run_tests.sh fast # Fast tests only
./run_tests.sh edge # Edge case tests
./run_tests.sh e2e # End-to-end workflow tests
./run_tests.sh performance # Performance & load tests
./run_tests.sh security # Security tests
./run_tests.sh coverage # Generate coverage report
```
### Test Suites
Our comprehensive test coverage includes:
- **Edge Cases** (50+ tests): Data boundaries, input validation, statistical/ML edge cases
- **E2E Workflows** (20+ tests): Complete medical RCT, survival analysis, ML training pipelines
- **Performance** (15+ tests): Load benchmarks, concurrent requests, stress tests
- **Security** (20+ tests): Injection attacks, path traversal, rate limiting, user isolation
See [TESTING_ENHANCEMENT_PLAN.md](docs/TESTING_ENHANCEMENT_PLAN.md) for details.
```bash
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=. --cov-report=html tests/
# Run specific markers
uv run pytest -m "edge_case" tests/
uv run pytest -m "e2e" tests/
uv run pytest -m "performance" tests/
uv run pytest -m "security" tests/
```
---
## ๐ License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
---
## ๐ Acknowledgments
Built with these excellent open source projects:
- [AutoGluon](https://auto.gluon.ai/) - AutoML framework
- [lifelines](https://lifelines.readthedocs.io/) - Survival analysis
- [tableone](https://github.com/tompollard/tableone) - Clinical table generation
- [FastAPI](https://fastapi.tiangolo.com/) - API framework
- [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) - AI agent protocol
---
## ๐ง Contact
- Use the repository Issues tab for bug reports and regressions.
- Use the repository Discussions tab for design questions and workflow proposals.
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessOutdated data