Skip to main content
Glama
README.md
# winreach

[![tests](https://github.com/Kkkkkkkeith10/winreach/actions/workflows/tests.yml/badge.svg)](https://github.com/Kkkkkkkeith10/winreach/actions/workflows/tests.yml)

Let an AI assistant on another computer use your Windows PC: run commands, read and write
files, run long jobs in the background, see the screen, and use the mouse and keyboard.

![Claude on a Mac typing into Notepad on a Windows PC and running a background job there](docs/demo.gif)

*Recorded with [examples/demo.py](examples/demo.py): every keystroke and the job were sent from a Mac.*

winreach is an [MCP](https://modelcontextprotocol.io) server. You run it on the Windows PC, and an
MCP client such as Claude Code on your Mac connects to it over your private network.

```
Mac (Claude Code)  ──  Tailscale  ──►  Windows PC (winreach)
                   key-protected HTTP
```

I built it to work on a Windows PC from my Mac: run an Android emulator, start a game server,
read its logs, and click through the app.

## What it can do

| Area | Tools |
|---|---|
| Commands | `run_command` (PowerShell, waits up to a time limit), `list_processes`, `kill_process`, `system_info` |
| Long jobs | `job_start`, `job_status`, `job_wait`, `job_output`, `job_stop`, `job_list`, `job_remove` |
| Files | `read_file`, `write_file`, `list_dir`, `upload_file`, `download_file` |
| Screen | `screenshot`, `list_displays` |
| Mouse and keyboard | `click`, `move_mouse`, `drag`, `scroll`, `type_text`, `press_keys` |
| Windows and apps | `list_windows`, `focus_window`, `window_action`, `launch_app` |

### Long jobs

Most remote tools wait for a command to finish, and clients give up after a minute or so. That
rules out builds, simulations and servers. `job_start` returns at once and the job runs on its
own, writing its output to a log:

```
job_start   {"command": "py train.py", "name": "training"}   → {"id": "20261203-081952-9d52a6", "state": "running"}
job_output  {"id": "...", "offset": -4000}                    → the last 4 KB of output
job_wait    {"id": "...", "seconds": 60}                      → {"state": "finished", "exit_code": 0}
```

Each job runs under its own small runner process, separate from the server, so a job keeps going
and its result is kept even if the server restarts.

### Action log

Every tool call is recorded on the PC, so you can check afterwards what the assistant did:

```
> winreach log -n 4
2026-12-03T08:36:47  ok  type_text(text='  > build finished\n')
2026-12-03T08:36:48  ok  type_text(text='  exit code 0\n')
2026-12-03T08:36:49  ok  job_remove(job_id='20261203-083641-701cee')
2026-12-03T08:36:50  ok  kill_process(pid=37128)
```

The log is `%USERPROFILE%\.winreach\actions.log`, one JSON object per line. Long values such as
file contents are replaced by their length, and the key is never written.

### Other details

- **Any language.** `type_text` types Chinese, emoji and accented text; command output is UTF-8.
- **Multiple displays and scaling.** Coordinates are real screen pixels across all displays, and
  every screenshot says how its pixels map to them.
- **Long commands.** Commands longer than Windows' 32,767-character limit go through a script file.
- **Address changes.** Set the address to `tailscale` and the server looks up the PC's current
  Tailscale address each time it starts.

## Setup

You need Python 3.11 or newer on the PC, and a way for the two computers to reach each other.
[Tailscale](https://tailscale.com) is the simplest: install it on both and sign in to the same account.

On the Windows PC, in a normal (not administrator) PowerShell window:

```powershell
py -m pip install --user git+https://github.com/Kkkkkkkeith10/winreach
py -m winreach init --host tailscale   # creates the settings and a secret key
py -m winreach install                  # starts the server now and at every login
py -m winreach client-config --name my-pc
```

The last command prints what the other computer needs, including the key. Keep that private.
On the Mac, run the `claude mcp add ...` line it prints, or paste the JSON into `~/.claude.json`.

If Windows Firewall asks, allow Python on private networks.

Other commands: `winreach status`, `winreach log`, `winreach restart`, `winreach uninstall`,
`winreach serve` (run in the current window, for debugging). Settings live in `%USERPROFILE%\.winreach\config.toml` and the
log in `server.log` next to it.

## Security

Anyone with the key can do anything your Windows account can do. So:

- **Every request needs the key.** Requests without the exact key get `401`. The key is 256 bits,
  compared in constant time, and the settings file is readable by your account only.
- **Don't expose it to the internet.** Listen on a private-network address such as Tailscale's,
  not `0.0.0.0`. The connection is plain HTTP; Tailscale encrypts it.
- **It runs as you, not as administrator.** It can't do what your account can't, and Windows
  blocks its input into programs running as administrator.
- **Desktop control can be turned off** with `winreach init --no-desktop` (commands and files
  still work).
- **Every action is logged** on the PC (see [Action log](#action-log)).
- **There is no on-screen warning** when the assistant uses the mouse and keyboard. If someone may
  be using the PC, prefer commands and files, or turn desktop control off.

## Limits

- The PC must be signed in, and the screen unlocked, for screenshots and input. Commands, files
  and jobs work either way while the server runs.
- Tested on Windows 10 22H2 with Python 3.12, two displays, connected from macOS over Tailscale.
  Windows 11 should work but is untested.
- No support yet for reading the accessibility tree (button names and positions); the assistant
  works from screenshots.

## Development

```bash
uv sync
uv run pytest
```

The tests run on Windows, macOS and Linux, on GitHub for every push. The desktop tests move the
mouse and type, so they only run on a real Windows desktop when asked:

```powershell
$env:WINREACH_DESKTOP_TESTS = "1"; uv run pytest tests/test_desktop_windows.py
```

Run them on an unlocked PC that nobody is using at the time; they open and close Notepad.

## Thanks

Inspired by [Windows-MCP](https://github.com/CursorTouch/Windows-MCP), which I used before writing
this. winreach is a separate implementation with a different design; it contains none of its code.
Built on the [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk),
[Pillow](https://python-pillow.org) and [psutil](https://github.com/giampaolo/psutil).

## License

MIT