Skip to content

Broccolito/PilotR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PilotR PilotR Logo

MCP-compliant R code execution and management agent for Claude Desktop Extension.

Empower R programming with Model Context Protocol.

Overview

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.

Features

  • 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

Installation (No Dependencies Needed)

Step 0: Download and Set Up Claude Desktop and R

  1. 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.
  2. Download and install R runtime, install it and make sure that it is within the system path.

Step 1: Download PilotR.mcpb

Simply download the latest PilotR.mcpb file from this repository or release page.

Step 2: Install in Claude Desktop

  1. Locate the downloaded PilotR.mcpb file
  2. Double-click the file
  3. Claude Desktop will open and prompt to install
  4. 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.)

Configuration (Optional)

To streamline your workflow:

  1. Open Claude Desktop
  2. Go to Settings → Extensions → MCP Servers
  3. Find "PilotR"
  4. Enable "Allow tools to run without permission" (Auto-approve)
  5. Restart Claude Desktop

Usage Examples

Once installed, you can interact with PilotR using natural language.
Here are common commands and workflows:

Common Commands

Setup & Configuration

"Set working directory to ~/my_analysis"    # Initialize workspace
"Show current state"                        # Check configuration
"Find R executable"                         # Verify R installation

File Management

"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

Code Execution

"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

Data Operations

"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

Visualization & Analysis

"Optimize my ggplot code"                   # Improve plot styling
"Check ggplot style in my script"           # Style analysis
"Create publication-ready plot"             # High-quality output

Example Workflows

Basic Data Analysis

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

Data Processing Pipeline

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

Publication-Quality Visualization

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

Exploratory Data Analysis

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

Available Tools

Core Operations

  • set_workdir — Set working directory for R operations
  • get_state — View configuration and runtime state
  • which_R — Locate R executable

File Management

  • 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

Execution

  • run_R_script — Execute R script file
  • run_R_expression — Evaluate R expression
  • inspect_R_objects — Explore workspace objects

Data Operations

  • list_exports — List exported files
  • read_export — Read file contents (text or binary)
  • preview_table — Preview CSV/TSV tables

Analysis Tools

  • ggplot_style_check — Optimize ggplot2 code for publication

Technical Details

  • Extension file: PilotR.mcpb
  • Protocol: MCP (Model Context Protocol) 1.0+
  • R Execution: via Rscript
  • Session Persistence: .pilotr directory for state
  • Security: Sandboxed file operations
  • Python: Requires Python 3.12+

Acknowledgments

Special thanks to Beniamin Krupkin and Sara Smith for the inspiration of this idea and their valuable contributions.

Maintainer

Wanjun Gu ([email protected])

License

MIT

About

MCP-compliant R code execution and management agent for Claude Desktop

Resources

License

Stars

Watchers

Forks

Packages

No packages published