WinRemote MCP
by zbynekdrlik
README.md
# WinRemote MCP Setup
One-line installer for [WinRemote MCP](https://github.com/dddabtc/winremote-mcp) on Windows machines, enabling remote control from Claude Code on Linux.
## What it does
Installs and configures WinRemote MCP server on Windows so Claude Code (running on Linux) can:
- Execute PowerShell/CMD commands as the desktop user
- Take screenshots
- Control mouse/keyboard and interact with GUI apps
- Access files, registry, services, and processes
No more SSH quoting hell or headless session limitations.
## Install
On the Windows machine, open PowerShell **as Administrator** and run:
```powershell
irm https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/install.ps1 | iex
```
The installer needs an admin PowerShell and checks it before it changes anything. From a normal
window it relaunches itself elevated (one UAC prompt). It stops with
`nothing was changed on this box` instead when it runs as a non-admin account over SSH, from a
program with no console input (e.g. an agent's Shell tool), with an explicit
`REMOTEOS_MCP_AUTH_KEY` (it never crosses the elevation), or when even the relaunch is not
elevated (UAC turned off for a standard user): open PowerShell as Administrator (or use an admin
account) and run it again. Over SSH, or elevated as another account, it starts the server through
the scheduled task, in the logged-in desktop user's session (a server started from the SSH
session would die with it). Elevated as another account, Python must be installed for all users:
a per-user Python of that account is refused before anything changes.
It installs ONE commit: `REMOTEOS_MCP_REF` (a branch, tag or commit; default `main`, as on Linux)
is resolved through the GitHub API to a commit sha, and both the code and its `constraints.txt`
come from that sha. The sha is printed and written to
`C:\Users\<user>\.remoteos-mcp\installed-ref.txt`.
**Download first, install offline, roll back (#64).** Before anything on the PC changes, the
installer downloads every wheel the install needs (and builds one for every source archive, the
remoteos archive itself included) into `%ProgramData%\remoteos-mcp\wheelhouse\<sha>`
(about 60 MB; the folder is owned by Administrators, the desktop user may only read it, because an
elevated pip installs from it). A failed download prints `[X] could not download ... -- nothing was changed on
this box` and the running server is untouched. Only then is the server stopped, and the install
runs with `--no-index` from that folder. A failure after the stop (pip, the import check, the
task, the firewall, the start, the health check) reinstalls the previous commit's wheelhouse
(the one `installed-ref.txt` names), restarts the server, proves its health and prints
`[X] ... -- rolled back to <old version>`; the first install with wheelhouses has nothing to go
back to and says so. After a proven install the current and the previous wheelhouse are kept and
older ones deleted. A re-run of the same commit reuses its wheelhouse (no download). A run KILLED
after the stop (an SSH drop, a crash) is rolled back from outside: the `RemoteOSMCP-Rollback` task
watches the installer, and its result is in `.remoteos-mcp\rollback.log`.
**The box updates itself (#65).** Every installer sets up a daily check (Linux: a systemd timer;
Windows: the `RemoteOSMCP-Updater` task; macOS: a LaunchAgent), which also catches up after the box
was off. `python -m remoteos.updater` reads the ring in `updater.json` (next to `config.json`) and
installs that ring's release through SelfUpgrade when it is newer; the installers prove it and roll
back. `stable` (default) = the newest release at least 14 days old, `canary` = the newest. A release
marked `prerelease` on GitHub is HELD: no box takes it. Nothing is ever downgraded. A release that
fails on a box is tried twice, then left alone until a newer one exists or an installer is run by hand. Set the ring with
`REMOTEOS_MCP_RING=stable|canary` on an installer run; a run without it keeps what the box has.
The log: Windows and macOS `.remoteos-mcp\updater.log`, Linux `journalctl -u remoteos-mcp-updater`.
Camera-box's enable-only cams get no timer: its provisioning updates them.
That's it. The script will:
1. Check/install Python 3.11+
2. Download remoteos-mcp and its dependencies into the commit's wheelhouse
3. Install remoteos-mcp offline from it
4. Keep the PC's auth key, or generate a random one
5. Create a start script and auto-start scheduled task
6. Open the firewall port
7. Start the server immediately, and roll back if it does not prove itself
8. Print the `claude mcp add` command to run on your Linux machine
On **macOS**: `curl -fsSL https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/install.sh | bash`.
Pin a source with `| REMOTEOS_MCP_REF=<full 40-hex commit sha | tag | branch> bash` (default `main`).
On **Linux** (systemd): `curl -fsSL https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/install-linux.sh | sudo bash`.
Pin a source with `| sudo REMOTEOS_MCP_REF=<commit sha | tag | branch> bash` (default `main`).
To install a given key, never put it on sudo's command line (`ps` shows it): `read -rs k`,
then `… | REMOTEOS_MCP_AUTH_KEY="$k" sudo --preserve-env=REMOTEOS_MCP_AUTH_KEY bash` (the key
reaches sudo's environment only; nothing is exported to curl or the rest of the shell).
### Where the installers put things (#12)
- **The auth key is never on a command line, in a service file or in the installer's output.**
The server reads it from `REMOTEOS_AUTH_KEY`:
- Linux: 0600 `/etc/remoteos-mcp/config.json` and the unit's 0600 `EnvironmentFile`
`/etc/remoteos-mcp/remoteos-mcp.env`;
- macOS: the LaunchAgent plist's `EnvironmentVariables` (plist and
`~/.remoteos-mcp/config.json` mode 600);
- Windows: `start-remoteos.bat` sets it before starting the server; the `.bat` and
`config.json` in `C:\Users\<user>\.remoteos-mcp\` are readable by that user, SYSTEM and
Administrators only.
- **A re-run keeps the key**: an explicit `REMOTEOS_MCP_AUTH_KEY`, else the key the running
service uses, else `config.json` (Windows: then `remoteos.toml`), else a new one.
- **Linux runs a dedicated venv**, the layout camera-box's provisioning uses too:
`/opt/remoteos-mcp-venv` (a link to the current build in `/opt/remoteos-mcp-venvs/`) and
`remoteos-mcp.service` (`User=` the desktop user with `DISPLAY` on a desktop box, headless
otherwise). A new source is built next to the running one and swapped in; the new install must
answer `/health` with its version, accept the key and refuse a request without it, or the box
goes back to the previous proven install (or, with none, is stopped and disabled: an unproven
agent never stays up). The key goes only to the unit's own process on :8092 (the check needs
`ss`, from iproute2). An unchanged source changes nothing.
- **Upgrading a Linux box from the old system-python install** moves it to the venv with the
same key. The old copy in the system python is removed only after the venv has proved itself.
The old unit showed that key to every local account (`systemctl cat`, `ps`), and the old
installers printed it: on a box with other local accounts, or whose earlier install output was
logged, rotate it with `REMOTEOS_MCP_AUTH_KEY` and update the clients. The same holds for a
migrated mac (the old plist's ProgramArguments) and Windows box (the old `.bat`'s
`--auth-key`).
- **Admin on Linux and macOS (#71).** The installer keeps `/etc/sudoers.d/90-remoteos-mcp`
(`<account> ALL=(ALL) NOPASSWD:ALL`, checked by `visudo -cf`, 0440 root) for the service's
account, so `sudo` in Shell needs no password and a reprovision keeps that. A root unit gets
none; a refused line stops the run before any change; an identical file is left as it is; the
uninstallers remove it. macOS's installer runs as the user: with no way to sudo (no terminal
for the password) it warns and the install stands.
- **Upgrade a box through MCP: the `SelfUpgrade` tool (Tier 3, #71)**, `remoteos-call <box>
SelfUpgrade --json '{"ref": "<sha, tag or branch>"}'` (no ref = main). It starts the OS's
installer detached from the server and returns at once with the log path; the installer proves
the new version or rolls back. Poll `/health` for the version. Linux: `sudo -n systemd-run`
(a root unit: no sudo), log in `/var/log/remoteos-mcp-upgrade-<ts>.log`, read with sudo.
Windows: the elevated task `RemoteOSMCP-Upgrade`, log `upgrade.log` next to `config.json`, ref in
`upgrade-ref.txt` beside it. macOS: `launchctl submit`, log in `~/.remoteos-mcp/`.
A box installed before 0.7.0.dev39 has neither the drop-in nor the task: its first upgrade to
this version needs the installer once more. A camera-box cam (read-only root) stays on camera-box's provisioning.
- **SSH is break-glass:** for a first install, or a box whose server is down. Never run an
installer through the agent's own Shell: on Linux that run is inside `remoteos-mcp.service`,
whose restart would kill it, so it is refused.
## Connect from Claude Code
After install, the script prints a command like:
```bash
claude mcp add --transport http win-mypc \
http://192.168.1.100:8092/mcp \
--header "Authorization: Bearer <the auth key>"
```
The key itself is not printed. Read it on the machine: `Get-Content $HOME\.remoteos-mcp\config.json`
(Windows), `cat ~/.remoteos-mcp/config.json` (macOS), `sudo cat /etc/remoteos-mcp/config.json`
(Linux). Run the command with it on your Linux machine, restart Claude Code, and you're connected.
**The server names its machine at connect (#59).** The name you give it (`win-mypc`) is only a
label and can go stale (a box reinstalled from Windows to Ubuntu keeps it). The MCP
`initialize` result's `instructions` say which machine it really is and what Shell runs, e.g.
`Remote OS MCP Server on stream-snv — Ubuntu 24.04.3 LTS, x86_64. The Shell tool runs /bin/bash -c.`
(Windows: `Windows 11 (build 10.0.26100)`, a Server `Windows Server (build …)`, and
`PowerShell (powershell -NoProfile -Command, …)`; macOS: `macOS 15.1` and `/bin/zsh -c`).
`/health` carries the same `os` and `hostname` next to `status` and `version`:
`{"status":"ok","version":"…","os":"Ubuntu 24.04.3 LTS","hostname":"stream-snv"}`. `/health`
needs no key, so whoever can reach the port sees the hostname and OS.
## Restrict access per project
To limit which Claude session controls which Windows machine, use project-scoped config.
Create `.mcp.json` in your project directory:
```json
{
"mcpServers": {
"win-strih": {
"type": "http",
"url": "http://192.168.1.10:8092/mcp",
"headers": {
"Authorization": "Bearer YOUR_KEY"
}
}
}
}
```
Claude Code only loads MCP servers from the current project's `.mcp.json`, so different projects = different Windows machines.
## Computer-use actions
| Action | Call |
|---|---|
| Triple click | `Click(x, y, action="triple")` |
| Click or scroll with modifiers | `Click(x, y, modifiers="ctrl+shift")`, `Scroll(3, "up", modifiers="ctrl")` |
| Press and release a button apart | `Click(x, y, action="down")`, `Move(...)`, `Click(x, y, action="up")` |
| Repeat a key | `Shortcut("down", repeat=5)` (1..100) |
| Hold keys | `HoldKey("shift+w", seconds=2)` (capped at 30 s) |
| Read the cursor | `CursorPosition(monitor=0, max_width=1280)`: image pixels of that frame and screen coordinates |
| Pause | `Wait(seconds)`: capped at 300 s, takes no desktop lock |
| Wait for the screen | `WaitFor(text="Saved", timeout=30)` or `WaitFor(window="Notepad")` |
Modifier keys and HoldKey keys are always released, also when the action fails. A button pressed
with `action="down"` stays down until its `action="up"`.
`WaitFor` checks every 0.5 s without the desktop lock, so other tools keep working. It replies
with what matched and where: the monitor and the OCR line for `text`, the window's rectangle in
image pixels for `window`. Not found within `timeout` (0..300 s) is an error.
## UI elements instead of pixels
`ElementTree` lists a window's real controls from the OS accessibility tree (UI Automation on
Windows, AX on macOS, AT-SPI on Linux X11), so buttons and fields are named, not guessed from a
screenshot:
```
ElementTree(window="", monitor=0, max_width=1280)
[4822.1] Edit "Search" enabled (300x24 at 40,12)
[4822.2] Button "Save" enabled (80x24 at 350,12)
[4822.3] Button "Delete" disabled (80x24 at 440,12)
```
- `window` is part of a title, matched as `FocusWindow` does; empty = the foreground window.
- Bounds are image pixels of the Snapshot frame `(monitor, max_width)`. Only interactive, visible
elements are listed, at most 300, and the reply says when the list is incomplete.
- `ClickElement(ref)` uses the element's own action (Invoke, AXPress, AT-SPI's click or press), which
needs no mouse. Without one, it clicks the element's centre, and refuses when anything else is on
top of it there (on Linux: when its window is not the active one).
- `TypeElement(ref, text)` sets the element's value (Value, AXValue, EditableText), **replacing** what
was there. An element with no settable value gets the focus and `text` is typed at its caret. The
reply says which it was.
- A ref belongs to the latest tree. A ref of an older tree, or an element that is gone, is an
error asking for a new `ElementTree`, never an action somewhere else. `AnnotatedSnapshot` starts
a new tree too. `Snapshot` does not end refs, unless the window stops answering: on Windows any
UI Automation timeout ends them.
- An app that blocks the call (a modal dialog opened by the button) ends in an error saying the
action may have happened. Look before repeating it.
**macOS** needs the Accessibility permission for the server's Python binary (`AXIsProcessTrusted`,
a separate check from posting events, in the same System Settings pane). Without it these tools
fail with what to allow, the server says so at start, and `AnnotatedSnapshot` reports it next to
its image.
**Linux** coverage depends on the app. GTK shows its controls. Qt and Chromium/Electron may show
none until asked, and then the reply carries a hint:
- Qt: start it with `QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1`.
- Chromium, Chrome, Electron: start it with `ACCESSIBILITY_ENABLED=1` in the environment **and**
`--force-renderer-accessibility`. The flag alone leaves it off the accessibility bus.
**Wayland is not supported.** Every tool that needs the screen or input fails there with one message
saying why (LockScreen and Notification still work): the tools drive X11 (`xdotool`, `scrot`, `wmctrl`, `xclip`) and there is no portal or `ydotool` backend. Log in
to an X11 session ("Ubuntu on Xorg", or `WaylandEnable=false` in `/etc/gdm3/custom.conf`).
## Marks on custom-drawn apps (AnnotatedSnapshot)
Ableton, Resolume and other JUCE-style apps draw their own controls, so accessibility sees almost
nothing there. `AnnotatedSnapshot` adds what OCR reads, as one numbered list on the image:
```
**Marks:** 3 (1 elements, 2 OCR)
[1] element Button "Save" ref 4822.2 at (390,24)
[2] ocr text "Sample bank" at (115,210)
[3] ocr text "Prehrať" at (496,342)
```
- A point is an image pixel, so `Click(115, 210)` hits mark 2 as it is. Elements are red, OCR blue.
- An element wins: a word with more than half of its area on an element adds no mark. Close words
on a line are one mark. Numbers run top-left to bottom-right, so a screen keeps its numbers.
- `max_elements` (1-300, default 300) bounds the marks. Elements go in first, and the reply says
how many were left out.
- An element's `ref` works with `ClickElement` and `TypeElement`. It starts a new ref tree, so it
ends the refs of an earlier `ElementTree`.
- OCR runs on the full capture, not the image shrunk to `max_width`, and adds seconds to the call.
If it fails, the reply says why and keeps the image and the elements.
- It finds text, not unlabelled icons.
OCR reads Slovak and English by default (`lang="slk+eng"`, for the `OCR` tool too). A language that
is not installed is left out, and the reply says so:
- **Linux:** Tesseract, with `tesseract-ocr-slk` from the installer.
- **Windows:** pytesseract if installed, else the Windows engine, which reads one language at a
time: the first of Slovak, English that is installed. A language comes from the Windows language
settings (its optical character recognition part), else the user profile's languages are used.
- **macOS:** word boxes need pytesseract. The Shortcuts fallback gives text only, so without
pytesseract `AnnotatedSnapshot` has no OCR marks and says so.
## Screen coordinates (Snapshot → Click)
Snapshot and AnnotatedSnapshot shrink the screenshot to `max_width` (default 1280 px). The
input tools use the **same pixels as that image**, so a point read off the screenshot can be
passed straight to Click / Move / Scroll / Type.
- **The text starts with the coordinate contract**, for example:
```
**Coordinates:** Image 1280x800 = screen 2560x1600 at origin (0,0), scale 2.000; input tools take IMAGE pixels of this frame (monitor=0, max_width=1280)
```
All window rects and element centers in the text are in image pixels too.
- **The server maps every point back to the screen:** `screen = origin + round(image × scale)`,
clamped to the captured area. The mapping is stateless: it is recomputed from `monitor` +
`max_width` at click time. If you used a non-default `monitor` / `max_width` for the
Snapshot, pass the same values to the input tool. The tool's reply shows the mapping:
`[image (640,400) → screen (1280,800); scale 2.000]`.
- **`coords="screen"`** passes raw OS coordinates through unchanged. Those are physical pixels
on Windows and Linux, and points on macOS.
- **`monitor=0`** means different things per OS:
- Windows: the whole virtual screen. Its origin is negative when a monitor sits left of
or above the primary.
- Linux: the X root, all heads, sized by `xrandr --current`. Needs `x11-xserver-utils`; the
installer adds it.
- macOS: the main display.
`monitor=N` is one display: `EnumDisplayMonitors` on Windows, `xrandr --listmonitors`
on Linux, `screencapture -D N` on macOS.
- **Windows runs per-monitor-v2 DPI aware**, set before pyautogui loads. That way screenshots,
window rects and the cursor all use physical pixels. The startup log prints
`Windows DPI awareness: …`.
- **OCR and ScreenRecord regions are still in screen coordinates.**
- **`Zoom(x, y, width, height)` reads small text.** The rectangle is in pixels of the Snapshot
image (same `monitor` / `max_width`), or raw OS coordinates with `coords="screen"`. It is cut
to the frame, captured at native resolution and downscaled only above `max_width`.
- Zoom is **view only**: input tools never take pixels of the zoomed image. The reply gives
the region's screen origin and scale:
```
**Coordinates:** Zoom image 640x400 = screen 640x400 at origin (200,100), scale 1.000; view only: ...
```
To click a point of the zoom, pass `origin + round(image × scale)` with `coords="screen"`.
- `max_width` also limits the reply: use `max_width=0` with `coords="screen"` for a native
capture wider than 1280 px.
- **`DisplayInventory()` says what each `monitor` value is on this machine:** what `monitor=0`
covers, then per display its `monitor=N` index, name, bounds, origin, scale and the primary
flag. Scale is Windows effective DPI / 96 and macOS pixels per point. It is `n/a` on X11, which
has no per-monitor scale, and on Windows when `GetDpiForMonitor` gives no answer.
## Scroll units
`Scroll(amount=3, direction="down")` turns the mouse wheel 3 **clicks** (notches), with the
same unit on every OS. `direction` is `up` / `down` / `left` / `right`, and `amount` is
clamped to 1..100.
- **Windows:** one `SendInput` wheel event of `clicks × 120`. Vertical uses
`MOUSEEVENTF_WHEEL`, horizontal uses `MOUSEEVENTF_HWHEEL`.
- **macOS:** Quartz line events, one line per click, in events of at most 10 lines.
- **Linux:** xdotool wheel buttons 4/5/6/7, once per click.
- **Legacy calls still work:** a signed `amount` (positive = up/right, negative = down/left)
with `horizontal=true` for left/right. An explicit `direction` wins over both.
## Typing text (Unicode)
`Type("Žltý kôň ďakuje – €")` types any Unicode text exactly, whatever the keyboard layout:
diacritics, symbols and emoji. `\n` (also `\r\n`) presses Enter and `\t` presses Tab.
- **Windows:** `SendInput` Unicode packets (`KEYEVENTF_UNICODE`), one down/up per UTF-16
code unit, so emoji go as surrogate pairs.
- **macOS:** Quartz keyboard events that carry the text, at most 20 UTF-16 units per event.
The process needs the Accessibility permission (System Settings › Privacy & Security).
- **Linux:** `xdotool type`.
- **The reply counts what was handed to the OS.** `Typed N chars` means N characters were
handed over.
- **Windows:** if `SendInput` refuses input part-way (a locked or disconnected session),
the reply is an error that says how many got through.
- **macOS:** refuses up front, when the process may not post keyboard events. Nothing is
then clicked, typed or pasted.
- **Windows and macOS:** a locked screen is refused before anything is typed (see
[Tool errors](#tool-errors-and-desktop-diagnoses)). On Linux X11, typed input reaches
the screen locker.
- **`method="paste"` (opt-in):** for an app that ignores typed keystrokes.
- It saves the clipboard text, pastes with Ctrl+V (Command+V on macOS), then restores the
clipboard.
- Only text can be restored. When the clipboard held none, the reply says so.
- The reply means the paste keys were pressed; it does not confirm the app took the text. Structured content goes out next to the text, so a reply is twice its output on the
wire: the 256 MiB reply limit means about 128 MiB of output.
- Not for secrets: clipboard history and sync keep a copy.
## Tool errors and desktop diagnoses
A tool that fails returns an MCP **error result** (`isError: true`), never a successful
reply with error text in it. The client shows it as a tool error. The text says what is
wrong, and for a tool call it keeps the task id, e.g.
`[task:1a2b3c4d5e6f] Shell error: working directory not found: C:\no such dir`.
Before a desktop tool touches the screen, it checks that the desktop can be used:
- **Screen tools** (Snapshot, AnnotatedSnapshot, Zoom, OCR, ScreenRecord) and **input tools**
(Click, Move, Type, Scroll, Shortcut, HoldKey, MinimizeAll).
- **Windows:**
- the server runs in session 0: start it with `schtasks /Run /TN RemoteOSMCP`;
- the server runs in a non-interactive window station;
- the session is disconnected: run **ReconnectSession**. It attaches the server's own
session to the console, then checks it worked. The screen and input tools refuse a
disconnected session instead of moving it, because a reconnect puts the user's desktop
on the machine's physical screen;
- the screen is locked, or a secure desktop (UAC prompt, Ctrl+Alt+Del) is showing.
- **macOS:** no GUI session, the session is not on the screen (fast user switching), or the
screen is locked. Also a missing permission: **Screen Recording** for the screen tools,
**Accessibility** for the input tools. The message names the Python binary to allow.
- **Linux:** no X11 session. The headless stub text itself is unchanged, and
Snapshot, ScreenRecord and OCR now return the bare stub instead of `<Tool> error: <stub>`.
A locked X11 screen is not refused: the screenshot shows the locker, and typed input
reaches it.
- `Snapshot(use_vision=False)` captures nothing, so it needs only the user's desktop, locked
or not. Its window list works on a disconnected or locked session too. It is refused only
in these cases: session 0, a non-interactive window station, no macOS GUI session, a macOS
session that is not on the screen, or no X11 session.
- **It never refuses a working desktop.** A check that cannot run (an older OS, a missing
API, a probe error) counts as "usable", and the tool goes ahead.
**Console output on Windows.** The output of PowerShell comes back as exact Unicode on every
Windows code page: `Žltý kôň ďakuje – €` stays exactly that, error text (`Write-Error`) and
parse errors included. This covers Shell, the service, task and EventLog helpers, app launch,
notifications and Windows OCR. On macOS and Linux, output is read in the locale's encoding
(UTF-8 on the fleet).
- Each command runs in its own hidden console. So a `chcp` inside one Shell command cannot
change how later replies are decoded.
- That console is switched to UTF-8 BEFORE PowerShell starts, by a small `python.exe` launcher
from the server's own Python folder. Your command reaches PowerShell unchanged: no code is
added to it, so error messages, exit codes, `param(...)` at the start of a script, and
Constrained Language Mode behave exactly as in plain PowerShell.
- Programs started from the command share that console, so a program that writes through the
console (`cmd /c echo Žltý kôň`) is exact too.
- Text that PowerShell pipes INTO a native program (`"čaká" | findstr "."`) uses Windows
PowerShell's default, ASCII: each non-ASCII character arrives as `?`.
- A line that is not UTF-8 is read on its own in the system's OEM code page, so it is exact
only for the characters that page holds. Example: a native program that writes the OEM page
whatever the console's page is.
- Such a native program's output loses its non-ASCII text when PowerShell itself captures it,
in a pipeline, an assignment or `| Out-String`. PowerShell decodes it as UTF-8 then.
- The UTF-8 page also applies to programs started from the command. For example, cmd.exe reads
a `.bat` file in the console's code page, which is UTF-8.
- A command that times out is stopped together with the processes it started (its process
tree on Windows, its process group elsewhere; best effort).
- A command never reads the server's own input: its stdin is empty.
- The launcher takes about 700 characters, plus the working directory, of Windows'
32 767-character command line, so the longest possible command is that much shorter than
before.
- If PowerShell cannot be started at all, the tool reports an error, never a command result.
- Ping runs without PowerShell and is read in the OEM code page. `tscon` also runs without
PowerShell; it is read UTF-8 first, and a line that is not UTF-8 in the OEM code page.
- Real Windows PowerShell 5.1 checks in CI (`tests_windows`, an en-US runner whose OEM code
page is 437): exact output, `cmd /c echo`, `Write-Error` text, exit codes, `param(...)`, a parse
error, and that a timed-out PowerShell is gone. The other points above are verified on the
fleet only.
**Shell on Linux: the user's session.** The Linux service is a systemd system unit, which has no
login-session environment. A Shell command still gets the session of the user the service runs
as, so `systemctl --user`, `journalctl --user` and GUI programs work through MCP (no SSH needed):
- `XDG_RUNTIME_DIR`, when `/run/user/<uid>` exists (any login or linger);
- `DBUS_SESSION_BUS_ADDRESS`, when its `bus` socket exists too;
- `DISPLAY` and `XAUTHORITY` of that same user's graphical session (the one found when the
service started) when its X socket exists, plus `WAYLAND_DISPLAY` in a Wayland session. The
service starts at boot, so after a reboot a login that came later is picked up only when the
service restarts.
A variable the service already has with a value is never changed; an empty one is filled in. A
service running as root gets none of them: it never borrows another user's session. (One known
exception, older than this feature: a Shell call made at the very moment an AnnotatedSnapshot
sets up its accessibility connection can copy that session's variables.)
Start a GUI program detached, so it outlives the Shell call: `setsid -f obs >/dev/null 2>&1`, or
`systemd-run --user obs`. A plain `obs &` keeps the call's output open: the call waits until its
timeout and is then stopped together with everything it started, the program included.
With `DISPLAY` set, a command that would prompt (an `ssh` host-key question or passphrase,
`sudo -A`) may open a dialog on the screen (`ssh-askpass`) and wait there until the timeout,
instead of failing at once. Run such commands non-interactively: `ssh -o BatchMode=yes`, or
`SSH_ASKPASS_REQUIRE=never` before the command. The session bus can do the same: a program that
asks a locked keyring for a secret (git's credential helper, `secret-tool`) makes the keyring
show its unlock dialog on the screen. Run it with `env -u DBUS_SESSION_BUS_ADDRESS`, or with a
short `timeout`.
**Shell's `timeout` (#125).** The default is 120 s, and the server sets no upper limit: pass what
the command really needs (an installer, a driver query, a batch of firewall rules). A command that
outlives its timeout is stopped part-way (with everything it started) and the rest of it never
runs, so a change that is not idempotent stays half done; work it had already handed to a service
(an `msiexec` install) or a detached process may go on. The error says so ("Command timed out
after Ns and was stopped: … Pass a larger timeout …"). A gateway or client in between can end a
call earlier (the dev1 gateway after about an hour): start such work detached (`Start-Process` on
Windows, `setsid -f cmd >log 2>&1` elsewhere) or with TaskCreate, and read its result with a later
call. The default also bounds how long a stuck call (a prompt, a plain `prog &`) holds one of the
3 Shell slots a machine runs at once.
## One-command onboarding
**Add a new computer: run ONE line on it.** Nothing to copy from dev1, no key, no token.
> **Status (#101):** the public name `enroll-dev1.newlevel.media` needs dev1's named cloudflared tunnel + its
> DNS record (an airuleset infrastructure change). Until it resolves, the line installs the agent but its
> registration POST fails; use `remoteos-gateway enroll` (below) meanwhile.
Windows (PowerShell; it asks for Administrator itself):
```powershell
irm https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/enroll.ps1 | iex
```
Linux:
```bash
curl -fsSL https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/enroll-linux.sh | sudo bash
```
macOS:
```bash
curl -fsSL https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/enroll.sh | bash
```
The line runs the normal installer with dev1's permanent enrollment endpoint
(`https://enroll-dev1.newlevel.media/enroll/`) and dev1's public SSH key baked in. On top of a normal
install it:
- installs Python 3.12 for all users when the box has none (Windows);
- enables the OpenSSH server with dev1's public key (break-glass). On Windows the key goes to
`administrators_authorized_keys` for an administrator, else to the user's `authorized_keys`; on macOS a
run with no sudo leaves Remote Login off with a `[!]` line;
- posts hostname, addresses, port, version, OS and the agent key to the endpoint;
- when the install fails, posts the tail of its log too, so the failure is readable on dev1
(`remoteos-gateway enroll-log`) with nobody typing anything on the box.
**Nothing is exposed until dev1 accepts it.** The URL is public, so anyone can post: a registration only
waits in a queue (0600 files on dev1, deleted after 24 h), and `remoteos-gateway check` puts ONE item
"Nový počítač čaká na prijatie" into the owner's footer U while one waits. Accept it with the name and
the projects the owner gave:
```bash
remoteos-gateway enroll-list # what waits (never a key)
remoteos-gateway enroll-accept predaj3 --name win-predaj3 --org slovnormal --projects pos
remoteos-gateway enroll-reject <id> # junk or an unknown box: deleted with its key
remoteos-gateway enroll-reject --source <ip> # everything one address posted (or --all)
remoteos-gateway enroll-log [<id>] # install logs boxes posted
```
`enroll-accept <id|hostname>` (the hostname when only one registration has it) first asks the box's public
`/health` on each posted PRIVATE address (tailscale / LAN only, never a public or loopback one) whether it is
the host that posted; only then sends the key in one `initialize`, then stores it, adds the machine to the
projects in `projects.toml`, runs `sync-configs` and `check`, exactly as `enroll` does. `--url` names the
machine's `/mcp` url when the posted addresses cannot be reached from dev1 (a box behind a site's NAT), and
`--replace` overwrites a machine already in the key store. A failed accept leaves the registration queued.
The endpoint (`remoteos-gateway enroll-listen`, unit `deploy/remoteos-gateway-enroll.service`) binds
127.0.0.1:8817 only; dev1's named cloudflared tunnel publishes it. It takes `POST /enroll/` (the
registration, at most 16 KiB, validated), `POST /enroll/log` (at most 256 KiB) and `GET /healthz`, limits
each address (Cloudflare's `CF-Connecting-IP`; an IPv6 /64 counts as one) to 10 posts per 10 minutes and
everyone to 120 (registrations and logs on separate budgets), and keeps at most 50 registrations, 5 per
address. It never logs a key or a body. A registration expires after 24 h (`check`'s 10-minute timer prunes
the queue); `enroll-log` prints control characters as `?`. Compare the source address in `enroll-list`
before accepting by hostname.
The endpoint and the key live in `installers/enroll-values.conf`; `python3 scripts/build_installers.py`
bakes them into `enroll.ps1`, `enroll-linux.sh` and `enroll.sh`.
### The per-enrollment command (`remoteos-gateway enroll`, #26)
The older flow still works when dev1's operator is at the box: one command on dev1, one on the box.
```bash
remoteos-gateway enroll win-new-pc --org nlmedia --projects songplayer,camera-box
```
It opens a one-time public URL (a Cloudflare quick tunnel to airuleset's one-shot `secret request`
endpoint: dev1 needs `cloudflared` and tailscale), prints the command for each OS (on Windows, run it in
PowerShell as Administrator: the one-time URL does not cross a UAC prompt), waits up to an hour, and
finishes like `enroll-accept`. `--org` (`nlmedia` / `slovnormal`) is required; a project already holding
machines of the other company is refused before the box is touched (see "One company per project" below).
If a step on dev1 fails, the registration stays in the vault for an hour and `enroll` prints the command
that retries it. The public drop lane cannot be used, because Cloudflare Access answers a box with no login
with a 302.
The key never reaches a screen, an argv, a log or a ticket, in either flow. Without `REMOTEOS_ENROLL` an
install does none of this.
## MCP gateway (dev1)
The machines are reachable only from boxes with a LAN route to them. `remoteos-gateway`
runs on dev1, which has that route, and lets a **remote fleet consumer** reach a machine's
MCP. Example consumer: `david3@subdev` → `win-pjsnvs-pokladna`. The machine key never
leaves dev1.
- **Listens on dev1's tailscale address only:** `100.104.8.125:8796`. It refuses
`0.0.0.0` / `::`.
- **One URL per machine:** `http://100.104.8.125:8796/<machine>/mcp`. The machine name is
its name in the key store, `~/.config/remoteos-gateway/machines.json` (#51).
- **Per-consumer tokens, registered by hash only.** The gateway checks the consumer's
`Authorization: Bearer <token>`. It then forwards the request with the machine's own key,
read from the key store (never copied). The consumer token is never forwarded.
- **Every project of the owner goes through it too (#51):** each project's `.mcp.json` is
GENERATED from one manifest, so a machine key lives in ONE place. See
[Every project through the gateway](#every-project-through-the-gateway-51).
- **Transparent streaming proxy.** JSON and SSE responses stream back unchanged, including
`Mcp-Session-Id`.
| Answer | Meaning |
|---|---|
| 401 | missing token, or its sha256 is not registered |
| 403 | consumer known, but not allowed that machine |
| 404 | machine not exposed (or unknown path) |
| 503 + JSON-RPC `-32000` | the machine is down / unreachable, or missing from the master config |
### Run it
Install into a **dedicated venv** with the pinned `constraints.txt`. Never install into the
user's shared site-packages: that would move `fastmcp` / `mcp` for every other tool of that
account.
```bash
python3 -m venv ~/.local/share/remoteos-gateway/venv
~/.local/share/remoteos-gateway/venv/bin/pip install \
-c https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/constraints.txt \
"git+https://github.com/zbynekdrlik/remoteos-mcp.git@main"
ln -sf ~/.local/share/remoteos-gateway/venv/bin/remoteos-gateway ~/.local/bin/remoteos-gateway
cp deploy/remoteos-gateway.service ~/.config/systemd/user/
systemctl --user daemon-reload && systemctl --user enable --now remoteos-gateway
loginctl enable-linger "$USER"
curl -s http://100.104.8.125:8796/healthz # {"status":"ok","version":"..."}
```
To upgrade, re-run the `pip install` line with `--force-reinstall` added. pip does not
re-fetch a git URL whose version is already installed. Then run
`systemctl --user restart remoteos-gateway` and check that `/healthz` shows the new version.
### Add a consumer
1. **The consumer**, on its own box, generates a random token and keeps it `0600` in its
home. It sends **only the sha256** of the token (through a ticket).
- The hash is over the exact token bytes, with no trailing newline:
```bash
umask 077; python3 -c 'import secrets; print(secrets.token_urlsafe(32), end="")' > ~/.remoteos-gateway.token
sha256sum < ~/.remoteos-gateway.token # 64 hex chars — this is what you send
```
2. **On dev1**, register it and grant a machine. `consumer add` refuses anything that is not
64 hex characters, so a raw token can never be registered by mistake.
```bash
remoteos-gateway consumer add david3@subdev --sha256 <64-hex>
remoteos-gateway expose win-pjsnvs-pokladna # once per machine
remoteos-gateway allow david3@subdev win-pjsnvs-pokladna
```
3. **The consumer's** `.mcp.json`:
```json
"win-pjsnvs-pokladna": {"type": "http",
"url": "http://100.104.8.125:8796/win-pjsnvs-pokladna/mcp",
"headers": {"Authorization": "Bearer <its own token>"}}
```
### Revoke, inspect
```bash
remoteos-gateway deny david3@subdev win-pjsnvs-pokladna # take one machine away
remoteos-gateway consumer revoke david3@subdev # remove the consumer entirely
remoteos-gateway consumer revoke david3@subdev --sha256 <hex> # retire one token (rotation)
remoteos-gateway unexpose win-pjsnvs-pokladna # kill switch for everyone
remoteos-gateway list # machines, consumers, hash prefixes
remoteos-gateway log --consumer david3@subdev --tail 50 # who called what, when
```
Every edit is written atomically to `~/.config/remoteos-gateway/registry.json` (`0600`). The
running gateway applies it on the next request, so no restart is needed. To force a re-read,
run `systemctl --user reload remoteos-gateway` (SIGHUP).
A registry that turns invalid is never applied: the last good copy stays and an error is
logged. A deleted registry denies everything.
**Logs:**
- `journalctl --user -u remoteos-gateway` — operational log: decisions, reloads, errors.
- `~/.local/state/remoteos-gateway/access.jsonl` — one line per request: time, consumer,
machine, JSON-RPC method, tool name, status, duration. It never holds a token, a key, or
tool arguments. It rotates to `.1` at 20 MiB.
### Every project through the gateway (#51)
Before #51, every project config held its own copy of each machine key. A key change made
every copy stale, and every running Claude Code session kept sending the old key until the
owner reconnected it. Now:
- **One key store** — `~/.config/remoteos-gateway/machines.json` (`0600`, dir `0700`), on
dev1: `{"<machine>": {"url": "http://<box>:8092/mcp", "key": "<key>", "org": "nlmedia"}}`.
It is the gateway's machine source (`serve --machines`, the default).
- **One manifest** — `~/.config/remoteos-gateway/projects.toml`: per project, where its
config lives and which machines it may reach.
- **Generated configs** — `remoteos-gateway sync-configs` writes each project's config. Each
fleet entry keeps its server NAME (so `mcp__win-stream-snv__Shell` stays) and points at the
gateway with the project's own token. Every other entry (n8n, playwright, …) stays byte-equal.
- **A drift watchdog** — `remoteos-gateway check`, every 10 minutes (a user timer).
| Task | Do this |
|---|---|
| A machine's key changed | `remoteos-gateway machine set-key <machine>` with the key on stdin. Every project routed through the gateway gets it on its next call: no config change, no reconnect. The direct remoteos-mcp copy is refreshed by `remoteos-gateway sync-configs`. |
| Add a machine to a project | Add it to the project's `machines` in `projects.toml`, then `remoteos-gateway sync-configs`. Running sessions reach it at once through the `fleet` server; its typed `mcp__<machine>__*` tools arrive with the next restart. |
| Add a NEW machine | `remoteos-gateway machine set-key <machine> --url http://<box>:8092/mcp --org <nlmedia\|slovnormal>` (key on stdin), then the step above. |
| Remove a machine (sold, gone) | `remoteos-gateway machine remove <machine> [<machine> ...] [--dry-run]`: out of `projects.toml` (comments kept), the key store, the registry (unexposed, out of every allow-list), then the normal `sync-configs`, which drops its entries from every config, the direct one included. All or nothing; it refuses when a project would be left with no machines (it names the project: remove or edit that project first). The next `check` forgets it (status file and `fleet-down`). |
| Rename a machine | `remoteos-gateway machine rename <old> <new> [--dry-run]`: the key-store entry moves as it is (url, key, org, repair recipe), the manifest gets the new name in place, exposure and every consumer's access carry over (a kill-switched box stays unexposed), then `sync-configs` (the old entry goes, the new one comes). A NEW name still left in the registry (exposed or allowed after a hand removal) is refused. If either command stops half way it prints the steps done; rerun the same command to finish. |
| Set a machine's company | `remoteos-gateway machine set-org <nlmedia\|slovnormal> <machine> [<machine> ...]` (all or nothing; keys are never shown). |
| A box switched off after hours (a pokladna) | `remoteos-gateway machine set-sleep <machine> on` (`off` undoes it). `check` then reports it only when it has not come up today, see "Boxes that sleep after hours" below. |
| A box switched on only now and then (a notebook) | `remoteos-gateway machine set-sleep <machine> occasional` (`on` / `off` change it back). `check` then never puts it in the owner notice while it is off (unreachable), however long (a `401` or `error` is still reported, it means the box is on and broken); its real state stays in `check`'s output and the `fleet` server. |
| Add a project | One `[projects.<name>]` table in `projects.toml`, then `remoteos-gateway sync-configs`. |
| See what would change | `remoteos-gateway sync-configs --dry-run` (every key and token masked). |
| See the machines | `remoteos-gateway machine list` (keys masked, org and `sleep on/off/occasional` per machine, counts per org) and `~/.local/state/remoteos-gateway/machines-status.json`. |
**One company per project (#105).** Every machine belongs to one company: `org` in the key store,
`nlmedia` or `slovnormal` (Slovnormal / Pekárova žena); `machine list` shows which box is which.
Any other value is refused.
- `sync-configs` refuses the whole run, changing nothing, when a project's machines belong to two
companies. The fleet-ops project `remoteos-mcp` is the only exception (`sync.CROSS_ORG_PROJECTS`
in the code, so no project can declare itself one).
- A machine with no org still serves through the gateway, but `sync-configs` refuses to run while a
manifest machine has none, and `machine list` prints `org MISSING` plus a warning. There is no
default: a forgotten Slovnormal box must not pass as nlmedia.
- `machine set-key --url` (a new machine) and `enroll` require `--org`; neither changes the org of a
known machine (that is `machine set-org`, which warns about every project it would mix); `machine import` adds a new
machine with no org (set it with `set-org` before the next `sync-configs`) and keeps the org of a
known one.
- The `fleet-down` owner notice stays one text, its boxes grouped under `Slovnormal:`, `nlmedia:`
and `bez organizácie:`. `check` writes each machine's `org` into the status file for this.
The manifest:
```toml
[gateway]
url = "http://100.104.8.125:8796"
[projects.camera-box]
host = "dev1" # where the project's sessions run (dev1 | dev2)
account = "newlevel" # whose ~/.claude it is
config = "~/.claude/mcp-configs/camera-box.mcp.json"
machines = ["win-stream-snv", "linux-cam1", "linux-cam2"]
[projects.remoteos-mcp] # keeps DIRECT entries: it debugs machines when the gateway is down
host = "dev1"
account = "newlevel"
config = "~/.claude/mcp-configs/remoteos-mcp.mcp.json"
mode = "direct"
machines = ["win-stream-snv", "linux-cam1", "linux-cam2"]
```
**How `sync-configs` behaves:**
- **The consumer.** For each project it keeps a consumer `<project>@<host>` in the registry,
marked `"managed_by": "sync-configs"`.
- Its token is minted once and lives only in the generated file.
- Its allow-list is EXACTLY the manifest's `machines`: a machine removed there leaves the
allow-list AND the config.
- A managed consumer whose project left the manifest loses every machine but keeps its token,
so putting the project back needs no new token and no restart. `sync-configs --prune`
removes such consumers. A manifest with no projects at all is refused.
- A hand-made consumer of the same name is never taken over.
- A write that fails after it may have landed (an ssh drop) keeps the last confirmed AND the
new token registered; the next run keeps whichever the file holds. However many writes
fail, the token the file holds stays registered and no more than two are.
- **What it writes.** It writes only fleet entries, and only when an entry changes: a config
whose entries are already right keeps its own layout, byte for byte. It first backs the file
up to `.backup-<date>/` next to it, then writes atomically with mode `0600`. A second run
changes nothing. The backups hold the OLD keys and tokens: delete them once the migration
is verified.
- **What it leaves alone.** An entry it did not generate stays as it is, even when its name
is in the key store, and it is reported (`! … not in the manifest`). For example, a direct
entry for a machine that dev1 cannot reach.
- **Direct entries it wrote (#109).** `~/.config/remoteos-gateway/sync-direct.json` (next to the
registry, urls only, never a key) records which entries sync wrote into each `direct` config.
A recorded entry whose machine left the key store is removed on the next run; a hand-made
entry is never recorded, so it stays. The first run after the upgrade seeds the record from
the entries already at the key store's urls (`--dry-run` says it would) and removes nothing
extra; a failed write keeps both the old and the new entries recorded.
- **Where it writes.**
- dev2 configs: over `ssh -o BatchMode=yes <account>@dev2`.
- Another account's configs: over `sudo -n -u <account>`.
- The file content travels on stdin only. When that access is missing, the command prints
the exact one-time step (`ssh-copy-id …`, or the sudoers line) and syncs the other
projects.
- **Exposure.** It never re-exposes a machine (`unexpose` stays a kill switch); it warns
instead. `machine import` and `machine set-key --url` expose only machines NEW to the key
store, and never one a consumer already allows while it is unexposed (a kill switch engaged
before #51); the import's dry run lists what it would expose.
- **Fail closed.** A manifest machine missing from the key store, an invalid or empty manifest
or key store, or `mode = "direct"` for any account but the gateway's own on dev1 refuses
the whole run before anything changes. An unparseable config is never overwritten.
- After a project's config changed, its RUNNING sessions need ONE restart (Claude Code reads
`.mcp.json` only at start). After that, a key change never reaches a session again.
**The `fleet` server: a new box without a restart.** Every gateway project also gets one entry
`fleet` (`<gateway>/fleet/mcp`, the project's token). Its three tools never change, so a machine
added later works in a session that is already running:
| Tool | What it does |
|---|---|
| `ListMachines()` | The machines this token may use, with `reachable`, `os`, `hostname`, `version`. A box that is down is listed as unreachable within a few seconds: the probes run in parallel and each has a bound. |
| `MachineTools(machine)` | That machine's tools with their schemas. |
| `Call(machine, tool, arguments)` | One tool call. Images and multi-content results pass through, and a tool's failure stays a tool error. |
```text
mcp__fleet__Call machine="win-new-box" tool="Shell" arguments={"command": "hostname"}
```
- **Same access.** `Call` goes through the same code as `/<machine>/mcp`, with the project's token:
same allow-list, same `unexpose` kill switch, same access log. A machine outside the allow-list
is refused and is absent from `ListMachines`. An audit line shows the machine and tool, never
the arguments.
- **Live.** A line in `projects.toml` + `sync-configs`, a `machine set-key`, an `unexpose`: each
takes effect on the next call of a running session.
- **The per-machine entries stay.** They have typed tools, so use them when they exist. `fleet` is
the way to a box that has no server of its own in this session yet.
- **Direct projects get no `fleet` entry:** remoteos-mcp stays independent of the gateway.
- **Limits.** A `Call` reply is at most 20 MB on the wire, and 32 MB across all calls in flight; over
that it is an error ("try again" when only the second limit was hit). A text result counts twice
(`content` + `structuredContent`), so that is about 9 MB of text, or a FileDownload of about
7 MB. Bigger files go through `remoteos-call get` or the machine's own server, which stream.
Progress messages of a running tool do not reach the caller.
- **Names.** `fleet` is reserved, so no machine can have it. A `fleet` entry with another url is
kept, with a warning, and that project gets no fleet server.
- **Rollout order.** Upgrade the gateway FIRST, then `sync-configs`: the old gateway treats
`/fleet/mcp` as a machine and answers 403. Before the upgrade, no machine named `fleet` may be
in `machines.json` or `registry.json`: the new gateway refuses such a file.
**Releases (stable and canary):** CI creates GitHub release `v<version>` on every merge to `main`,
after all test jobs passed (`scripts/create-release.sh`, a no-op when it exists).
- `canary` = the newest release that is not held.
- `stable` = the newest release that is not held and at least `REMOTEOS_SOAK_DAYS` old (default 14).
- **Hold a bad release:** mark it "pre-release" in the GitHub UI. Everything ignores it from then on.
- `remoteos.release_channel` is the resolver; `check` uses it, the per-box updater (#65) will too.
**Restart list:** after a real `sync-configs`, every project whose config was written is scanned
where it lives (local, `sudo -n`, ssh) for live Claude sessions: `claude` processes whose cwd's
`.mcp.json` resolves to that config, with their tmux pane. ONE text names them with
"spusti `/exit` a `claude -c`". It is printed and logged ONLY: owner ROZHODNUTÉ 2026-11-17
(#109) — no notify, no `restart-<project>` U item, and `sync-configs` has no notify options. No
live session, no text. `--dry-run` prints which sessions a real run would affect. A failed scan
is reported in the output and never fails the sync. `check` clears any `restart-<project>`
notice an older version left in U, once.
**`check` (the watchdog):**
- **What it probes.** Every key-store machine directly with its stored key (`initialize`),
plus the gateway's `/healthz`.
- **What it records.** `ok` / `401` / `unreachable` / `error`, with `since`, in
`machines-status.json`.
- **Notifications.** It announces each state change ONCE, through
`~/devel/airuleset/airuleset.py notify --body` (owner from
`REMOTEOS_GATEWAY_NOTIFY_OWNER`). Without airuleset it writes a log line instead. A
notification that did not go out (airuleset printed neither `sent`, `dedup` nor `suppressed`)
is retried on the next run. `suppressed` means the owner's airuleset policy posts nothing for
this kind of message: it counts as handled, and the text stays in the journal. A check that
cannot run at all (an invalid key store) is announced once too, exits 1, and its recovery is
announced.
- **Owner notices in the footer U (#102).** When the installed airuleset has `notify
--owner-notice` (airuleset #1300; read once per run from `notify --help`), every open
condition is a notice with a slug. The machine conditions are ONE notice per KIND, never one
per box (owner ruling 2026-11-16: 17 unreachable boxes must not be 17 U items):
- `fleet-down` lists every box that is not ok (unreachable / 401 / error) with its state,
- `fleet-stale` every box behind the stable release, `fleet-no-admin` every box without admin.
- **Boxes that sleep after hours (#118, owner 2026-11-17).** A machine with `may_sleep`
(`machine set-sleep <machine> on`) is left out of `fleet-down` while it is not ok, unless it
has not been ok at any moment since local midnight (Europe/Bratislava) and it is 10:00 local or
later; then it is reported like any other box. So a pokladna closed at 18:00 raises nothing
overnight, and one that did not come up by 10:00 is reported. A box without the flag is reported
at once, as before. `check`'s output and the status file still show its real state
(`unreachable`, marked `asleep (may_sleep)`); each record keeps `last_ok` (the last run that saw
it ok). Waking up after an unreported night is not news; a box that WAS reported announces its
recovery as usual. The rule applies to the plain messages too. A box still down after a reported
day drops out of the item at midnight and comes back at 10:00 (the rule is per day).
- **Boxes switched on only occasionally (#130, owner 2026-11-19).** `machine set-sleep <machine>
occasional` (key store `"occasional": true` next to `"may_sleep": true`; `occasional` without
`may_sleep` is refused) is for a notebook that is off for days or weeks: it is left out of
`fleet-down` and the plain messages whenever it is off (`unreachable`), at any hour, however
long. One that answers `401` or `error` is on and broken: the after-hours rule above applies. `check`'s
output marks it `asleep (occasional)`, the status record carries `occasional: true`, and the
`fleet` server shows its real state. Coming back up is not news, even after it was reported
before it was made occasional. Switching a reported box to occasional re-sends `fleet-down`
without it (or clears the item when it was the only box).
When the set of boxes (or a box's state) changes, the same slug is sent again with the new text
and replaces the item; when the set is empty the slug is cleared. What each kind's last
delivered text said (a fingerprint: the boxes with their state, version or stable tag) is kept
in the status file (`fleet_notices`), so a run that had to send plain does not re-send it. The
texts carry no day counts ("pozadu od <dátum>"), so an unchanged item stays true. Only a
changed SET of boxes is news (#109): the same boxes with another state, version or org, or a
fingerprint written by an older release, are not re-sent, so an item the owner acknowledged
does not come back after a deploy. The other slugs are `gateway-health` and `check-failed`. A suppressed notice becomes one item in the footer `U` of the
remoteos-mcp checkout, and `notify --clear-owner-notice <slug>` drops it once the condition is
gone (no box down, behind or without admin; the gateway answers; the check runs; an
old `restart-<project>` left by an earlier version is cleared once). A box going back to ok is plain news, not a U item. The
recorded slugs live in `~/.local/state/remoteos-gateway/owner-notices.json`; a clear that fails
stays there and is retried on the next run, and an old per-box slug (`state-<box>`,
`stale-<box>`, `no-admin-<box>`) still in that file is cleared once and forgotten. A notice
airuleset did not record (exit 1) is not delivered and is retried too. Without the flag, the
notices are the plain, grouped messages above.
- `--notify-project-dir` (env `REMOTEOS_GATEWAY_NOTIFY_PROJECT_DIR`, default
`~/devel/remoteos-mcp`) is airuleset's `--cwd`, passed explicitly because the unit runs in
`$HOME`. It must be a git checkout root and not `$HOME`; otherwise an error is logged and the
plain notices are sent. `--notices-file` (env `REMOTEOS_GATEWAY_NOTICES_FILE`) moves the book.
- **Fleet version drift.** It records each machine's `/health` version (`machine list` shows the
last one seen) and compares it with the stable release:
- A box older than stable for more than 3 days is reported once, with its version and days,
until it catches up.
- A box that does not answer keeps its last version and is not judged.
- A failed read of the release list skips drift for that run (a log line), nothing else.
- **Auto-repair of a 401** happens only for a machine with an explicit recipe:
`remoteos-gateway machine repair-recipe linux-cam2 --ssh root@cam2.lan [--sudo]`.
- The recipe reads the box's installer `config.json` (`/etc/remoteos-mcp/config.json`)
over ssh.
- It stores the key only if the machine accepts it.
- Without a recipe, a 401 is only reported, never guessed.
```bash
cp deploy/remoteos-gateway-check.service deploy/remoteos-gateway-check.timer ~/.config/systemd/user/
systemctl --user daemon-reload && systemctl --user enable --now remoteos-gateway-check.timer
journalctl --user -u remoteos-gateway-check # each run's table
```
**Migrating from hand-written configs (once, on dev1):**
1. Upgrade the gateway venv (the `pip install … --force-reinstall` line above). Do NOT restart
it yet: the new version reads the key store by default.
2. Write `projects.toml` from today's configs (one table per project, `machines` = its fleet
entries).
3. Build the key store: `remoteos-gateway machine import --from-manifest --dry-run`, then
without `--dry-run`. For each machine, the copy the machine accepts wins; every conflict
and every machine it could not verify is listed. A machine the key store already has
keeps its entry unless a copy AT ITS URL verifies (a copy at another url needs
`--accept-url-change`). An unreadable `--from` file, or no machine at all, writes nothing
and exits 1.
4. `systemctl --user restart remoteos-gateway` (it now reads the key store), then check
`/healthz`.
5. `remoteos-gateway sync-configs --dry-run`, review, then `remoteos-gateway sync-configs`.
6. Install the check timer, and restart each project's sessions once.
**Adding the org to an existing key store (0.7.0.dev58, #105):** upgrade the venv, restart the
gateway (an older gateway refuses a key store with `org`, an unknown key: at reload it keeps its last
good copy), then `remoteos-gateway machine set-org slovnormal <boxes...>` and `machine set-org nlmedia
<the rest...>`, check `machine list` shows no `org MISSING`, then `sync-configs`. The `fleet-down` U
item is sent once more after the upgrade (its fingerprint now holds the org) and after each org change of
a down box; it replaces the same item. Rolling back below
0.7.0.dev58 needs the `org` fields removed from `machines.json` first.
**Turning on `may_sleep` (0.7.0.dev64, #118):** upgrade the venv and restart the gateway FIRST, then
`machine set-sleep <machine> on` for each after-hours box. An older gateway refuses a key store with
`may_sleep` (an unknown key): at reload it keeps its last good copy, at a start it refuses. Rolling back
below 0.7.0.dev64 needs `machine set-sleep <machine> off` for each one first (off removes the key).
**Turning on `occasional` (0.7.0.dev66, #130):** the same order: upgrade the venv and restart the
gateway FIRST, then `machine set-sleep <machine> occasional`. An older gateway refuses the `occasional`
key the same way. Rolling back below 0.7.0.dev66 needs `machine set-sleep <machine> on` (or `off`) for
each one first. A key store without the key reads exactly as before.
**Rolling back** to a gateway older than 0.7.0.dev33 after `sync-configs` has run: the old
version rejects the registry's `managed_by` field (an unknown key) and refuses to start. Drop
the field from `~/.config/remoteos-gateway/registry.json` first, and point `--machines` back
at `~/.claude/mcp-configs/remoteos-mcp.mcp.json` (the old default).
## Scripts: `remoteos-call` (#70)
A script reaches a machine through MCP with `remoteos-call`, never `sshpass ssh`/`scp`. It ships
in the package (console script, module `remoteos.cli_call`). On dev1 it is in the gateway venv:
`~/.local/share/remoteos-gateway/venv/bin/remoteos-call`.
```bash
remoteos-call --list # the fleet machines in the config
remoteos-call linux-stream-snv Shell 'sudo -n true; echo ok' # stdout, stderr, the remote exit code
remoteos-call linux-stream-snv Shell 'make' --cwd /opt/app --timeout 500
remoteos-call linux-stream-snv put ./big.deb /tmp/big.deb # any size, sha256-checked, atomic
remoteos-call linux-stream-snv get /var/log/syslog ./syslog # FileDownload, size-checked
remoteos-call win-resolume-pp GetSystemInfo --json '{}' # any tool, its text on stdout
```
**Which config.** `--config PATH`, else `--project NAME` (reads
`~/.claude/mcp-configs/NAME.mcp.json`, the file `sync-configs` writes), else `./.mcp.json` in the
current directory. The machine entry's `url` and `Authorization` header are read the way the
gateway reads them (`gateway/registry.py`: any spelling of the header name, an http(s) url with
a host). Only `win-…`, `linux-…` and `mac-…` entries count as machines. The token is read from
that file only: it is never in an argv, an output line or a log record. The request goes
straight to the url: `HTTP(S)_PROXY`, `~/.netrc` and `SSL_CERT_FILE`/`SSL_CERT_DIR` are ignored
(an https url is verified against the system trust store).
**Exit codes:**
| Code | Meaning |
|---|---|
| Shell: N | the remote command's exit code. A code outside 0..255 is 255 (a POSIX signal `-S` is 128+S), and one stderr line names the real code. |
| 0 | put/get/any other tool succeeded |
| 125 | the tool failed (the MCP result is an error: `Command timed out after 120s and was stopped: …`, `File not found: …`, `Unknown tool: …`, invalid arguments), or a put/get size or sha256 check failed |
| 126 | the CLI got no result: no or broken config, an unknown machine, connection refused, 401/403/404, 413 (request too large), no reply in time, a dropped connection, a local file it cannot read or write. After a timeout or a dropped connection the remote command MAY have run, or may still run: do not blindly retry a command that is not idempotent. |
| 130 | interrupted (Ctrl-C); the remote command may still run |
| 141 | stdout was closed (a broken pipe, e.g. `\| head`) |
| 2 | a usage error |
The CLI's own failures are always ONE stderr line that starts with `remoteos-call:`. A remote
command that itself exits 125, 126, 130 or 141 prints no such line. On Ctrl-C the CLI exits 130
rather than dying from the signal, so a bash loop over machines carries on: check for 130 to
stop it. Ctrl-C while the CLI is still starting (its first fraction of a second, the imports)
gives Python's own traceback.
**Server version.** Machines must run remoteos-mcp 0.7.0.dev28 or later (#32). Before that, a
failing tool answered with success text (`Error in Shell: …`) and the CLI would exit 0.
**Shell.** stdout goes to stdout and stderr to stderr, exactly as the command wrote them (ANSI
escapes included): Shell's structured content carries `stdout`, `stderr` and `exit_code` next to
the text. Structured content goes out next to the text, so a reply is twice its output on the
wire: the 256 MiB reply limit means about 128 MiB of output. `--timeout` (default 120 s) is Shell's own
timeout; the client waits 60 s more. Through the gateway a call must answer within 3700 s (its
upstream read timeout), so `--timeout 3600` is the most a call can use, and a machine runs at most
3 Shell calls at once (a fourth waits 60 s, then fails). Use `--` before a command
that starts with `-`. `sudo` inside Shell works without a password on the Linux MCP boxes (#67).
A server older than 0.7.0.dev43 sends only the text. Structured content goes out next to the text, so a reply is twice its output on the
wire: the 256 MiB reply limit means about 128 MiB of output. The CLI then parses it, prints each stream
with one trailing newline, and some output cannot round-trip:
- leading whitespace of stdout and trailing whitespace of the last part are lost, and blank
lines at the end of either stream;
- a stdout line that starts with `[STDERR] ` is read as the start of stderr;
- a LAST line `[Exit code: N]` printed by the command itself is read as its exit code;
- a command whose whole output is `(no output)` prints nothing.
**put / get.** A machine takes at most 4 MiB per request (the mcp transport's limit; the gateway
allows 16 MiB), so `put` sends the file in 2.5 MB chunks to `<remote>.part` (FileUpload
`append`), checks its size and sha256 (FileHash), then renames it over the target (FileRename).
Any failure leaves the target as it was and may leave the `.part`, which the next `put` replaces
(so a file of yours called `<remote>.part` is overwritten); two `put`s to the same target at once
are not supported. The `.part` starts with an existing target's permissions, and the new file takes
its POSIX mode and group (as root, its owner too), not its ACLs or extended attributes. A symlink
is written through, a target the account may not write is refused, and the `.part` must be on the
target's filesystem. `put` needs remoteos-mcp 0.7.0.dev43 or later (an older server: exit
125, nothing written). `--timeout` is the wait of each call, not of the whole `put`. `get` checks the byte count FileDownload declared, then writes the local file like `cp` (through a
symlink, an existing file keeps its mode, a new one gets `0666 & ~umask`), but through a fsynced
temp file in the same directory, so never a half-written file. A `get` reply may be up to
256 MiB of base64 (about 190 MB of file). `--timeout` is how long the client waits (default 300 s).
**Any tool.** `--json` passes the tool's arguments as a JSON object; the reply's text goes to
stdout. A non-text block is named, never dumped: a Snapshot prints `[image block: image/jpeg]`
and then its text. A call
that declares its runtime (Shell's `timeout`, Wait's `seconds`, WaitFor's `timeout`) is waited for that long plus
60 s, unless `--timeout` says otherwise.
## Uninstall
```powershell
# in an elevated PowerShell
irm https://raw.githubusercontent.com/zbynekdrlik/remoteos-mcp/main/uninstall.ps1 | iex
```
## Security
- Auth key is required for all connections
- The key is kept in owner-only files and reaches the server through `REMOTEOS_AUTH_KEY`, never
its command line (`ps`, Task Manager), a unit file or the installer output. The server drops
it from its environment at start, so no tool child inherits it; its initial process
environment (`/proc/<pid>/environ`) still holds it, readable by root and by the account the
server runs as (on a desktop box: the desktop user's own programs)
- The Windows firewall rule allows inbound TCP 8092 on all profiles (it survives network
drift); the server binds 0.0.0.0, so keep the machines on a trusted network
- On LAN this is fine over HTTP
- For internet exposure, use TLS reverse proxy or SSH tunnel
- **Bind guard (#39):** a non-loopback bind (`0.0.0.0`, a LAN or tailnet address) with no auth
key refuses to start (exit 2) while any Tier 3 tool (Shell, files, services) is enabled. With
Tier 1/2 only it starts with a warning. `--enable-all` with a key, the way every installer
starts, is unaffected
- **Caller values never become code (#39):** a value put into a PowerShell script (service and
task names, EventLog's log name, App's path and arguments) is a single-quoted literal; the
toast title and message reach PowerShell in environment variables. macOS AppleScript strings
escape `\` before `"`
- **Scrape (#39):** http(s) only, at most 5 MiB read (a larger body is an error; a redirect's own
body is never read). LAN and private
addresses are allowed; `--scrape-block-private` (or `scrape_block_private = true` under
`[security]` in `remoteos.toml`) refuses them, every resolved address and redirect checked
- **OAuth (optional, off unless `--oauth-client-id`/`--oauth-client-secret`, #39):** PKCE S256
only; redirect URIs must be `https://` or loopback `http://`; a configured client secret is
required at the token endpoint and never returned by registration. The authorize endpoint
approves every client, so OAuth WITHOUT `--oauth-client-secret` lets anyone obtain a token
(accepted next to the auth key): never turn it on without a secret (the server warns at start)
- **App (Windows):** the name and the arguments are taken literally since #39: `$env:VAR` or
`$(...)` in them is no longer expanded by PowerShell
- **`remoteos.toml` booleans** are real TOML booleans or the strings `true`/`false`/`1`/`0`/
`yes`/`no`; anything else stops the server with an error naming the key (#39)
- **Dependency audit (#39):** CI runs `pip-audit -r constraints.txt` (Python 3.12 on Linux,
Windows and macOS, and 3.11 on Linux) with no ignore list; a finding is fixed by upgrading the
pin. Python 3.11 is the floor since #64 (Pillow 13, the fix of its CVEs, needs it), so every
supported pin set is audited
## Powered by
- [WinRemote MCP](https://github.com/dddabtc/winremote-mcp) - the actual MCP server (40+ tools)
- [Model Context Protocol](https://modelcontextprotocol.io) - the transport layer
This server cannot be deployed
Maintenance
ActivityActive
ResponsivenessNo recent community issues