Examples
Each example in the repository serves MCP on its own port, so several can run at once. Point an MCP client at the endpoint, read app://windows, then call the tools.
| Example | Port | Covers |
|---|---|---|
gpui/counter | 8931 | The smallest end-to-end integration |
gpui/todo | 8932 | Tables, parameterized tools, validation, dynamic availability |
gpui/form | 8933 | Modal chains collapsing the operable set, redaction |
gpui/dashboard | 8934 | Self-updating state, truncation, async handlers |
gpui/multi-window | 8935 | Windows created at runtime, each with its own tools |
sh
cargo run -p gpui-counter
cargo run -p gpui-todo # {winId}__add {"text": "buy milk"}
cargo run -p gpui-form # {winId}__submit → confirm/cancel on the modal
cargo run -p gpui-dashboard # {winId}__page {"offset": 10}
cargo run -p gpui-multi-window # {winId}__open {"title": "Notes"}Examples live in their own Cargo workspace (examples/), separate from the root one, so building or testing Purview itself never compiles a GUI toolkit.
The tools each one exposes
Every tool is named {winId}__{action}; read app://windows for the current winIds.
| Example | Window | Tool | Params |
|---|---|---|---|
| counter | Counter | increment / decrement | — |
| todo | Todos | add | { text: string } |
toggle / remove | { index: number } (1-based; remove is destructive) | ||
clear_done | — (destructive; hidden until something is done) | ||
| form | Transfer | fill | { recipient?, amount?, account? } |
submit | — (destructive; opens the modal) | ||
Confirm transfer | confirm / cancel | — | |
| dashboard | Dashboard | page | { offset: number } (read_only) |
pause | — | ||
report | — (read_only, async) | ||
| multi-window | Library | open | { title: string } |
| each document | append | { line: string } | |
clear | — (destructive) |
Watch the list change
form and multi-window are the interesting ones. In form, submitting opens a modal and the Transfer tools leave tools/list until it is dismissed. In multi-window, each document you open adds its own pair. See Free protocol behaviour.
A checklist for your own integration
- Install the bridge where the live context exists — for gpui, inside
Application::run. - Describe each window and keep the block handles you will need.
- Write one sync method per view and call it after every mutation. Never write the projection anywhere else.
- Register actions that call the same code your buttons do.
- Hide what is not callable with
set_available, and make sure modals can be dismissed.
For the wire format and normative requirements, see the protocol specification.