MCPR
MCPR enables AI agents to participate in interactive R sessions for professional analysis workflows.
claude mcp add --transport stdio phisanti-mcpr R --quiet --slave -e MCPR::mcpr_server()
How to use
MCPR enables a persistent, interactive R session that an AI agent can connect to and issue commands against. This framework preserves the workspace state across requests, allowing iterative exploration, modeling, and visualization without restarting R for each step. The MCPR package exposes tools to manage sessions, execute arbitrary R code, and generate graphics in a collaborative setting. The core workflow is to start the MCPR server within R, expose the session on the local machine, and have your AI agent discover and join that session to run code and retrieve results, plots, and workspace state in real time.
Once connected, you can use the execute_r_code tool to run R expressions within the live session, the create_plot tool to render visualizations (with optional width/height parameters and format), and manage_r_sessions to list available sessions or join a specific one. This design gives the AI agent structured, well-defined endpoints for common R operations, while maintaining the stateful context needed for meaningful, multi-step analysis. For example, an agent can execute data transformations, generate plots, and then query the workspace to review results, all within the same session.
How to install
Prerequisites:
- Install R on your system (https://cran.r-project.org/).
- Ensure you have a working internet connection.
- Install the MCPR package from GitHub:
# Install remotes if needed
if (!require("remotes")) install.packages("remotes")
# Install MCPR from GitHub
remotes::install_github("phisanti/MCPR")
- Install the MCPR server integration so the agent can connect to R:
library(MCPR)
# Optional: install any required system dependencies for your setup
install_mcpr(agent = "claude") # Example for Claude; supported agents may include claude, gemini, copilot, codex
- Start the MCPR server inside an R session (the server exposes a session discoverable on the local machine):
library(MCPR)
mcpr_session_start()
- If using the manual MCP configuration method (Claude Desktop), create or update the MCP configuration file with:
{
"mcpServers": {
"mcpr": {
"command": "R",
"args": ["--quiet", "--slave", "-e", "MCPR::mcpr_server()"]
}
}
}
- Verify the session discovery and connection from your AI agent, following the agent-specific instructions to list and join sessions (e.g., manage_r_sessions('list') and manage_r_sessions('join', session_id)).
Additional notes
Tips and considerations:
- Ensure that the R session running MCPR has network access if your agent is remote (the default setup uses local discovery). If you run into port or firewall issues, you may need to adjust network bindings.
- The create_plot tool relies on a graphics subsystem (httpgd when available) for efficient off-screen rendering; if httpgd is not installed, MCPR will fall back to base graphics devices.
- For large results or plots, be mindful of payload sizes and token usage; the plotting tool returns base64-encoded images with metadata.
- If you encounter authentication or discovery problems, re-run mcpr_session_start() and confirm that the R process remains active and reachable by the agent.
- Keep your MCPR version up to date to benefit from improvements in session management and tool capabilities.
Related MCP Servers
TrendRadar
⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
Wax
Sub-Millisecond RAG on Apple Silicon. No Server. No API. One File. Pure Swift
pgmcp
An MCP server to query any Postgres database in natural language.
furi
CLI & API for MCP management
Pare
Dev tools, optimized for agents. Structured, token-efficient MCP servers for git, test runners, npm, Docker, and more.
workflowy
Powerful CLI and MCP server for WorkFlowy: reports, search/replace, backup support, and AI integration (Claude, LLMs)