Crosstabs MCP Server
A Python MCP (Model Context Protocol) server registering 39 statistical tools for contingency-table analysis plus two versioned evidence resources. Individual tools report whether their inference is exact, asymptotic, or simulated.
Features
Core Statistical Tests
| Test | Description |
|---|---|
| Chi-square | Pearson's chi-square test of independence |
| G-test | Likelihood-ratio alternative with an asymptotic p-value |
| Fisher's exact | Two-sided fixed-margin exact p-value for 2×2 integer counts |
| McNemar's | Exact two-sided binomial inference for fewer than 20 discordant pairs; continuity-corrected chi-square otherwise |
Effect Sizes & Measures
| Measure | Use Case |
|---|---|
| Cramér's V | Effect size for any table size (with bias correction) |
| Phi coefficient | Effect size for 2×2 tables |
| Odds ratio | Association strength with a large-sample Woolf log interval |
| Relative risk | Risk comparison between groups |
| Risk difference | Absolute risk reduction |
| Attributable risk | Population-level impact |
Ordinal Measures
| Measure | Description |
|---|---|
| Spearman's rho | Rank correlation |
| Kendall's tau | Concordance measure |
| Goodman-Kruskal gamma | Ordinal association |
| Somers' D | Asymmetric ordinal measure |
| Stuart's tau-c | Rectangular table measure |
Agreement & Reliability
| Measure | Description |
|---|---|
| Cohen's kappa | Inter-rater agreement with an asymptotic normal interval |
| Weighted kappa | Linear/quadratic agreement with an asymptotic normal interval |
Advanced Analysis
| Tool | Description |
|---|---|
| CMH test | Stratified analysis with a Robins-Breslow-Greenland pooled-OR interval |
| Breslow-Day | Test homogeneity of odds ratios |
| Correspondence analysis | Dimensionality reduction for tables |
| Monte Carlo chi-square | Fixed-margin simulated p-value estimate |
| Power analysis | Equal-group, two-sided normal approximation using Cohen's h |
| Multiple comparisons | Bonferroni and FDR corrections |
Installation
From PyPI (recommended)
pip install crosstabs
Inspect the public source distribution
python -m pip download --no-deps --no-binary=:all: crosstabs
The development repository is currently private. PyPI publishes the package's source archive; email support@crosstabs.com for issue reports or source-access questions.
Quick Start
Run the MCP Server
crosstabs
Or directly:
python -m crosstabs_mcp.server
Configure Claude Code
Add to your ~/.claude/claude_desktop_config.json:
{
"mcpServers": {
"crosstabs": {
"command": "crosstabs"
}
}
}
Or with Python path:
{
"mcpServers": {
"crosstabs": {
"command": "python",
"args": ["-m", "crosstabs_mcp.server"]
}
}
}
Usage Examples
Once configured, Claude can perform statistical analysis:
Chi-square Test
User: Test if there's an association between treatment and outcome:
Treatment A: 50 success, 30 failure
Treatment B: 20 success, 40 failure
Claude: [Uses chi_square_test with matrix [[50,30],[20,40]]]
χ² = 11.67, p = 0.0006
Cramér's V = 0.29 (small-medium effect)
There is a significant association between treatment and outcome.
Odds Ratio
User: Compare an adverse outcome between exposure groups:
Exposed: 30 outcome-present, 70 outcome-absent
Unexposed: 15 outcome-present, 85 outcome-absent
Claude: [Uses odds_ratio with matrix [[30,70],[15,85]]]
OR = 2.43 (95% CI: 1.21-4.87)
Exposure is associated with 143% higher odds of the outcome.
The epidemiology tools (odds_ratio, relative_risk, risk_difference, and
attributable_risk) use one explicit orientation:
[[exposed outcome+, exposed outcome-], [unexposed outcome+, unexposed outcome-]].
They return machine-readable zero/infinite/undefined states rather than silently
continuity-correcting point estimates. Attributable/prevented fractions require
causal identification assumptions; an association alone does not establish the
counterfactual effect of removing an exposure.
Fisher's Exact Test
User: I have a small sample: [[3,1],[1,5]]. Is it significant?
Claude: [Uses fishers_exact with the matrix]
p = 0.190476 (two-tailed exact)
Not statistically significant at α=0.05.
Available Tools
| Tool Name | Description |
|---|---|
chi_square_test |
Chi-square test of independence |
g_test |
G-test (likelihood ratio) |
fishers_exact |
Fisher's exact test (2×2) |
mcnemar_test |
McNemar's test for paired data |
odds_ratio |
Odds ratio with CI |
relative_risk |
Relative risk with CI |
risk_difference |
Risk difference with CI |
cramers_v |
Cramér's V effect size |
phi_coefficient |
Phi for 2×2 tables |
cohens_kappa |
Cohen's kappa |
weighted_kappa |
Weighted kappa |
spearmans_rho |
Spearman's rank correlation |
kendalls_tau |
Kendall's tau-b |
goodman_kruskal_gamma |
Gamma coefficient |
somers_d |
Somers' D |
tau_c |
Stuart's tau-c |
cmh_test |
Cochran-Mantel-Haenszel |
breslow_day_test |
Breslow-Day test |
linear_trend_test |
Linear-by-linear association |
correspondence_analysis |
Correspondence analysis |
monte_carlo_chi_square |
Fixed-margin Monte Carlo p-value estimate |
power_analysis |
Two-sided normal-approximation power/sample size using Cohen's h |
bonferroni_correction |
Bonferroni p-value adjustment |
fdr_correction |
Benjamini-Hochberg FDR |
standardized_residuals |
Cell residuals |
post_hoc_chi_square |
Post-hoc chi-square decomposition |
proportion_ci |
Confidence interval for proportion |
check_assumptions |
Validate chi-square assumptions |
recommend_test |
Method suggestions with assumption caveats |
mosaic_plot_data |
Data for mosaic visualization |
stacked_bar_data |
Data for stacked bar chart |
attributable_risk |
Attributable risk measures |
chi_square_yates |
Yates' continuity correction |
effect_size |
Multiple contingency-table effect sizes |
lambda_coefficient |
Goodman–Kruskal lambda |
uncertainty_coefficient |
Theil's uncertainty coefficient |
detect_outliers |
Outlier detection |
crosstab_from_data |
Build table from raw data |
crosstab_from_csv |
Build table from CSV |
Development
Run Tests
pip install -e ".[dev]"
pytest tests/ -v
Project Structure
mcp-server-python/
├── crosstabs_mcp/
│ ├── __init__.py
│ ├── server.py # Main MCP server
│ └── advanced_stats.py # Compatibility imports; math lives in server.py
├── tests/
│ ├── test_statistics.py # Statistical behavior tests
│ └── test_reference_parity.py # Public SciPy reference parity
├── scripts/ # Distribution verification
├── LICENSE
├── pyproject.toml
├── uv.lock
└── README.md
Requirements
- Python 3.10+
- mcp >= 1.0.0
- fastmcp >= 0.1.0
- numpy >= 1.24.0
- scipy >= 1.10.0
- pandas >= 2.0.0
- statsmodels >= 0.14.0
License
MIT License - see LICENSE for details.
Contributing
The development repository is currently private. Send corrections and proposed changes to support@crosstabs.com.
Links
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crosstabs-1.0.4.tar.gz.
File metadata
- Download URL: crosstabs-1.0.4.tar.gz
- Upload date:
- Size: 241.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2de44502771a5189d63e7df4af23266cb21d84242da449b74d07c6fb105721f8
|
|
| MD5 |
c798fd658eebd52ae69f2313b800c5c5
|
|
| BLAKE2b-256 |
6164c7e8fdb1d54a66ebd973b16dbd469e520983350b9f63b1e3bf6e1426f00b
|
Provenance
The following attestation bundles were made for crosstabs-1.0.4.tar.gz:
Publisher:
release-python-mcp.yml on barangaroo/crosstabs-lite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crosstabs-1.0.4.tar.gz -
Subject digest:
2de44502771a5189d63e7df4af23266cb21d84242da449b74d07c6fb105721f8 - Sigstore transparency entry: 2443806445
- Sigstore integration time:
-
Permalink:
barangaroo/crosstabs-lite@926cabb70cd8d5c76f102aa32cefcf2adc8532df -
Branch / Tag:
refs/heads/main - Owner: https://github.com/barangaroo
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-mcp.yml@926cabb70cd8d5c76f102aa32cefcf2adc8532df -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file crosstabs-1.0.4-py3-none-any.whl.
File metadata
- Download URL: crosstabs-1.0.4-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0543ce7e7100806d212f4ce0f5cbeb1a1588ecc4a0420df6513f77ff32e99bf7
|
|
| MD5 |
c5772b912c78349d45a9f9d18d88897d
|
|
| BLAKE2b-256 |
7f026a32ef8649809a8edbaf05eaab58bf70dca09e7320198fc9be6f3652b7ff
|
Provenance
The following attestation bundles were made for crosstabs-1.0.4-py3-none-any.whl:
Publisher:
release-python-mcp.yml on barangaroo/crosstabs-lite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crosstabs-1.0.4-py3-none-any.whl -
Subject digest:
0543ce7e7100806d212f4ce0f5cbeb1a1588ecc4a0420df6513f77ff32e99bf7 - Sigstore transparency entry: 2443806694
- Sigstore integration time:
-
Permalink:
barangaroo/crosstabs-lite@926cabb70cd8d5c76f102aa32cefcf2adc8532df -
Branch / Tag:
refs/heads/main - Owner: https://github.com/barangaroo
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-mcp.yml@926cabb70cd8d5c76f102aa32cefcf2adc8532df -
Trigger Event:
workflow_dispatch
-
Statement type: