Chapters

Docs App frameworks

Accessibility and automation

BifrOSt exposes its screens to other programs in four ways: accessibility roles that screen readers read through AT-SPI2, an element map that the shell serves by name, JSON-RPC control sockets for each app, and the bifrost-mcp server that lets an AI assistant use all of these. This chapter covers each one and how to add to it.

Accessibility roles

Every element that BifrOSt reports has a role. The role tells a screen reader or an agent what kind of control it is. The roles mirror the AppKit accessibility classes, so an app that already uses NSAccessibility terms can map them directly. The enum is Role in bifrost_ui, and the SDK re-exports it as bifrost_app::controls.

RoleUse it forAT-SPI2 role name
ButtonA command, such as a push buttonpush button
TextFieldAn editable text fieldentry
ListA container of rowslist
RowAn item in a listlist item
ToggleA binary on or off switch (NSSwitch)toggle button
CheckboxA binary checked control (NSButton checkbox style)check box
SliderA numeric range (NSSlider)slider
SegmentedControlA group of mutually exclusive choicespage tab list
StaticTextText that cannot be changedlabel
MenuItemA command in a menumenu item
WindowA top-level windowframe
ProgressIndicatorA determinate or indeterminate progress displayprogress bar

The kit's draw helpers choose the role for you. A toolbar button records Button, and a text field records TextField. An app that draws its own views records each element with one call. See UI kit.

Values and states

Each element has a label, a value, and an enabled flag. The label is what the user reads. The value is text. Its meaning depends on the role:

An element that is disabled still appears in the map, with enabled set to false. Assistive technology does not act on it.

Note

Values can be read but not set through the element map. Setting a value from the map is Not yet available for the shell. Apps can set values through the AT-SPI bridge described below.

AT-SPI2 bridge

The AT-SPI2 bridge exports the accessibility tree of each running app to the session's accessibility bus. Screen readers such as Orca read it from there. The bridge is a Cargo feature of the springboard crate, named atspi. It is not part of the desktop-wayland feature set, so you build it with it turned on:

cd springboard
cargo build --features "desktop-wayland atspi"

The bridge is inactive unless the session has an org.a11y.Bus. Without one, it turns itself off for the session and the shell runs normally. The bridge does not block the shell. It connects on a helper thread and publishes snapshots at most four times a second.

The bridge works like this:

Important

The bridge is only as complete as the app's element tree. An app with its own drawing that declares no elements exports an empty tree. See Add a control method and the element rules in UI kit.

Text fields: label, title, help and caret

A screen reader needs more than the value of a text field. It needs the field's name, what the field is for, and where the user is in the text. The label is what the field is for, and it comes from the placeholder you pass to the field. The title is the field's visible name (accessibilityTitle). The help says what the field does (accessibilityHelp). The screen reader reads the title first, then the help after the label.

let name = TextField::new("Name", "name")
    .with_ax_title("Full name")
    .with_ax_help("Your name as it appears on the card");

A TextField in a window reports its caret, its selection and its visible range without extra code. The caret and the range count characters, not bytes. An app that draws its own text element returns the same values from its own ax_text and ax_meta methods.

TextField::with_ax_title(title)
Sets the visible title of the field, which the screen reader reads as its name.
TextField::with_ax_help(help)
Sets the help text of the field, which the screen reader reads after the label.
fn ax_meta(&self, ctx: &Ctx) -> Vec<AxMeta>
Returns the title and help of each element that has one. The SDK sends it only when it changes.
fn ax_text(&self, ctx: &Ctx) -> Vec<AxText>
Returns the caret, selection and visible range of each text element. The SDK sends it only when it changes.
text_ax(id, text, anchor, head, visible, secure)
Builds one AxText from a field's text, its anchor and caret, its visible character range and its secure flag.
AxText::selected_range()
Returns the selected range as a start and an end in characters. The range is empty when only a caret is set.
AxText::selected_text(text)
Returns the selected part of the field's value. A secure field always returns an empty string.
Note

The text attributes cover single-line fields only. A screen reader cannot move the caret or set the selection yet, because there is no message from the screen reader to the app for it. There is no line number or attributed text range for a multi-line field.

Text changes and caret movement

Screen readers follow typing without a call from your app. The bridge compares each text field with its last snapshot. When the value changes, it sends a text-changed event with the offset, the length and the text that was inserted or deleted. When the caret or the selection moves, it sends a caret-moved or a selection-changed event. The bridge publishes snapshots at most four times a second, so a fast burst of keys can arrive as one event.

Live announcements

Some results change while the user looks elsewhere, such as a copy that finishes in the background. Announce them so a screen reader speaks them without moving focus. Call announce on the context with the text and a priority.

ctx.announce("3 files copied", bifrost_ui::ax::Priority::Medium);
Ctx::announce(text, priority)
Speaks the text through the screen reader without moving focus. An empty text is ignored.
Priority::Low, Priority::Medium, Priority::High
Set how urgently the text is spoken. Low and medium are polite and wait their turn. High is assertive and interrupts the speech in progress. Medium is the default.
Note

On the AT-SPI bus, an announcement is sent as the announcement event of AT-SPI 2.46 (the counterpart of a live region). The shell keeps at most 8 pending announcements for each app.

Secure fields

A password field must not show its text to a screen reader. The shell's own text fields and its sign-in sheet hide the text this way. The bridge exports a secure field as a password text element. Its value is one bullet for each character, its selected text is empty, and only the length crosses the wire.

An app that draws its own field marks it secure in the AxText it returns from ax_text. Pass true for the secure argument of text_ax, or set the secure field yourself.

Important

The SDK TextField has no secure mode yet. It draws its text, and it reports its text as not secure. A screen reader can read the text of a password entered in that field. Use a custom field that marks itself secure until the SDK adds the flag.

The element map

The shell keeps one map of every element it can address. Each element has an address, built from the labels the user sees:

ScopeExampleContains
os/settings/os/settings/general/software-updateEach Settings page and its rows
os/menubar/os/menubar/edit/select-allMenu bar menus and their items
os/apps/os/apps/settingsInstalled apps. The value is open while a window exists
app/<app-id>/app/is.olibuijr.files.desktop/button/new-folderA running app's elements

Names are slugged: "Software Update" becomes software-update, and Icelandic letters fold to ASCII. A repeated name under one parent gets a number, so the second About row is about-2.

The shell's control port is 127.0.0.1:7777. You can change the port with the SPRINGBOARD_CONTROL_PORT environment variable. The port accepts one request per connection, as a single text line. The two ax commands are:

ax list [prefix]
Lists the elements at or below the prefix, one per line, as tab-separated fields: address, role, name, value and enabled. An empty prefix lists the whole map.
ax press <address or name>
Presses an element. The argument can be a full address, a path such as General > Software Update, or a name that is unique in the map. The reply is ok <address>.

Errors start with error: and say why the press failed: no element matched, the name is ambiguous and lists the candidates, the element is disabled, or the element cannot be pressed yet.

exec 3<>/dev/tcp/127.0.0.1/7777
printf 'ax list os/settings/general\n' >&3
cat <&3
exec 3>&-

A press on a Settings element does the same as a tap on that row. A press on a menu item runs the menu action. A press on an app element sends a tap at the element's centre to the app.

Note

The map does not yet cover window controls such as close and minimise, the dock's order, or the status icons. It is also not a tree in the AppKit sense: app elements are listed flat under their role. Each of these is a gap that the project tracks, not a feature you can call.

App control sockets

Each running app with a control socket answers JSON-RPC 2.0 requests. The socket is at $XDG_RUNTIME_DIR/bifrost/apps/<app-id>.sock. The directory is mode 0700 and the socket is mode 0600. The app accepts a connection only from its own user, which it checks with SO_PEERCRED.

Each connection carries one request, a JSON object ending in a newline. The app sends one reply and closes the connection. A request can be at most 256 KiB, including the newline.

Use the bifrost pc control command to talk to a socket:

bifrost pc control list                       # running apps that answer
bifrost pc control info <app-id>              # id, sdk_version, pid and data directory
bifrost pc control methods <app-id>           # the methods the app serves
bifrost pc control call <app-id> <method> '<json params>'

Every app serves two methods. app.info returns the app's id, SDK version, process id and data directory. app.methods lists every method the app serves. An app that declares App Intents also serves intent.list, entity.query and one intent.<id> method for each intent.

Errors use the JSON-RPC codes:

CodeMeaning
-32700The request is not valid JSON
-32600The request is not a JSON-RPC 2.0 request, or the method is missing
-32601The app does not serve that method
-32602The params are invalid
-32603The app failed while it ran the method

The command prints an error as error <code>: <message> and exits with status 1. A socket file can outlive a killed app. list reports such a socket as not answering.

Add a control method

An app adds its own methods by implementing two methods of the App trait. The SDK serves the socket and handles the app.* methods for you.

fn rpc_methods(&self) -> Vec<&'static str>
The method names the app serves. They appear in app.methods. The default is an empty list.
fn rpc(&mut self, ctx: Option<&Ctx>, data_dir: &Path, method: &str, params: &Json) -> Result<Json, RpcError>
Answers one request on the app's main thread. ctx is None before the first Configure. data_dir is always set. Return RpcError::new(METHOD_NOT_FOUND, …) for a method the app does not know.

Keep these rules when you add a method:

Important

An app control method runs as the app's own user. Any process of that user can call it. Treat the socket as a public API of the app: document each method's parameters and reply.

The bifrost-mcp server

bifrost-mcp is a Model Context Protocol server. It lets an AI assistant see the screen, operate windows and apps, and read system state. The server is one binary that speaks JSON-RPC 2.0 over stdio, or over HTTP and a Unix socket. It is installed with BifrOSt PC, and bifrost-mcp.service runs it on start, unless you turn the service off.

The server has two transports:

TransportAddressWho uses it
HTTP (Streamable HTTP)http://<machine>:7420/mcpRemote clients. Each request needs Authorization: Bearer <token>, including requests from the same machine.
Unix socket/run/bifrost-mcp.sockAgents running on the machine. Newline-delimited JSON-RPC, with no token.

The HTTP port is 7420 by default. Set BIFROST_MCP_PORT to change it, and BIFROST_MCP_LISTEN to change the address it binds. The default address is 0.0.0.0. The token is created on first start at /var/lib/bifrost-mcp/token, mode 0600.

Important

The server runs as root and allows every action, including file writes and shell commands. Run it only on a machine where you accept that. Do not register it against a machine with data you cannot replace.

Connect an AI assistant

An MCP client connects in one of two ways. Claude Code is shown here. Other clients use the same server with their own configuration.

Over HTTP, from any machine that can reach the port. Store the token in an environment variable and read it from the machine's token file:

{"mcpServers":{"bifrost":{"type":"http","url":"http://<machine>:7420/mcp","headers":{"Authorization":"Bearer ${BIFROST_MCP_TOKEN}"}}}}

Over ssh, as a stdio server. The assistant starts bifrost-mcp on the machine, with no arguments, through an ssh session. No port is opened, and no token is needed:

{"mcpServers":{"bifrost":{"command":"ssh","args":["<machine>","/usr/bin/bifrost-mcp"]}}}

Run bifrost-mcp call <tool> '<json>' on the machine to test one tool call from a shell. The call prints the result and its time.

MCP tools

The server offers these tools. Each description is written for the model that reads it.

ToolWhat it does
observeText snapshot of the screen size, the open windows, and the shell state. Cheaper than a screenshot.
screenshotPNG of the screen, a region, or one window by name. diff=true reports what changed since the last capture.
click, pointer, scrollPointer input at screen pixels, or in a window's image pixels with window.
key, typeKeys and chords on a kernel keyboard, and text typed into the focused field.
windowActivate, close, maximize, minimize or full-screen a window, by title or app id.
openLaunch an app by name or id, open a URL, or open a folder in Files.
uiList the element map under a prefix, or press an element by address or name. The same as ax list and ax press.
appList apps with a control socket, list an app's methods, or call one.
waitWait for a window, an element, a shell state line, a command, or for the screen to change or settle.
exec, file, systemRun a command as root, read and write files, and read system facts.
shellSend a raw line to the shell's control port.
batchRun several tool calls in order in one round trip.
logs, crash, perfNew journal lines, crash records and core-dump backtraces, and CPU use per process.
lifecycleStatus, restart, netboot or unattended reinstall of the lab machine. See Lifecycle tool.
devUpload a file, install a package, restart the shell, the compositor, an app, or the server.

Coordinates are screen pixels. A downscaled screenshot reports image_scale, and you pass that value back to click. A window screenshot reports where the window sits on the screen. Prefer ui to pixel clicks when an element is in the map. The map is faster and does not depend on the layout.

The tool list is in springboard/mcp/src/tools.rs. The project's evaluation tasks check that an assistant can finish common jobs with these tools. The tool descriptions change when the evaluations show a task failing.

Lifecycle tool

The tool ships in the Bifrost MCP 0.5.0 package.

The lifecycle tool controls the boot of the lab machine. It reports the status, restarts the machine, boots it into the lab installer once, or runs an unattended reinstall. Every action returns a job id at once, and the machine goes down three seconds later, so the caller reconnects instead of waiting on the call.

ActionWhat it doesGuard
statusLab flag, uptime, version, boot entries and any pending unattended presetNone
restartReboots the machineNone
netbootSets the next boot to the network installer and reboots into itLab hardware, and confirm is NETBOOT followed by the hostname
reinstallWrites an unattended preset, sets the next boot to the network installer and reboots. The installer erases the system disk and installs a fresh systemLab hardware, and confirm is REINSTALL followed by the hostname
confirm
The action name in capitals and the machine's own hostname, for example REINSTALL <hostname>. A call for another machine fails for that reason.
Lab hardware
netboot and reinstall refuse on any machine that is not the lab hardware. The check reads the hardware, not a file that an earlier install could have written: the system's product name and the network card's MAC address. The installer repeats the check before it erases a disk.
bifrost-mcp call lifecycle '{"action":"status"}'
bifrost-mcp call lifecycle '{"action":"reinstall","confirm":"REINSTALL <hostname>"}'

Job records are kept on the machine. A reinstall erases them, so after a reinstall check the new boot instead: lifecycle status, or the uptime in system overview.

The tester account

A reinstall leaves a fresh system with a tester account. It logs in automatically, and the MCP server is enabled for it. The lab holds the account's password, and it is not part of these docs. Use this account for app tests on the lab machine.

Note

netboot and reinstall refuse on any other machine. status and restart have no hardware guard.