You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add MCP server for cross-OS control from Claude Code
Instead of a standalone agent loop, this exposes remote CUP machines as MCP
tools that Claude Code can call directly. Just add the MCP server to your
config, point it at cup_server instances on each machine, and talk naturally.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: examples/cross-os/README.md
+85-50Lines changed: 85 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,80 +1,123 @@
1
1
# Cross-OS Agent Demo
2
2
3
-
An AI agent that performs tasks across multiple machines running different operating systems, all using the same CUP (Computer Use Protocol) format.
3
+
Control multiple machines running different operating systems from Claude Code (or any MCP client), all through the same CUP accessibility tree format.
4
4
5
-
This demonstrates CUP's core value: **one protocol, every OS**. The agent sees identical accessibility tree formats whether a machine runs Windows, macOS, or Linux — no platform-specific code needed.
5
+
This demonstrates CUP's core value: **one protocol, every OS**. Claude sees identical UI trees whether a machine runs Windows, macOS, or Linux — no platform-specific prompting needed.
6
6
7
7
## Architecture
8
8
9
9
```
10
10
┌──────────────────────────────────────────────┐
11
-
│ Agent (agent.py) │
12
-
│ Claude interprets CUP trees from all │
13
-
│ machines and coordinates actions across them │
14
-
└──────┬──────────────┬──────────────┬─────────┘
15
-
│ │ │
16
-
WebSocket WebSocket WebSocket
17
-
│ │ │
18
-
┌──────▼──────┐ ┌─────▼───────┐ ┌───▼─────────┐
19
-
│ Windows PC │ │ Linux Box │ │ Mac │
20
-
│ cup_server │ │ cup_server │ │ cup_server │
21
-
│ (UIA) │ │ (AT-SPI2) │ │ (AXUIElement│
22
-
└─────────────┘ └─────────────┘ └─────────────┘
11
+
│ Claude Code / MCP Client │
12
+
│ "Open Notepad on windows, type hello, │
13
+
│ then open Notes on mac and paste it" │
14
+
└──────────────────┬───────────────────────────┘
15
+
│ MCP (stdio)
16
+
┌──────────────────▼───────────────────────────┐
17
+
│ mcp_server.py (MCP bridge) │
18
+
│ Exposes snapshot, action, find tools │
19
+
│ for each connected machine │
20
+
└──────┬──────────────────────────┬────────────┘
21
+
│ WebSocket │ WebSocket
22
+
┌──────▼──────┐ ┌─────▼────────────┐
23
+
│ Windows PC │ │ Mac │
24
+
│ cup_server │ │ cup_server │
25
+
│ (UIA) │ │ (AXUIElement) │
26
+
└─────────────┘ └──────────────────┘
23
27
```
24
28
25
29
## Files
26
30
27
31
| File | Purpose |
28
32
|------|---------|
29
-
|`cup_server.py`| WebSocket server that wraps `cup.Session()` — run on each machine |
30
-
|`cup_remote.py`| Client library: `RemoteSession` (single machine) and `MultiSession` (multi-machine) |
31
-
|`agent.py`| The orchestrator: connects to all machines, uses Claude to perform cross-OS tasks |
33
+
|`cup_server.py`| WebSocket server wrapping `cup.Session()` — run on each machine |
34
+
|`mcp_server.py`| MCP bridge — connects to remote cup_servers, exposes tools to Claude Code |
35
+
|`cup_remote.py`| Client library: `RemoteSession` and `MultiSession`|
36
+
|`agent.py`| Standalone agent (alternative to MCP — runs its own Claude loop) |
32
37
33
-
## Setup
38
+
## Quick Start (MCP + Claude Code)
34
39
35
40
### 1. Install dependencies on every machine
36
41
37
42
```bash
38
43
pip install computeruseprotocol websockets
39
44
```
40
45
41
-
### 2. Start the server on each machine
46
+
### 2. Start cup_server on each machine
42
47
48
+
**On your Windows PC:**
43
49
```bash
44
-
# On your Windows PC (e.g., 192.168.1.10)
45
-
python cup_server.py --port 9800
50
+
python cup_server.py --host 0.0.0.0 --port 9800
51
+
```
52
+
53
+
**On your Mac:**
54
+
```bash
55
+
python cup_server.py --host 0.0.0.0 --port 9800
56
+
```
57
+
58
+
### 3. Add the MCP server to Claude Code
59
+
60
+
Install the MCP server dependencies (on the machine running Claude Code):
61
+
```bash
62
+
pip install mcp websocket-client
63
+
```
46
64
47
-
# On your Linux box (e.g., 192.168.1.20)
48
-
python cup_server.py --port 9800
65
+
Add to your Claude Code MCP config:
49
66
50
-
# On your Mac (e.g., 192.168.1.30)
51
-
python cup_server.py --port 9800
67
+
```json
68
+
{
69
+
"mcpServers": {
70
+
"cup-cross-os": {
71
+
"command": "python",
72
+
"args": [
73
+
"C:/path/to/examples/cross-os/mcp_server.py",
74
+
"windows=ws://localhost:9800",
75
+
"mac=ws://192.168.1.30:9800"
76
+
]
77
+
}
78
+
}
79
+
}
52
80
```
53
81
54
-
### 3. Run the agent from any machine
82
+
Replace the paths and IPs for your setup. If you're running Claude Code on your Windows machine, `windows` can point to `localhost`.
83
+
84
+
### 4. Talk to Claude
85
+
86
+
Now just ask Claude Code naturally:
87
+
88
+
```
89
+
"What apps are open on both machines?"
90
+
91
+
"Open Notepad on windows and type 'Hello from Mac', then open TextEdit on mac and type 'Hello from Windows'"
92
+
93
+
"Take a snapshot of the foreground window on mac"
94
+
95
+
"Click the Submit button on windows"
96
+
```
97
+
98
+
Claude sees the CUP tools (`snapshot_machine`, `act_on_machine`, etc.) and uses them to interact with both machines.
99
+
100
+
## Standalone Agent (alternative)
101
+
102
+
If you prefer a self-contained script instead of MCP:
55
103
56
104
```bash
57
-
# Install agent dependencies
58
105
pip install anthropic websocket-client
59
106
60
-
# Set your API key
61
-
export ANTHROPIC_API_KEY=sk-ant-...
62
-
63
-
# Run with a task
64
107
python agent.py \
65
-
windows=ws://192.168.1.10:9800 \
66
-
linux=ws://192.168.1.20:9800 \
67
-
--task "Open Notepad on Windows and type 'Hello from Linux', then open gedit on Linux and type 'Hello from Windows'"
108
+
windows=ws://localhost:9800 \
109
+
mac=ws://192.168.1.30:9800 \
110
+
--task "Open a text editor on both machines and type today's date"
0 commit comments