Skip to main content
Glama

shotbox

PyPI npm CI Glama

Eyes, ears and hands on a real graphical program, for an AI agent, a script or CI.

An agent working on a program with a window can't see it or hear it. shotbox runs the program in a sealed session of its own, X11 or Wayland, and lets whatever is driving it look, listen and act: read the accessible tree, take screenshots, record what it plays, click by a button's name, type, hold keys and gamepad buttons, and wait until the program is actually ready. Then measure what it finds: names a screen reader can't say, contrast, the Tab order, pixels changed against a reference, where it flickers, how fast it follows the pointer, where its sound drops out, and what it used. Nothing it runs reaches your desktop or speakers by accident, and with --net loopback, not your network either.

shotbox finding an unnamed button and faint text and hearing what Orca says of them, comparing pictures, hearing a dropout, catching flicker, driving a game with a gamepad and finding a brittle, blind test

Made with shotbox: each scene is a play script in a sealed session, recorded by shotbox record. With sound.

claude mcp add shotbox -- shotbox mcp --allow ~/src/app/shotbox-programs

Without an agent, it's the same session from the command line:

shotbox shoot editor.png --window '.*Text Editor' -- gnome-text-editor notes.md

Worked examples, from checking a change to a game's smoke test: docs/recipes.md. How it differs from other tools that drive a GUI: docs/comparison.md.

For agents

shotbox mcp --allow PROGRAMS gives an agent sealed sessions over the Model Context Protocol (stdio). It can start a session, spawn programs from the list in PROGRAMS (NAME = COMMAND a line, and nothing else), and then:

  • read the accessible tree, and take screenshots, which come back as images;

  • click by a node's name, press keys, type and work a gamepad;

  • wait for windows, stillness and announcements;

  • lint, measure contrast and walk the Tab order;

  • record what a session plays, and hear where it dropped out.

That's enough for an agent to check its own change in a GUI, test a game by playing it, audit what a screen reader hears, or reproduce a bug report in a session that's the same each time. The accessible tree is the cheap way to look, a thousand or two tokens of text; a screenshot is for what only pixels say. An agent can't run anything off the list, and its sessions stop when the server does.

What it's for, the tools, and how it's built: docs/mcp.md.

An agent that runs a program itself, from its shell, runs it on your desktop: a window opens on your screen, a sound plays through your speakers, a browser run under xvfb-run finds your Wayland display all the same. To keep it in a session, put this in the project's CLAUDE.md or AGENTS.md, or your own:

## Graphical programs, browsers and sound

Never run a graphical program, a browser (headless too) or anything that
makes sound straight on this machine: it reaches my desktop and speakers.
Run it in a shotbox session:

- a picture: `shotbox shoot OUT.png --window RE -- COMMAND`
- a script or a test suite with windows: `shotbox run [--audio] -- COMMAND`
- with none, a headless browser say: `shotbox exec [--audio] -- COMMAND`;
  the shotbox package's `sealed()` seals a browser's environment, but
  not the speakers
- a session to come back to: `shotbox start --name NAME`, then
  `shotbox spawn --session NAME -- COMMAND`, and `shotbox stop NAME`

Not `xvfb-run`: it lets `WAYLAND_DISPLAY` and the session bus through. A
server started for a test listens on 127.0.0.1, not 0.0.0.0.

Related MCP server: AI Web Tester

Why

An agent checking its change, a screenshot for a README, and a test in CI all want the same things, and every project was growing its own copy:

  • Sealed. Nothing of yours leaks in by accident, and nothing the program does reaches your desktop or speakers, where bubblewrap can make a sandbox (it says when it can't): What's sealed.

  • Ready, not slept. Waits are for things: a window mapped, a port open, a file written, text on a terminal's screen, or the picture holding still. No sleep 6 and hope.

  • Deterministic. X11 on Xvfb, GTK's software renderer, LANG=C.UTF-8, TZ=UTC, text carets that don't blink (GTK's, Qt 6.5's, browsers'; and GTK's animations off), GTK 4's text drawn at its color, as its manual font rendering does, not fainter by however much a GTK release's automatic one draws it (more), and PNGs with no timestamps in them. It's the same every time, not the same as a desktop: differences from a desktop.

  • Cleaned up. Every program runs in its own process group, and the group is killed on the way out: signalling a wrapper script alone leaves its children running.

Install

On Debian, with what every command and option can use:

sudo apt install xvfb xauth dbus-daemon imagemagick x11-utils python3-gi gir1.2-vte-2.91 \
  at-spi2-core gir1.2-atspi-2.0 python3-gi-cairo gir1.2-pango-1.0 libglib2.0-bin pipewire \
  wireplumber ffmpeg bubblewrap libfaketime
pipx install --system-site-packages shotbox

--system-site-packages lets it see the system's PyGObject, which shotbox term and --a11y use; pip install shotbox works too. Or run it from a checkout: ln -s "$PWD/bin/shotbox" ~/.local/bin/shotbox.

shotbox doctor says what's here and what's missing, a line each, and how to get it. What each command and option needs: Needs.

No Python packages: it's the standard library and those tools. Wayland sessions need more; see Wayland.

In a GitHub Actions job on Ubuntu, the Action installs it and what it runs, as of the release (or branch) it's used at, with what each feature needs asked for by name (all off unless set), and lets bubblewrap make its sandbox, which Ubuntu's AppArmor holds back:

- uses: mishan/shotbox@v0.12.0
  with:
    a11y: true        # --a11y and `shotbox a11y`
    speak: true       # `shotbox a11y speak`: Orca, and what a11y installs
    term: true        # `shotbox term`
    # wayland, audio, record, gamepads and clock too
- run: shotbox shoot app.png --window 'My App' -- ./my-app

A quick tour

shotbox shoot app.png --window 'My App' -- ./my-app          # a picture, once it's up
shotbox shoot app.png --twice --window 'My App' -- ./my-app  # the same every time?
shotbox compare ref.png app.png --diff diff.png              # what changed, and where
shotbox run -- ./take-pictures.sh       # a script that waits, clicks and captures inside
shotbox exec --audio -- npx playwright test        # sealed, with no display
shotbox start --name ed --a11y          # a session to come back to
shotbox spawn --session ed -- gnome-text-editor
shotbox --session ed a11y click Open
shotbox --session ed capture open.png
shotbox stop ed

Commands

Command

What it does

shoot

runs a program, waits, takes the picture; --twice proves it comes out the same

run

runs a command in a sealed session and exits with its status

exec

the same, with no display: a headless browser, a test suite

start, spawn, stop, sessions

a session that lasts, the programs in it, stopping one, listing them

term

a terminal to take pictures of

wait

waits for a window, a port, a file, stillness, a picture, a change, a log line

capture

takes a picture, or a burst of them

record

records a video, the sound, or both

key, type, click, move, scroll, drag

presses keys, types, works the pointer; held too

park, focus

moves the pointer out of the way; gives a window the keyboard

play

plays a script of timed input, on one clock

latency

how fast what's drawn follows the pointer

flicker

finds a part of the screen that flickers or flashes

pad

works a virtual gamepad

a11y, wait announce, wait node

the accessible tree: read, lint, Tab order, click by name, contrast, announcements, a node to show

compare

counts the pixels that differ, picture by picture or directory by directory

vision

a picture as colorblind eyes see it

listen

a recording's level, clipping and dropouts

mutate

runs a browser test against small changes to its page: is it brittle, or blind?

mcp

sessions for an agent, over MCP

doctor

what's here of what each command needs

The options sessions take, --wayland, --a11y, --audio, --gamepads, --net loopback, --identity, --clock, --dark and the rest: Session options.

What's sealed

A session keeps a program from reaching your desktop by accident, not one that sets out to:

  • Its environment is rebuilt from an allowlist; HOME and every XDG directory are a scratch dir.

  • Its display, session bus and system bus, and with --a11y and --audio its accessibility bus and sound server, are its own; the sound server plays to nowhere. It has no printers (but CUPS on localhost:631, unless --net loopback). --machine-bus gives it the machine's system bus and printers.

  • Where bubblewrap can make a sandbox (it says when it can't), nothing reaches the machine's sound devices or your desktop's Wayland, PulseAudio, PipeWire and bus sockets.

  • Your network is reachable unless --net loopback, your user and host name show unless --identity, and the real time unless --clock.

  • Not sealed: the files outside the scratch home, your X server, and other processes.

All of it, and what each option covers and doesn't: docs/sealed.md.

Accessibility

--a11y starts an accessibility (AT-SPI) bus of the session's own, so what a screen reader would hear can be read and checked. Without it, a session has none: GTK is told not to look. Your desktop's bus is never touched either way.

shotbox a11y prints the tree, lints it for what has no name to say, walks the Tab order, clicks by name and measures contrast, shotbox wait announce waits for what's announced, and shotbox wait node for a node to show; for GTK, Qt, AccessKit's toolkits and Chromium. The commands, how it's put together, and what each check can and can't tell: docs/accessibility.md.

Wayland

--wayland makes a session a Wayland one: the program runs under a headless sway, drawing in software, instead of on Xvfb. --xwayland adds an Xwayland to it, and DISPLAY, so an X client runs the way it does on a Wayland desktop, GTK programs made to with --env GDK_BACKEND=x11.

Needs sway and grim, Xwayland for --xwayland, and wf-recorder for record: sudo apt install sway grim xwayland wf-recorder. Why sway, how it fits, and what differs from X11: docs/wayland.md.

Docs

License

MIT. See LICENSE.

Available Tools

18 tools
check_accessible_namesA
Read-only

Lint the accessibility tree for nodes a screen reader has no name to say for: controls, images (not inside a named control) and anything else that takes the focus. The answer: a tree line each, with bounds, then what's wrong; or "No problems.". Use it to check labels after a change; for colors, use check_contrast.

Inputs: session (required), ignore, window.

check_contrastA
Idempotent

Check that text, buttons, links and images stand out from their background: WCAG's 4.5:1 for text (3 for large text) and 3:1 for images unless text_ratio and graphics say otherwise, and with edges, a button's or field's edge too. It raises the window and measures a picture of the screen in each node's bounds. The answer: each node that fails, a tree line with bounds, its ratio and colors, or "No problems."; then what it couldn't measure, which doesn't fail (too small, or GTK 4's, whose positions are wrong), and why. A window where nothing can be measured, as GTK 4's, is an error, not a pass. Switches, sliders, check boxes, disabled nodes and what's scrolled out of view are skipped. For missing names, use check_accessible_names.

Inputs: session (required), edges, ignore, window, +2 more.

check_focus_orderA

Check the keyboard focus order in one call: press Tab, or key, until the focus comes back round, and list where it went, a tree line each, after a "began in" line. Then the controls the key never reached, and how it ended: round again (fine), stuck (a trap, or a text view nothing leaves), not round after most presses, lost (no node has the focus), stopped (a text view closed as it was left), or nothing focused to begin with (click the window with click_element first). With visible, "focus not shown on N" counts stops that don't show it. A text view that takes Tab is left as a person would, with ctrl+Tab, shift+Tab, Escape or F6. The focus stays where it ended. To press a few keys yourself, use press_keys.

Inputs: session (required), key, most, ignore, +2 more.

click_elementA

Click an element by its accessible name, or a point by x and y, on the screen or inside a window. By name is the one to use: it waits up to timeout seconds for the node, raises its window and clicks its middle, and the answer gives the node and its bounds. When two nodes match it lists them, with where they are; when none does, the nearest names. A click gives a window the keyboard, which nothing else does on X11. hold and state, by x and y, hold the button as press_keys holds keys.

Inputs: session (required), x, y, hold, +7 more.

get_accessible_treeA
Read-only

Read what a screen reader would find: every visible node, a line each, indented, with its role, name, description and the states a screen reader says (focusable, focused, checked...). The cheapest way to see what's on screen and what can be clicked by name. A node with an empty name ("") is one a screen reader can say nothing for. Use take_screenshot for how it looks.

Inputs: session (required), bounds, window.

get_program_outputA
Read-only

Read the last lines (40, or lines) a spawned program wrote to stdout and stderr, after a line saying whether it's still running or exited, with its status. It works after the program has exited, until the session stops; for a program spawned more than once, it reads the latest. Use it when a window never comes up or a program seems to have crashed; to wait for a line in a log file, use wait_for line.

Inputs: program (required), session (required), lines.

list_announcementsA
Read-only

List what programs in the session have announced to a screen reader since it started, oldest first, a line each with its politeness: "polite: Saved", "assertive: Error". That's GTK's announcements and a browser's live regions. Reading doesn't clear them; "Nothing announced yet." means none so far. Use it to check what a screen reader user heard after an action; to wait for one, use wait_for announcement.

Inputs: session (required).

press_keysA

Press keys in turn, each a chord: Tab, Return, Escape, ctrl+s, alt+shift+Tab, F6. They go to whatever has the keyboard; click a window first with click_element if nothing does. hold presses them all together and keeps them down that long (walking while running); state down leaves them down, across calls, until a call with state up (move or click while a key is held). The answer says what it pressed.

Inputs: keys (required), session (required), hold, state.

record_audioC

Record what a session started with audio plays, from a call with action start to one with action stop, across the calls between that make the sound. stop's answer: the sound's length, peak and RMS level (dBFS), samples clipped, and each gap of exact silence between the first sound and the last, as a program that falls behind leaves; then what's wrong, if anything (gaps, clipping, silence). Sounds meant to be apart, two beeps say, need a gap longer than the silence between them. For a video of the screen with its sound, up to a minute, use record_video with sound.

Inputs: action (required), session (required), gap.

record_videoA

Record a video of the screen, or of one window, and save it as an .mp4: in the session's scratch directory, gone when the session stops, or at path. The answer is the saved path, how long the clip is, and up to 8 frames from it RETURNED AS ONE IMAGE, with the times they show: you can't play the clip, but a person or another tool can. A clip stops at 100 MB. sound also says what it heard, as record_audio does. until_line ends it at an event instead; the answer gives the line. For a few moments of motion, take_screenshot's burst is cheaper.

Inputs: session (required), crop, file, path, +5 more.

scroll_wheelA

Turn the mouse wheel over a node by its name, found as click_element finds it (waiting for it, its window raised), or at a point by x and y, leaving the pointer there. Use it for what's past a list's, a page's or a window's edge, then wait_for stable and look again; to move the keyboard focus, use press_keys.

Inputs: session (required), x, y, dx, +4 more.

spawn_programA

Start one of the programs the person allowed this server to run, by its name, in a session; nothing else can run. The answer gives its pid. Then wait_for its window, by the program's name, before looking at it. If it doesn't come up, get_program_output says why.

Inputs: program (required), session (required).

start_sessionA

Start a sealed session: a display of its own (X11 under Xvfb, or Wayland under a headless sway), its own D-Bus and accessibility bus, and a scratch home. Nothing in it reaches the desktop of the person you're working for, and nothing of theirs reaches it. The answer gives its name, display and size, the programs spawn_program can start in it, and anything it couldn't seal. It lasts until stop_session.

Inputs: tz, net, a11y, dark, +11 more.

stop_sessionA
DestructiveIdempotent

Stop a session start_session made, when you're done with it: every program in it is killed, unsaved work and all, and its scratch directory is deleted, with any clip record_video saved there (one saved at a path is kept). In a session started with usage, the answer says its programs' peak memory and CPU time. You needn't stop sessions before the server ends: they all stop with it.

Inputs: session (required).

take_screenshotA
Idempotent

Take a picture of the screen, or of one window, RETURNED AS AN IMAGE for you to look at: the only way to see colors, layout and what's drawn. Pictures cost far more than get_accessible_tree; take the window rather than the screen, and crop when you need a part. vision checks nothing is told apart by color alone; burst, as one image, is for motion, an animation or a transition. The answer gives its size, and if it was shrunk, the scale.

Inputs: session (required), crop, park, burst, +3 more.

type_textA

Type text into whatever has the keyboard focus, a key at a time. ASCII only: a character with no key fails the call, once what's before it is typed. For keys and shortcuts (Return, ctrl+s), use press_keys.

Inputs: text (required), session (required).

use_gamepadA

Work a virtual gamepad, in a session started with gamepads: press buttons together, tapped, held for hold seconds, or with state down left down until a call with state up; push a stick to x, y; pull a trigger to value; or neutral, letting go of everything. A stick or trigger stays where it's put, unless hold says for how long. Programs in the session see a real Xbox 360 controller, and none of the machine's. For keys and the mouse, press_keys and click_element.

Inputs: action (required), session (required), x, y, +6 more.

wait_forA
Read-only

Wait, instead of sleeping, for: a window (value: its title, exactly or a regex, or app=RE, or the name of a program spawn_program started, for a window of that program's, whatever its title; giving up, it lists the windows there are), stable (the screen, or the window, unchanged for value seconds, 0.5, up to 60: after a click, for the repaint), an announcement (value: a regex in what was announced to a screen reader; each announcement is waited for once), focus (value: the name of the node with the keyboard focus, as click_element takes one), match (value: a PNG, by its path from the allow file's directory, that the screen, or the window, cropped to crop, should look like), change (from how it looked when the wait started), or line (value: a regex found in a line of file, written after the wait starts, or with from_start, anywhere in it: for a program that logs its events, rather than a sleep; a file not there yet is waited for, and one rotated or rewritten is read from the top). match and change say how long they took; line answers with the line. Fails after timeout seconds, saying so.

Inputs: what (required), session (required), crop, file, +6 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools target clearly distinct actions (start_session/stop_session, click_element, scroll_wheel, press_keys, type_text, record_video, record_audio, the three check_* linters), and the descriptions explicitly draw boundaries (e.g. type_text vs press_keys, screenshot vs accessible_tree). The main overlap is wait_for, which reimplements waiting on announcements, log lines, focus, and screen changes that other tools also observe, creating some potential misselection.

    Naming Consistency5/5

    Every tool uses snake_case with a predictable verb_noun or verb_object pattern: start_session, stop_session, spawn_program, get_program_output, get_accessible_tree, take_screenshot, click_element, scroll_wheel, press_keys, record_video, record_audio, use_gamepad, check_accessible_names, check_contrast, check_focus_order. wait_for is the only slight deviation but remains readable and consistent in style.

    Tool Count4/5

    18 tools is on the heavier side but each earns its place across the distinct sub-domains of session management, program spawning, input simulation, observation, recording, and accessibility checks. It is slightly large but not padded; nothing appears redundant enough to remove.

    Completeness5/5

    The surface covers the full lifecycle: session start/stop, program spawn/output, input (text, keys, clicks, scroll, gamepad), observation (accessible tree, screenshots, video, audio, announcements), flexible waits, and three accessibility linters. Coverage is comprehensive for a GUI/accessibility testing domain with no obvious dead ends.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to automate Linux desktop GUI by launching and interacting with Wayland applications in isolated virtual KWin sessions, or connecting to live desktops for collaborative automation.
      162 PyPI
      87
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to operate a real GNOME Wayland desktop through accessibility-tree widget actions, pointer/keyboard input, OCR, window management, and screen capture, optionally on a private headless session.
      33
      27 PyPI
      11
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents and automation tools to interact with GUI applications in isolated X11 displays via MCP, supporting input, window management, screenshots, clipboard, and accessibility actions.
      4
      MIT