Skip to main content
Glama

Stats & R MCP Server

An MCP (Model Context Protocol) server that gives Claude access to a comprehensive statistics knowledge base and R library expertise for research projects.

What It Does

When connected to Claude (via Claude Desktop, Claude Code, or the API), this server provides:

Tools (14 tools Claude can call)

Tool

Purpose

select_statistical_test

Recommends the right test based on your study design

get_test_details

Deep-dive into any test — assumptions, R code, effect sizes

list_all_tests

Browse all 29 tests by category

check_assumptions

Step-by-step assumption checking with R code

generate_analysis_script

Complete R analysis script from study parameters

power_analysis_guide

Sample size / power calculations with R code

effect_size_calculator

Effect size formulas and R code

convert_effect_sizes

Convert between effect size metrics (d, r, η², f, OR)

missing_data_guide

Missing data diagnosis and imputation with R code

multiple_comparisons_guide

Correction methods (Bonferroni, Holm, Tukey, FDR) with R code

mediation_analysis_guide

Mediation, moderation, and moderated mediation with R code

get_r_package_info

Detailed info on 34 R packages

recommend_r_packages

Package recommendations by task

list_r_packages

Browse the full R package database

Resources (read-only knowledge bases)

  • stats://knowledge-base — Decision table + all test details

  • stats://r-packages — Complete R package reference

  • stats://sample-sizes — Sample size rules of thumb

Prompts (workflow templates)

  • research_analysis_workflow — Full analysis pipeline from question to APA report

  • statistical_test_selection — Interactive test selection guide

  • r_package_recommendation — Package recommendations for a task

Related MCP server: statistician-mcp

Statistical Tests Covered

Comparing Means: t-tests (independent, paired, Welch's), ANOVA (one-way, two-way, repeated measures)

Correlation: Pearson, Spearman

Categorical: Chi-square, Fisher's exact

Regression: Linear, multiple, logistic, ordinal, Poisson

Nonparametric: Mann-Whitney U, Kruskal-Wallis, Friedman

Mixed Models: LMM (lmer), GLMM (glmer)

Survival: Cox regression, Kaplan-Meier, log-rank

Multivariate: PCA, Exploratory Factor Analysis

R Packages Covered

tidyverse, ggplot2, dplyr, lme4, lmerTest, car, emmeans, performance, effectsize, survival, survminer, broom, psych, rstatix, pwr, report, brms, gt, gtsummary, mice, naniar, lavaan, mediation, interactions, and more (34 total)

Setup

Prerequisites

  • Python 3.10+

  • uv (recommended) or pip

Install

# Clone or copy the project
cd stats-r-mcp

# Using uv (recommended)
uv venv
source .venv/bin/activate   # macOS/Linux
# .venv\Scripts\activate    # Windows
uv pip install -e .

# Or using pip
pip install -e .

Connect to Claude Desktop

Add this to your Claude Desktop config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "stats-r-research": {
      "command": "uv",
      "args": [
        "--directory", "/FULL/PATH/TO/stats-r-mcp",
        "run", "server.py"
      ]
    }
  }
}

Replace /FULL/PATH/TO/stats-r-mcp with the actual path on your machine.

Alternative (using python directly):

{
  "mcpServers": {
    "stats-r-research": {
      "command": "/FULL/PATH/TO/stats-r-mcp/.venv/bin/python",
      "args": ["/FULL/PATH/TO/stats-r-mcp/server.py"]
    }
  }
}

Connect to Claude Code

claude mcp add stats-r-research -- uv --directory /FULL/PATH/TO/stats-r-mcp run server.py

Test with MCP Inspector

cd stats-r-mcp
uv run mcp dev server.py

This opens a browser-based inspector where you can test all tools interactively.

Example Usage

Once connected, you can ask Claude things like:

  • "I have pre and post scores for 45 patients across 3 treatment groups. What test should I use?"

  • "Generate an R script for a mixed-design ANOVA with treatment as between-subjects and time as within-subjects"

  • "What R packages do I need for survival analysis?"

  • "How do I check the assumptions for a linear mixed model?"

  • "I need to calculate sample size for a two-sample t-test with a medium effect size"

  • "Walk me through a complete analysis for my RCT data"

Extending the Knowledge Base

The server is designed to be easily extended. To add new tests or packages, edit the STATISTICAL_TESTS or R_PACKAGES_DB dictionaries in server.py. Each entry follows a consistent schema so new additions integrate automatically with all tools.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a virtual statistician for AI agents, offering real statistical methods such as design of experiments, hypothesis testing, regression, and process control. It includes an advisor tool to recommend appropriate analyses and generates plain-language interpretations of results.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to run verified statistical and analytics computations—including hypothesis tests, A/B testing, descriptive summaries, and sample-size planning—directly on local CSV, TSV, Excel, and Parquet files of any size. Results include effect sizes, confidence intervals, plain-English interpretations, and assumption warnings, with optional independent checks.
      23
      73 npm
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to safely execute statistical analyses, parse results into Markdown and JSON, and generate publication-ready charts through a local IBM SPSS Statistics installation on macOS and Windows.
      51
      37 PyPI
      1
      MIT