MCP-compliant R code execution and management agent for Claude Desktop Extension.
Empower R programming with Model Context Protocol.
PilotR is an MCP (Model Context Protocol) server that allows Claude to generate, execute, and manage R scripts within a user-specified directory. It provides a complete workflow for statistical programming and data analysis through natural language interaction — no manual setup required.
- Execute R code and scripts directly from Claude
- Manage R script files — create, rename, append, and write
- Set and manage working directories for analysis projects
- Inspect R objects and session state
- Read and preview output files (CSV, TSV, RDS, text, etc.)
- List and manage exported results
- Automatic workspace saving
- Sandboxed file operations for safety
- Download Claude Desktop and set up your Claude account. Free-tier accounts are sufficient to get started with PilotR, but the Pro accounts are recommended for more complicated tasks.
- Download and install R runtime, install it and make sure that it is within the system path.
Simply download the latest PilotR.mcpb file from this repository or release page.
- Locate the downloaded
PilotR.mcpbfile - Double-click the file
- Claude Desktop will open and prompt to install
- Follow the on-screen instructions. (A Python runtime might need to be installed at this step. Please just follow the prompts to proceed with the installation.)
To streamline your workflow:
- Open Claude Desktop
- Go to Settings → Extensions → MCP Servers
- Find "PilotR"
- Enable "Allow tools to run without permission" (Auto-approve)
- Restart Claude Desktop
Once installed, you can interact with PilotR using natural language.
Here are common commands and workflows:
"Set working directory to ~/my_analysis" # Initialize workspace
"Show current state" # Check configuration
"Find R executable" # Verify R installation
"Create an R file called analysis.R" # New script with scaffold
"Write R code to load and plot data" # Generate and save code
"Append summary statistics to my script" # Add to existing file
"Rename script.R to final_analysis.R" # Rename files
"List all R files" # View R scripts
"Run my R script" # Execute primary file
"Run R expression: mean(1:10)" # Quick calculations
"Execute analysis.R with arguments" # Run with parameters
"Show R objects in workspace" # Inspect saved data
"Preview data.csv" # View CSV/TSV data
"Read results.txt" # Read text files
"List all output files" # See generated files
"Show files created today" # Recent outputs
"Optimize my ggplot code" # Improve plot styling
"Check ggplot style in my script" # Style analysis
"Create publication-ready plot" # High-quality output
You: Create an R script for linear regression analysis
You: Load the mtcars dataset and fit a model of mpg vs weight
You: Run the script and show the model summary
You: Create diagnostic plots for the model
You: Save the plots as high-resolution PNGs
You: Set working directory to ~/data_project
You: Read my raw_data.csv file and show a preview
You: Create a script to clean missing values and outliers
You: Transform the data and save as cleaned_data.csv
You: Generate summary statistics and visualizations
You: Create a ggplot scatter plot with trend line
You: Add confidence intervals and customize colors
You: Optimize the plot code for publication
You: Save as figure1.png with 800 DPI
You: Load the iris dataset
You: Create a script for exploratory analysis
You: Generate summary statistics by species
You: Create box plots and correlation matrices
You: Run everything and show the results
- set_workdir — Set working directory for R operations
- get_state — View configuration and runtime state
- which_R — Locate R executable
- create_R_file — Create new R script
- rename_R_file — Rename existing script
- write_R_code — Write code to file (with overwrite protection)
- append_R_code — Append to existing file
- set_primary_file — Set default script for operations
- list_R_files — List R scripts in workspace
- run_R_script — Execute R script file
- run_R_expression — Evaluate R expression
- inspect_R_objects — Explore workspace objects
- list_exports — List exported files
- read_export — Read file contents (text or binary)
- preview_table — Preview CSV/TSV tables
- ggplot_style_check — Optimize ggplot2 code for publication
- Extension file:
PilotR.mcpb - Protocol: MCP (Model Context Protocol) 1.0+
- R Execution: via Rscript
- Session Persistence:
.pilotrdirectory for state - Security: Sandboxed file operations
- Python: Requires Python 3.12+
Special thanks to Beniamin Krupkin and Sara Smith for the inspiration of this idea and their valuable contributions.
Wanjun Gu ([email protected])
MIT