领航
Claude Desktop Extension的MCP兼容R代码执行和管理代理。
使用模型上下文协议授权R编程。
概述
领航 是一个MCP(模型上下文协议)服务器,允许Claude在用户指定的目录中生成、执行和管理R脚本。它通过自然语言交互为统计编程和数据分析提供了一个完整的工作流程,无需手动设置。
特性
- 执行R代码和脚本 直接来自克劳德
- 管理R脚本文件 --创建、重命名、追加和写入
- 设置和管理工作目录 用于分析项目
- 检查R对象 和会话状态
- 读取和预览输出文件 (CSV、TSV、RDS、文本等)
- 列出并管理导出的结果
- 自动保存工作空间
- 沙盒文件操作 为了安全
安装(不需要依赖关系)
步骤0:下载并设置Claude Desktop和R
第一步:下载 PilotR.mcpb
只需下载最新 PilotR.mcpb 此存储库或发布页面中的文件。
步骤2:在Claude Desktop中安装
- 找到下载的
PilotR.mcpb文件 - 双击文件
- Claude Desktop将打开并提示安装
- 按照屏幕上的说明进行操作。(此步骤可能需要安装Python运行库。请按照提示继续安装。)
配置(可选)
要简化您的工作流程:
- 打开克劳德桌面
- 首选 设置→ 扩展→ MCP服务器
- 找到 “飞行员”
- 启用 “允许工具在未经许可的情况下运行” (自动批准)
- 重新启动克劳德桌面
使用示例
安装后,您可以与进行交互 PilotR 使用自然语言。\ 以下是常见的命令和工作流程:
常用命令
设置和配置
"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 --设置R操作的工作目录
- get_state --查看配置和运行时状态
- 哪个_R --查找R可执行文件
文件管理
- create_R_file --创建新的R脚本
- 重命名_文件 --重命名现有脚本
- write_R_code --将代码写入文件(具有覆盖保护)
- 附录_代码 --附加到现有文件
- set_primary_file --设置操作的默认脚本
- list_R_files --在工作区中列出R脚本
执行
- run_R_script --执行R脚本文件
- run_R_表达式 --评估R表达式
- inspect_R_对象 --探索工作空间对象
数据运营
- list_导出 --列出导出的文件
- read_导出 --读取文件内容(文本或二进制)
- preview_table --预览CSV/TSV表格
分析工具
- ggplot_style_check --优化ggplot2代码以供发布
技术细节
- 扩展文件:
PilotR.mcpb - 协议: MCP(模型上下文协议)1.0+
- R执行: 通过Rscript
- 会话持久性:
.pilotr州目录 - 安全: 沙盒文件操作
- python 需要Python 3.12+
致谢
特别感谢 贝尼亚明·克鲁普金 和 萨拉·史密斯 感谢这一思想的启发和他们的宝贵贡献。
维护者
顾万军 (wanjun.gu@ucsf.edu)
许可证
麻省理工学院
