Metadata-Version: 2.5
Name: chromium-web-audit-toolkit
Version: 0.2.2
Summary: Local evidence-led public web app audits through Chromium browsers and MCP clients
Project-URL: Homepage, https://nirv067.github.io/chromium-web-audit-toolkit/
Project-URL: Repository, https://github.com/nirv067/chromium-web-audit-toolkit
Project-URL: Releases, https://github.com/nirv067/chromium-web-audit-toolkit/releases
License-Expression: MIT
License-File: LICENSE
Keywords: accessibility,browser-extension,chromium,core-web-vitals,mcp,web-audit
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.12
Requires-Dist: fastmcp<4,>=3.0
Requires-Dist: pillow>=10.0.0
Requires-Dist: pydantic<3,>=2.10
Description-Content-Type: text/markdown

# Chromium Web Audit Toolkit

Audit web apps through Chromium-based browsers with an MCP-compatible AI client. A local MCP server, paired browser extension, and audit skill collect functional, visual, performance, design-system and accessibility evidence in a reusable audit record.

**New here?** Start with the [product overview](https://nirv067.github.io/chromium-web-audit-toolkit/) or jump to [installation](#install). Preview a plan before it opens Chromium, then review the evidence-backed report and its coverage limits.

## Feature highlights

- **Use your existing Chromium session.** The extension works with Google Chrome, Brave, Arc and Edge, including a profile where you are already signed in. The toolkit does not restart the browser or require a remote-debugging port.
- **Keep browser access local.** The MCP server and extension communicate through an authenticated loopback bridge. Pairing and reconnecting are automatic; pairing secrets are stored locally and are not printed by setup or included in reports.
- **Audit real page flows.** Inspect visible text, links, headings, controls, ARIA widgets and Shadow DOM. Discover same-origin pages, generate candidate journeys from forms and navigation, or compile a plain-language goal into a reviewable journey.
- **Control interactions and cleanup.** Run declared, step-by-step journeys with clicks, typing, key chords, hover, scrolling, dragging and waits. Assertions check named outcomes; data-changing journeys require explicit cleanup. Password entry and file selection stay manual in the browser.
- **Review responsive states.** Capture screenshots at declared desktop, tablet and mobile-sized viewports, with named page states and SHA-256 evidence identifiers. Add severity-colored annotations to screenshots when a finding has a selector.
- **Check accessibility.** Run bundled axe-core checks for WCAG 2.2 A/AA rules. Store rule results as evidence-backed findings and report incomplete checks and frame-coverage limits explicitly.
- **Measure quality signals.** Collect console errors and warnings, check visited same-origin links for HTTP errors, measure LCP, CLS, FCP, TTFB and long tasks, and inspect CSS design tokens, colors and typography.
- **Export evidence and compare runs.** Produce a local HTML report viewer, prioritized Markdown summary, detailed report, portable findings JSON, issue drafts, machine-readable `context.json`, and a screenshot gallery. Compare runs as new, persistent, resolved or not rechecked; analyze quality, defect and performance trends over time.
- **Run audits concurrently.** Keep several runs active at once, one browser tab per run, with per-tab command lanes so different tabs run in parallel while commands for one tab stay ordered. See [Concurrent audits](#concurrent-audits).
- **Resume and recover safely.** Persist run state, inspect progress and blocking reasons, resume without replaying uncertain actions, finish declared cleanup, and re-export partial runs without marking unfinished checks as passed. The extension re-attaches to its tabs if Chrome restarts its service worker mid-audit and records that network and console logs from before the restore are incomplete.
- **Protect sensitive data.** Public HTTP(S) targets are the default; private-network targets need explicit opt-in. Reports omit live form values, redact known URL secrets and keep private recovery state separate from shareable output. Purge removes a completed run and its evidence.
- **Use from MCP clients or the terminal.** Install the server and packaged skill for Codex, Antigravity, Claude, Cursor or Windsurf, or use the `chromium-audit` CLI directly. Structured logging on stderr is available for both; see [Logging](#logging).

## MCP functionality

The MCP server exposes these tools:

| Tool | Function |
|---|---|
| `audit_pages` | List browser tabs for a specified run or target URL. |
| `audit_start` | Start a run with an audit specification and optional selected tab. |
| `audit_status`, `audit_select_page` | Read page, check, journey and budget progress; inspect blockers and next steps; or bind a run to an explicit in-scope tab. |
| `audit_inspect`, `audit_act`, `audit_capture` | Inspect the page, execute a declared action, and save a named state, screenshot and assertions. |
| `audit_accessibility`, `audit_performance`, `audit_design_tokens` | Run accessibility, performance, and design-token/typography checks. |
| `audit_generate_journeys`, `audit_compile_journey` | Generate candidate flows from page structure or prepare context for compiling a plain-language goal. |
| `audit_check_links`, `audit_record_finding`, `audit_annotate_screenshot` | Check visited links, record evidence-linked findings, and annotate screenshot evidence. |
| `audit_export`, `audit_compare`, `audit_trend` | Export a run, compare two runs, or review trends across prior runs. |
| `audit_finish`, `audit_purge` | Run declared cleanup and detach, or permanently remove a completed run. |

The CLI provides setup and connection diagnostics (`setup`, `doctor`, `bridge`), safe starter plans and previews (`quickstart`, `preview`), MCP serving and client installation (`serve`, `install`), tab listing and bounded discovery (`pages`, `audit`), specification-based journeys (`run`), recent-run listing (`runs`), watchable progress (`status --watch`), and run lifecycle commands (`finish`, `export`, `compare`, `purge`).

## Install

Requirements: macOS (the tested platform), a Chromium-based browser with Manifest V3 extension support, Python 3.12+, and [uv](https://docs.astral.sh/uv/). The existing browser session is used without restarting the browser or enabling a remote-debugging port. Run-store file locking also has a Windows implementation (`msvcrt`); it has not been tested on real Windows.

From this source directory:

```sh
uv sync --locked
uv run chromium-audit setup
uv run chromium-audit bridge
```

`setup` prints the extension directory and an MCP configuration. It does not print a pairing secret. The MCP server starts the bridge automatically when it runs; the extension pairs and reconnects automatically when the local bridge is available.

1. In your Chromium browser, open `chrome://extensions` and enable Developer mode.
2. Choose **Load unpacked** and select this project's `extension` directory.
3. Start the registered MCP server or run `uv run chromium-audit bridge`. The extension pairs automatically; its options page reports connection status. Only one browser profile can be paired at a time; a second profile is refused with `profile_conflict`.
4. Run `uv run chromium-audit doctor --format text`. Follow its next steps until it says the toolkit is ready. Use `--format json` for scripts and integrations.

The extension must be loaded manually. There is no silent auto-install: Google Chrome 137 and later ignores `--load-extension`, and other routes need enterprise policy or a Chrome Web Store listing.

Pairing grants the locally built extension debugger access to pages you select. Load it only in the intended browser profile. Automatic pairing is limited to the extension's browser origin and the loopback bridge. The bridge secret stays in its private local state directory and the extension's local storage; it is neither printed by `setup` nor included in reports or source bundles.

## Use from MCP-compatible AI clients

Install globally for Codex with:

```sh
uv run chromium-audit install --target codex
```

This adds the `chromium-audit` MCP server to `~/.codex/config.toml` and copies the packaged skill to `~/.agents/skills/chromium-web-audit/`. The installer replaces an existing `dia-audit` registration; remove that entry manually if you configured the server yourself. Existing run data remains in its original state directory; pass that directory with `--state-dir` to continue an earlier run. Config updates preserve unrelated settings, are atomic, and fail closed on malformed files. Reload Codex tools and skills after installation.

For manual setup, use the command and arguments printed by `setup`, or:

```sh
codex mcp add chromium-audit -- /absolute/path/to/.venv/bin/chromium-audit --state-dir /absolute/path/to/state --output-dir /absolute/path/to/outputs/audits serve
```

The packaged `skills/chromium-web-audit/SKILL.md` is the source of truth. For project-only use, copy it into that project's `.agents/skills/` directory. Then ask:

> Use $chromium-web-audit to audit https://my-public-app.example. Inspect public pages and the account already signed into your selected browser. Capture desktop, tablet and mobile-sized layouts, run accessibility checks, and export a structured report that turns captured data into findings and analysis. Compare with the previous run if available.

Local MCP registration does not by itself make the toolkit available to hosted ChatGPT web. The toolkit has no remote/cloud service or separate LLM API integration.

## Use from the terminal

```sh
uv run chromium-audit quickstart https://my-public-app.example --preset overview
uv run chromium-audit preview chromium-audit-spec.json
uv run chromium-audit run chromium-audit-spec.json
uv run chromium-audit doctor
uv run chromium-audit pages --url https://demo.playwright.dev/todomvc/
uv run chromium-audit audit https://demo.playwright.dev/todomvc/
uv run chromium-audit run examples/todomvc.json
uv run chromium-audit runs
uv run chromium-audit status RUN_ID
uv run chromium-audit status RUN_ID --watch
uv run chromium-audit status RUN_ID --resume
uv run chromium-audit finish RUN_ID
uv run chromium-audit export RUN_ID
uv run chromium-audit compare BEFORE_RUN_ID AFTER_RUN_ID
uv run chromium-audit purge RUN_ID
```

`quickstart` creates an overview or accessibility plan and never opens the browser. Private or localhost targets are rejected unless you explicitly pass `--allow-private-network`. `preview` prints its target, goals, screen sizes, page limit, journeys, expected assertions, possible data changes and cleanup without connecting to Chromium. Review the plan, then use `run` to start it. `doctor --format text` gives human-readable setup steps; its default JSON format remains available for scripts.

Global `--state-dir`, `--output-dir`, `--log-level` and `--log-format` options come before the subcommand. Defaults are `work/chromium-audit-state` and `outputs/audits` under your current directory. Use absolute arguments in MCP registration so all clients address the same run store.

The terminal audit explores ordinary same-origin links, captures declared viewports, and runs accessibility checks. It does not use an LLM, assign invented business requirements, or perform a real-user usability study. An MCP-compatible AI client supplies visual interpretation and evidence-linked analysis through the skill.

## Concurrent audits

Multiple runs can be active at the same time. The run store tracks the set of active runs, and each run has its own lock. The extension keeps one debugger session per tab. Browser commands for different tabs run in parallel; commands for the same tab stay ordered.

- Only one browser profile can be paired with the bridge at a time.
- Use a separate browser window for each concurrent run. Selecting a page activates its tab, so runs sharing a window compete for the foreground tab.
- `audit_start`, `audit_status`, `audit_pages`, `audit_finish` and `audit_compare` still share one global lock and run one at a time.

## Logging

```sh
uv run chromium-audit --log-level DEBUG --log-format json serve
```

`--log-level` accepts `DEBUG`, `INFO`, `WARNING`, `ERROR` or `CRITICAL`; `--log-format` accepts `text` or `json`. Defaults come from `CHROMIUM_AUDIT_LOG_LEVEL` and `CHROMIUM_AUDIT_LOG_FORMAT=json`, falling back to `WARNING` and `text`. Logs go to stderr only, because stdout carries MCP stdio. Bridge tokens and fill values are not logged.

## Journeys

An audit specification contains `url`, optional `goals`, `account_role`, `requires_authentication`, `journeys`, `limits`, `viewports`, `baseline_run_id`, `crawl_sitemap` and `allow_private_network`. Private and localhost targets are blocked by default; set `allow_private_network: true` only for a trusted target. Unknown top-level fields are rejected. See `examples/todomvc.json` for a runnable public-demo workflow. Set `requires_authentication: true` when a signed-in session is expected; a visible password form then blocks the run for manual sign-in. This detection is a heuristic, not a complete authentication-state detector.

- Automatic discovery can navigate same-origin links and toggle menus, tabs and details. Paths that appear to log out, delete, buy or confirm are excluded from discovery. Link inspection is heuristic; use a test session for applications where navigation itself has effects.
- Input filling, key presses, hover, double-clicks and ordinary clicks must match the next exact step in a supplied journey. Steps use CSS selectors or fresh `ref:<reference>` values returned by inspection. For text-scoped CSS, use `css=.item >> has-text=Exact item text >> css=button`. Each target must resolve to one visible element. `has-text` filters the preceding scope by substring, and ambiguous matches are rejected.
- Journeys that fill fields, submit forms, or press Enter require `changes_application_data: true` and explicit cleanup steps. This is also checked against live form controls at execution time. Generated form journeys are candidates only; add cleanup before starting one.
- Password entry and file selection are manual in version one. Sign in in the selected browser and resume the run. No credentials need to be supplied in chat.
- An uncertain action is not replayed. Its cursor advances before dispatch; inspect the resulting state before deliberately proceeding. To rerun a failed journey from the beginning, finish and clean up the existing run first.
- Each run is bound to one selected browser tab. Several runs can be active at once; see [Concurrent audits](#concurrent-audits).

## Reports

Each run gets a unique directory containing:

| File | Contents |
|---|---|
| `report.md` | Evidence, check counts, findings, recommendations and explicit limitations organized into captured evidence, findings and analysis. |
| `report.html` | Offline, keyboard-friendly report viewer joining the overview, findings, evidence, check statuses, human-review items and limitations. |
| `summary.md` | Short, severity-ordered audience summary with finding status, expected/actual behavior, reproduction steps and evidence links. |
| `findings.json` | Portable tracker-friendly findings data with no local evidence file paths. Finding text and linked evidence may contain private app content; review it before sharing. |
| `issue-drafts.md` | Copy/paste-ready issue drafts for findings. It does not post to an external service; review the app content before sharing. |
| `context.json` | Versioned LLM context with claim types, confidence, source evidence, checks and missing data. |
| `evidence.html` | Local screenshot gallery. |
| `evidence/` | PNG captures and JSON page/accessibility/diagnostic evidence, identified by hashes. |
| `state/runs/RUN_ID.json` | Private runtime record needed for recovery and re-export; stored outside the shareable report directory. |

Inspection never returns live form values. Fill values needed for recovery stay in private runtime state; reports and exported context omit them. URLs redact known secret-bearing path segments, query parameters, and fragments. The extension does not log raw commands, and network request tracking is bounded. Page text and screenshots can still contain information visible to the signed-in user. Review evidence before sharing it externally. `chromium-audit purge RUN_ID` permanently removes a completed run's private record, reports, and evidence.

`audit_compare` identifies **new**, **persistent**, **resolved**, and **not rechecked** findings. It only resolves a finding when the corresponding route, named state, viewport and check were executed. Manual visual findings without a corresponding executed check remain not rechecked. Matched screenshots are linked for review; no arbitrary visual score is produced.

## Limits and recovery

Defaults: five pages, three journeys, fifty interaction attempts, fifteen minutes of active tool execution, and viewport sizes 1440×900, 768×1024 and 390×844. Active time excludes waiting between tool calls. Limits can be supplied in the audit spec as `spec.limits`. Sitemap discovery adds three more:

| Limit | Default | Range |
|---|---|---|
| `sitemap_depth` | 2 | 0-5 |
| `sitemap_fetches` | 10 | 1-50 |
| `max_path_depth` | 8 | 1-32 |

Sitemap discovery returns at most 500 URLs. Nested sitemaps on another origin are never fetched. Truncation by any of these limits is recorded as a run limitation. Set `crawl_sitemap: false` in the spec to skip sitemap discovery.

Missing tabs, redirects outside the app's origin, expired sessions, uncertain results and limit exhaustion block further exploration. Top-level document redirects are intercepted before leaving the approved origin. Inspect `audit_status`; sign in manually or explicitly choose the intended tab before resuming. `audit_finish` remains available for cleanup even after limits are reached, then restores viewport emulation and detaches. Cleanup errors and skipped work are retained in the report.

A process interruption preserves the run store. Restart the MCP server with the same directories, inspect the active run, and finish or resume it. A bridge command that expires before delivery is discarded; a command timing out after delivery returns an uncertain result and is never automatically replayed. CDP commands time out after 30 seconds, and a keep-alive alarm runs while tabs are attached. If Chrome kills the Manifest V3 service worker, the extension restores its sessions (tab, origin and private-network flag, kept in `chrome.storage.session`) and re-attaches. Results are flagged `restored`, and the run records a limitation that network and console logs from before the restore are incomplete.

The bridge rate-limits requests that lack the bridge token; authenticated traffic is not throttled.

## Coverage boundaries

- Accessibility checks use bundled axe-core 4.14.1 and its A/AA rules through WCAG 2.2. Incomplete checks remain blocked, not passed. This is automated checking, not comprehensive accessibility certification.
- The initial scan injects axe only in the top frame. Frame coverage is explicitly reported as incomplete.
- Viewports are emulated in the desktop browser. Physical mobile devices, platform-specific gestures, cross-browser behavior and real-user usability need separate testing.
- Core Web Vitals field metrics (LCP, CLS, FCP, TTFB and long tasks) are measured from the current page; this is not Lighthouse or a full browser performance trace. Team dashboards, schedules and browser-specific experimental AI features are outside version one.
- Concurrent runs share one paired browser profile and the same foreground-tab constraint; see [Concurrent audits](#concurrent-audits).
- A clean report indicates no recorded findings in the sampled coverage, not proof that the product has no defects.

## Development and verification

```sh
uv sync --locked
uv run pytest tests/ -q
uv run ruff check src tests
node --check extension/background.js
node --check extension/options.js
node --test extension/tests/dispatch.test.mjs extension/tests/recovery.test.mjs
uv build
```

The suite has 105 Python tests and 9 extension tests. Tests cover actual decision rules: command expiration and uncertain outcomes, authentication boundaries, explicit tab selection, evidence integrity, assertion failures, limits, cleanup, concurrent runs, service worker recovery and missing comparison coverage. Tests using a fixture adapter are not represented as live browser tests.

The underlying extension architecture is adapted from [damnitjoshua/dia-mcp](https://github.com/damnitjoshua/dia-mcp) at the revision in `vendor/provenance.json`. License notices for that project and axe-core are included in `vendor/`.
