README.mdโข6.2 kB
# DoWhy MCP v2.0 - Rigorous Causal Inference Tools
[](https://www.python.org/downloads/)
[](https://github.com/py-why/dowhy)
[](https://opensource.org/licenses/MIT)
[](https://github.com/psf/black)
## ๐ฏ Project Vision
DoWhy MCP v2.0 is a **complete rewrite** of the DoWhy MCP server, designed to provide **rigorous, theoretically-grounded causal inference tools** through the Model Context Protocol (MCP). This version matches the **scientific rigor and theoretical depth** of the official DoWhy library.
## ๐ฌ Theoretical Foundation
Built on the solid theoretical foundations of:
- **Structural Causal Models (SCM)** - Pearl's causal hierarchy
- **Graphical Causal Models (GCM)** - Modern causal discovery and inference
- **Potential Outcomes Framework** - Rubin's causal model
- **Do-Calculus** - Formal causal reasoning
## ๐ Key Features
### โ
What's New in v2.0
- **๐งฎ Rigorous Statistical Inference**: True Bootstrap confidence intervals, not noise simulation
- **๐ Comprehensive Sensitivity Analysis**: Full suite of refutation tests and E-value analysis
- **๐ Complete Causal Toolkit**: 42 specialized tools covering all DoWhy functionality
- **๐ฏ Theoretical Rigor**: Every method backed by solid causal inference theory
- **โก Performance Optimized**: Efficient implementation with proper error handling
- **๐ Advanced Visualization**: Causal graphs, attribution plots, and diagnostic charts
### ๐ ๏ธ Complete Tool Categories
1. **Modeling Tools** (6 tools)
- Causal graph construction and validation
- Structural and Graphical Causal Models
- Causal mechanism learning
2. **Causal Effect Estimation** (10 tools)
- Backdoor, frontdoor, and IV identification
- Linear regression, PSM, doubly robust, DML
- Causal forests and TMLE
3. **Causal Influence Quantification** (6 tools)
- Shapley value attribution
- Direct and total causal influence
- Path-specific effects
4. **Root Cause Analysis** (5 tools)
- Anomaly attribution
- Distribution change attribution
- Causal chain tracing
5. **Counterfactual Analysis** (6 tools)
- Individual and population counterfactuals
- Intervention simulation
- What-if scenario analysis
6. **Sensitivity Analysis** (6 tools)
- Unobserved confounder analysis
- Comprehensive refutation tests
- E-value and tipping point analysis
7. **Causal Discovery** (3 tools)
- PC, GES, and FCM algorithms
- Structure learning from data
## ๐ Installation
```bash
# Install from source (development)
git clone https://github.com/dowhy-mcp/dowhy-mcp-v2.git
cd dowhy-mcp-v2
pip install -e ".[dev]"
# Install from PyPI (when released)
pip install dowhy-mcp-v2
```
## ๐ง Quick Start
```python
from dowhy_mcp_v2 import DoWhyCausalAnalyzer
# Initialize analyzer
analyzer = DoWhyCausalAnalyzer()
# Estimate causal effect with full rigor
result = analyzer.estimate_causal_effect(
data="data.csv",
treatment="intervention",
outcome="result",
confounders=["age", "gender", "income"],
method="doubly_robust",
bootstrap_samples=1000,
sensitivity_analysis=True
)
# Get comprehensive results
print(f"Causal Effect: {result.causal_effect:.4f}")
print(f"95% CI: [{result.confidence_interval[0]:.4f}, {result.confidence_interval[1]:.4f}]")
print(f"P-value: {result.p_value:.4f}")
print(f"Robustness Score: {result.robustness_score:.2f}")
```
## ๐๏ธ Architecture
```
DoWhy MCP v2.0
โโโ Core Engine # Causal inference engine
โ โโโ Model Builder # SCM/GCM construction
โ โโโ Inference Engine # Causal reasoning
โ โโโ Validation Framework # Result verification
โโโ Tool Modules # 42 specialized tools
โ โโโ Modeling # Graph and model tools
โ โโโ Estimation # Effect estimation
โ โโโ Attribution # Influence quantification
โ โโโ Root Cause # Anomaly analysis
โ โโโ Counterfactual # What-if analysis
โ โโโ Sensitivity # Robustness testing
โ โโโ Discovery # Structure learning
โโโ MCP Interface # Protocol integration
```
## ๐ Comparison with v1.0
| Feature | v1.0 | v2.0 |
|---------|------|------|
| Theoretical Rigor | Basic | โ
Complete |
| Bootstrap CI | โ Fake noise | โ
True Bootstrap |
| Sensitivity Analysis | โ Simplified | โ
Comprehensive |
| Causal Graphs | โ Limited | โ
Full Support |
| Tool Count | 4 basic | 42 rigorous |
| Statistical Tests | โ Missing | โ
Complete Suite |
| Error Handling | โ Basic | โ
Robust |
| Documentation | โ Minimal | โ
Comprehensive |
## ๐งช Testing & Validation
- **Unit Tests**: 95%+ coverage with rigorous testing
- **Integration Tests**: End-to-end workflow validation
- **Benchmark Tests**: Performance and accuracy benchmarks
- **Theoretical Tests**: Validation against known causal results
## ๐ Documentation
- [๐ User Guide](docs/user_guide.md)
- [๐ฌ Theoretical Background](docs/theory/)
- [๐ ๏ธ API Reference](docs/api/)
- [๐ Examples](docs/examples/)
## ๐ค Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- [DoWhy Team](https://github.com/py-why/dowhy) for the foundational causal inference library
- [Judea Pearl](http://bayes.cs.ucla.edu/jp_home.html) for causal inference theory
- [Microsoft Research](https://www.microsoft.com/en-us/research/) for DoWhy development
## ๐ Support
- ๐ [Report Issues](https://github.com/dowhy-mcp/dowhy-mcp-v2/issues)
- ๐ฌ [Discussions](https://github.com/dowhy-mcp/dowhy-mcp-v2/discussions)
- ๐ง Email: support@dowhy-mcp.org
---
**DoWhy MCP v2.0** - Where Rigorous Science Meets Practical Application