feat(cua-driver-rs): wire up --claude-code-computer-use-compat + make it default for claude - #1678
Conversation
… it default for claude
The flag was previously documented in Skills/SKILL.md as the recommended
Claude Code install command but was a silent no-op on the Rust binary —
the only artifact was an orphan platform-macos/src/tools/screenshot_compat.rs
not even in mod.rs.
This PR finishes the port:
1. **macOS**: wire screenshot_compat.rs into tools/mod.rs. Add
`register_tools_with_compat(compat)` for the MCP path; existing
`register_tools()` calls `with_compat(false)` for ListTools/etc.
2. **Windows + Linux**: add `ScreenshotCompatTool` next to the regular
`ScreenshotTool` in each platform's `tools/impl_.rs`. Same shape as
the macOS variant — `pid` + `window_id` BOTH required, validates
window belongs to pid, JPEG @ 85%, returns a text note pointing the
caller at pixel-addressed tools so the LLM uses the window's
coordinate space.
3. **`build_registry(compat: bool)`** on each platform conditionally
registers ScreenshotTool or ScreenshotCompatTool — same MCP tool
name "screenshot", so callers see one or the other depending on
how the daemon was started.
4. **CLI plumbing**: `--claude-code-computer-use-compat` parsed in
`cli.rs`, added to `Command::Mcp { claude_code_compat }`. Both Mcp
arms in main.rs store it into a `static CLAUDE_CODE_COMPAT:
AtomicBool` which `build_registry` / `build_registry_no_cursor`
read when picking the screenshot variant. Static keeps the
dependency arrow pointed away from platform crates.
5. **`mcp-config --client claude` and `--client claude-code`** now
default to the compat command:
claude mcp add --transport stdio cua-computer-use \
-- <binary> mcp --claude-code-computer-use-compat
The server name is `cua-computer-use` (Claude Code reserves the
literal "computer-use" key for its built-in tool family) and the
binary self-registers the compat tool set on launch.
## Verified on Windows
- Build clean, 0 warnings.
- `cargo test --test-threads=1 -p cua-driver -p mcp-server -p platform-windows`: 49+28+32 all pass.
- `cua-driver mcp-config --client claude` prints the compat command.
- `cua-driver mcp --claude-code-computer-use-compat` initialize:
`tools/list` returns the compat screenshot with pid + window_id
required and the window-scoped description.
- `cua-driver mcp` (no flag) returns the regular screenshot with no
required fields.
macOS + Linux not compile-checked locally; CI will catch issues there.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a ChangesClaude Code Computer-Use Compatibility Mode
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…de compat MCP entry (#1679) The Claude Code section in `post-install-hints.txt` listed both the plain `cua-driver` MCP server and the `--claude-code-computer-use-compat` variant. Since #1678 made compat mode the default for Claude Code, the plain entry is redundant — keep only the compat-mode line and reword the description to stand on its own. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…bypass PowerShell arg mangling (#1680) Follow-up to #1678. The `claude mcp add NAME -- BIN mcp --extra-flag` form works in bash + cmd but PowerShell's native-command arg parser mangles `--<long-flag>` tokens passed after a bare `--`, producing: error: unknown option '--claude-code-computer-use-compat' even though commander.js (claude CLI's parser) handles `--` correctly. Verified by running the exact same command in Git Bash on the same Windows host and seeing the MCP server register cleanly. Switch the output to `claude mcp add-json`, which takes the whole server config as a single JSON string. No shell + no parser ambiguity on either dash. Smoke-tested end-to-end via `eval` of the generated output — registers + lists + removes cleanly. Binary path is normalised to forward slashes (Windows accepts them and forward-slash-in-JSON is fewer escape headaches across bash + PS). The single-quoted JSON literal works in PowerShell + bash + cmd-with- EnableDelayedExpansion. cmd users with naive double-quoted shells can paste the raw JSON into `~/.claude.json` instead — `mcp-config` with no `--client` flag still emits that format.
Summary
The `--claude-code-computer-use-compat` flag was documented in Skills/SKILL.md as the recommended Claude Code install but was a silent no-op on the Rust binary — the only artifact was an orphan `platform-macos/src/tools/screenshot_compat.rs` not even in `mod.rs`.
This PR finishes the port and makes it the default output of `mcp-config --client claude` (and `--client claude-code`).
What the flag does
When `cua-driver mcp --claude-code-computer-use-compat` is on argv, the registry swaps the regular `screenshot` tool for a compat variant — same tool name, different schema + behaviour:
Mirrors `ClaudeCodeComputerUseCompatTools.swift` in the Swift port.
What the default output now says
```
$ cua-driver mcp-config --client claude
claude mcp add --transport stdio cua-computer-use -- mcp --claude-code-computer-use-compat
```
Implementation
macOS: wired `screenshot_compat.rs` into `tools/mod.rs`. Added `register_tools_with_compat(compat)` for the MCP path; existing `register_tools()` calls `with_compat(false)` for ListTools / Describe / Call.
Windows + Linux: added `ScreenshotCompatTool` next to `ScreenshotTool` in each platform's `tools/impl_.rs` (~80 lines each, same shape as the macOS variant).
`build_registry(compat: bool)` on each platform conditionally registers ScreenshotTool or ScreenshotCompatTool.
CLI plumbing: `--claude-code-computer-use-compat` parsed top-level in `cli.rs`, added to `Command::Mcp { claude_code_compat }`. Both Mcp arms in `main.rs` store it into a process-global `static CLAUDE_CODE_COMPAT: AtomicBool` which `build_registry` / `build_registry_no_cursor` read when picking the screenshot variant.
`mcp-config --client claude` / `--client claude-code` outputs the compat install command by default.
Verified on Windows
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
--claude-code-computer-use-compatflag to enable Claude Code computer-use compatibility mode.