
MCPR使AI代理能够参与专业分析工作流程的互动R会议。
概览
MCPR(R 模型上下文协议工具)包解决了当前 AI 辅助 R 编程范式中的一个根本限制。现有的 AI 代理运行在无状态执行模型中,每个命令调用 Rscript,这与严肃数据分析中迭代、依赖状态的特性背道而驰。分析工作流是一个累积的探索、建模和验证过程,可能持续数小时甚至数天。此外,中间步骤可能涉及大量计算,且下游代码的细微修改(如绘图美观)需要重新运行整个脚本。MCPR 旨在通过使 AI 代理在实时 R 环境中建立持久的交互会话来解决这一问题,从而保留工作区状态并支持复杂多步的分析工作流。 MCPR在2分钟内启动并运行: 你的AI代理可以执行R代码,创建图,并检查持久的私有工作区。
概述(AI 翻译)
MCPR(R 模型上下文协议工具)包处理
当前AI辅助R范式的根本局限性
编程。现有的人工智能代理运行在无状态执行模型中,
对每个命令调用Rscript,这与
严肃数据分析具有迭代、依赖状态的特性。一个
分析工作流程是一个累积性的探索、建模过程,
验证时间可能持续数小时甚至数天。此外,中间步骤
可能涉及大量计算,以及对下游代码进行小幅修改,如
因为剧情美学需要重新运行整个脚本。MCPR的目标是
通过使人工智能代理能够建立持久性,
实时R环境中的交互式会话,从而保留
工作区状态,并支持复杂、多步骤的分析工作流。
MCPR演示
快速启动
MCPR在2分钟内启动并运行:
就是这样! 你的AI代理可以执行R代码,创建情节,并且
检查一个持久的私有工作区。如果你想让代理正常工作
在现有的交互式R会话中,运行mcpr_session_start()
在那里,并与manage_r_sessions()相连。
核心能力
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCPR: A Practical Framework for Stateful Human-AI Collaboration in R
The MCPR (Model Context Protocol Tools for R) package addresses a
fundamental limitation in the current paradigm of AI-assisted R
programming. Existing AI agents operate in a stateless execution model,
invoking Rscript for each command, which is antithetical to the
iterative, state-dependent nature of serious data analysis. An
analytical workflow is a cumulative process of exploration, modelling,
and validation that can span hours or days. Moreover, intermediate steps
can involve heavy computation, and small changes in downstream code such
as plot aesthetics require running the entire script again. MCPR aims to
tackle this issue by enabling AI agents to establish persistent,
interactive sessions within a live R environment, thereby preserving
workspace state and enabling complex, multi-step analytical workflows.
Quick Start
Get up and running with MCPR in under 2 minutes:
# 1. Install MCPR
remotes::install_github("phisanti/MCPR")
# 2. Configure your AI agent to launch the MCPR server
library(MCPR)
install_mcpr(agent = "claude")
# 3. In your AI agent (Claude, etc.), start using MCPR tools
# MCPR::mcpr_server() is the agent's private R session by default
# 4. Optionally attach to a live R session with manage_r_sessions()
# Example: execute_r_code("summary(mtcars)")
That’s it! Your AI agent can execute R code, create plots, and
inspect a persistent private workspace. If you want the agent to work
inside an existing interactive R session, run mcpr_session_start()
there and attach with manage_r_sessions().
Core capabilities
MCPR’s design is guided by principles of modularity, robustness, and practicality.
- Communication Protocol: MCPR uses JSON-RPC 2.0 over
nanonextsockets, providing a lightweight, asynchronous, and reliable messaging layer. This choice ensures cross-platform compatibility and non-blocking communication suitable for an interactive environment.
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"mcpr": {
"command": "R",
"args": ["--quiet", "--slave", "-e", "MCPR::mcpr_server()"]
}
}
}