Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .codex/mcp-tool-prompts.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ browser_wait_for required You are testing the mcp-accessibility-scanner MCP tool
audit_site required You are testing the mcp-accessibility-scanner MCP tool audit_site. Use mcp-accessibility-scanner. First call browser_navigate with __FIXTURE_URL__. Then call audit_site with strategy "provided", urls ["__FIXTURE_URL__"], maxPages 1, maxDepth 0, sameOriginOnly true, includeSubdomains false, excludePathPatterns ["logout|signout"], ignoreQueryParams ["utm_source"], violationsTag ["wcag2a","wcag2aa"], maxNodesPerViolation 5, and waitAfterNavigationMs 50. Return only PASS if audit_site completes with exactly one scanned page and zero errored pages, otherwise FAIL with the observed output.
scan_page_matrix required You are testing the mcp-accessibility-scanner MCP tool scan_page_matrix. Use mcp-accessibility-scanner. Navigate to data:text/html,%3Ctitle%3EMatrix%3C/title%3E%3Cimg%20src%3D%22x%22%3E%3Ch1%3EMatrix%3C/h1%3E, then call scan_page_matrix with variants [{"name":"baseline"},{"name":"mobile","viewport":{"width":390,"height":844}}], violationsTag ["wcag2a","wcag2aa"], maxNodesPerViolation 5, waitAfterApplyMs 50, and reloadBetweenVariants true. Return only PASS if scan_page_matrix completes and reports a JSON report path or variants, otherwise FAIL with the observed output.
audit_keyboard required You are testing the mcp-accessibility-scanner MCP tool audit_keyboard. Use mcp-accessibility-scanner. Navigate to data:text/html,%3Ctitle%3EKeyboard%3C/title%3E%3Ca%20href%3D%22%23main%22%3ESkip%20to%20main%3C/a%3E%3Cmain%20id%3D%22main%22%3E%3Cinput%20aria-label%3D%22Search%22%3E%3Cbutton%3EGo%3C/button%3E%3C/main%3E, then call audit_keyboard with maxTabs 8, includeShiftTab false, stopOnCycle true, cycleWindow 4, checkSkipLink true, skipLinkMaxTabs 3, activateSkipLink false, checkFocusTrap true, checkFocusVisibility true, checkFocusJumps true, jumpScrollThresholdPx 600, screenshotOnIssue false, and maxIssueScreenshots 2. Return only PASS if audit_keyboard completes and reports a JSON report path or keyboard summary, otherwise FAIL with the observed output.
audit_keyboard_operation required Use mcp-accessibility-scanner. Navigate to data:text/html,%3Cbutton%20id%3D%22toggle%22%20aria-expanded%3D%22false%22%20onclick%3D%22this.setAttribute%28%27aria-expanded%27%2C%27true%27%29%22%3EOpen%3C%2Fbutton%3E, then call audit_keyboard_operation with {"steps":[{"key":"Tab","expect":[{"selector":"#toggle","focused":true}]},{"key":"Enter","expect":[{"selector":"#toggle","expanded":true}]}]}. Return PASS only if the result reports status passed, both steps passed and a JSON report link; otherwise FAIL with observed output.
audit_form_validation required Use mcp-accessibility-scanner. Navigate to data:text/html,%3Cform%20novalidate%20onsubmit%3D%22event.preventDefault%28%29%3B%20document.getElementById%28%27error%27%29.textContent%3D%27Enter%20a%20valid%20email%27%22%3E%3Clabel%20for%3D%22email%22%3EEmail%3C%2Flabel%3E%3Cinput%20id%3D%22email%22%20aria-describedby%3D%22error%22%3E%3Cbutton%20id%3D%22submit%22%3ESubmit%3C%2Fbutton%3E%3Cp%20id%3D%22error%22%3E%3C%2Fp%3E%3C%2Fform%3E, then call audit_form_validation with {"fields":[{"selector":"#email","value":"invalid-email"}],"submitSelector":"#submit","expectedFeedback":[{"selector":"#error","kind":"error"}],"timeoutMs":100}. Return PASS only if the result reports outcome completed, zero findings and a JSON report link; otherwise FAIL with observed output.
43 changes: 43 additions & 0 deletions .codex/run-mcp-direct-harness.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,49 @@ const tests = [
assertText(restored, /\b0\b/);
}),

test('audit_keyboard_operation', async () => {
await navigate('<button id="toggle" aria-expanded="false" onclick="this.setAttribute(\'aria-expanded\',\'true\')">Open</button>');
const result = await callTool('audit_keyboard_operation', {
steps: [
{ key: 'Tab', expect: [{ selector: '#toggle', focused: true }] },
{ key: 'Enter', expect: [{ selector: '#toggle', expanded: true }] },
],
});
if (result.structuredContent?.status !== 'passed' || result.structuredContent.steps.length !== 2)
throw new Error('Keyboard operation did not verify both steps.');
assertText(result, /JSON report:/);
const failed = await callTool('audit_keyboard_operation', {
timeoutMs: 0,
steps: [{ key: 'Enter', expect: [{ selector: '#toggle', expanded: false }] }],
});
if (failed.structuredContent?.status !== 'failed' || failed.structuredContent.findings[0]?.property !== 'expanded')
throw new Error('Keyboard operation did not detect the incorrect expected outcome.');
await navigate('<label for="entry">Entry</label><input id="entry">');
const typing = await callTool('audit_keyboard_operation', {
steps: [
{ key: 'Tab', expect: [{ selector: '#entry', focused: true }] },
{ text: 'draft', expect: [{ selector: '#entry', value: 'draft' }] },
{ key: 'Backspace', expect: [{ selector: '#entry', value: 'draf' }] },
],
});
if (typing.structuredContent?.status !== 'passed')
throw new Error('Keyboard text entry and editing did not complete.');
}),

test('audit_form_validation', async () => {
await navigate('<form novalidate onsubmit="event.preventDefault(); document.getElementById(\'error\').textContent=\'Enter a valid email\'">'
+ '<label for="email">Email</label><input id="email" aria-describedby="error"><button id="submit">Submit</button><p id="error"></p></form>');
const result = await callTool('audit_form_validation', {
fields: [{ selector: '#email', value: 'invalid-email' }],
submitSelector: '#submit',
expectedFeedback: [{ selector: '#error', kind: 'error' }],
timeoutMs: 100,
});
if (result.structuredContent?.outcome !== 'completed' || result.structuredContent.interactionMode !== 'keyboard' || result.structuredContent.summary.findingCount !== 0)
throw new Error('Form validation did not recognize the associated error.');
assertText(result, /JSON report:/);
assertText(await callTool('browser_evaluate', { function: '() => document.getElementById("email").value' }), /invalid-email/);
}),
...(connectOnly ? [test('browser_connect', async () => {
assertText(await callTool('browser_connect', { name: 'default' }), /Successfully changed connection method/);
})] : []),
Expand Down
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ audit_text_spacing {}

These are MCP tool calls, not shell subcommands. For terminal use, see [interactive mode](#interactive-repl-interactive-subcommand).

`scan_page` returns text findings with JSON node details and remediation links. With `annotateScreenshot: true`, it also saves a full-page annotated PNG and returns a file resource link. It does **not** save a JSON report. `audit_keyboard`, `audit_screen_reader` and `audit_text_spacing` save JSON reports and return summaries and report links; `audit_site` and `scan_page_matrix` also save JSON reports. There is no generated HTML report dashboard. Review incomplete checks, coverage warnings and the page states you haven't tested.
`scan_page` returns text findings with JSON node details and remediation links. With `annotateScreenshot: true`, it also saves a full-page annotated PNG and returns a file resource link. It does **not** save a JSON report. `audit_keyboard`, `audit_keyboard_operation`, `audit_form_validation`, `audit_screen_reader` and `audit_text_spacing` save JSON reports and return summaries and report links; `audit_site` and `scan_page_matrix` also save JSON reports. There is no generated HTML report dashboard. Review incomplete checks, coverage warnings and the page states you haven't tested.

To reproduce the screenshot, serve the demo from this repository with `python3 -m http.server 8765 --bind 127.0.0.1 --directory docs/assets`, navigate to `http://127.0.0.1:8765/accessibility-demo.html`, then run `scan_page` with `annotateScreenshot: true`. The screenshot used a 1000×720 viewport (`--viewport-size 1000,720`).

Expand Down Expand Up @@ -696,6 +696,48 @@ Audits real keyboard focus behavior by pressing Tab (and optional Shift+Tab) wit
3. Review focus findings and open the generated JSON report path
```

#### `audit_keyboard_operation`
Exercises a caller-defined keyboard scenario and checks the outcome after each key. Unlike `audit_keyboard`, this tests operation: opening a menu, selecting an option, dismissing a dialog, or returning focus. It does not discover tasks or decide which outcome your application should produce.

Start from a known page state. Supply `steps`, each with exactly one of `key` or `text` and a nonempty `expect` array. Expectations use stable selectors so they can address elements that appear or rerender during the scenario. Actions use real keyboard input, never programmatic focus, clicks, or fills. Use `Tab` steps to reach the control instead of bypassing keyboard reachability.

```json
{
"steps": [
{ "key": "Tab", "expect": [{ "selector": "#open-menu", "focused": true }] },
{ "key": "Enter", "expect": [{ "selector": "#open-menu", "expanded": true }, { "selector": "#menu", "visible": true }] },
{ "key": "Escape", "expect": [{ "selector": "#menu", "visible": false }, { "selector": "#open-menu", "focused": true }] }
]
}
```

**Parameters and bounds:** `steps` accepts 1–20 steps, with 1–10 expectations each. Keys are `Tab`, `Shift+Tab`, `Enter`, `Space`, the four arrow keys, `Escape`, `Home`, `End`, `Backspace`, `Delete` and `ControlOrMeta+A`. A `text` step enters 1–500 characters sequentially into the currently focused editable element. The audit checks that the same element remains focused and editable before and after each character; focus theft, removal or replacement makes the scenario incomplete instead of sending the remaining text elsewhere. Each expectation requires a CSS `selector` and at least one of `focused`, `visible`, `text`, `value`, `expanded`, `checked`, `selected`, `pressed` or `disabled`. Boolean states are exact; `checked` and `pressed` also accept `"mixed"`. Text compares trimmed `textContent`; values compare native form values or `aria-valuenow`. Text/value contents are omitted from reports. Selectors address the main frame and open shadow roots, not iframe contents. The audit compares selector matches before and after the outcome sample. If those matches differ, the step is incomplete. A match that changes and reverts between those checks can be missed. An ambiguous selector or unsupported state is incomplete, not a pass. `visible` checks rendering (content inside a closed `<details>` or `hidden=until-found` is not visible), layout boxes and computed visibility, not opacity or visual occlusion; use `audit_keyboard` separately for focus visibility/obscuration heuristics. `timeoutMs` is the per-step observation window (0–1000 ms, default 300). All outcomes for a step are measured together at the end of that window so a brief focus match before a delayed trap is not accepted immediately; zero samples once without waiting. Changes after the window are not covered. The overall scenario budget is 30 seconds.

This is a **state-changing** tool: a key can submit a form or navigate. It does not undo actions. Use controlled test data and reset the page before repeating a scenario. An assertion mismatch stops the scenario; subsequent steps are not run. An interrupted action or unavailable measurement is not a passing check. JSON reports and structured results distinguish tested outcomes from incomplete work. This supports investigation of WCAG 2.1.1, 2.1.2 and 2.4.3, not certification of keyboard access across the site.

#### `audit_form_validation`
Exercises one caller-defined invalid-input case: reaches the named text inputs/textarea fields through keyboard navigation, replaces their contents through keyboard input, activates the supplied submit control, and inspects the expected error/status feedback. It does not discover forms, choose invalid values, or submit other forms automatically.

```json
{
"fields": [{ "selector": "#email", "value": "invalid-email" }],
"submitSelector": "#submit",
"expectedFeedback": [{ "selector": "#email-error", "kind": "error" }]
}
```

`interactionMode` defaults to `"keyboard"`: starting from the current focus, it presses Tab to reach each field (up to 50 presses per target), selects existing text with `ControlOrMeta+A`, clears it with Backspace, and enters the supplied value character by character. It then reaches the submit control through Tab and presses Enter. It never calls focus, fill or click in this mode. A target that cannot be reached, focus that moves elsewhere during entry, or a field that does not retain the supplied value makes the scenario incomplete and prevents later submission. Keyboard mode rejects CR/LF in single-line input values before mutation; textarea newlines are supported. Use `interactionMode: "direct"` for the previous fill-and-click behavior; direct mode does not prove keyboard reachability. Both modes verify the supplied field values before activating submit and stop as incomplete on a mismatch. Reports identify the mode used.

Text input follows browser key/input event sequences without randomized timing. It does not reproduce human cadence, an operating-system keyboard layout, IME composition, or a screen reader. Some Unicode characters are inserted by the browser without physical-key-equivalent events.

Supply selectors for the fields and feedback in the main document; expected feedback may appear after validation. The audit examines native/ARIA invalid state, same-root error associations, feedback visibility, focus and changes to live-region content. Unfocused status feedback needs a change within the same live region, with polite or assertive semantics in both the pre-submit and post-submit samples. The JSON report records the current region’s pre-submit value as `baselineLive` when the region was exposed. A message inserted into a pre-existing, exposed live region counts when that same container survives submission. Changes between samples can still be missed. It reports programmatic feedback evidence, **not actual NVDA/VoiceOver announcements**. An associated error does not also have to be a live region; native browser validation and focus-managed feedback must be considered. Human review is still needed to judge whether an error explains the problem and suggests an appropriate correction (WCAG 3.3.1/3.3.3), and whether status feedback is announced usefully (4.1.3).

**Parameters and bounds:** `fields` and `expectedFeedback` each accept 1–20 entries. Field `value` is a string (up to 10,000 characters); supported fields are editable text/email/url/tel/password/search inputs and textareas. CSS selectors are limited to 500 characters and must be unambiguous. Feedback `kind` is `error` or `status`. `timeoutMs` sets the post-activation observation window (100–10,000 ms, default 3000); feedback is read once at its end. Keyboard actions have a 30-second budget; very long inputs may be incomplete. Direct mode retains its observation window plus 5-second overall budget and 1-second individual action bounds. Feedback text follows rendered descendants through open shadow roots and slots, excludes hidden or collapsed disclosure content and slot fallback replaced by assigned content, and retains visually clipped screen-reader-only text. Each target is bounded to 10,000 visited nodes and 10,000 exposed characters; exceeding either limit sets `textTruncated` and makes the audit incomplete. Native validation is reported as a possible browser-managed feedback route, not a verified announcement. Findings describe observed gaps; `completed` means the scenario was measured, not that the form conforms to WCAG. Other frames, transient feedback and message quality need separate review.

This is a **state-changing** tool: supplied values are entered and the submit control is activated. An unexpectedly accepted value can submit the form. Use a test environment and reset its state between cases; the audit cannot undo submissions. Reports omit submitted values and feedback text. Both new interaction audits accept `reportFile` for a JSON report, use the normal MCP output directory and never overwrite an existing explicitly named report.

While either interaction audit runs, overlapping MCP tool calls routed to the same browser context are rejected with a busy error before their actions start. Starting an interaction audit while another tool is active is also rejected; calls are not queued for later mutation. Calls routed to other browser sessions can proceed independently. This coordinates MCP calls, not page scripts, manual browser use, or independently connected clients.

#### `audit_screen_reader`
Inspects the browser's accessibility tree (`page.ariaSnapshot`), accessible names and element geometry for potential accessibility issues. No actual screen reader is installed or driven, and its announcements and interactions are not tested.

Expand Down Expand Up @@ -1338,6 +1380,10 @@ roles remain in the logs; they do not count as tool failures. Recovered Codex
connection retries are accepted only when the turn completes successfully.
Canceling the run exits with status 130.

### Benchmarking interaction audits

See [the before/after benchmark report](bench/interaction-audits/RESULTS.md) for pinned external fixtures, GPT-6 Luna scenarios, measured results, exclusions, and reproduction commands. These bounded checks do not establish human-level accessibility accuracy or actual screen-reader interoperability.

### Benchmarking tool latency

`bench/mcp-bench.mjs` measures what a client actually waits for: it serves a fixed
Expand Down
Loading
Loading