
How to add MCPR to Windsurf
Let AI agents run code inside live, stateful R sessions for real data-analysis workflows. Paste the config into ~/.codeium/windsurf/mcp_config.json and restart Windsurf.
Last updated June 14, 2026 · 25★ · stdio · no auth
Windsurf config for MCPR
remotes::install_github("phisanti/MCPR"){
"mcpServers": {
"mcpr": {
"command": "R",
"args": [
"--quiet",
"--slave",
"-e",
"MCPR::mcpr_server()"
]
}
}
}Setup steps
- 1Open Windsurf → Cascade → the hammer/MCP icon → Configure (or edit ~/.codeium/windsurf/mcp_config.json).
- 2Paste the MCPR config below.
- 3Fill in placeholder secrets, then save.
- 4Click Refresh in the MCP panel.
- 5MCPR's tools become available to Cascade.
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 Windsurf
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 + Windsurf FAQ
Where is the Windsurf config file?
Windsurf reads MCP servers from ~/.codeium/windsurf/mcp_config.json. Paste the MCPR config there under the "mcpServers" key and restart the client.
Is MCPR safe to use with Windsurf?
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.