# Inspect a running app

When a page behaves differently in a real window, inspect the live view tree before guessing at coordinates. Debug desktop and emulator builds in this repository include DevTools; Release, browser, and mobile builds do not enable the same stdio switch.

## Start a controllable process

Build first so compiler output cannot mix with the protocol stream:

```sh
dotnet build Xui/Apps/DemoApp/DemoApp.Desktop.csproj -c Debug
dotnet Xui/Apps/DemoApp/bin/Debug/net10.0/DemoApp.Desktop.dll --enable-stdio-jsonrpc
```

Send one JSON-RPC object per input line:

```json
{"jsonrpc":"2.0","id":1,"method":"ui.inspect"}
{"jsonrpc":"2.0","id":2,"method":"app.frame","params":{"elapsedMilliseconds":16}}
{"jsonrpc":"2.0","id":3,"method":"ui.screenshot"}
{"jsonrpc":"2.0","id":4,"method":"app.quit"}
```

Wait until inspection returns a window. Use the reported view ID and center to choose an input target. `input.click` takes numeric `x` and `y`; obtain them from the current inspection instead of copying coordinates from another window size.

## Reproduce the sequence

In stdio mode, explicit `app.frame` requests advance the controlled animation clock. An input response acknowledges UI-thread delivery; it does not prove that the intended page became active. Inspect again and verify the destination before taking a screenshot or measuring a frame.

Stdout contains protocol responses and application console output goes to stderr. Keep request IDs so responses can be matched to actions. Close stdin or send `app.quit` when finished. Commands currently target the most recently created app window, which matters when a sample opens a secondary window.

## Connect an assistant

The repository MCP server exposes app launch, inspection, screenshots, and input through tools:

```sh
dotnet run --project Xui/Utils/MCP/Xui.MCP.csproj
```

Configure that command as a stdio server in an MCP-capable client. Client configuration formats differ; the command alone does not install or configure an integration. Give controls useful IDs so a human or assistant can verify the exact target. Use [deterministic tests](../deterministic/index.md) for fast repeatable regressions after isolating the live failure.
