# phisanti/MCPR [Health: Active]

**Category:** 👨‍💻 Code Execution  
**Repository:** https://github.com/phisanti/MCPR  
**GitHub Stars:** 27  
**Views:** 7  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/phisanti-mcpr

## Description
Model Context Protocol for R: enables AI agents to participate in interactive live R sessions.

## Claude Desktop Quick Installation
No confirmed install details yet, so no config is published. Follow the setup steps in the repository above.

## Documentation

## What phisanti/MCPR does

phisanti/MCPR connects MCP-compatible AI agents with persistent R sessions. Rather than starting a new `Rscript` process for each request, the server maintains an R workspace where objects, loaded packages, computed results, and other session state can remain available between tool calls.

The default arrangement gives the agent a private R session owned by the MCPR server. This supports iterative analysis, including data preparation, modelling, validation, and follow-up changes to existing results. MCPR can also work alongside a human in an interactive R console by attaching the agent to a session started with `mcpr_session_start()`.

## How it works

The agent launches `MCPR::mcpr_server()`, normally through an MCP client configuration. Ordinary tools operate on the currently active session without requiring a session identifier on every call. Session routing is controlled separately through `manage_r_sessions`.

MCPR uses JSON-RPC 2.0 messaging over `nanonext` sockets. For graphics, it uses `httpgd` when available for off-screen rendering and can fall back to standard R graphics devices. Agent-targeted images include metadata and token usage information, with image handling intended to avoid oversized payloads.

A human can run `mcpr_session_start()` inside an existing R console. The agent can then list sessions, join a selected session, detach back to its private workspace, or create and close an MCPR-owned secondary session.

## Setup and configuration

R is required. Install the package from GitHub, for example:

```r
if (!require("remotes")) install.packages("remotes")
remotes::install_github("phisanti/MCPR")
```

The `install_mcpr()` helper can install the MCP configuration for Claude, Gemini, Copilot, or Codex:

```r
library(MCPR)
install_mcpr(agent = "claude")
```

Manual configuration can launch the server with:

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

The documented configuration locations are Claude Desktop settings, Gemini global or project-local settings, VS Code MCP configuration for Copilot, and Codex's global TOML configuration. Paths vary by operating system.

## Tools and capabilities

- `execute_r_code(code)` evaluates an R expression string in the active session and returns structured results, printed output, warnings, and errors.
- `show_plot(expr, target, width, height, format)` evaluates plotting code. User-targeted output goes to the active graphics device; agent-targeted output returns a base64-encoded image with metadata and token information.
- `manage_r_sessions(action, session)` lists sessions, joins a human session, starts an MCPR-owned secondary session, detaches to private/local execution, or closes an MCPR-owned secondary session.
- `view` provides session inspection as part of the server's tool set.

The tools are deliberately separate: code execution, graphics, inspection, and session attachment can be composed without passing a session argument to every ordinary operation.

## Limitations and notes

MCPR is marked as experimental. Its installation requires R and a GitHub package installation path. Session attachment is optional; without it, operations run in the server's private R process. Secondary sessions created by MCPR can be closed through session management, while the workflow also supports returning to the private session with `detach`.

_Full upstream README: https://allmcps.com/mcp/phisanti-mcpr/readme_

