R MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@R MCP Serverfit a linear model to mtcars"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
R MCP Server
An MCP (Model Context Protocol) server that lets AI assistants execute R code, create visualizations, analyze data, and manage packages — all through a local Rscript CLI.
Features — 62 Tools
Execution (3 tools)
Tool | Description |
| Execute inline R code and return console output |
| Run an |
| Run testthat tests and report pass/fail |
Visualization (5 tools)
Tool | Description |
| Execute base R plotting code and save as PNG |
| Create ggplot2 plots with auto-theme and save as PNG |
| Generate a correlation heatmap from a data file |
| Arrange multiple ggplots into a multi-panel figure |
| Render |
Statistical Analysis (5 tools)
Tool | Description |
| Fit lm/glm and return coefficients, R-squared, p-values |
| Compute correlation matrix with p-values |
| Run t-test, Wilcoxon, chi-squared, Shapiro-Wilk, etc. |
| Per-column mean, sd, quartiles, skewness, kurtosis |
| Principal Component Analysis with loadings and variance |
Data Wrangling (5 tools)
Tool | Description |
| Read CSV, TSV, Excel, JSON, Parquet, or RDS files |
| Execute R code and save results to CSV/TSV/RDS/JSON |
| Pivot data between wide and long formats (tidyr) |
| Join two data files (inner, left, right, full) |
| Load built-in R datasets (mtcars, iris, etc.) as CSV |
Time Series (4 tools)
Tool | Description |
| Fit ARIMA/ETS/TBATS/Holt-Winters and forecast with plot |
| Decompose into trend, seasonal, and remainder (STL/classical) |
| Unit root tests — ADF, KPSS, Phillips-Perron |
| Plot ACF and PACF side by side with significance bounds |
Clustering (2 tools)
Tool | Description |
| K-means with elbow plot, silhouette score, PCA projection |
| Hierarchical clustering with dendrogram and cophenetic correlation |
Advanced Statistics (7 tools)
Tool | Description |
| One-way and two-way ANOVA with post-hoc tests |
| Fit linear mixed-effects models (lme4) |
| Bootstrap confidence intervals for any statistic |
| Shapiro-Wilk, Anderson-Darling, Kolmogorov-Smirnov, Lilliefors |
| Grubbs, Dixon, Rosner, IQR, and Z-score methods |
| Fit quantile regression at specified quantiles |
| Kaplan-Meier survival curves and Cox proportional hazards |
Interactive & Publication Plots (5 tools)
Tool | Description |
| Create interactive plotly visualizations saved as HTML |
| Publication-ready plots using ggpubr |
| Correlation matrix visualization (corrplot package) |
| Group comparisons with statistical significance |
| Regression diagnostic plots (residuals, Q-Q, Cook's distance) |
Probability Distributions (5 tools)
Tool | Description |
| Compute d/p/q/r for 16 distributions (normal, binomial, t, F, chi-sq, etc.) |
| Histogram of random samples with theoretical density overlay |
| Sample from any population with/without replacement |
| Q-Q plot to assess distributional fit with Shapiro-Wilk test |
| Central Limit Theorem simulation for any distribution |
Proportion & Contingency Tests (5 tools)
Tool | Description |
| One-sample and two-sample proportion tests (prop.test) |
| Exact binomial test for small samples |
| Chi-squared test for goodness of fit, independence, homogeneity |
| Fisher's exact test on 2x2 contingency tables |
| Create contingency table with mosaic plot and chi-squared test |
Regression & Post-hoc (6 tools)
Tool | Description |
| Robust regression (MASS::rlm/lqs) resistant to outliers |
| Fit and compare polynomial models of different degrees |
| Predictions with confidence and prediction intervals |
| Tukey's HSD post-hoc pairwise comparisons after ANOVA |
| Kruskal-Wallis nonparametric test for group differences |
| Compute sample size or power for t-test and proportion test |
Exploratory Data Analysis (5 tools)
Tool | Description |
| Scatterplot matrix with correlations and histograms |
| Kernel density estimation plot with multiple kernels |
| Empirical CDF plot with optional normal overlay |
| Text-based stem-and-leaf display with five-number summary |
| F-test, Bartlett's, and Fligner-Killeen variance equality tests |
Utilities (5 tools)
Tool | Description |
| Static analysis via lintr |
| Load CSV/TSV/RDS and return summary stats |
| List all installed R packages |
| Return R version and session info |
| Install a CRAN package |
Related MCP server: Skill Management MCP Server
Prerequisites
R (>= 4.0) with
Rscripton your PATHPython (>= 3.10)
Install R from CRAN or via Homebrew:
brew install rInstallation
git clone https://github.com/sergiudanstan/r-mcp.git
cd r-mcp
pip install -e .Usage
With Claude Code
Add to your Claude Code MCP settings (~/.claude/settings.json):
{
"mcpServers": {
"r": {
"command": "python",
"args": ["-m", "r_mcp"],
"cwd": "/path/to/r-mcp"
}
}
}Standalone
python -m r_mcpThe server communicates over stdio using the MCP protocol.
How It Works
The server wraps the Rscript --vanilla CLI. Each tool call spawns a fresh R session, executes the code, and returns structured JSON results. Code is wrapped in tryCatch for clean error reporting.
Workspace: Output files (plots, rendered docs) are saved to
~/r-mcp-workspace/Timeout: Default 60s per execution (configurable per call)
Safety: Path traversal prevention on file outputs; output truncation at 50K chars
Examples
Run R code
# Via the evaluate_r_code tool
x <- rnorm(100)
cat("Mean:", mean(x), "\nSD:", sd(x), "\n")Create a plot
# Via the create_r_plot tool
library(ggplot2)
df <- data.frame(x = rnorm(200), y = rnorm(200))
ggplot(df, aes(x, y)) + geom_point(alpha = 0.5) + theme_minimal()Probability distributions
# Via the distribution_calculator tool
# Compute P(X <= 1.96) for standard normal
pnorm(1.96, mean=0, sd=1)
# Via the distribution_plot tool
# Visualize chi-squared(5) distribution with 1000 samplesHypothesis testing
# Via the proportion_test tool
# Test if 42 out of 100 differs from 50%
prop.test(42, 100, p = 0.5)
# Via the hypothesis_test tool
# Two-sample t-test
t.test(x, y, alternative = "two.sided")Analyze a CSV
Use get_data_summary with a file path to get dimensions, column types, summary statistics, and a preview.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sergiudanstan/r-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server