MCP Directory

MCPR

Let AI agents run code inside live, stateful R sessions for real data-analysis workflows.

Unverified
stdio (local)
No auth
R

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
remotes::install_github("phisanti/MCPR")

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcpr": {
      "command": "R",
      "args": [
        "--quiet",
        "--slave",
        "-e",
        "MCPR::mcpr_server()"
      ]
    }
  }
}

Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf

Before you start

  • R installed on the machine
  • The MCPR package installed via remotes::install_github("phisanti/MCPR")
  • A running R session made discoverable with mcpr_session_start()
  • Optional: httpgd for high-performance off-screen plot rendering

About MCPR

MCPR addresses the limitation that AI agents typically run R in a stateless way, invoking Rscript per command, which breaks the iterative and state-dependent nature of serious data analysis. MCPR enables agents to establish persistent, interactive sessions within a live R environment, preserving workspace state and supporting complex, multi-step analytical workflows. The user starts an R session, calls mcpr_session_start() to make it discoverable, and instructs the agent to list and join the session. The agent then uses a small set of tools to execute code, create plots, and inspect the environment while maintaining full context.

Tools & capabilities (4)

execute_r_code

Execute arbitrary R code within the live session context. Takes a character string of R expressions and returns a structured response with results, output, warnings, and errors.

create_plot

Generate visualizations with AI-optimized output. Takes an R plotting expression plus width, height, and format, and returns a base64-encoded image with metadata and token-usage information.

manage_r_sessions

Session discovery and management. Actions: 'list' to enumerate active sessions with metadata, 'join' to connect to a specific session by ID, and 'start' to launch a new R session process.

view

Environment introspection and debugging. The 'what' argument selects 'session' (object summaries with statistical metadata), 'terminal' (command history), 'workspace' (file system context), or 'installed_packages' (available libraries).

When to use it

  • Run a multi-hour exploratory data analysis where the agent keeps the loaded data and intermediate objects in memory between steps
  • Iteratively tweak ggplot2 plot aesthetics without re-running an entire upstream script each time
  • Have an AI agent fit, validate, and refine statistical models inside an existing R workspace
  • Inspect the current session's objects, command history, and installed packages for debugging and reproducibility

Security notes

The server executes arbitrary R code inside a live R session on your machine, including full filesystem and package access. Only connect agents you trust, and be mindful that the agent shares whatever state and data are loaded in the session.

MCPR FAQ

How does the agent connect to my R session?

You start an R session and run mcpr_session_start() to make it discoverable. The agent then calls manage_r_sessions('list') to find the session ID and manage_r_sessions('join', session=ID) to connect.

Which AI agents are supported?

The install_mcpr() helper can configure Claude, Gemini, Copilot, and Codex. For Claude Desktop you can also manually add the mcpServers block to claude_desktop_config.json.

Why does plotting fail?

Ensure the plotting expression is valid and all required libraries are loaded. Installing the httpgd package enables high-performance off-screen rendering; without it MCPR falls back to standard R graphics devices.

Alternatives to MCPR

Compare all alternatives →

Official MCP server providing persistent, file-backed knowledge-graph memory across sessions.

Verified
stdio (local)
No auth
TypeScript
9 tools
Updated 5 months agoRepo

Structured step-by-step reasoning tool for breaking problems into revisable thought sequences.

Verified
stdio (local)
No auth
TypeScript
1 tool
Updated 6 months agoRepo

Fully managed remote server for AWS docs, blogs, What's-New and Well-Architected guidance — no key.

Verified
HTTP (remote)
No auth
Hosted
6 tools
Updated 5 months agoRepo