RemotePaw
by jiaqinq
README.md
# RemotePaw
**Give your AI agent hands on another computer.**
RemotePaw (远程爪) provides **remote shell, file transfer and Windows desktop control for AI agents**.
Use **CLI + MCP**, powered by the **Python standard library**, to run commands, move files and
operate another computer's desktop from an agent on your laptop.
**Status: v1.3.1, not yet published to PyPI.** Use a source checkout or the single-file deployment
below; `pip install remotepaw` is the intended command after the first PyPI publication.
**Trusted machines only:** the server defaults to all IPv4 interfaces and unencrypted HTTP.
Never expose it directly to the internet; use your generated token, not the example below.
```bash
# install from a source checkout on each machine first: python -m pip install .
# on the remote machine
remotepaw serve
# on your laptop
remotepaw add box 192.168.1.20:8765 --token 7fK2mQ9xLpA3vN8sR4tYuE1b
remotepaw exec "npm test" # runs on `box`, output streams back live
```
One file, zero dependencies, no SSH server required on the remote side.


[](https://github.com/jiaqinq/remotepaw/blob/main/LICENSE)
[](https://github.com/jiaqinq/remotepaw/actions)
English · [简体中文](https://github.com/jiaqinq/remotepaw/blob/main/README.zh-CN.md)
---
## The problem
You build with an AI agent on your laptop. But the thing you're building only runs on *that other
box* — the Windows machine with the GPU, the licensed software, the weird driver.
So you copy commands into RDP, one long line at a time. Every iteration costs you a manual
round-trip, and the agent that wrote the code can't see whether it works.
`remotepaw` closes that loop. The agent gets a shell on the other machine — plus file transfer,
background jobs, screenshots, and a control tree for clicking real buttons.
## Install
The first PyPI release has **not** been published. For now, install from source on each machine
that needs the CLI:
```bash
git clone https://github.com/jiaqinq/remotepaw
cd remotepaw
python -m pip install .
```
After the first PyPI publication, the package installation command will be `pip install remotepaw`.
Do not assume a currently available package with that name is this project's release.
Or skip pip entirely — `remotepaw.py` is a single self-contained file. Copy it to the other machine
and run `python remotepaw.py serve`. That's the whole deployment.
Requires Python 3.8+. No third-party packages, on either side.
Check the installed command without contacting a remote machine:
```bash
remotepaw --version
remotepaw --help
```
`remotepaw selftest` is an optional local integration check, not a read-only diagnostic:
it starts a loopback server, executes commands and creates temporary files. On Windows it also
captures the screen and inspects windows/accessibility trees. Run it only on an authorized,
disposable test desktop.
## Quickstart
**Before starting:** the default bind is `0.0.0.0` (all IPv4 interfaces), and traffic is
unencrypted HTTP. Use only a trusted LAN or an encrypted VPN/tunnel, restrict firewall access,
and never forward this port directly to the internet. `--cwd` is not a filesystem sandbox.
All addresses and tokens below are examples: use the freshly generated token, not the sample.
Read the [security policy](https://github.com/jiaqinq/remotepaw/blob/main/SECURITY.md).
**On the remote machine (B):**
```bash
remotepaw serve --cwd D:\work\myproject
```
It prints a ready-to-paste command with its IP and a generated token:
```bash
$ remotepaw serve
...
remotepaw add b 192.168.1.20:8765 --token 7fK2mQ9xLpA3vN8sR4tYuE1b
```
> Windows may show a firewall prompt. Allow access only for trusted peers on the intended
> **private network**; do not enable public-network access merely to fix connectivity.
**On your laptop (A):**
```bash
remotepaw add b 192.168.1.20:8765 --token 7fK2mQ9xLpA3vN8sR4tYuE1b
remotepaw exec "npm test"
```
Output streams back while the command runs; the exit code is passed through unchanged, so your
agent can tell success from failure without parsing text.
A successful result requires a valid final `exit` event. A disconnected or malformed stream
is an error, not exit code 0. If the result is unknown, check the remote state before retrying:
the command may already have made changes. Ctrl+C closes the connection but does not confirm
that the remote process has stopped; use `--timeout` for a server-side time limit, or use
`job start` / `job stop` for work that needs explicit lifecycle control.
## What it can do
| | |
|---|---|
| **Run commands** | streaming stdout/stderr, real exit codes, timeouts, `--stdin` piping |
| **Move files** | `push` / `pull` whole directories, `read` / `write`, `tail -f` logs |
| **Background jobs** | start a dev server, follow its log, stop it — without blocking |
| **Screen** | capture screenshots, record a GIF, crop or scale (Windows) |
| **GUI control** | click by element name via UI Automation, or fall back to coordinates |
| **AI-native** | works as a plain shell tool, *and* as an MCP server |
### File transfer behavior
- Single-file `pull` and `read -o` preserve file bytes, including UTF-8 BOM and LF/CRLF line endings.
- CLI/MCP `pull` defaults to the basename of the server-resolved path, including when Windows and
POSIX hosts differ. A single file pulled to an **existing local directory** is saved inside it.
Directory pulls instead merge their **contents directly into** the selected local path, without
another nested source directory. Existing files may be overwritten; review the destination first.
For a single file, create missing local parent directories yourself; a trailing local separator
requires an existing directory. Remote roots or names invalid on the local OS require an explicit
local path.
- Directory transfers preserve empty directories and share the same skip rules across CLI and MCP.
Common generated directories and `.DS_Store` are excluded by default; CLI `push --all` / `pull --all`
disables these exclusions. These rules are not a secret scanner: review the source tree yourself.
- Directory transfer supports ordinary files and directories only. Links (including hard links),
device files and FIFOs cause an explicit error; they are not silently skipped or followed.
Archive paths must be relative, without `..` components, backslashes or colons.
Gzip checksums/trailers are validated before extraction writes any destination files.
- Unreadable files and failed directory scans fail the transfer instead of reporting partial success.
Extraction is **not transactional**: disk/permission errors can leave files already written.
Check the destination before retrying. Archive checks are not a filesystem sandbox and cannot
protect against another process concurrently changing destination paths.
For a Windows target named `b`, in PowerShell or a POSIX shell (create `downloads` first):
```sh
remotepaw -t b pull 'C:\work\report.txt' # saves ./report.txt
remotepaw -t b pull 'C:\work\report.txt' downloads/ # saves downloads/report.txt
remotepaw -t b pull 'C:\work\project' ./snapshot # merges contents into ./snapshot
```
## Hook it up to your agent
The CLI is the whole integration for any agent that can run shell commands. Give it the contract:
```markdown
<!-- append to AGENTS.md / CLAUDE.md / .cursorrules -->
The machine "b" is reachable via the `remotepaw` CLI. Anything that must run on b
goes through `remotepaw exec "..."`, not your local shell. To read or edit files on b,
use `remotepaw read` / `remotepaw pull` / `remotepaw write` / `remotepaw push` — your own file
tools only see this laptop. Full command reference:
https://github.com/jiaqinq/remotepaw/blob/main/AI-INSTRUCTIONS.md
```
[`AI-INSTRUCTIONS.md`](https://github.com/jiaqinq/remotepaw/blob/main/AI-INSTRUCTIONS.md) is a ready-made prompt covering the traps
(your file tools are local, don't use `exec` for long-running servers, coordinate scaling, …).
**Or use MCP** — for clients that support it, `remotepaw` exposes 15 tools directly:
```jsonc
// Claude Code (.mcp.json) / Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"remotepaw": {
"command": "remotepaw",
"args": ["-t", "b", "mcp"]
}
}
}
```
```toml
# Codex (~/.codex/config.toml)
[mcp_servers.remotepaw]
command = "remotepaw"
args = ["-t", "b", "mcp"]
```
`remotepaw_exec`, `remotepaw_read`, `remotepaw_write`, `remotepaw_ls`, `remotepaw_push`, `remotepaw_pull`,
`remotepaw_job_start`, `remotepaw_job_logs`, `remotepaw_job_stop`, `remotepaw_info`, `remotepaw_screenshot`,
`remotepaw_ui`, `remotepaw_mouse`, `remotepaw_keyboard`, `remotepaw_windows`.
Tool discovery lists the `remotepaw_*` names. Legacy `portal_*` calls remain accepted as deprecated
compatibility aliases but are not duplicated in the tool list. For target selection, use
`REMOTEPAW_TARGET`; `PORTAL_TARGET` remains a fallback when the new variable is not set.
Temporary `host:port` targets use `REMOTEPAW_TOKEN`, with `PORTAL_TOKEN` as the legacy fallback.
Both token variables contain secrets; do not print or publish them.
## Driving the GUI
When there's no CLI for the job, there's usually still a window. Two ways in, in order of
reliability:
**1. By element name (recommended).** Apps that expose an accessibility tree let you locate
supported buttons and fields by name:
```bash
remotepaw ui tree --title "Notepad" # see what's there
remotepaw ui click "Save" # click by name — no coordinates involved
remotepaw ui set "File name" "out.txt" # fill an input
remotepaw ui read "Status" # read text off a control
```
Pattern-based actions do not depend on screen coordinates. Clicks use `InvokePattern` or
another supported accessibility action where possible; unsupported controls may fall back to
coordinates, which still depend on visibility, focus and screen layout.
**2. By coordinates (fallback).** For canvas UIs, games, and anything without a control tree:
```bash
remotepaw screen -o shot.png # screenshot to your laptop
remotepaw mouse click 1240 86 # then click a pixel
remotepaw type "hello" # Unicode text, Chinese included
remotepaw key "ctrl+s" # key combos
```
`remotepaw record -o demo.gif --seconds 5` captures the whole session if you want to watch what the
agent did afterwards.
## Security
Read this before exposing it to anything.
- **The token is the only credential.** It's generated on first `serve`, stored in
`~/.portal/server_token`, and compared in constant time. Anyone with it can run commands and
drive your mouse. Treat it like an SSH private key.
- **There is no TLS.** Traffic is plain HTTP. Use it on a trusted LAN, or wrap it in a tunnel:
[Tailscale](https://tailscale.com/) (easiest), WireGuard, or `ssh -L`.
- **Never expose the port directly to the internet.**
- The default is `0.0.0.0`; bind to the intended interface, e.g. `remotepaw serve --host 192.168.1.20`,
and restrict firewall access. Binding an interface is not encryption.
- Client tokens are stored in plaintext in `~/.portal/config.json`; startup output prints the
server token. Protect file permissions, terminal history and logs. Do not commit them.
- If exposed, stop the server, remove or securely replace its saved token, restart without an old
explicit `--token`, and register clients again. Previously started processes need a separate check.
- `--cwd` does not restrict file access or commands. `/health` is unauthenticated and includes
the version, hostname and OS family. See the [security policy](https://github.com/jiaqinq/remotepaw/blob/main/SECURITY.md) for details.
This is a tool for machines you own, talking to each other. It is not a multi-tenant service.
## How it works
```
A — your laptop B — the other computer
AI agent remotepaw serve
└─ remotepaw exec "npm test" ───────► └─ cmd / sh
HTTP + token / NDJSON
◄─────── live output + exit code
```
- **B** runs a `ThreadingHTTPServer`. `/exec` responds with newline-delimited JSON events
(`start` / `out` / `err` / `exit`), one per chunk, flushed as it happens.
`Connection: close` gives a natural EOF boundary, so no chunked encoding is needed.
- **A** is a CLI with a tiny state file (`~/.portal/config.json`): targets, tokens, and the
current working directory per target. The server keeps background-job records in memory,
not a persistent shell session.
- Every command is a fresh process. `cd` is tracked client-side, which is more reliable than
keeping a long-lived shell alive.
- The GUI layer uses GDI for capture and `SendInput` for input. Performance depends on the
machine, screen size and content; there is no fixed screenshot latency or GIF size guarantee.
The control tree comes from Windows UI Automation, which cannot hold element references across
processes, so each call does *find + act* in one shot.
Why one file? Because the deployment story matters more than the module layout: copy it, run it.
`pip install` is a convenience on top, not a requirement.
## Limitations
- **CLI messages are currently Chinese-only.** Subcommands, flags, exit codes, `--json` output and
MCP payloads are language-neutral, so agents work fine — but a human reading `remotepaw serve` needs
a little Chinese. Localization is on the roadmap.
- Desktop features (`screen`, `ui`, `mouse`, `key`, `type`, `win`, `record`) and the built-in
`autostart` installer are **Windows only**. Command execution and file transfer also support
Linux and macOS. Windows GUI control needs a logged-in interactive desktop.
- Accessibility support varies by app and version. Chromium, WPF, UWP and Qt apps may expose
useful trees; games and custom-drawn canvases may require coordinate-based input.
- No interactive TTY. `stdin` is empty unless you pass `--stdin`.
- Background-job records live in memory and are lost when the server restarts. Graceful shutdown
attempts to stop jobs; a crash or forced termination may leave processes running.
- No TLS, by design — see above.
## FAQ
**Why not just SSH?**
SSH gives you a terminal. An agent needs something slightly different: per-command exit codes, live
output, file transfer, background jobs, and GUI access — on Windows, without installing an SSH
server. `remotepaw` is that interface. If you already have SSH and only need shells, use SSH.
**Does it need admin rights?**
No. It runs as your user, which is also why GUI automation works (services run in a session with
no desktop).
**Can two people share one server?**
It is not designed for safe multi-user sharing. Requests can arrive concurrently, but all clients
share one token, one operating-system account and one desktop; there is no isolation.
**What happened to portal / portal-remote?**
The project is now **RemotePaw** (远程爪), at `jiaqinq/remotepaw`. The PyPI package name and primary
CLI are both `remotepaw`, and the primary source module is `remotepaw.py`. Version remains **1.3.1**;
the first PyPI publication is still pending.
The old `portal` CLI and `portal.py` module remain **deprecated compatibility aliases**. Prefer
`remotepaw` / `remotepaw.py` for new commands and deployments. Existing `~/.portal` configuration,
including `config.json` and `server_token`, stays in place and is shared by both entry points;
there is **no automatic migration** to another directory. Do not install alongside unrelated
packages that provide the same commands or modules.
## Development
```bash
git clone https://github.com/jiaqinq/remotepaw
cd remotepaw
python -m pip install -e ".[dev]"
python -B -m unittest discover -s tests -v
python remotepaw.py --version
```
See the [contribution guide](https://github.com/jiaqinq/remotepaw/blob/main/CONTRIBUTING.md) for safe tests, packaging checks and the release
checklist. Tests use loopback networking and temporary files; they must not contact configured
remote targets. Do not run GUI self-tests on an active user desktop.
Releases require a matching version tag and a configured PyPI trusted publisher for this GitHub
repository, `publish.yml` and its configured publishing environment. Configure GitHub private vulnerability
reporting and review the tagged commit and artifacts before publishing. Tags or a manual workflow
can publish when those platform settings allow it; editing the version alone is not a release.
The [publishing workflow](https://github.com/jiaqinq/remotepaw/blob/main/.github/workflows/publish.yml) also supports TestPyPI validation.
Never upload old local artifacts or reuse a version already uploaded to the selected index.
## License
MIT — see [LICENSE](https://github.com/jiaqinq/remotepaw/blob/main/LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues