Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8802371
perf: cut MCP tool latency by ~73%, and add a benchmark that measures it
claude Aug 1, 2026
9de0113
fix: address PR review on the latency work
claude Aug 1, 2026
b3935b8
fix: report frames a scan could not reach, and verify cached refs res…
claude Aug 1, 2026
0e54e82
fix: report every unscanned frame, expose them in matrix output, clea…
claude Aug 2, 2026
be17d68
test: cover the partial-scan warning in scan_page and audit_site
claude Aug 2, 2026
f868246
fix: harden frame coverage reporting, restore matrix ordering, guard …
claude Aug 2, 2026
c296ec9
fix: bound every frame probe and verify the injection is this server's
claude Aug 2, 2026
246c124
fix: settle failed requests, and do not warn about frames scoped out …
claude Aug 2, 2026
57dbf46
fix: preserve session media emulation, zoom across reloads, and neste…
claude Aug 2, 2026
581ddb9
fix: settle sub-frame navigations, pierce shadow roots, propagate fra…
claude Aug 2, 2026
5e9f847
fix: bound frame lookup, suppress deltas across partial scans, flush …
claude Aug 2, 2026
77161aa
fix: do not blame a variant for the baseline's missing coverage
claude Aug 2, 2026
55e2190
fix: do not let queued frame injections consume their own timeout
claude Aug 2, 2026
587dbef
fix: revalidate cached ref semantics
JustasMonkev Aug 2, 2026
41f66d9
fix: validate refs with public aria snapshots
JustasMonkev Aug 2, 2026
429b00f
fix: version nullable matrix deltas
JustasMonkev Aug 2, 2026
9dd486d
fix: harden frame coverage and snapshot caching
JustasMonkev Aug 2, 2026
e70d16c
fix: align hidden frames and benchmark totals
JustasMonkev Aug 2, 2026
5eaa61f
fix: isolate axe scan readiness
JustasMonkev Aug 2, 2026
0d231b4
fix: reject stale snapshot captures
JustasMonkev Aug 2, 2026
763b998
fix: preserve complete scan coverage
JustasMonkev Aug 2, 2026
9db220d
fix: namespace axe readiness tokens
JustasMonkev Aug 2, 2026
d720e14
fix: invalidate refs across navigation
JustasMonkev Aug 2, 2026
247f136
fix: mirror axe hidden semantics
JustasMonkev Aug 2, 2026
750f6c2
fix: stabilize axe frame coverage
JustasMonkev Aug 2, 2026
343d05d
fix: align axe frame scope semantics
JustasMonkev Aug 2, 2026
c73fef1
fix: validate benchmark report path
JustasMonkev Aug 2, 2026
7443761
fix: cap unscanned frame URLs
JustasMonkev Aug 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@
"tests/tools-axe.test.ts",
"tests/tools-scanPageMatrix.test.ts",
"tests/tools-auditKeyboard.test.ts",
"tests/tools-auditSite.integration.test.ts"
"tests/tools-auditSite.integration.test.ts",
"bench/**"
],
"rules": {
"notice/notice": "off"
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Test: `npm test`
- Coverage: `npm run test:coverage`
- Docker smoke test: `npm run test:docker`
- Tool latency benchmark: `npm run bench` (see the Benchmarking section of `README.md`; build first, and compare revisions with `npm run bench:compare`)
- TypeScript config is driven by `tsconfig.json` and `tsconfig.all.json`.
- Accessibility behavior centers around Axe + Playwright integrations in `src/tools/axe.ts`, `src/tools/auditSite.ts`, `src/tools/auditKeyboard.ts`, and related helpers.
- Keep output and report paths compatible with the current README and CLI expectations.
Expand Down
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ Create a `config.json` file with the following options:
- `browser.contextOptions.storageState`: Start each session from a recorded Playwright storage state; applied in every mode except `--extension` (fresh contexts receive it at creation, reused contexts via `setStorageState()`). Sessions that share one reused context (non-isolated CDP modes) get the state applied once per context — a session joining a live context inherits its current state, not a fresh copy of the file; see [Auditing pages behind a login](#auditing-pages-behind-a-login)
- `timeouts.navigationTimeout`: Maximum time for page navigation in milliseconds (default: `60000`)
- `timeouts.defaultTimeout`: Default timeout for Playwright operations in milliseconds (default: `5000`)
- `timeouts.settle`: How long to wait after each action for triggered work to settle before responding (default: `500`)
- `timeouts.settle`: How long to wait after an action that started network work or navigated, for that work to settle before responding (default: `500`). An action that finishes quietly is watched for up to 100ms (or the settle delay, whichever is shorter) in case it scheduled work rather than starting it; if nothing appears in that window, the response goes out without the settle delay.
- `network.allowedOrigins`: List of origins to allow (blocks all others if specified)
- `network.blockedOrigins`: List of origins to block

CLI equivalents are also available: `--cdp-launch-command`, `--cdp-launch-args`, `--cdp-launch-cwd`, `--cdp-launch-port`, `--cdp-launch-startup-timeout`, `--cdp-endpoint`, `--cdp-header` (repeat for multiple headers, e.g. `--cdp-header "Authorization: Bearer <token>"`), and `--cdp-timeout`. The CDP headers and timeout can also be set via the `PLAYWRIGHT_MCP_CDP_HEADERS` (one `Name: Value` entry per line) and `PLAYWRIGHT_MCP_CDP_TIMEOUT` environment variables.

Use `--timeout-settle` or `PLAYWRIGHT_MCP_TIMEOUT_SETTLE` to override the post-action settle delay.
Use `--timeout-settle` or `PLAYWRIGHT_MCP_TIMEOUT_SETTLE` to override the post-action settle delay. It applies after actions that actually started something: a click that fires a request or navigates waits it out, while a click that only changed local DOM state responds without it. Work the action scheduled on a timer still counts — a short window after the action catches it before the response is built.

#### HTTP Heartbeat

Expand Down Expand Up @@ -360,6 +360,11 @@ In `audit_site`, selectors apply to every crawled page, so an `includeSelectors`
**Incomplete ("needs review") results:**
Axe returns `incomplete` for checks it cannot decide on its own -- contrast over a background image or gradient, ambiguous labels, elements it could not fully evaluate. `scan_page`, `audit_site`, and `scan_page_matrix` report these in a section separate from violations so you can resolve them by inspecting the page (screenshot, snapshot, `browser_evaluate`). Set `includeIncomplete: false` to suppress them.

**Frames that could not be scanned:**
Axe is installed into every frame of the page before the scan runs. A frame that navigates mid-injection, or whose renderer does not answer within a second, is left out -- and its contents then contribute no findings. Rather than let that pass as a clean result, all three scan tools print a `WARNING: Axe could not be installed in N frame(s)` block listing the frame URLs, and `audit_site` and `scan_page_matrix` also record them per page and per variant in their JSON reports (`unscannedFrames`) and in `structuredContent`. A frame that was still loading usually succeeds on a re-run; one that fails consistently has to be audited on its own.

A frame you scoped out yourself is not reported: with `excludeSelectors: ["iframe.intercom-frame"]` that widget failing to load is the outcome you asked for, not a gap. Scope is resolved through the whole frame chain, so an `includeSelectors` entry naming an ancestor still covers frames nested several levels below it, and excluding an outer frame silences everything inside it. Anything the check cannot resolve is reported rather than hidden.

### Audit Tools

#### `audit_site`
Expand Down Expand Up @@ -694,6 +699,30 @@ cd mcp-accessibility-scanner
npm install
```

### Benchmarking tool latency

`bench/mcp-bench.mjs` measures what a client actually waits for: it serves a fixed
synthetic site, speaks MCP to the built server over stdio, and times real
`tools/call` round trips for navigation, interaction, snapshots and every audit
tool. Build first — it runs the compiled server from `lib/`.

```bash
npm run build
npm run bench -- --out after.json --label after
```

Useful flags: `--iterations <n>` and `--warmups <n>` (defaults 5 and 1),
`--browser`/`--executable-path` when the browser lives outside Playwright's own
download directory, and `--server <path/to/cli.js>` plus `--lib <path/to/lib>` to
point at a different build — that is how a revision is compared with another:

```bash
git worktree add /tmp/baseline main && (cd /tmp/baseline && npm install && npm run build)
npm run bench -- --server /tmp/baseline/cli.js --lib /tmp/baseline/lib --out before.json --label before
npm run bench -- --out after.json --label after
npm run bench:compare -- before.json after.json
```

## License

MIT
4 changes: 2 additions & 2 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Scan the current page for accessibility violations using Axe.
{"violationsTag": ["wcag2aa", "wcag21aa", "wcag22aa"]}
```

For Electron CDP targets, `scan_page` may currently fail with `Target.createTarget: Not supported`. If that happens, keep using the CLI session, select the live app tab with `browser_tabs`, and run Axe through `browser_evaluate` by injecting the local `node_modules/axe-core/axe.min.js` bundle.
The scan injects Axe into the frames that are already open and runs it there; it no longer opens a helper page, which is what used to fail on Electron CDP targets with `Target.createTarget: Not supported`. If a scan still fails on such a target, keep using the CLI session, select the live app tab with `browser_tabs`, and run Axe through `browser_evaluate` by injecting the local `node_modules/axe-core/axe.min.js` bundle.

### audit_site

Expand Down Expand Up @@ -311,7 +311,7 @@ Typical REPL flow:
> browser_evaluate {"function":"() => document.querySelector('SELECTOR_FOR_NEXT_STEP')?.click()"}
```

If `scan_page {}` fails on the Electron target, use this Axe fallback from the same REPL session:
If `scan_page {}` still fails on the Electron target, use this Axe fallback from the same REPL session:

```json
{
Expand Down
96 changes: 96 additions & 0 deletions bench/fixture.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Deterministic pages served to the benchmarked MCP server.
*
* The markup is generated from a fixed seed so every run - and every revision
* compared against another - scans exactly the same DOM.
*/

const seededRandom = seed => () => {
seed = (seed * 1103515245 + 12345) & 0x7fffffff;
return seed / 0x7fffffff;
};

function heavyPage() {
const random = seededRandom(42);
const rows = [];
for (let index = 0; index < 220; index++) {
const label = `Item ${index}`;
// A mix of named and unnamed controls so axe finds real violations and the
// aria snapshot has interactive refs to click.
const missingAlt = random() < 0.2;
// Every fifth button is genuinely unnamed - no label, and an aria-hidden
// glyph for its only content - so the scan really does report button-name.
const unnamed = index % 5 === 0;
rows.push([
'<li class="row">',
`<a href="/page-${index % 12}.html">${label} link</a>`,
unnamed
? `<button id="btn-${index}"><span aria-hidden="true">&#9654;</span></button>`
: `<button id="btn-${index}" aria-label="Action ${index}">Go ${index}</button>`,
`<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ${missingAlt ? '' : `alt="Thumb ${index}"`}>`,
`<span class="muted" style="color:#bbb;background:#fff">Low contrast text ${index}</span>`,
'</li>',
].join(''));
}
return [
'<!doctype html><html lang="en"><head><meta charset="utf-8">',
'<title>Benchmark heavy page</title>',
'<style>.row{display:flex;gap:4px;align-items:center}.muted{font-size:12px}',
'button{min-width:12px;min-height:12px}img{width:16px;height:16px}</style>',
'</head><body>',
'<a href="#main" class="skip">Skip to main content</a>',
'<header><nav><a href="/page-1.html">Home</a><a href="/page-2.html">Docs</a></nav></header>',
'<main id="main"><h1>Benchmark heavy page</h1>',
'<form><label>Search <input aria-label="Search" name="q"></label>',
'<select aria-label="Sort"><option>Newest</option><option>Oldest</option></select>',
'<button type="button" id="submit" aria-label="Submit search">Submit</button></form>',
`<ul>${rows.join('')}</ul>`,
'</main></body></html>',
].join('');
}

function smallPage(index) {
return [
'<!doctype html><html lang="en"><head><meta charset="utf-8">',
`<title>Benchmark page ${index}</title></head><body>`,
`<main><h1>Page ${index}</h1>`,
`<p>Body copy for page ${index}.</p>`,
`<a href="/page-${(index + 1) % 12}.html">Next page</a>`,
`<a href="/page-${(index + 2) % 12}.html">Skip ahead</a>`,
`<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">`,
'<button><span aria-hidden="true">&#9654;</span></button>',
'</main></body></html>',
].join('');
}

export const pages = new Map([
['/', heavyPage()],
['/heavy.html', heavyPage()],
...Array.from({ length: 12 }, (_, index) => [`/page-${index}.html`, smallPage(index)]),
]);

/** A string with many embedded data URLs, for the string-processing micro benchmark. */
export function dataUrlHeavyText(repeat = 400) {
const payload = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'.repeat(4);
const lines = [];
for (let index = 0; index < repeat; index++) {
lines.push(`- img "Thumb ${index}" [ref=e${index}]:`);
lines.push(` - /url: data:image/gif;base64,${payload}`);
lines.push(`- text: plain aria node ${index} with no url at all`);
lines.push(`- link "Item ${index}" [ref=e${index}b]:`);
lines.push(` - /url: https://example.com/page-${index}`);
}
return lines.join('\n');
}

/** A large aria snapshot with no data URLs at all - the common case. */
export function plainSnapshotText(repeat = 2000) {
const lines = [];
for (let index = 0; index < repeat; index++) {
lines.push(`- listitem [ref=e${index}]:`);
lines.push(` - link "Item ${index} link" [ref=e${index}a]: /page-${index % 12}.html`);
lines.push(` - button "Action ${index}" [ref=e${index}b]`);
lines.push(` - text: Low contrast text ${index}`);
}
return lines.join('\n');
}
Loading