Skip to content

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.

ExamplePortCovers
gpui/counter8931The smallest end-to-end integration
gpui/todo8932Tables, parameterized tools, validation, dynamic availability
gpui/form8933Modal chains collapsing the operable set, redaction
gpui/dashboard8934Self-updating state, truncation, async handlers
gpui/multi-window8935Windows 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.

ExampleWindowToolParams
counterCounterincrement / decrement
todoTodosadd{ text: string }
toggle / remove{ index: number } (1-based; remove is destructive)
clear_done— (destructive; hidden until something is done)
formTransferfill{ recipient?, amount?, account? }
submit— (destructive; opens the modal)
Confirm transferconfirm / cancel
dashboardDashboardpage{ offset: number } (read_only)
pause
report— (read_only, async)
multi-windowLibraryopen{ title: string }
each documentappend{ 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

  1. Install the bridge where the live context exists — for gpui, inside Application::run.
  2. Describe each window and keep the block handles you will need.
  3. Write one sync method per view and call it after every mutation. Never write the projection anywhere else.
  4. Register actions that call the same code your buttons do.
  5. 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.