Skip to main content
Glama
README.md
# PyWebView Driver MCP

A local stdio MCP server that lets a coding agent launch, see, operate, test and live-reload a real [PyWebView](https://pywebview.flowrl.com/) application. It drives the actual Qt WebEngine window through the page-level Chrome DevTools Protocol: semantic snapshots, real mouse and keyboard input, assertions, screenshots, console/network/process logs, page reload and process restart.

- Python only. No Node.js, no browser, no changes to your application.
- Linux with PyWebView on Qt (PySide6). Other renderers and platforms are not supported.
- Web content only: native dialogs, window frames and devices are not automated and are reported as not covered.

See the [verification report](docs/verification.md) for what has been tested and how.

> **Security:** this is a privileged developer tool, not a sandbox. It runs commands you give it and opens an unauthenticated loopback debugging port on the launched app. Use it only with trusted code and disposable test profiles. Details in [docs/security.md](docs/security.md).

## Install

Requires [uv](https://docs.astral.sh/uv/) and Python 3.11–3.14. The server runs in its own isolated environment; your application keeps its own environment with `pywebview` and `PySide6`.

Generic MCP configuration ([configs/mcp.github.json](configs/mcp.github.json)):

```json
{
  "mcpServers": {
    "pywebview": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/bigbatmanorg/pywebview-driver-mcp", "pywebview-driver-mcp"]
    }
  }
}
```

Claude Code:

```sh
claude mcp add pywebview -- uvx --from git+https://github.com/bigbatmanorg/pywebview-driver-mcp pywebview-driver-mcp
```

Codex CLI:

```sh
codex mcp add pywebview -- uvx --from git+https://github.com/bigbatmanorg/pywebview-driver-mcp pywebview-driver-mcp
```

Pin a version by appending `@v0.1.0` (or a commit SHA) to the Git URL. The unpinned URL follows the default branch and `uvx` caches it; run `uvx --refresh --from git+https://github.com/bigbatmanorg/pywebview-driver-mcp pywebview-driver-mcp --version` to upgrade. There is no self-update.

## Use

Ask your agent, for example:

> Use the pywebview MCP. Launch this app, take a snapshot, click through the settings flow, assert the result and show me a screenshot. Stop the session when done.

The agent's first calls are `get_guide` (packaged instructions), `launch` and `snapshot`. A typical launch:

```json
{"argv": ["uv", "run", "python", "main.py"], "cwd": "/absolute/path/to/app", "target": {"title": "My App"}}
```

Your app must render with Qt. If it does not call `webview.start(gui="qt")`, add `"env": {"PYWEBVIEW_GUI": "qt"}` to the launch call. For apps without a `js_api`, add `"readiness": {"bridge": false}`.

### Tools

| Tool | Purpose |
|---|---|
| `get_guide`, `doctor` | Packaged guidance; environment check |
| `launch`, `attach`, `stop` | Start an owned app, attach to an existing loopback debug port, stop or detach |
| `list_sessions`, `status`, `targets` | Session state, PID, windows |
| `snapshot`, `inspect` | Visible controls with role, name, state and refs |
| `click`, `fill`, `press`, `interact` | Real CDP mouse/keyboard input; hover, scroll, type, select |
| `wait`, `assert_ui` | Bounded conditions; a failed assertion is an error result |
| `screenshot`, `diagnostics` | PNG of the web content; console, errors, network, stdout, stderr, process, reload logs |
| `reload`, `configure_reload` | Page reload or process restart; file watching |
| `evaluate_js` | Privileged debugging, only when the server is started with `--allow-js` |

Locators: `{"ref": "s1:d1:r10"}`, `{"role": "button", "name": "Save"}`, `{"css": "#save"}` or `{"text": "Save"}`, with optional `scope` and `index`. A locator must match exactly one element. More in [docs/tools.md](docs/tools.md).

### Live reload

Off by default. Enable it at launch or later with `configure_reload`:

```json
{"operation": "set", "config": {"mode": "auto", "watch_roots": ["."]}}
```

- `frontend`: HTML/CSS/JS changes reload the page; the Python process keeps running.
- `auto`: additionally, Python/TOML changes restart the process with the same session and profile.
- Pause watching during test scenarios with `{"operation": "pause"}`; `resume` applies pending changes.

After any reload, old snapshot refs return `STALE_REF`; snapshot again.

### Skills

Two agent skills ship in the package and are served as `skill://` resources and through `get_guide`. To copy them into an agent's skills directory:

```sh
uvx --from git+https://github.com/bigbatmanorg/pywebview-driver-mcp pywebview-driver-mcp skills export --destination /path/to/skills
```

Existing files are never overwritten.

## Develop

```sh
uv sync --group gui
uv run pytest -m 'not gui'      # unit and MCP protocol tests, no display needed
uv run pytest -m gui            # real Qt tests, needs a display (or xvfb-run -a env QT_QPA_PLATFORM=xcb ...)
uv build
```

Further reading: [specification](docs/specification.md), [architecture](docs/architecture.md), [compatibility](docs/compatibility.md), [security](docs/security.md).

## License

MIT

TDQS

B3.1/5.0

Scored across 21 tools

Disambiguation4/5

The core lifecycle (launch/attach/stop/list_sessions/status/targets) and the observation vs. action split (snapshot/inspect vs. click/fill/press) are clearly delineated, and descriptions explicitly warn about ref invalidation. Minor overlap remains between fill and interact (both can type text), between press and interact, and between wait and assert_ui, but the wording largely disambiguates them.

Naming Consistency3/5

Most names are short lowercase tokens, but the set mixes verb_noun (get_guide, list_sessions, configure_reload, assert_ui, evaluate_js) with bare nouns (status, targets, snapshot, diagnostics) and bare verbs (click, fill, stop). It stays readable, yet there is no single predictable pattern an agent can rely on.

Tool Count3/5

21 tools is on the heavy side for a single-app UI driver, and a few pairs could plausibly merge (fill/interact, status/list_sessions, wait/assert_ui). Each tool does map to a real capability, so it is defensible rather than bloated, but it sits at the upper bound.

Completeness4/5

Coverage is strong across the lifecycle: launch/attach, session enumeration, target selection, snapshot/inspect, input actions, screenshots, assertions, diagnostics, and reload policy configuration. Gaps are modest — no explicit navigation/open-URL tool, no window/target management beyond listing, and no file upload or drag operations.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues