
How to add MCPR to Cursor
Let AI agents run code inside live, stateful R sessions for real data-analysis workflows. Paste the config into ~/.cursor/mcp.json and restart Cursor.
Last updated June 14, 2026 · 25★ · stdio · no auth
Cursor config for MCPR
remotes::install_github("phisanti/MCPR"){
"mcpServers": {
"mcpr": {
"command": "R",
"args": [
"--quiet",
"--slave",
"-e",
"MCPR::mcpr_server()"
]
}
}
}Setup steps
- 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
- 2Paste the MCPR config below into the "mcpServers" object.
- 3Fill in placeholder secrets, then save.
- 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
- 5Ask Cursor to use one of MCPR's tools to confirm it's connected.
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 Cursor
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 + Cursor FAQ
Where is the Cursor config file?
Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the MCPR config there under the "mcpServers" key and restart the client.
Is MCPR safe to use with Cursor?
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.