# glovebox-mcp
A **sandboxed computer-use MCP server** — let an AI agent drive a real browser and desktop apps
(mouse, keyboard, screenshots, clipboard, vision grounding), confined to a **nested X11 window** so
its input and vision never touch your real screen or the windows of your other apps.
Like a lab **glovebox**: the agent reaches in and manipulates real applications, sealed off from
your desktop. Bring the sandbox up, log into whatever sites or apps you want to automate *inside
that window*, and the agent operates only there — you can watch it live and close it instantly.
> Speaks the [Model Context Protocol](https://modelcontextprotocol.io), so it works with MCP clients
> like Claude Code. Your host can run Wayland; the sandbox gives the agent a real X server to drive.

An agent driving a real browser in the sandbox — gliding the cursor, inserting a unicode name (`Nadja Kovačič`), typing, and submitting. All confined to a nested X11 window.
## Why a nested X11 sandbox?
- Most desktop automation (xdotool, PyAutoGUI) is **X11-only**, but many modern desktops run **Wayland**.
- **Xephyr** provides a real X server *inside a single window* (`DISPLAY :1`). Everything the agent
does — clicks, typing, screenshots — is **confined to that window**, not your real desktop.
- You stay in control: watch it live, `pkill Xephyr` to close everything.
The isolation is **display-level** (see [Safety](#safety)): the apps themselves run as your user with
your filesystem. For OS-level isolation run glovebox inside a VM or container.
## Requirements
- **Linux** — the sandbox nests a real X server (Xephyr), so it works even on **Wayland** hosts
(via Xwayland). Developed on Ubuntu; any modern Linux with the packages below.
**macOS / Windows, or a Linux you do not want to install packages on:** use
[container mode](#container-mode-docker) — it needs only Docker.
- **Python 3.10+** and [`uv`](https://docs.astral.sh/uv/) (used for the virtualenv).
- **System packages** — `xserver-xephyr` (Xephyr), `openbox`, `scrot`, `x11-utils`, `x11-xkb-utils`
(xkbcomp: gives the sandbox your keyboard layout), `xdotool`, `wmctrl`, `xclip`, optional `at-spi2-core` + `gir1.2-atspi-2.0` + `python3-gi` (focus check in native apps) (+ `tesseract-ocr`
for `basic`). On Debian/Ubuntu the installer **auto-installs**
them via `apt` (sudo); on Fedora/Arch it prints the matching `dnf`/`pacman` command. The MCP server
itself is distro-agnostic — any Linux with these tools works. `openbox` is not optional in
practice: without a window manager Xephyr ignores synthetic pointer motion, so clicks would land in
the screen center (`launch_app` warns when it is missing).
- A **browser** in the sandbox (Chromium, Chrome, Brave, Edge, Vivaldi or Opera).
- **NVIDIA GPU (≥6 GB VRAM)** — only for the `local` vision mode. The server checks this itself
(`status()` → `vision.gpu`) and `auto` falls back to `basic`/`none` when it is not met.
## Install
One command. Run on a terminal with no arguments, the installer **asks** — on this desktop or in
a Docker container, which vision backend or app set, whether to install the Claude Code skill —
offering only what this machine can run (it shows the GPU and whether Docker is there), then
prints the plan as the equivalent command and installs after a last Enter:
```bash
git clone https://github.com/segentic-lab/glovebox-mcp && cd glovebox-mcp && ./install.sh
```
```
Glovebox installer
This machine: Linux x86_64 · GPU: NVIDIA RTX A5000 (16384 MiB) · Docker: found
Where should the sandbox run?
1) On this desktop — the apps and logins you already have, as windows on your screen
2) In a Docker container — only Docker is installed; apps cannot see your files; you watch it in a browser tab
Choice [1]:
…
Plan — the same as running: ./install.sh container --apps full --no-skill
Proceed? [Y/n]:
```
Every question has a default, so Enter all the way through is `./install.sh auto`. Nothing is
asked when a mode is named (`./install.sh auto`, `basic`, `container`, …), with `-y`/`--yes`, or
when the script is not on a terminal (piped, CI) — those behave as before. `--plan` prints what
would be installed and stops.
Natively, the installer probes the GPU, installs the system packages (auto via `apt` on
Debian/Ubuntu; it prints the line for dnf/pacman), creates the Python env from `pyproject.toml`,
downloads the vision models the machine can run, writes `mcp-config.json` **and** `.mcp.json`
(Claude Code) with your paths, and installs the Claude Code skill.
What `auto` picks: an NVIDIA GPU with ≥ 6 GB VRAM → **`local`** (OmniParser + ScreenParser, typed
elements; ~4 GB of downloads, `--no-screenparser` skips the 153 MB detector); otherwise
**`basic`** (Tesseract OCR, CPU). Tesseract is installed in every mode — the server's own `auto`
backend selection falls back to it when the GPU is busy. Force a mode with `./install.sh none|basic|local`;
`./install.sh skill` installs only the skill; `--no-skill`, `--dev` (pytest) are the other flags.
Re-running is safe: it only downloads what is missing.
The requested mode is written to `.vision-mode` (`auto` unless you forced one; override per run
with the `GLOVEBOX_VISION` env var). `python vision.py check` prints the same diagnosis `status()`
returns (GPU, weights, detector, tesseract).
### Container mode (Docker)
The same server in a Linux container, for hosts that are not Linux (macOS, Windows) or when the
sandbox should not have your files. Nothing but Docker is installed on the machine:
```bash
git clone https://github.com/segentic-lab/glovebox-mcp && cd glovebox-mcp && ./install.sh container
# or, without the installer: docker compose up -d --build
```
```
container "glovebox" (long-lived; survives agent sessions, restarts with Docker)
Xvfb :0 + openbox + noVNC a desktop nobody sits at — you watch and use it in a browser:
│ http://localhost:6080/vnc.html?autoconnect=1&resize=scale
├─ Xephyr :2 ── chromium one window per instance, exactly as on a real desktop
└─ Xephyr :3 ── …
each agent session: docker exec -i glovebox glovebox-server (MCP over stdio)
```
MCP client config — either form:
```jsonc
// 1. the launcher: starts the container when it is not running (needs python3 on the host)
{ "command": "python3", "args": ["/path/to/glovebox-mcp/container.py"] }
// 2. plain Docker: the container must already be up (`docker compose up -d`)
{ "command": "docker", "args": ["exec", "-i", "glovebox", "glovebox-server"] }
```
An existing native install switches with one line in its config: `"env": {"GLOVEBOX_MODE": "container"}`
— `server.py` then hands the session to the container instead of driving your desktop.
What is different from native mode — `status()` says so in `container` and `notes`:
| | Native | Container |
|---|---|---|
| Isolation | display only: apps run as you, with your files | the container: apps see only `container-data/files` and `container-data/profiles` |
| Apps | everything installed on your machine | the image's app set (below); `status().container.apps.installed` lists them |
| Logins | your per-instance profiles in `profiles/` | `container-data/profiles` — log in once through the web viewer; kept across rebuilds |
| Where you watch | windows on your desktop | the web viewer, published on `127.0.0.1` only (`GLOVEBOX_VNC_PASSWORD` adds a password) |
| Grounding | accessibility, OCR, or OmniParser on your GPU | accessibility and OCR; optionally your GPU through the host's vision service (below) |
| File paths in replies | host paths | container paths (`/app/files//…` = `container-data/files//…` on the host) |
Chromium runs with `--no-sandbox` in the container, because Docker's default seccomp profile
forbids the user namespaces its sandbox needs; `status()` reports it (`container.browser_sandbox`).
The container itself is then the isolation layer. Start the container with a seccomp profile that
allows user namespaces and Glovebox keeps Chromium's sandbox on by itself.
**App sets** — chosen when the image is built:
| Set | Apps | Image size |
|---|---|---|
| `browser` (default) | Chromium | ~1.8 GB |
| `basic` | + Mousepad (editor), PCManFM (files), Evince (PDF), Eye of GNOME (images), Galculator, File Roller, xterm | ~2.0 GB |
| `full` | + LibreOffice, GIMP, Inkscape, Firefox ESR, VLC | ~3.5 GB |
```bash
./install.sh container --apps full # or: GLOVEBOX_APPS=full python3 container.py build
docker build -t glovebox-mcp:local --build-arg APPS=basic --build-arg EXTRA_APT="thunderbird kate" .
python3 container.py install gedit # into the RUNNING container; lasts until `down`
```
All of them except Firefox answer through accessibility (`source: at-spi`), so `find_elements` and
`act` work on them without any vision; Firefox is read by OCR. Any Debian package can be added
with `EXTRA_APT`.
**Vision** — three levels, cheapest first:
1. **Accessibility** (always on): browsers and the apps above describe themselves. No model.
2. **OCR** (always in the image): Tesseract, for what accessibility does not expose.
3. **Your GPU, shared from the host** (opt-in, Linux hosts with a native `./install.sh local`):
`./install.sh container --vision host`, or `GLOVEBOX_CONTAINER_VISION=host` when the container
is created. The container gets nothing but a read-only mount of one directory holding a link
to the host's vision-service socket; `parse_screen` then answers with `"via": "host-service"`.
The image stays small, and native and container agents share **one** model load. The trade-off
is stated in `status()`: screenshots sent for parsing leave the container. When the host's
service is not running (it idle-exits), vision falls back to OCR and says why; every new
session through `container.py` starts it again.
There is no image with the GPU models built in: it would be ~8 GB larger, need the NVIDIA
container toolkit, and the icon detector's AGPL-3.0 weights could not be shipped in it anyway.
The sandbox user inside the container takes the numeric id of the data folder's owner, so what
the apps write there belongs to you, whatever your user id is.
`python3 container.py up | down | status | build | install` manage the container; the image is built for
amd64 and arm64 (Apple Silicon) and both are exercised in CI.
### Claude Code skill
The installer copies `skills/glovebox/SKILL.md` into `~/.claude/skills/glovebox/` when `~/.claude`
exists (`./install.sh skill` does only that) — a skill that teaches Claude Code the observe → act → verify loop, grounding per vision mode, the
upload and navigation gotchas, and when to stop. Claude Code loads it automatically when an agent
is asked to drive a GUI app (or explicitly with `/glovebox`). AGENTS.md remains the long form for
any other agent/harness.
### Works with any MCP client / harness
Claude Code, Cursor, Codex, or your own agent — it's a standard MCP server, not tied to any one host.
Two compatibility notes: **`basic`/`local`** return element **coordinates as text**, so they work even
with text-only agents; **`none`** relies on the client passing the tool's **screenshots** to a
multimodal model (fine for Claude Code, Cursor, and other image-capable MCP clients). In any mode,
`clipboard()` gets exact text out of an app without vision at all.
## Quickstart
1. **Start the sandbox** (leave it running):
```bash
./start-display.sh # 1440×900 Xephyr window with a browser
./start-display.sh 1920x1080 # …or pass a screen size (or set $RES)
```
Log into any sites or apps you want to automate **in that window**.
2. **Register the server** with your MCP client. `install.sh` already wrote **`mcp-config.json`** with
your real install path — copy its `glovebox` block into your client's MCP config:
```jsonc
{ "mcpServers": { "glovebox": {
"command": "/abs/path/to/glovebox-mcp/.venv/bin/python", // filled in by install.sh
"args": ["/abs/path/to/glovebox-mcp/server.py"],
"env": { "DISPLAY": ":1" }
} } }
```
Restart the client so it loads the server.
3. Ask the agent to screenshot / click / type — it operates **only** on the `:1` window.
> **Driving it with an AI agent?** Paste [`AGENTS.md`](AGENTS.md) into the agent's system prompt — it
> teaches the observe → act → verify loop, grounding, the upload/unicode gotchas, and when to stop.
## Tools (31)
| Tool | What |
|---|---|
| `status()` | Server + sandbox status in one read-only call: version, the vision diagnosis (requested vs. effective backend and *why*, GPU name/VRAM, OmniParser code/weights, tesseract languages), live instances, and which system deps are present. Run it first — and paste it into bug reports. |
| `screenshot(instance, region?, scale?, format?, save_as?)` | `[json, image]`. `region="x,y,w,h"` zooms into a rectangle, `scale=0.5` shrinks, `format="jpeg"` compresses — cut payload or read small text. `save_as="step1.png"` writes the image into the staging folder and returns JSON only (evidence to attach, no image tokens). |
| `parse_screen(instance, source?, granularity?)` | The on-screen elements as JSON (id, type, label, interactive, pixel-center; capped at 300 per call, flagged via `"truncated"`) + a numbered Set-of-Mark image. **`source="auto"` asks the app first** — its accessibility information: exact labels, real element types, `states` (disabled, checked, expanded…), `value`, no GPU, tens of milliseconds — and falls back to vision for apps that expose nothing (canvas, games, Tk); `"source"` in the reply says who answered (`browser-dom`, `at-spi`, `vision`). In vision mode `basic` OCR words are merged into **lines** (`"Sign in"` = one target; `granularity="word"` for single words). |
| `find_elements(query, type?, source?)` | Parse + filter in one call: the elements whose label contains `query` (and optionally of one `type`), ids ready for `click_element` / `act` / `fill(element=)`. With an accessibility source it also finds what is **scrolled out of view** (`"onscreen": false`) — the click scrolls it in. `count: 0` is an honest "not there". |
| `act(element, action?, value?)` | Operate an element **through the app's accessibility interface — no pointer, no keyboard, no coordinates**: `press` (button, link, checkbox, menu item), `set_value` (text, a `