
How to add MCPR to Claude Desktop
Let AI agents run code inside live, stateful R sessions for real data-analysis workflows. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 14, 2026 ยท 25โ ยท stdio ยท no auth
Claude Desktop config for MCPR
remotes::install_github("phisanti/MCPR"){
"mcpServers": {
"mcpr": {
"command": "R",
"args": [
"--quiet",
"--slave",
"-e",
"MCPR::mcpr_server()"
]
}
}
}Setup steps
- 1Open Claude Desktop โ Settings โ Developer โ Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the MCPR config below under the top-level "mcpServers" key.
- 3Fill in any placeholder secrets (API keys, paths) in the snippet.
- 4Save the file, then fully quit and reopen Claude Desktop.
- 5Open a chat and confirm MCPR's tools appear under the ๐ tools menu.
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
What MCPR can do in Claude Desktop
execute_r_codeExecute 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_plotGenerate 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_sessionsSession 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.
viewEnvironment 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).
Security
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 + Claude Desktop FAQ
Where is the Claude Desktop config file?
Claude Desktop reads MCP servers from ~/Library/Application Support/Claude/claude_desktop_config.json. Paste the MCPR config there under the "mcpServers" key and restart the client.
Is MCPR safe to use with Claude Desktop?
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.
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.