Skip to content

Commit fcd8b2e

Browse files
committed
feat: add GitHub Copilot CLI setup support
1 parent a59740c commit fcd8b2e

7 files changed

Lines changed: 163 additions & 24 deletions

File tree

‎NEWS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Added GitHub Copilot CLI setup support via `install_cli(tools = "copilot")`, including both `copilot mcp add` and `~/.copilot/mcp-config.json` instructions.
56
- Added optional async job progress reporting through `clauder_progress(stage, message = NULL, percent = NULL)` and MCP `get_async_result` progress text.
67
- Hardened Windows multi-session stale discovery cleanup by replacing `tools::pskill(pid, signal = 0)` liveness probing with a read-only PID check.
78
- Added regression coverage for async progress sidecar helpers, MCP bridge progress text, and Windows-safe cleanup.

‎R/install_cli.r‎

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#' @title Install and Set Up ClaudeR for CLI Tools
22
#' @description An installer that configures ClaudeR to be used with command-line
3-
#' AI tools like the Claude Code CLI, OpenAI Codex CLI, and Google Gemini CLI.
3+
#' AI tools like the Claude Code CLI, OpenAI Codex CLI, GitHub Copilot CLI,
4+
#' Qwen Code CLI, and Google Gemini CLI.
45
#'
56
#' By default, it uses `uvx` to run the `clauder-mcp` PyPI package, which
67
#' handles all Python dependencies automatically. No Python path or pip
78
#' install needed.
89
#'
910
#' @param tools A character vector specifying which CLI tools to configure.
10-
#' Can be `"claude"`, `"codex"`, `"gemini"`, or a combination like
11-
#' `c("claude", "codex")`.
11+
#' Can be `"claude"`, `"codex"`, `"copilot"`, `"qwen"`, `"gemini"`,
12+
#' or a combination like `c("claude", "codex", "copilot")`.
1213
#' @param use_uvx Logical. If `TRUE` (the default), generates commands using
1314
#' `uvx clauder-mcp` which handles Python dependencies automatically. If
1415
#' `FALSE`, falls back to the legacy method of finding a Python executable
@@ -19,14 +20,15 @@
1920
#' missing R dependencies.
2021
#' @details This function will:
2122
#' 1. Check for and install required R packages.
22-
#' 2. Provide you with the exact command to run (for Claude/Codex) or the exact
23-
#' JSON to copy (for Gemini) to complete the setup.
23+
#' 2. Provide you with the exact command to run (for Claude/Codex/Copilot/Qwen)
24+
#' or the exact JSON to copy (for Gemini/Copilot) to complete the setup.
2425
#' @export
2526
install_cli <- function(tools = "claude", use_uvx = TRUE, python_path = NULL, ...) {
2627
# --- 1. Parameter Validation ---
27-
tools <- try(match.arg(tools, choices = c("claude", "codex", "gemini"), several.ok = TRUE), silent = TRUE)
28+
cli_choices <- c("claude", "codex", "copilot", "qwen", "gemini")
29+
tools <- try(match.arg(tools, choices = cli_choices, several.ok = TRUE), silent = TRUE)
2830
if (inherits(tools, "try-error")) {
29-
stop("Invalid 'tools' argument. Please choose 'claude', 'codex', 'gemini', or a combination.", call. = FALSE)
31+
stop("Invalid 'tools' argument. Please choose 'claude', 'codex', 'copilot', 'qwen', 'gemini', or a combination.", call. = FALSE)
3032
}
3133

3234
# --- 2. Check R Dependencies ---
@@ -144,6 +146,90 @@ install_cli <- function(tools = "claude", use_uvx = TRUE, python_path = NULL, ..
144146
cat(toml_block, "\n\n")
145147
}
146148

149+
if (tool == "copilot") {
150+
copilot_env <- list()
151+
if (.Platform$OS.type == "windows") {
152+
userprofile <- Sys.getenv("USERPROFILE", unset = "")
153+
if (nzchar(userprofile)) {
154+
copilot_env$USERPROFILE <- userprofile
155+
}
156+
copilot_env$NO_PROXY <- "127.0.0.1,localhost"
157+
copilot_env$PYTHONIOENCODING <- "utf-8"
158+
}
159+
160+
copilot_env_flags <- character()
161+
if (length(copilot_env) > 0) {
162+
copilot_env_flags <- paste(
163+
"--env",
164+
vapply(
165+
names(copilot_env),
166+
function(name) shQuote(paste0(name, "=", copilot_env[[name]]), type = "cmd"),
167+
character(1)
168+
)
169+
)
170+
}
171+
172+
if (use_uvx) {
173+
add_string <- paste(c(
174+
"copilot mcp add r-studio --transport stdio --tools \"*\"",
175+
copilot_env_flags,
176+
"-- uvx clauder-mcp"
177+
), collapse = " ")
178+
copilot_server <- list(
179+
type = "local",
180+
command = "uvx",
181+
args = list("clauder-mcp")
182+
)
183+
} else {
184+
add_string <- paste(c(
185+
"copilot mcp add r-studio --transport stdio --tools \"*\"",
186+
copilot_env_flags,
187+
"--",
188+
shQuote(mcp_command, type = "cmd"),
189+
shQuote(mcp_args, type = "cmd")
190+
), collapse = " ")
191+
copilot_server <- list(
192+
type = "local",
193+
command = mcp_command,
194+
args = list(mcp_args)
195+
)
196+
}
197+
if (length(copilot_env) > 0) {
198+
copilot_server$env <- copilot_env
199+
}
200+
copilot_server$tools <- list("*")
201+
202+
copilot_config <- list(
203+
mcpServers = list(
204+
`r-studio` = copilot_server
205+
)
206+
)
207+
copilot_json_string <- jsonlite::toJSON(copilot_config, pretty = TRUE, auto_unbox = TRUE)
208+
209+
cat("\n--- For GitHub Copilot CLI ---\n")
210+
cat("Pick whichever setup path you prefer:\n\n")
211+
cat("Option A. Use the Copilot CLI command:\n\n")
212+
cat("copilot mcp remove r-studio 2>/dev/null ;", add_string, "\n\n")
213+
cat("Option B. Open ~/.copilot/mcp-config.json and add or merge this block:\n\n")
214+
cat(copilot_json_string, "\n\n")
215+
}
216+
217+
if (tool == "qwen") {
218+
remove_string <- 'qwen mcp remove --scope user r-studio 2>/dev/null'
219+
if (use_uvx) {
220+
add_string <- 'qwen mcp add --scope user --transport stdio r-studio uvx clauder-mcp'
221+
} else {
222+
add_string <- sprintf(
223+
'qwen mcp add --scope user --transport stdio r-studio %s %s',
224+
shQuote(mcp_command, type = "cmd"),
225+
shQuote(mcp_args, type = "cmd")
226+
)
227+
}
228+
cat("\n--- For Qwen Code CLI ---\n")
229+
cat("Copy and paste this complete command into your terminal:\n\n")
230+
cat(remove_string, ";", add_string, "\n\n")
231+
}
232+
147233
if (tool == "gemini") {
148234
if (use_uvx) {
149235
gemini_config <- list(

‎README.md‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="assets/ClaudeR_logo.png" alt="ClaudeR Logo" width="150"/>
33
<h1>ClaudeR - The Modern Researcher's Toolkit</h1>
44
<p>
5-
<b>Connect RStudio to Claude Code, Codex, Qwen Code, Gemini CLI, or any MCP-based LLM agent for interactive coding, multi-agent orchestration, automated manuscript auditing, and data annotation.</b>
5+
<b>Connect RStudio to Claude Code, Codex, GitHub Copilot CLI, Qwen Code, Gemini CLI, or any MCP-based LLM agent for interactive coding, multi-agent orchestration, automated manuscript auditing, and data annotation.</b>
66
</p>
77
<p>
88
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
@@ -18,7 +18,7 @@
1818

1919
---
2020

21-
**ClaudeR** is an R package that forges a direct link between RStudio and MCP configured LLM agents like Claude Code, Codex, or Qwen Code. This allows interactive coding sessions where the agent can execute code in your active RStudio environment so it can see the executed code and any generated plots in real-time. If you need help editing a script, a quick analysis done, or an LLM to audit your statistical claims against any manuscript before submission: ClaudeR has got your back.
21+
**ClaudeR** is an R package that forges a direct link between RStudio and MCP configured LLM agents like Claude Code, Codex, GitHub Copilot CLI, or Qwen Code. This allows interactive coding sessions where the agent can execute code in your active RStudio environment so it can see the executed code and any generated plots in real-time. If you need help editing a script, a quick analysis done, or an LLM to audit your statistical claims against any manuscript before submission: ClaudeR has got your back.
2222

2323
This package, additionally, allows multiple agents to work on one script, or it can make multiple RStudio windows siloed so multiple agents can operate independently on different datasets. It's also compatible with Cursor and any service that support MCP servers.
2424

@@ -33,6 +33,7 @@ devtools::install_github("IMNMV/ClaudeR")
3333
library(ClaudeR)
3434
install_clauder() # For Claude Desktop / Cursor
3535
install_cli(tools = "claude") # For Claude Code CLI
36+
install_cli(tools = "copilot") # For GitHub Copilot CLI
3637

3738
# Start the server in RStudio
3839
claudeAddin()
@@ -57,7 +58,8 @@ claudeAddin()
5758
- **Export clean script.** Click "Export Clean Script" in the Shiny addin to strip all timestamps, agent labels, and log headers from a session log, producing a runnable `.R` file with just the code. Error blocks are preserved as comments. Also available programmatically via `export_log_as_script()`.
5859
- **PyPI package (`clauder-mcp`).** The Python MCP bridge is now available as a standalone package on PyPI. Run it with `uvx clauder-mcp` for zero-config setup with no Python path or pip install needed. The installers (`install_cli()` and `install_clauder()`) default to uvx, with a `use_uvx = FALSE` fallback for legacy setups.
5960
- **`read_file` tool.** Agents can now read any text file from disk (.R, .qmd, .csv, .log, etc.) without it being open in RStudio. Enables session continuity workflows: point an agent at a previous log file and tell it to pick up where the last session left off.
60-
- **Codex + Qwen Code CLI support.** `install_cli(tools = "codex")` and `install_cli(tools = "qwen")` generate setup commands for OpenAI Codex and the [Qwen Code CLI](https://github.com/QwenLM/qwen-code) (Alibaba's gemini-cli fork). Both join Claude Code and Gemini as supported CLI agents.
61+
- **GitHub Copilot CLI support.** `install_cli(tools = "copilot")` generates the `copilot mcp add` command and the `~/.copilot/mcp-config.json` block needed to connect Copilot CLI to ClaudeR through `uvx clauder-mcp`.
62+
- **Codex + Qwen Code CLI support.** `install_cli(tools = "codex")` and `install_cli(tools = "qwen")` generate setup commands for OpenAI Codex and the [Qwen Code CLI](https://github.com/QwenLM/qwen-code) (Alibaba's gemini-cli fork). They join Claude Code, Copilot CLI, and Gemini as supported CLI agents.
6163
- **Multi-agent orchestration.** Run multiple AI agents on the same R session or spread them across separate RStudio windows. Each agent gets a unique ID on startup. Console output, log files, and execution history are all attributed per agent, so you always know who did what. On its very first tool call, each agent receives a context briefing with its own ID, any other agents active on the session, and the log file path, giving it full awareness of the shared environment without any manual setup. Agents can call `get_session_history` to review what other agents have done, or read the shared log file directly. The Shiny viewer tracks connected agents in real-time.
6264
- **Session discovery.** Each RStudio session writes a discovery file to `~/.claude_r_sessions/` on startup. AI agents find sessions automatically with no hardcoded ports. Name your sessions (e.g. "analysis", "modeling") and run them on different ports. When multiple sessions exist, agents automatically route to the session named "default". Non-default agents should call `connect_session` to bind to their target session. Single-session setups work with zero config.
6365
- **Redesigned Shiny viewer.** Cleaner UI with grouped panels for Session, Agents, Logging, and Advanced settings. Shows connected agents and execution count in real-time. Click the `?` button for a built-in guide on multi-session setup and agent identity.
@@ -132,7 +134,7 @@ With these tools, you can:
132134
- **Feedback & Assistance**: Get explanations of your R scripts or request edits at specific lines.
133135
- **Visualization**: The AI can generate, view, and refine plots and visualizations.
134136
- **Data Analysis**: Let the AI analyze your datasets and iteratively provide insights.
135-
- **Multi-Agent Workflows**: Run Claude Desktop, Claude Code, Codex, Qwen Code, and Gemini CLI on the same R session simultaneously. Each agent is uniquely identified, and they can see each other's work through shared history and log files.
137+
- **Multi-Agent Workflows**: Run Claude Desktop, Claude Code, Codex, GitHub Copilot CLI, Qwen Code, and Gemini CLI on the same R session simultaneously. Each agent is uniquely identified, and they can see each other's work through shared history and log files.
136138
- **Long-Running Analysis**: Async execution handles model fitting, simulations, and large data processing without timing out.
137139
- **Code Logging**: Save all code executed by the AI to log files for future reference. Every entry is tagged with the agent that ran it.
138140
- **Console Printing**: Print the AI's code to the console before execution.
@@ -253,7 +255,7 @@ This architecture ensures that the AI can only perform approved operations throu
253255

254256
## CLI Integration
255257

256-
ClaudeR supports command-line interface (CLI) tools: the **Claude Code CLI**, the **OpenAI Codex CLI**, the **Qwen Code CLI**, and the **Google Gemini CLI**. This is ideal for developers who prefer a terminal-based workflow, allowing you to interact with your AI assistant directly from the command line while maintaining a live connection to your RStudio session.
258+
ClaudeR supports command-line interface (CLI) tools: the **Claude Code CLI**, the **OpenAI Codex CLI**, the **GitHub Copilot CLI**, the **Qwen Code CLI**, and the **Google Gemini CLI**. This is ideal for developers who prefer a terminal-based workflow, allowing you to interact with your AI assistant directly from the command line while maintaining a live connection to your RStudio session.
257259

258260
## Security Model
259261

@@ -312,7 +314,7 @@ library(ClaudeR)
312314
install_clauder(use_uvx = FALSE, python_path = "/path/to/your/python")
313315
```
314316

315-
#### Option B: For CLI Tools (Claude Code / Codex / Qwen / Gemini)
317+
#### Option B: For CLI Tools (Claude Code / Codex / Copilot / Qwen / Gemini)
316318

317319
This non-interactive function generates the exact command or JSON configuration needed for your CLI tool.
318320

@@ -325,6 +327,9 @@ install_cli(tools = "claude")
325327
# For OpenAI Codex CLI
326328
install_cli(tools = "codex")
327329

330+
# For GitHub Copilot CLI
331+
install_cli(tools = "copilot")
332+
328333
# For Qwen Code CLI (requires `npm install -g @qwen-code/qwen-code`)
329334
install_cli(tools = "qwen")
330335

@@ -340,6 +345,7 @@ install_cli(tools = "claude", use_uvx = FALSE, python_path = "/path/to/my/python
340345

341346
After running the function, you must **manually apply the configuration**:
342347
- **For Claude / Codex / Qwen**: Copy the command printed in the R console and run it in your terminal.
348+
- **For Copilot**: Copy the printed `copilot mcp add` command, or merge the printed block into `~/.copilot/mcp-config.json`.
343349
- **For Gemini**: Copy the generated JSON and manually add it to your `gemini.json` settings file.
344350

345351
After setup, **quit and restart** any active Desktop Apps or terminal sessions for the new settings to load.
@@ -364,7 +370,7 @@ The ClaudeR add-in will appear in your RStudio Viewer pane. Click **"Start Serve
364370
### Part 2: In Your AI Tool
365371

366372
- **For Desktop Apps**: Open the Claude Desktop App or Cursor and begin your session.
367-
- **For CLI Tools**: Open your terminal and use the `claude`, `codex`, `qwen`, or `gemini` commands to start interacting with your AI assistant.
373+
- **For CLI Tools**: Open your terminal and use the `claude`, `codex`, `copilot`, `qwen`, or `gemini` commands to start interacting with your AI assistant.
368374

369375
> Note: You can regain console/active document control by clicking the stop button in the RStudio console. This closes the Shiny UI but the MCP server keeps running in the background and your AI agents stay connected. Re-run `claudeAddin()` to bring the viewer pane back with the same server state (port, session name, execution count). To fully stop the server, click **"Stop Server"** in the UI before closing.
370376
@@ -424,7 +430,7 @@ If you can do it with R, your AI assistant can too.
424430

425431
## Limitations
426432

427-
- Each R session can connect to one Claude Desktop/Cursor app at a time. However, multiple CLI agents (Claude Code, Codex, Qwen Code, Gemini) can share the same session alongside a Desktop app. To isolate agents, run separate RStudio windows with different session names and ports.
433+
- Each R session can connect to one Claude Desktop/Cursor app at a time. However, multiple CLI agents (Claude Code, Codex, GitHub Copilot CLI, Qwen Code, Gemini) can share the same session alongside a Desktop app. To isolate agents, run separate RStudio windows with different session names and ports.
428434
- R is single-threaded, but async jobs run in a separate process via `callr` so the main session stays responsive. The background process does not share the main session's environment by default. Use the `inputs`/`outputs` parameters on `execute_r_async` to auto-marshal data in and out, or write self-contained code that uses `saveRDS()`/`readRDS()` manually.
429435

430436
## License

‎clauder-mcp/README.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
MCP server that connects AI assistants to RStudio for interactive R coding and data analysis.
44

5-
This is the Python MCP bridge component of [ClaudeR](https://github.com/IMNMV/ClaudeR). It works with Claude Desktop, Claude Code, Codex CLI, Qwen Code CLI, Gemini CLI, Cursor, and any other MCP-compatible client.
5+
This is the Python MCP bridge component of [ClaudeR](https://github.com/IMNMV/ClaudeR). It works with Claude Desktop, Claude Code, Codex CLI, GitHub Copilot CLI, Qwen Code CLI, Gemini CLI, Cursor, and any other MCP-compatible client.
66

77
## Prerequisites
88

@@ -31,6 +31,28 @@ claude mcp add --transport stdio --scope user r-studio -- uvx clauder-mcp
3131
codex mcp add r-studio -- uvx clauder-mcp
3232
```
3333

34+
### GitHub Copilot CLI
35+
36+
```bash
37+
copilot mcp add r-studio --transport stdio --tools "*" -- uvx clauder-mcp
38+
```
39+
40+
You can also add the same server to `~/.copilot/mcp-config.json`:
41+
42+
```json
43+
{
44+
"mcpServers": {
45+
"r-studio": {
46+
"type": "local",
47+
"command": "uvx",
48+
"args": ["clauder-mcp"],
49+
"env": {},
50+
"tools": ["*"]
51+
}
52+
}
53+
}
54+
```
55+
3456
### Qwen Code CLI
3557

3658
```bash

‎llms-install.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ devtools::install_github("IMNMV/ClaudeR")
2222

2323
### Step 2: Run the Setup Function for Your AI Tool
2424

25-
Ask the user which CLI agent they want to install for (Claude Code, Codex, Qwen Code, or Gemini), then run the matching command:
25+
Ask the user which CLI agent they want to install for (Claude Code, Codex, GitHub Copilot CLI, Qwen Code, or Gemini), then run the matching command:
2626

2727
**For Claude Code CLI:**
2828
```R
@@ -36,6 +36,12 @@ library(ClaudeR)
3636
install_cli(tools = "codex")
3737
```
3838

39+
**For GitHub Copilot CLI:**
40+
```R
41+
library(ClaudeR)
42+
install_cli(tools = "copilot")
43+
```
44+
3945
**For Qwen Code CLI:**
4046
```R
4147
library(ClaudeR)
@@ -55,7 +61,7 @@ install_clauder()
5561
# For Cursor: install_clauder(for_cursor = TRUE)
5662
```
5763

58-
Each function prints the exact command or config you need to apply. For CLI tools, copy and run the printed command in your terminal. For Gemini, copy the JSON into your `gemini.json` settings file.
64+
Each function prints the exact command or config you need to apply. For Claude Code, Codex, and Qwen, copy and run the printed command in your terminal. For Copilot, use the printed `copilot mcp add` command or merge the JSON block into `~/.copilot/mcp-config.json`. For Gemini, copy the JSON into your `gemini.json` settings file.
5965

6066
### Step 3: Start the Server in RStudio (Manual Step)
6167

0 commit comments

Comments
 (0)