@kinti/a11y-toolkit 5.22.0 → 5.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/a11y_toolkit/__init__.py +5 -0
  2. package/a11y_toolkit/a11y.py +115 -0
  3. package/a11y_toolkit/a11yact.py +167 -0
  4. package/a11y_toolkit/a11yaudit.py +1951 -0
  5. package/a11y_toolkit/a11ybadge.py +102 -0
  6. package/a11y_toolkit/a11ybudget.py +122 -0
  7. package/a11y_toolkit/a11ycrit.py +1017 -0
  8. package/a11y_toolkit/a11ydiff.py +192 -0
  9. package/a11y_toolkit/a11ydisprove.py +175 -0
  10. package/a11y_toolkit/a11ydocx.py +132 -0
  11. package/a11y_toolkit/a11ydom.py +1831 -0
  12. package/a11y_toolkit/a11yevidence.py +272 -0
  13. package/a11y_toolkit/a11yfix.py +330 -0
  14. package/a11y_toolkit/a11yi18n.py +100 -0
  15. package/a11y_toolkit/a11yinit.py +113 -0
  16. package/a11y_toolkit/a11yjourney.py +284 -0
  17. package/a11y_toolkit/a11yledger.py +210 -0
  18. package/a11y_toolkit/a11ymutants.py +406 -0
  19. package/a11y_toolkit/a11yopenacr.py +207 -0
  20. package/a11y_toolkit/a11ypdf.py +273 -0
  21. package/a11y_toolkit/a11yroute.py +378 -0
  22. package/a11y_toolkit/a11ysarif.py +139 -0
  23. package/a11y_toolkit/a11yscroll.py +212 -0
  24. package/a11y_toolkit/a11ystatement.py +158 -0
  25. package/a11y_toolkit/a11yvalidate.py +127 -0
  26. package/a11y_toolkit/a11yvpat.py +238 -0
  27. package/a11y_toolkit/a11yvtt.py +136 -0
  28. package/a11y_toolkit/a11ywcag3.py +262 -0
  29. package/a11y_toolkit/arialive.js +107 -0
  30. package/a11y_toolkit/arialive_js.py +113 -0
  31. package/a11y_toolkit/contrast.py +536 -0
  32. package/a11y_toolkit/locales/_template.json +468 -0
  33. package/a11y_toolkit/locales/en.json +525 -0
  34. package/a11y_toolkit/locales/es.json +525 -0
  35. package/a11y_toolkit/server.py +1529 -0
  36. package/bin/a11y-toolkit-mcp.cjs +2 -2
  37. package/bin/a11y-toolkit.cjs +2 -2
  38. package/lib/runner.cjs +30 -22
  39. package/package.json +2 -1
@@ -0,0 +1,1529 @@
1
+ #!/usr/bin/env python3
2
+ """a11y-toolkit MCP v3 · stdio MCP server (JSON-RPC, zero dependencies).
3
+
4
+ The accessibility layer for AI coding agents: audit → fix → document → watch.
5
+
6
+ Tools:
7
+ - a11y_audit_url(url | html, lang?, timeout?) express static WCAG audit
8
+ - a11y_audit_dom(url, lang?, timeout?) rendered audit (Playwright):
9
+ real contrast, target size 2.5.8,
10
+ focus indicator
11
+ - a11y_contrast_pair(fg, bg, lang?) ratio + AA/AAA verdicts + fix
12
+ - a11y_contrast_image(path, text_color, ...) text over image, pixel sampling
13
+ - a11y_suggest_color(fg, bg, target?) nearest passing color
14
+ - a11y_generate_declaration(...) legal statement RD 1112/2018 / EAA
15
+ - a11y_snapshot(url) interactive elements + tab order
16
+ - a11y_diff(a, b) regression diff between snapshots
17
+ - a11y_diff_urls(url_a, url_b) staging vs production in one call
18
+ - a11y_aria_live_snippet(lang?) injectable live-region monitor
19
+ - a11y_criterion(code|signal, lang?) criterion OR signal explained (+ACT rules)
20
+ - a11y_badge(score, lang?, date?) honest SVG badge (score+date+scope)
21
+ - a11y_autofix(html, lang?, title?) deterministic safe fixes
22
+ - a11y_reflow(url, …) 320px reflow check (1.4.10)
23
+ - a11y_keyboard(url, …) keyboard-trap detection (2.1.2)
24
+ - a11y_scroll(url, …) infinite-scroll audit
25
+ - a11y_forms(url, …) form errors 3.3.1/3.3.3 (fill+submit)
26
+ - a11y_hover(url, …) tooltip Escape dismissibility (1.4.13)
27
+ - a11y_sr_transcript(url, …) what a blind user hears, linearized
28
+ - a11y_journey_verdict(task, steps, outcome) blindfold task verdict: friction log → scored evidence
29
+ - a11y_vtt_check(url, …) caption CONTENT quality (1.2.2)
30
+ - a11y_audit_pdf(path) PDF structural screening — nobody automated it
31
+ - a11y_docx_screen(path) DOCX structural screening (alt, fake headings, lang, table headers)
32
+ - a11y_reduced_motion(url) does the site honor prefers-reduced-motion? (2.2.2)
33
+ - a11y_forced_colors(url) SVG hardcoded fills vs forced-colors (Windows HCM)
34
+ - a11y_generate_vpat(product, pack|reports, …) VPAT 2.5 (WCAG) draft from the evidence pack
35
+ - a11y_generate_openacr(product, pack|reports, …) OpenACR YAML (GSA) — machine-readable ACR
36
+ - a11y_contrast_dom(url, selector, …) real text-over-anything contrast (auto-region sampling)
37
+ - a11y_disprove(url, report?, …) re-verify findings → confirmed/rejected
38
+ - a11y_ledger(action, url?, report?, …) persistent coverage ledger
39
+ - a11y_html_validate(url|html, …) W3C Nu parser view
40
+ - a11y_evidence(reports, …) verifiable evidence pack
41
+ - a11y_wcag3_preview(report, lang?) re-group findings under the WCAG 3
42
+ Working Draft outcomes (no score)
43
+ - a11y_route(goal, lang?) the router: goal → ordered tools (start here)
44
+
45
+ Prompts: audit-page, fix-contrast, pre-deploy-check, declaration-eaa,
46
+ conformance-wcagem, blindfold-task.
47
+
48
+ Register in an MCP client (no clone needed):
49
+
50
+ { "mcpServers": { "a11y-toolkit": {
51
+ "command": "uvx", "args": ["--from", "a11y-toolkit", "a11y-toolkit-mcp"] } } }
52
+ """
53
+
54
+ import json
55
+ import os
56
+ import sys
57
+
58
+ HERE = os.path.dirname(os.path.abspath(__file__))
59
+
60
+ from .contrast import pair as pair_fn, image_contrast, suggest, parse_color # noqa: E402
61
+ from .a11ystatement import generate as statement_fn # noqa: E402
62
+ from .a11yaudit import audit_url as audit_url_fn, audit_html as audit_html_fn # noqa: E402
63
+ from .a11ydom import audit_dom_url, audit_reflow, audit_keyboard, audit_forms, audit_hover, sr_transcript # noqa: E402
64
+ from .a11yfix import autofix as autofix_fn # noqa: E402
65
+ from .a11yscroll import audit_scroll # noqa: E402
66
+ from .a11yvalidate import validate_url, validate_html # noqa: E402
67
+ from .a11yevidence import build_pack as build_pack_fn # noqa: E402
68
+ from .a11ydiff import snapshot as snapshot_fn, diff as diff_fn # noqa: E402
69
+ from .a11ycrit import criterion as criterion_fn # noqa: E402
70
+ from .a11yjourney import verdict as journey_verdict_fn # noqa: E402
71
+ from .a11yvtt import vtt_check as vtt_check_fn # noqa: E402
72
+ from .a11ypdf import pdf_screen as pdf_screen_fn # noqa: E402
73
+ from .a11ydocx import docx_screen as docx_screen_fn # noqa: E402
74
+ from .a11ydom import audit_reduced_motion as reduced_motion_fn, audit_forced_colors as forced_colors_fn # noqa: E402
75
+ from .a11ydisprove import disprove as disprove_fn # noqa: E402
76
+ from .a11yledger import record as ledger_record, gaps as ledger_gaps, summary as ledger_summary # noqa: E402
77
+ from .a11ybadge import badge as badge_fn # noqa: E402
78
+ from .a11yaudit import audit_site as audit_site_fn # noqa: E402
79
+ from .a11yvpat import generate_vpat as vpat_fn # noqa: E402
80
+ from .a11yopenacr import generate_openacr as openacr_fn # noqa: E402
81
+ from .a11ydom import contrast_dom as contrast_dom_fn # noqa: E402
82
+ from .a11ywcag3 import preview as wcag3_preview_fn # noqa: E402
83
+ from .a11yroute import route as route_fn # noqa: E402
84
+
85
+ try:
86
+ from .arialive_js import ARIALIVE_JS # installed as a module (pip)
87
+ except ImportError:
88
+ ARIALIVE_JS = None # repo checkout: read the file
89
+
90
+ VERSION = '5.22.2'
91
+
92
+ # Params renombrados a inglés en 5.11.0; se aceptan los nombres previos.
93
+ PARAM_ALIASES = {
94
+ 'metodo': 'method',
95
+ 'fecha_evaluacion': 'evaluation_date',
96
+ 'reclamacion': 'complaints',
97
+ 'disponibilidad_alternativa': 'alternative_format',
98
+ 'fecha': 'date',
99
+ 'max_pasos': 'max_steps',
100
+ 'max_tandas': 'max_batches',
101
+ }
102
+
103
+ INSTRUCTIONS = (
104
+ 'Accessibility toolkit (WCAG 2.2), multilanguage es/en. '
105
+ 'Loop: AUDIT (a11y_audit_url for a fast static pass with a 0-100 score; '
106
+ 'a11y_audit_dom for a rendered audit with real computed contrast, 2.5.8 target '
107
+ 'size and focus indicator — needs local Playwright) → FIX (a11y_contrast_pair, '
108
+ 'a11y_contrast_image, a11y_suggest_color) → DOCUMENT (a11y_generate_declaration: '
109
+ 'RD 1112/2018 or European Accessibility Act wording) → WATCH (a11y_snapshot — '
110
+ 'includes the computed accessibility tree — + a11y_diff across deploys). '
111
+ 'Site sampling reads /sitemap.xml first (WCAG-EM enumeration, links as fallback); '
112
+ 'rendered tools accept auth_state (Playwright storage_state) to audit behind login; '
113
+ 'a11y_forms submits invalid data and judges error announcement (3.3.1/3.3.3). '
114
+ 'a11y_evidence records verified codes as agent-verified (automated-fail stays fail). '
115
+ 'a11y_criterion explains what any criterion means. Every tool returns es/en '
116
+ 'findings with concrete remediation. '
117
+ 'a11y_route(goal) tells you which tools solve a task — ask it instead of scanning descriptions. '
118
+ 'a11y_wcag3_preview re-groups audit findings under the WCAG 3 Working Draft '
119
+ 'outcomes (demo only, no score: WCAG 2.2 remains the audit target). '
120
+ 'Automation covers about one third of WCAG: pair audits with the manual checklist '
121
+ 'in the audit-page prompt (keyboard, screen reader, zoom). '
122
+ 'The evidence pack (a11y_evidence) is vendor-neutral and locally verifiable '
123
+ '(hashes, criteria matrix, effort classes).'
124
+ )
125
+
126
+ TOOLS = [
127
+ {
128
+ 'name': 'a11y_audit_url',
129
+ 'description': ('Express WCAG 2.2 audit of a URL or an HTML string: 20+ automated '
130
+ 'signals with a weighted 0-100 score — images without alt (1.1.1), '
131
+ 'controls without accessible names (4.1.2), form fields without labels '
132
+ '(3.3.2), missing autocomplete on user-data fields (1.3.5), click '
133
+ 'handlers on non-interactive elements (2.1.1), unknown ARIA roles and '
134
+ 'broken aria-labelledby (4.1.2), duplicated unnamed landmarks, timed '
135
+ 'meta refresh (2.2.1), missing skip mechanism (2.4.1), lang/title '
136
+ '(3.1.1, 2.4.2), heading structure (1.3.1), blocked zoom (1.4.4), '
137
+ 'captions (1.2.2), autoplay audio (1.4.2), generic/duplicated link text '
138
+ '(2.4.4), target=_blank without warning (3.2.5), positive tabindex '
139
+ '(2.4.3), aria-hidden on focusable elements, tables without th, '
140
+ 'duplicate ids, duplicate accesskeys. Each finding includes concrete '
141
+ 'remediation. Filter, not verdict: automation covers ~1/3 of WCAG; '
142
+ 'query a11y_criterion for what a criterion means.'),
143
+ 'inputSchema': {'type': 'object', 'properties': {
144
+ 'url': {'type': 'string', 'description': 'URL to fetch and audit'},
145
+ 'html': {'type': 'string', 'description': 'raw HTML to audit directly (overrides url)'},
146
+ 'pages': {'type': 'integer', 'minimum': 1, 'maximum': 20, 'description': 'light same-domain crawl: audit up to N pages, aggregated by score and recurring signals (default 1, max 20)'},
147
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
148
+ 'timeout': {'type': 'number', 'description': 'fetch timeout seconds (30 default)'},
149
+ }},
150
+ },
151
+ {
152
+ 'name': 'a11y_audit_dom',
153
+ 'description': ('Deep RENDERED WCAG audit via local Playwright/Chromium: real computed '
154
+ 'text contrast against effective backgrounds with alpha compositing '
155
+ '(1.4.3), pixel-sampled measurement of text over images/gradients '
156
+ '(background captured with the text transparent), minimum target size '
157
+ '24×24 (2.5.8, new in WCAG 2.2), visible '
158
+ 'focus indicator heuristic (2.4.7), plus rendered versions of the '
159
+ 'static checks (alt, accessible names, labels, headings, lang/title, '
160
+ 'tabindex, aria-hidden, captions, tables). Findings include remediation. '
161
+ 'Requires playwright: pip install playwright && playwright install '
162
+ 'chromium.'),
163
+ 'inputSchema': {'type': 'object', 'properties': {
164
+ 'url': {'type': 'string'},
165
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
166
+ 'timeout': {'type': 'number', 'description': 'page load timeout seconds (45 default)'},
167
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit behind login — local file, never uploaded'},
168
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
169
+ 'color_scheme': {'type': 'string', 'enum': ['light', 'dark'], 'description': 'Emulate prefers-color-scheme: run the contrast pass in dark mode too — dark themes fail where light passes (nobody audits both)'},
170
+ },
171
+ 'required': ['url']},
172
+ },
173
+ {
174
+ 'name': 'a11y_contrast_pair',
175
+ 'description': ('Exact WCAG contrast ratio for a color pair: per-criterion verdicts '
176
+ '1.4.3 (AA), 1.4.6 (AAA), 1.4.11 (non-text). Accepts #hex, rgb(), '
177
+ 'hsl(), CSS color names; rgba/hsl with alpha is composited over the '
178
+ 'background. If AA fails, suggests the nearest passing color.'),
179
+ 'inputSchema': {'type': 'object', 'properties': {
180
+ 'fg': {'type': 'string'}, 'bg': {'type': 'string'},
181
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
182
+ }, 'required': ['fg', 'bg']},
183
+ },
184
+ {
185
+ 'name': 'a11y_contrast_image',
186
+ 'description': ('TEXT OVER IMAGE contrast: pixel-level sampling of the real background '
187
+ 'behind the text box → worst/median/p95 ratio, % of area passing AA, '
188
+ 'and automatic hostile-zone detection on a 3×3 grid (worst_zone). What '
189
+ 'pair-only checkers cannot do. region="x,y,w,h" recommended.'),
190
+ 'inputSchema': {'type': 'object', 'properties': {
191
+ 'path': {'type': 'string'}, 'text_color': {'type': 'string'},
192
+ 'region': {'type': 'string'},
193
+ 'sample': {'type': 'integer'},
194
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
195
+ }, 'required': ['path', 'text_color']},
196
+ },
197
+ {
198
+ 'name': 'a11y_suggest_color',
199
+ 'description': ('Nearest opaque color (RGB distance) to fg that reaches the target '
200
+ 'ratio against bg (4.5 default). Returns the color, its ratio and '
201
+ 'whether it lightens or darkens.'),
202
+ 'inputSchema': {'type': 'object', 'properties': {
203
+ 'fg': {'type': 'string'}, 'bg': {'type': 'string'},
204
+ 'target': {'type': 'number'},
205
+ }, 'required': ['fg', 'bg']},
206
+ },
207
+ {
208
+ 'name': 'a11y_generate_declaration',
209
+ 'description': ('Generates an Accessibility Statement in HTML: art. 10 RD 1112/2018 '
210
+ '(Spanish public sector, framework="rd1112") or European Accessibility Act '
211
+ 'wording (Directive (EU) 2019/882 / Ley 11/2023, framework="eaa"; EN output '
212
+ 'uses Directive (EU) 2016/2102 / EAA wording). The generated document '
213
+ 'is itself accessible. Saves to output_path when given.'),
214
+ 'inputSchema': {'type': 'object', 'properties': {
215
+ 'entity': {'type': 'string', 'description': 'Legal entity name as it should appear in the statement'},
216
+ 'url': {'type': 'string', 'description': 'Website URL the statement covers'},
217
+ 'status': {'type': 'string', 'enum': ['full', 'partial', 'not_conformant'],
218
+ 'description': 'Compliance state: full | partial | not_conformant (plena | parcial | no_conforme, pre-5.11, still accepted as aliases)'},
219
+ 'inaccessible_content': {'type': 'array', 'items': {'type': 'string'},
220
+ 'description': 'Non-accessible content list: one string per item, ideally criterion + reason + alternative'},
221
+ 'method': {'type': 'string', 'description': 'How conformance was evaluated (e.g. "self-evaluation: a11y-toolkit screening + manual review")'},
222
+ 'evaluation_date': {'type': 'string', 'description': 'ISO date of the last evaluation (YYYY-MM-DD)'},
223
+ 'review_date': {'type': 'string', 'description': 'ISO date of the next scheduled review'},
224
+ 'feedback': {'type': 'string', 'description': 'Contact channel for accessibility feedback (email or URL)'},
225
+ 'complaints': {'type': 'string', 'description': 'Claim/complaint procedure URL or address (legally required in several jurisdictions)'},
226
+ 'framework': {'type': 'string', 'enum': ['rd1112', 'eaa'],
227
+ 'description': 'rd1112 (Spanish public sector, art. 10) or eaa (European Accessibility Act / private sector)'},
228
+ 'alternative_format': {'type': 'string', 'description': 'Where to get the content in an alternative accessible format'},
229
+ 'output_path': {'type': 'string', 'description': 'save the HTML here (optional)'},
230
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
231
+ }, 'required': ['entity', 'url', 'status']},
232
+ },
233
+ {
234
+ 'name': 'a11y_snapshot',
235
+ 'description': ('Accessibility snapshot of a URL: interactive elements (tag, role, '
236
+ 'accessible name, href) in DOM order, the REAL tab focus order, and '
237
+ 'when Playwright ≥1.49 is available the computed ACCESSIBILITY TREE '
238
+ '(aria snapshot — what a screen reader announces). Save it before a '
239
+ 'deploy and compare after with a11y_diff. Requires local Playwright.'),
240
+ 'inputSchema': {'type': 'object', 'properties': {
241
+ 'url': {'type': 'string', 'description': 'Page URL to snapshot (http/https or file://)'},
242
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to snapshot behind login'},
243
+ }, 'required': ['url']},
244
+ },
245
+ {
246
+ 'name': 'a11y_diff',
247
+ 'description': ('Regression diff between two accessibility snapshots (before/after a '
248
+ 'deploy): added/removed/renamed interactives and focus-order changes. '
249
+ 'ok=false means a regression to review. Accepts inline JSON (starting '
250
+ 'with "{") or file paths.'),
251
+ 'inputSchema': {'type': 'object', 'properties': {
252
+ 'a': {'type': 'string', 'description': 'BEFORE snapshot (inline JSON or path)'},
253
+ 'b': {'type': 'string', 'description': 'AFTER snapshot (inline JSON or path)'},
254
+ }, 'required': ['a', 'b']},
255
+ },
256
+ {
257
+ 'name': 'a11y_diff_urls',
258
+ 'description': ('Snapshot two URLs and diff them in a single call (e.g. staging vs '
259
+ 'production). Requires local Playwright.'),
260
+ 'inputSchema': {'type': 'object', 'properties': {
261
+ 'url_a': {'type': 'string'}, 'url_b': {'type': 'string'},
262
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit behind login — stays local'},
263
+ }, 'required': ['url_a', 'url_b']},
264
+ },
265
+ {
266
+ 'name': 'a11y_aria_live_snippet',
267
+ 'description': ('Returns injectable JavaScript for an aria-live announcement monitor '
268
+ '(bookmarklet or page.evaluate): logs every dynamic-region '
269
+ 'announcement with time, politeness, role and text — what a screen '
270
+ 'reader would say, visible on screen.'),
271
+ 'inputSchema': {'type': 'object', 'properties': {
272
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'monitor panel language (en default)'},
273
+ }},
274
+ },
275
+ {
276
+ 'name': 'a11y_badge',
277
+ 'description': ('Returns an HONEST accessibility badge as accessible SVG: score, '
278
+ 'date and scope (automated screening ≈ 1/3 of WCAG), color-coded '
279
+ 'by score. Deliberately does NOT say "conformant" — the honest '
280
+ 'seal. Embed it in audited sites or statements.'),
281
+ 'inputSchema': {'type': 'object', 'properties': {
282
+ 'score': {'type': 'number', 'description': '0-100 (from an audit result)'},
283
+ 'date': {'type': 'string', 'description': 'ISO date (today by default)'},
284
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
285
+ }, 'required': ['score']},
286
+ },
287
+ {
288
+ 'name': 'a11y_autofix',
289
+ 'description': ('DETERMINISTIC safe auto-fixes applied to HTML — the honest '
290
+ 'anti-overlay: a short closed list of fixes where the correct '
291
+ 'answer is unique (unblock viewport zoom 1.4.4, add the exact '
292
+ 'autocomplete token 1.3.5, fill missing html lang and empty title '
293
+ 'when provided). Everything requiring judgment (alt text, '
294
+ 'contrast, accessible names) is NOT touched — it returns '
295
+ 'not_applied with the reason and remediation instead. Returns '
296
+ 'fixed_html + applied + not_applied.'),
297
+ 'inputSchema': {'type': 'object', 'properties': {
298
+ 'html': {'type': 'string', 'description': 'raw HTML to fix'},
299
+ 'url': {'type': 'string', 'description': 'URL context for the report metadata (default: "(html)")'},
300
+ 'form_errors': {'type': 'boolean', 'description': 'inject the accessible form-error layer into forms without their own handling (default true)'},
301
+ 'lang': {'type': 'string', 'description': 'only if provided and <html> lacks lang'},
302
+ 'title': {'type': 'string', 'description': 'only if provided and <title> is empty'},
303
+ }, 'required': ['html']},
304
+ },
305
+ {
306
+ 'name': 'a11y_reflow',
307
+ 'description': ('Reflow check at 320px — criterion 1.4.10 (AA), the check axe and '
308
+ 'Lighthouse do not automate. Loads the URL at 1280px, then at '
309
+ '320px, and reports real horizontal scroll + the overflowing '
310
+ 'elements. Method note: browser zoom RE-LAYS OUT at 320 CSS px '
311
+ '(that is the standard\'s own equivalence: 1280 @ 400% zoom = 320px), '
312
+ 'so the correct measurement is a 320px viewport. Requires local '
313
+ 'Playwright.'),
314
+ 'inputSchema': {'type': 'object', 'properties': {
315
+ 'url': {'type': 'string'},
316
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
317
+ 'timeout': {'type': 'number'},
318
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to test behind login'},
319
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
320
+ },
321
+ 'required': ['url']},
322
+ },
323
+ {
324
+ 'name': 'a11y_keyboard',
325
+ 'description': ('Keyboard-trap detection (2.1.2) with REAL Tab walking in Chromium: '
326
+ 'up to 60 real tab stops, cycle detection (the modal pattern), then '
327
+ 'the decisive test — does ESCAPE release the cycle? A modal that '
328
+ 'cycles and releases on Escape is correct and NOT reported; a cycle '
329
+ 'Escape cannot leave is a trap (high severity). Returns the full tab '
330
+ 'stop list too. Requires local Playwright.'),
331
+ 'inputSchema': {'type': 'object', 'properties': {
332
+ 'url': {'type': 'string'},
333
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
334
+ 'max_steps': {'type': 'integer', 'description': 'max real Tab presses (60 default)'},
335
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to Tab-walk behind login'},
336
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
337
+ },
338
+ 'required': ['url']},
339
+ },
340
+ {
341
+ 'name': 'a11y_scroll',
342
+ 'description': ('Infinite-scroll accessibility audit — the documented disaster nobody '
343
+ 'automates (Deque guidance + ARIA APG Feed pattern; criteria 2.4.3, '
344
+ '4.1.3, 2.2.2). Real scrolling batches in Chromium with a live-region '
345
+ 'observer: does the focused element SURVIVE each batch (re-render '
346
+ 'destroys it — the documented failure)? Is new content ANNOUNCED '
347
+ '(aria-live/status receives text, role=feed)? Does the feed END or '
348
+ 'offer a load-more alternative (footer reachability)? APG feed pattern '
349
+ 'as positive signal. Honest guard: if no standard items are detected '
350
+ '(login walls, non-standard markup) the unfounded signals are skipped '
351
+ 'with a note. Requires local Playwright.'),
352
+ 'inputSchema': {'type': 'object', 'properties': {
353
+ 'url': {'type': 'string'},
354
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
355
+ 'max_batches': {'type': 'integer', 'description': 'scroll batches (5 default)'},
356
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit an authenticated feed'},
357
+ },
358
+ 'required': ['url']},
359
+ },
360
+ {
361
+ 'name': 'a11y_evidence',
362
+ 'description': ('Builds the verifiable evidence pack: the machine→human '
363
+ 'handoff object for WCAG conformance work. Takes one or more audit '
364
+ 'reports (any mode — static, rendered, reflow, keyboard, scroll) and '
365
+ 'returns: the full 55-criterion A/AA matrix (automated-fail / '
366
+ 'automated-review / not-flagged — NOT pass / not-run / manual-only), '
367
+ 'each row priced with its human-effort class (MIN 1-3 / MED 5-10 / '
368
+ 'MAX 15-30 min of human review remaining) and total remaining minutes '
369
+ 'every artifact SHA-256-'
370
+ 'hashed with timestamps, an empty signature block (name, credential, '
371
+ 'date) whose statement must reference the pack\'s own sha256, and the '
372
+ 'tamper-evidence rule stated. Vendor-neutral: any qualified human can '
373
+ 'review it. Evidence, never conformance.'),
374
+ 'inputSchema': {'type': 'object', 'properties': {
375
+ 'reports': {'type': 'array', 'items': {'type': 'object'},
376
+ 'description': 'audit report objects (any mode)'},
377
+ 'snapshot': {'type': 'object', 'description': 'a11y_snapshot output (optional)'},
378
+ 'reviewer': {'type': 'object', 'description': '{"name":…, "credential":…, "review_date":…} to prefill the signature block'},
379
+ 'verified': {'type': 'array', 'items': {'type': 'string'}, 'description': 'Criterion codes an agent/human verified against this sample (manual checklist protocol) — they become agent-verified in the matrix; automated-fail stays fail'},
380
+ }, 'required': ['reports']},
381
+ },
382
+ {
383
+ 'name': 'a11y_forms',
384
+ 'description': ('Form error testing (3.3.1 Error Identification, 3.3.3 Error Suggestion) — '
385
+ 'the guided flow no competitor automates: fills every validatable field '
386
+ 'with INVALID data, really submits, and judges the post-submit DOM — are '
387
+ 'errors identified in text and associated with the field (aria-invalid + '
388
+ 'aria-describedby, error summary, role=alert), or does the form swallow '
389
+ 'them? Native browser validation counts as identification (unless the '
390
+ 'form has novalidate); forms that navigate on submit are honestly noted '
391
+ 'as not measurable in-page. Requires local Playwright.'),
392
+ 'inputSchema': {'type': 'object', 'properties': {
393
+ 'url': {'type': 'string', 'description': 'Page URL with the form(s) to test'},
394
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
395
+ 'timeout': {'type': 'number', 'description': 'Page load timeout seconds (45 default)'},
396
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON to test forms behind login'},
397
+ },
398
+ 'required': ['url']},
399
+ },
400
+ {
401
+ 'name': 'a11y_html_validate',
402
+ 'description': ('The W3C\'s own parser as a toolkit mode: checks a URL or raw HTML '
403
+ 'against the Nu Html Checker (validator.w3.org/nu) — doctype, encoding, '
404
+ 'structural validity, plus alt/lang/role issues from the authoritative '
405
+ 'source, mapped to WCAG criteria where they overlap. PRIVACY: html mode '
406
+ 'POSTs the document to the W3C service (url mode shares only the URL, '
407
+ 'like a11y_audit_url); self-hosted vnu instances supported via base_url '
408
+ 'for sensitive content.'),
409
+ 'inputSchema': {'type': 'object', 'properties': {
410
+ 'url': {'type': 'string', 'description': 'Page URL to validate (shares the URL with the W3C service)'},
411
+ 'html': {'type': 'string', 'description': 'Raw HTML to validate — POSTs the content to validator.w3.org/nu; use url or a self-hosted instance for sensitive pages'},
412
+ 'base_url': {'type': 'string', 'description': 'Base URL of a self-hosted vnu instance (docker ghcr.io/validator/validator) instead of the public W3C service'},
413
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
414
+ }},
415
+ },
416
+ {
417
+ 'name': 'a11y_hover',
418
+ 'description': ('Content on Hover or Focus (1.4.13): finds tooltip/overlay '
419
+ 'candidates, hovers each, and tests whether Escape dismisses '
420
+ 'the result — tooltips that do not dismiss are flagged. '
421
+ 'Requires local Playwright. — Scope: tooltips only; full audit '
422
+ 'is a11y_audit_dom, keyboard traps are a11y_keyboard.'),
423
+ 'inputSchema': {'type': 'object', 'properties': {
424
+ 'url': {'type': 'string', 'description': 'Page URL to test'},
425
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
426
+ 'timeout': {'type': 'number', 'description': 'Page load timeout (45 default)'},
427
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit behind login — stays local'},
428
+ }, 'required': ['url']},
429
+ },
430
+ {
431
+ 'name': 'a11y_sr_transcript',
432
+ 'description': ('Screen reader TRANSCRIPT: what a blind user HEARS on this page. '
433
+ 'Walks the accessibility tree linearly and returns the announcement '
434
+ 'text with roles, names and states — the linearized reading '
435
+ 'experience, as prose an agent can READ to understand the page '
436
+ 'from a blind user\'s perspective. — Read-only: for structure '
437
+ 'use a11y_snapshot, for keyboard traps use a11y_keyboard. '
438
+ 'Requires Playwright.'),
439
+ 'inputSchema': {'type': 'object', 'properties': {
440
+ 'url': {'type': 'string', 'description': 'Page URL to transcribe'},
441
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
442
+ 'timeout': {'type': 'number', 'description': 'Page load timeout (45 default)'},
443
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit behind login — stays local'},
444
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
445
+ }, 'required': ['url']},
446
+ },
447
+ {
448
+ 'name': 'a11y_disprove',
449
+ 'description': ('Disprover pattern (from Cloudflare\'s security-audit-skill): '
450
+ 're-runs the audit against the live page and marks each finding '
451
+ 'confirmed or rejected — findings that don\'t reproduce are '
452
+ 'rejected with the reason. Catches false positives, race '
453
+ 'conditions, and page changes between audit and report. Returns '
454
+ 'a fresh score over confirmed findings only. — Run this before '
455
+ 'acting on any audit report.'),
456
+ 'inputSchema': {'type': 'object', 'properties': {
457
+ 'url': {'type': 'string', 'description': 'URL to re-verify against'},
458
+ 'report': {'type': 'object', 'description': 'existing audit report (optional; if absent, audits first)'},
459
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
460
+ 'timeout': {'type': 'number', 'description': 'Timeout seconds (30 default)'},
461
+ }, 'required': ['url']},
462
+ },
463
+ {
464
+ 'name': 'a11y_ledger',
465
+ 'description': ('Coverage ledger (from Cloudflare\'s security-audit-skill): '
466
+ 'persistent record of what has been audited, when, and with what '
467
+ 'result. Actions: record (add audit result), gaps (what has never '
468
+ 'been checked on a URL), summary (portfolio overview). Accumulates '
469
+ 'across runs — second audits show resolved findings.'),
470
+ 'inputSchema': {'type': 'object', 'properties': {
471
+ 'action': {'type': 'string', 'enum': ['record', 'gaps', 'summary'],
472
+ 'description': 'What to do'},
473
+ 'url': {'type': 'string', 'description': 'URL (for record/gaps)'},
474
+ 'report': {'type': 'object', 'description': 'audit report object (for record)'},
475
+ 'ledger_path': {'type': 'string', 'description': 'ledger file path (default: a11y-ledger.json)'},
476
+ }, 'required': ['action']},
477
+ },
478
+ {
479
+ 'name': 'a11y_criterion',
480
+ 'description': ('Explains a WCAG 2.2 success criterion in plain language (es/en): '
481
+ 'what it requires, typical failures, and how to verify it with this '
482
+ 'toolkit (which tool automates which part). Codes like "1.4.3", '
483
+ '"2.5.8", "4.1.2". Give a finding SIGNAL instead (e.g. img_no_alt, '
484
+ 'kbd_trap — the id in every audit finding) and it resolves to its '
485
+ 'criterion AND its published ACT rule(s) with official w3.org links. '
486
+ 'Use it whenever you need to explain WHY a finding matters or what '
487
+ 'the criterion actually says.'),
488
+ 'inputSchema': {'type': 'object', 'properties': {
489
+ 'code': {'type': 'string', 'description': 'criterion number, e.g. 1.4.3 (or give signal)'},
490
+ 'signal': {'type': 'string', 'description': 'engine signal id from a finding (e.g. img_no_alt, kbd_trap) — resolves criterion + ACT rules with w3.org links'},
491
+ 'lang': {'type': 'string', 'enum': ['es', 'en']},
492
+ }, 'required': []},
493
+ },
494
+ {
495
+ 'name': 'a11y_journey_verdict',
496
+ 'description': ('Blindfold journey verdict — the capability no other accessibility tool '
497
+ 'has: the agent attempted a REAL task (sign up, checkout, password reset) '
498
+ 'perceiving only the accessibility tree and acting by accessible name and '
499
+ 'keyboard; perceive via your browser accessibility snapshot (state-preserving). ''This turns its friction log into a deterministic scored verdict. '
500
+ 'Pass = task completable non-visually by the agent; friction items map to '
501
+ 'WCAG criteria and flow into the evidence pack (report:journey). Use with '
502
+ 'the blindfold-task prompt: act by '
503
+ 'accessible name, log friction per step, then call this. Task usability '
504
+ 'evidence, never conformance.'),
505
+ 'inputSchema': {'type': 'object', 'properties': {
506
+ 'task': {'type': 'object', 'description': '{"goal": what the agent attempted, "kind": sign-up|checkout|password-reset|search|custom}'},
507
+ 'steps': {'type': 'array', 'items': {'type': 'object'}, 'description': 'journey steps: {action, target (accessible name), perceived, friction?} — friction is {pattern: journey_* key} or {criterion, severity, issue, remediation?}'},
508
+ 'outcome': {'type': 'object', 'description': '{"completed": bool, "gave_up": bool, "workaround_used": bool, "notes"}'},
509
+ 'url': {'type': 'string', 'description': 'page(s) where the journey ran'},
510
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
511
+ 'output_path': {'type': 'string', 'description': 'write the full verdict JSON here instead of returning it inline'},
512
+ }, 'required': ['task', 'steps', 'outcome']},
513
+ },
514
+ {
515
+ 'name': 'a11y_generate_vpat',
516
+ 'description': ('Generates a VPAT 2.5 (WCAG edition) accessibility conformance report '
517
+ 'in accessible HTML from an a11y_evidence pack (or raw audit reports): '
518
+ 'the full 55-criterion WCAG 2.2 A/AA table with Remarks auto-filled from '
519
+ 'the pack (status, measured values, examples, remaining human effort) and '
520
+ 'every Conformance Level starting at Not Evaluated — automated fails force '
521
+ 'Does Not Support and a qualified human sets the final level via overrides '
522
+ '(supports, partially_supports, does_not_support, not_applicable, '
523
+ 'not_evaluated). The document is a DRAFT until the signature block, which '
524
+ 'must reference the pack sha256, is completed. VPAT is the US/ADA '
525
+ 'counterpart of a11y_generate_declaration (EU/EAA): the machine fills '
526
+ 'Remarks, the human signs the claim.'),
527
+ 'inputSchema': {'type': 'object', 'properties': {
528
+ 'product': {'type': 'string', 'description': 'Product name as it must appear in the VPAT'},
529
+ 'pack': {'type': 'object', 'description': 'a11y_evidence output (evidence pack); alternative to reports'},
530
+ 'reports': {'type': 'array', 'items': {'type': 'object'}, 'description': 'Audit report objects to bundle (when pack is not given, the pack is built here first)'},
531
+ 'report_date': {'type': 'string', 'description': 'VPAT report date ISO (default: today)'},
532
+ 'product_description': {'type': 'string', 'description': 'Product description paragraph'},
533
+ 'contact': {'type': 'string', 'description': 'Contact information for questions about this VPAT'},
534
+ 'methods': {'type': 'string', 'description': 'Evaluation methods used (default: honest automated-screening note)'},
535
+ 'notes': {'type': 'string', 'description': 'Additional notes to include'},
536
+ 'overrides': {'type': 'object', 'description': 'Criterion → conformance level set by a qualified human: {"1.1.1": "supports", "1.2.2": "not_applicable", …}'},
537
+ 'reviewer': {'type': 'object', 'description': '{"name":…, "credential":…, "review_date":…} to prefill the signature block'},
538
+ 'output_path': {'type': 'string', 'description': 'save the VPAT HTML here (optional)'},
539
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Document language (default en)'},
540
+ }, 'required': ['product']},
541
+ },
542
+ {
543
+ 'name': 'a11y_generate_openacr',
544
+ 'description': ('Generates an OpenACR (the GSA open standard, VPAT-derived) '
545
+ 'accessibility conformance report in machine-readable YAML from an '
546
+ 'a11y_evidence pack (or raw audit reports): the full 55-criterion '
547
+ 'WCAG 2.2 A/AA matrix as chapters with one web component per '
548
+ 'criterion, adherence levels starting at not-evaluated (automated '
549
+ 'fails force does-not-support, review-level signals '
550
+ 'partially-supports) and notes auto-filled from the pack (status, '
551
+ 'measured values, remaining human effort, sha256). Same honesty '
552
+ 'rule as a11y_generate_vpat: the machine fills notes, a qualified '
553
+ 'human sets levels via overrides (supports, partially_supports, …; '
554
+ 'hyphenated OpenACR forms accepted). OpenACR is what US federal '
555
+ 'procurement and GSA buyers parse — emit it from the same pack as '
556
+ 'the human-readable VPAT.'),
557
+ 'inputSchema': {'type': 'object', 'properties': {
558
+ 'product': {'type': 'string', 'description': 'Product name as it must appear in the OpenACR'},
559
+ 'pack': {'type': 'object', 'description': 'a11y_evidence output (evidence pack); alternative to reports'},
560
+ 'reports': {'type': 'array', 'items': {'type': 'object'}, 'description': 'Audit report objects to bundle (when pack is not given, the pack is built here first)'},
561
+ 'product_version': {'type': 'string', 'description': 'Product version'},
562
+ 'report_date': {'type': 'string', 'description': 'ACR report date ISO (default: today)'},
563
+ 'product_description': {'type': 'string', 'description': 'Product description paragraph'},
564
+ 'author': {'type': 'object', 'description': '{"name":…, "company":…, "email":…, "website":…} — the ACR author block'},
565
+ 'contact': {'type': 'string', 'description': 'Contact email (author.email fallback)'},
566
+ 'methods': {'type': 'string', 'description': 'Evaluation methods used (default: honest automated-screening note)'},
567
+ 'notes': {'type': 'string', 'description': 'Additional notes to include'},
568
+ 'overrides': {'type': 'object', 'description': 'Criterion → adherence level set by a qualified human: {"1.1.1": "supports", "1.2.2": "not_applicable", …} (hyphenated forms accepted)'},
569
+ 'output_path': {'type': 'string', 'description': 'save the OpenACR YAML here (optional)'},
570
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Document language (default en)'},
571
+ }, 'required': ['product']},
572
+ },
573
+ {
574
+ 'name': 'a11y_contrast_dom',
575
+ 'description': ('REAL contrast of an element against whatever is behind it (image, '
576
+ 'gradient, video, photo): loads the page in Chromium, screenshots the '
577
+ 'element matched by selector with its text turned transparent — so only '
578
+ 'the real background is sampled, no text pixels, no antialiasing edges — '
579
+ 'and contrasts the pixels with the text color (computed from the element '
580
+ 'when not given). The automated version of a11y_contrast_image: no '
581
+ 'manual screenshot, no region math. Requires local Playwright.'),
582
+ 'inputSchema': {'type': 'object', 'properties': {
583
+ 'url': {'type': 'string', 'description': 'Page URL where the element lives (http/https or file://)'},
584
+ 'selector': {'type': 'string', 'description': 'CSS selector of the text element to measure'},
585
+ 'text_color': {'type': 'string', 'description': 'Text color (default: computed from the element)'},
586
+ 'sample': {'type': 'integer', 'description': 'Pixel step (default 4)'},
587
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (default en)'},
588
+ 'timeout': {'type': 'number', 'description': 'Page load timeout seconds (default 45)'},
589
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON to measure behind login — stays local'},
590
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
591
+ }, 'required': ['url', 'selector']},
592
+ },
593
+ {
594
+ 'name': 'a11y_vtt_check',
595
+ 'description': ('WebVTT caption QUALITY (1.2.2) — the substance, not the presence. '
596
+ 'Everyone stops at "<track> exists"; this downloads and parses the actual '
597
+ '.vtt and judges what viewers get: malformed timing lines, empty cues, '
598
+ 'overlaps, impossible reading speed (>21 chars/second, BBC/Netflix '
599
+ 'standard) and coverage vs the media duration when given. Pass the .vtt '
600
+ 'URL (same http/https guard as the audits). Not a substitute for human '
601
+ 'review of accuracy or speaker identification. '
602
+ 'Returns JSON: {mode: "vtt", cues, characters, captioned_seconds, '
603
+ 'findings [{criterion, severity, signal, issue, remediation}], summary, limits}.'),
604
+ 'inputSchema': {'type': 'object', 'properties': {
605
+ 'url': {'type': 'string', 'description': 'URL of the .vtt caption file'},
606
+ 'duration': {'type': 'number', 'minimum': 1, 'description': 'media duration in seconds — enables the coverage check (1.2.2 completeness)'},
607
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
608
+ }, 'required': ['url']},
609
+ },
610
+ {
611
+ 'name': 'a11y_audit_pdf',
612
+ 'description': ('PDF accessibility screening — the space nobody automated (axe, pa11y, '
613
+ 'Lighthouse: HTML only). Zero-dep structural first pass on a LOCAL file: '
614
+ 'tagged tree (/StructTreeRoot — the root failure), title, language, '
615
+ 'outline, /Alt entries, text layer (scanned detection), encryption, and '
616
+ 'AcroForm fields without accessible labels (/TU — what a screen reader '
617
+ 'announces; 3.3.2 inputs, 4.1.2 buttons). '
618
+ 'Full PDF/UA conformance needs a spec validator (veraPDF); this finds '
619
+ 'the failures that make full validation pointless. Use for enterprise '
620
+ 'document pipelines and PDFs linked from the audited site. '
621
+ 'Returns JSON: {mode: "pdf", pages, tagged, lang, title, images, '
622
+ 'alt_entries, form_fields, form_labels, findings, summary, limits}.'),
623
+ 'inputSchema': {'type': 'object', 'properties': {
624
+ 'path': {'type': 'string', 'description': 'local PDF file path (never fetched remotely — download it yourself first)'},
625
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
626
+ }, 'required': ['path']},
627
+ },
628
+ {
629
+ 'name': 'a11y_docx_screen',
630
+ 'description': ('DOCX accessibility screening — the other half of enterprise paperwork. '
631
+ 'Zero-dep structural pass on a LOCAL .docx: images with no alt text '
632
+ '(docPr without descr), fake headings (bold+big paragraphs with no Heading '
633
+ 'style — invisible to navigation pane and TOC), document language, tables '
634
+ 'without marked header row. Full review needs a human; this finds what '
635
+ 'makes it pointless. Returns JSON: {mode: "docx", language, images, tables, '
636
+ 'findings, summary, limits}.'),
637
+ 'inputSchema': {'type': 'object', 'properties': {
638
+ 'path': {'type': 'string', 'description': 'local .docx file path'},
639
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
640
+ }, 'required': ['path']},
641
+ },
642
+ {
643
+ 'name': 'a11y_reduced_motion',
644
+ 'description': ('Does the site HONOR prefers-reduced-motion? Loads the page normally, '
645
+ 'counts looping CSS animations (>0.15s infinite), then reloads emulating '
646
+ 'prefers-reduced-motion: reduce and counts again. If the number does not '
647
+ 'drop, the site ignores the user\'s preference (2.2.2; 2.3.3 AAA). '
648
+ 'Nobody else automates this — axe leaves it as manual review. Covers CSS '
649
+ 'animations and video[autoplay]; JS/WebGL/scroll-parallax remain manual. '
650
+ 'Returns JSON: {mode, normal, reduced, respects, score, findings, limits}.'),
651
+ 'inputSchema': {'type': 'object', 'properties': {
652
+ 'url': {'type': 'string', 'description': 'Page URL to test'},
653
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to test behind login — stays local'},
654
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
655
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
656
+ 'timeout': {'type': 'number', 'description': 'page load timeout seconds (45 default)'},
657
+ }, 'required': ['url']},
658
+ },
659
+ {
660
+ 'name': 'a11y_forced_colors',
661
+ 'description': ('Does content survive forced-colors: active (Windows High Contrast)? '
662
+ 'Loads the page normally, flags SVGs with hardcoded colored fills (they '
663
+ 'fall back to inherited and icons can vanish), then emulates '
664
+ 'forced-colors and compares. Review-grade heuristic — the definitive '
665
+ 'check is visual on Windows HCM; this prepares it. Heuristic rev '
666
+ '1: SVG fills only, images queued for the next rev. '
667
+ 'Returns JSON: {mode, normal, forced, score, findings, limits}.'),
668
+ 'inputSchema': {'type': 'object', 'properties': {
669
+ 'url': {'type': 'string', 'description': 'Page URL to test'},
670
+ 'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to test behind login — stays local'},
671
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
672
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
673
+ 'timeout': {'type': 'number', 'description': 'page load timeout seconds (45 default)'},
674
+ }, 'required': ['url']},
675
+ },
676
+ {
677
+ 'name': 'a11y_wcag3_preview',
678
+ 'description': ('WCAG 3 demo — the view layer nobody ships: takes an audit report '
679
+ 'and re-groups its WCAG 2.2 findings under the outcomes of the WCAG 3 '
680
+ 'Working Draft (10 September 2026). Informative only: WCAG 3 is not a '
681
+ 'completed standard, the W3C has published no official WCAG 2 to WCAG 3 '
682
+ 'mapping (this one is curated and labeled as such), and NO score, tier '
683
+ 'or conformance claim is produced — the draft\'s tier thresholds are '
684
+ 'still TBD. Use it to show teams where today\'s 2.2 findings will land '
685
+ 'tomorrow; keep auditing against WCAG 2.2.'),
686
+ 'inputSchema': {'type': 'object', 'properties': {
687
+ 'report': {'type': 'object', 'description': 'audit report object with a findings list (from a11y_audit_url, a11y_audit_dom, a11y_disprove, …)'},
688
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
689
+ }, 'required': ['report']},
690
+ },
691
+ {
692
+ 'name': 'a11y_route',
693
+ 'description': ('The router — start here when unsure which tool solves a task: '
694
+ 'state the goal in plain language ("gate my PR", "fix the contrast '
695
+ 'of my hero", "generate the legal statement") and get the ordered '
696
+ 'tool sequence with the why of each step. Deterministic keyword '
697
+ 'index over the toolkit map, not an LLM guessing; when nothing '
698
+ 'matches, the honest fallback route says where everyone begins. '
699
+ 'Makes 33 specialized tools an O(1) choice — ask once instead of '
700
+ 'scanning descriptions. Optional sequential-diagnosis mode: pass '
701
+ 'url or html and the router takes the page\'s cheap vitals (static '
702
+ 'pass) and orders the next exams by expected yield — the evidence '
703
+ 'decides (forms → form error testing, menus → keyboard, video → '
704
+ 'caption content), severity only breaks ties; the ordered plan '
705
+ 'never replaces the full catalog.'),
706
+ 'inputSchema': {'type': 'object', 'properties': {
707
+ 'goal': {'type': 'string', 'description': 'the task in plain language (es or en)'},
708
+ 'url': {'type': 'string', 'description': 'optional diagnosis mode: page URL — its cheap signals (static pass) order the next exams by expected yield'},
709
+ 'html': {'type': 'string', 'description': 'optional diagnosis mode: inline HTML instead of a URL'},
710
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
711
+ }},
712
+ },
713
+ ]
714
+
715
+ _PROMPTS = [
716
+ {
717
+ 'name': 'audit-page',
718
+ 'description': 'Full accessibility audit workflow for a URL: automated tools + what to verify manually (keyboard, screen reader, zoom).',
719
+ 'arguments': [
720
+ {'name': 'url', 'description': 'page to audit', 'required': True},
721
+ {'name': 'language', 'description': 'es or en (default: match the user)', 'required': False},
722
+ ],
723
+ },
724
+ {
725
+ 'name': 'fix-contrast',
726
+ 'description': 'Guided contrast fix: verify the pair (or the text-over-image region), get the nearest passing color, apply it to the code.',
727
+ 'arguments': [
728
+ {'name': 'fg', 'description': 'foreground/text color', 'required': True},
729
+ {'name': 'bg', 'description': 'background color', 'required': True},
730
+ {'name': 'context', 'description': 'file(s) or component where the colors live', 'required': False},
731
+ ],
732
+ },
733
+ {
734
+ 'name': 'pre-deploy-check',
735
+ 'description': 'Pre-deploy regression check: express audit of the URL plus snapshot diff against a baseline snapshot.',
736
+ 'arguments': [
737
+ {'name': 'url', 'description': 'staging URL to check', 'required': True},
738
+ {'name': 'baseline', 'description': 'path or URL of the before snapshot', 'required': False},
739
+ ],
740
+ },
741
+ {
742
+ 'name': 'declaration-eaa',
743
+ 'description': 'Generate a European Accessibility Act / RD 1112/2018 accessibility statement, collecting any missing legal fields from the user.',
744
+ 'arguments': [
745
+ {'name': 'entity', 'description': 'organization name', 'required': True},
746
+ {'name': 'url', 'description': 'website URL', 'required': True},
747
+ {'name': 'status', 'description': 'plena | parcial | no_conforme', 'required': False},
748
+ ],
749
+ },
750
+ {
751
+ 'name': 'conformance-wcagem',
752
+ 'description': 'Guided WCAG-EM conformance ladder for a site: express screening → agent-verified guided evaluation on a representative sample → conformance report inputs.',
753
+ 'arguments': [
754
+ {'name': 'url', 'description': 'site root to evaluate', 'required': True},
755
+ {'name': 'tier', 'description': 'express | guided | conformance (default: express)', 'required': False},
756
+ {'name': 'language', 'description': 'es or en', 'required': False},
757
+ ],
758
+ },
759
+ {
760
+ 'name': 'blindfold-task',
761
+ 'description': ('Blindfold usability test — the agent attempts a real task perceiving '
762
+ 'ONLY the accessibility tree and acting only by accessible name and '
763
+ 'keyboard, logging friction per step; closes with a11y_journey_verdict. '
764
+ 'The capability no other accessibility tool has: task-based non-visual '
765
+ 'testing where the agent IS the screen-reader user.'),
766
+ 'arguments': [
767
+ {'name': 'url', 'description': 'page where the task lives', 'required': True},
768
+ {'name': 'goal', 'description': 'the task in user terms ("sign up for the newsletter")', 'required': True},
769
+ {'name': 'kind', 'description': 'sign-up | checkout | password-reset | search | custom', 'required': False},
770
+ {'name': 'language', 'description': 'es or en', 'required': False},
771
+ ],
772
+ },
773
+ ]
774
+
775
+
776
+ def _prompt(name, args):
777
+ L = (args.get('language') or 'en').lower()
778
+ if L not in ('es', 'en'):
779
+ L = 'en'
780
+ t = {
781
+ 'audit-page': {
782
+ 'en': f"Run a full accessibility audit of {args.get('url','the URL')} and report in the user's language:\n"
783
+ "1. Call a11y_audit_url (static express pass). If Playwright is available, also call a11y_audit_dom for real computed contrast, 2.5.8 target size and focus indicator.\n"
784
+ "2. Group findings by severity; for each, cite the WCAG criterion, the evidence, and the remediation the tool returned.\n"
785
+ "3. State clearly what automation CANNOT check, and verify what you can: keyboard operability (Tab/Shift+Tab/Enter/Esc, focus visible), heading landmarks, form flow, 200% zoom reflow.\n"
786
+ "4. End with a prioritized fix list (high/medium/low) and the honest scope note: automation ≈ 1/3 of WCAG; recommend screen-reader testing for the rest.",
787
+ 'es': f"Ejecuta una auditoría de accesibilidad completa de {args.get('url','la URL')} e informa en el idioma de la persona usuaria:\n"
788
+ "1. Llama a a11y_audit_url (pase estático exprés). Si hay Playwright, llama también a a11y_audit_dom para contraste real computado, tamaño de objetivo 2.5.8 e indicador de foco.\n"
789
+ "2. Agrupa por severidad; para cada hallazgo cita el criterio WCAG, la evidencia y la remediación devuelta por la herramienta.\n"
790
+ "3. Deja claro lo que la automatización NO puede revisar y verifica lo que puedas: operabilidad por teclado (Tab/Shift+Tab/Enter/Esc, foco visible), landmarks, flujo de formularios, reflujo al 200%.\n"
791
+ "4. Cierra con una lista priorizada de arreglo (alta/media/baja) y la nota honesta: automatización ≈ 1/3 de WCAG; recomienda prueba con lector de pantalla para el resto.",
792
+ },
793
+ 'fix-contrast': {
794
+ 'en': f"Fix the contrast of {args.get('fg','fg')} on {args.get('bg','bg')}"
795
+ + (f" in {args.get('context','')}" if args.get('context') else '') + ":\n"
796
+ "1. Call a11y_contrast_pair to get the exact ratio and per-criterion verdicts.\n"
797
+ "2. If AA fails, take sugerencia_aa (or call a11y_suggest_color with the needed level: 4.5 normal text, 3.0 large text, 3.0 UI components).\n"
798
+ "3. Locate the color in the code" + (f" ({args.get('context','')})" if args.get('context') else '')
799
+ + ", replace it with the suggested value, and re-verify with a11y_contrast_pair.\n"
800
+ "4. If the text sits over an image or gradient, use a11y_contrast_image with a screenshot region instead — pixel sampling is the only honest check there.",
801
+ 'es': f"Corrige el contraste de {args.get('fg','fg')} sobre {args.get('bg','bg')}"
802
+ + (f" en {args.get('context','')}" if args.get('context') else '') + ":\n"
803
+ "1. Llama a a11y_contrast_pair para el ratio exacto y los veredictos por criterio.\n"
804
+ "2. Si no pasa AA, toma sugerencia_aa (o llama a a11y_suggest_color con el nivel necesario: 4.5 texto normal, 3.0 texto grande, 3.0 componentes UI).\n"
805
+ "3. Localiza el color en el código" + (f" ({args.get('context','')})" if args.get('context') else '')
806
+ + ", sustitúyelo por el valor sugerido y reverifica con a11y_contrast_pair.\n"
807
+ "4. Si el texto va sobre imagen o degradado, usa a11y_contrast_image con la región de una captura — el muestreo píxel a píxel es la única verificación honesta ahí.",
808
+ },
809
+ 'pre-deploy-check': {
810
+ 'en': f"Pre-deploy accessibility regression check for {args.get('url','the URL')}:\n"
811
+ "1. Call a11y_audit_url on the staging URL (and a11y_audit_dom if Playwright is available).\n"
812
+ + (f"2. Compare against baseline {args.get('baseline','')} with a11y_diff (if the baseline is a URL, snapshot it first with a11y_snapshot).\n"
813
+ if args.get('baseline') else
814
+ "2. If a baseline snapshot exists, diff it with a11y_diff; if not, create one with a11y_snapshot for the next deploy.\n")
815
+ + "3. Report: new findings (blockers), resolved findings (good news), interactive elements added/removed/renamed, focus-order changes.\n"
816
+ "4. Verdict: GO (no new high findings and no focus regressions) / NO-GO (otherwise) with the evidence.",
817
+ 'es': f"Comprobación de regresión de accesibilidad antes de desplegar {args.get('url','la URL')}:\n"
818
+ "1. Llama a a11y_audit_url sobre la URL de staging (y a11y_audit_dom si hay Playwright).\n"
819
+ + (f"2. Compara con la referencia {args.get('baseline','')} mediante a11y_diff (si la referencia es una URL, captúrala antes con a11y_snapshot).\n"
820
+ if args.get('baseline') else
821
+ "2. Si existe un snapshot de referencia, compara con a11y_diff; si no, créalo con a11y_snapshot para el próximo despliegue.\n")
822
+ + "3. Informa: hallazgos nuevos (bloqueantes), hallazgos resueltos (buenas noticias), interactivos añadidos/eliminados/renombrados, cambios de orden de foco.\n"
823
+ "4. Veredicto: GO (sin hallazgos altos nuevos ni regresiones de foco) / NO-GO (en caso contrario) con la evidencia.",
824
+ },
825
+ 'conformance-wcagem': {
826
+ 'en': f"Run the WCAG-EM conformance ladder for {args.get('url','the site')} (tier: {args.get('tier','express')}):\n"
827
+ "1. EXPRESS (always): a11y_audit_url on the root and the 4-5 key pages (use pages parameter / crawl). Report scores and findings by severity.\n"
828
+ "2. GUIDED: pick a WCAG-EM sample — structured pages (home, contact, login, a content page, a form flow) plus a random pick from the crawl. On each sample page, run a11y_audit_dom if Playwright is available, then verify the manual checklist yourself (keyboard walk, focus visibility, zoom 200%, error announcement on one form). Mark each item verified-by-agent vs automated-only.\n"
829
+ "3. CONFORMANCE: only with a human in the loop — compile the evidence (sample, pages, results, dates) into WCAG-EM report structure, state the scope honestly (sample-based evaluation, not a certification), and feed inaccessible_content into a11y_generate_declaration.\n"
830
+ "Escalate one tier at a time; never present tier 1 or 2 as conformance.",
831
+ 'es': f"Ejecuta la escalera de conformidad WCAG-EM para {args.get('url','el sitio')} (nivel: {args.get('tier','express')})\u003a\n"
832
+ "1. EXPRESS (siempre): a11y_audit_url en la raíz y las 4-5 páginas clave (parámetro pages). Informa puntuaciones y hallazgos por severidad.\n"
833
+ "2. GUIDED: elige una muestra WCAG-EM — páginas estructurales (inicio, contacto, login, una de contenido, un flujo de formulario) más una aleatoria del rastreo. En cada una, a11y_audit_dom si hay Playwright, y verifica tú el checklist manual (recorrido de teclado, foco visible, zoom 200%, anuncio de errores en un formulario). Marca cada punto como verificado-por-agente o solo-automático.\n"
834
+ "3. CONFORMANCE: solo con humana en el bucle — recopila la evidencia (muestra, páginas, resultados, fechas) en la estructura del informe WCAG-EM, declara el alcance con honestidad (evaluación por muestreo, no certificación) y alimenta inaccessible_content en a11y_generate_declaration.\n"
835
+ "Escala un nivel cada vez; nunca presentes el nivel 1 o 2 como conformidad.",
836
+ },
837
+ 'declaration-eaa': {
838
+ 'en': f"Generate an accessibility statement for {args.get('entity','the entity')} ({args.get('url','URL')}):\n"
839
+ "1. Establish the compliance state with a11y_audit_url (parcial is the honest default when findings exist).\n"
840
+ f"2. Current estado argument: {args.get('status','(missing)')}. If missing, infer from the audit and confirm with the user.\n"
841
+ "3. Collect what is missing: feedback contact, claim procedure (reclamación), evaluation method and dates. Ask the user only for what you cannot infer.\n"
842
+ "4. List inaccessible_content from the audit findings with reasons and alternatives.\n"
843
+ "5. Call a11y_generate_declaration (marco='eaa' for private sector / EAA; 'rd1112' for Spanish public sector), lang matching the site, and save with output_path.\n"
844
+ "6. Remind: the statement must be linked from every page (typically the footer) and reviewed after significant changes.",
845
+ 'es': f"Genera la declaración de accesibilidad de {args.get('entity','la entidad')} ({args.get('url','URL')}):\n"
846
+ "1. Establece el estado de conformidad con a11y_audit_url (parcial es lo honesto por defecto si hay hallazgos).\n"
847
+ f"2. Argumento estado actual: {args.get('status','(falta)')}. Si falta, infiérelo de la auditoría y confírmalo con la persona usuaria.\n"
848
+ "3. Recoge lo que falte: contacto de feedback, procedimiento de reclamación, método y fechas de evaluación. Pregunta solo lo que no puedas inferir.\n"
849
+ "4. Enumera inaccessible_content a partir de los hallazgos, con razón y alternativa.\n"
850
+ "5. Llama a a11y_generate_declaration (marco='eaa' para sector privado / EAA; 'rd1112' para sector público español), lang del sitio, y guarda con output_path.\n"
851
+ "6. Recuerda: la declaración debe enlazarse desde todas las páginas (típico en el pie) y revisarse tras cambios significativos.",
852
+ },
853
+ 'blindfold-task': {
854
+ 'en': f"BLINDFOLD TEST of the task “{args.get('goal','the task')}” on {args.get('url','the URL')}:\n"
855
+ "1. PERCEIVE through the accessibility tree only: your browser's accessibility snapshot (browser_snapshot) at EVERY step — it preserves session state (filled forms, open dialogs); optionally a11y_sr_transcript ONCE at journey start for the linearized “what a screen reader says” prose. Reading HTML, screenshots or CSS is FORBIDDEN: what is not in the tree does not exist for you.\n"
856
+ "2. ACT only by accessible name and keyboard: click by role+name, Tab/Enter/Escape. Never coordinates or CSS selectors.\n"
857
+ "3. NAVIGATE LIKE A SCREEN-READER USER, not like a Tab machine: real users move by HEADINGS and LANDMARKS first, Tab second. From each snapshot, list the headings and landmarks explicitly and jump by them; if the headings are missing, mis-leveled or the page has no main landmark, that is friction (journey_heading_nav_broken 2.4.6, journey_landmark_missing 2.4.1) — navigation itself is under test. AFTER EVERY ACTION: re-perceive and log friction with a journey_* pattern (unnamed control 4.1.2, focus lost 2.4.3, silent error 3.3.1, unannounced status 4.1.3, no instructions 3.3.2, unreachable 2.1.1, dialog trap 2.1.2, generic link 2.4.4, hidden from tree 1.3.1, unextendable timeout 2.2.1, headings broken 2.4.6, no landmarks 2.4.1, keyboard-swallowing widget 4.1.2, duplicate accessible names 4.1.2, stale tree after action 4.1.3) or criterion+issue if rarer. Describe STRUCTURE; never quote page content.\n"
858
+ "4. NO CHEATING: if you only completed the task through a path a real screen reader would not offer, mark workaround_used. If after three reasonable attempts you cannot advance, log gave_up (a paid outcome, not an agent failure).\n"
859
+ "5. CLOSE with a11y_journey_verdict (task, steps, outcome). Report verdict + score + friction with criterion and remediation, grouped by severity, plus the score_note: usability evidence, never conformance.",
860
+ 'es': f"PRUEBA A CIEGAS de la tarea «{args.get('goal','la tarea')}» en {args.get('url','la URL')}:\n"
861
+ "1. PERCIBE solo por el árbol de accesibilidad: el snapshot de accesibilidad de TU navegador (browser_snapshot) en CADA paso — conserva el estado de la sesión (formularios rellenos, diálogos abiertos); opcionalmente a11y_sr_transcript UNA vez al inicio para la prosa linealizada de lo que diría un lector. PROHIBIDO leer el HTML, capturas o CSS: si no está en el árbol, para ti no existe.\n"
862
+ "2. ACTÚA solo por nombre accesible y teclado: clic por rol+nombre, Tab/Enter/Escape. Nunca coordenadas ni selectores CSS.\n"
863
+ "3. NAVEGA COMO UNA PERSONA USUARIA DE LECTOR DE PANTALLA, no como una máquina de Tab: los usuarios reales se mueven primero por ENCABEZADOS y LANDMARKS, y Tab es el plan B. En cada snapshot, lista explícitamente los encabezados y landmarks y salta por ellos; si los encabezados faltan, rompen la jerarquía o no hay main, eso ES fricción (journey_heading_nav_broken 2.4.6, journey_landmark_missing 2.4.1) — la navegación misma está bajo prueba. TRAS CADA ACCIÓN: vuelve a percibir y registra la fricción con un patrón journey_* (control sin nombre 4.1.2, foco perdido 2.4.3, error silencioso 3.3.1, estado sin anunciar 4.1.3, sin instrucciones 3.3.2, no alcanzable 2.1.1, diálogo-trampa 2.1.2, enlace genérico 2.4.4, oculto al árbol 1.3.1, tiempo sin prórroga 2.2.1, encabezados rotos 2.4.6, sin landmarks 2.4.1, widget que se traga teclas 4.1.2, nombres duplicados 4.1.2, árbol obsoleto 4.1.3) o criterio+issue si es más raro. Describe ESTRUCTURA; nunca cites contenido de la página.\n"
864
+ "4. SIN ATAJOS: si solo completaste la tarea por una vía que un lector real no ofrecería, marca workaround_used. Si tras 3 intentos razonables no avanzas, registra gave_up (resultado pagado, no fallo del agente).\n"
865
+ "5. CIERRA con a11y_journey_verdict (task, steps, outcome). Comunica veredicto + score + fricción con criterio y remediation, agrupado por severidad, y el score_note: evidencia de usabilidad, nunca conformidad.",
866
+ },
867
+ }
868
+ txt = t[name][L]
869
+ return {'description': next(p['description'] for p in _PROMPTS if p['name'] == name),
870
+ 'messages': [{'role': 'user', 'content': {'type': 'text', 'text': txt}}]}
871
+
872
+
873
+ # ── Parameter documentation (100% coverage, pinned by test_solido) ──────────
874
+ # TDQS/Glama's top penalty was undocumented params; this table is the single
875
+ # source, injected at import time so the literals above stay readable.
876
+ _PARAM_DOCS = {
877
+ ('a11y_audit_url', 'url'): 'Page URL to fetch and audit (http/https only; local HTML goes in the html argument)',
878
+ ('a11y_audit_url', 'html'): 'Raw HTML string to audit directly (overrides url — use for pages you already fetched or local files)',
879
+ ('a11y_audit_url', 'pages'): 'Light same-domain crawl: audit up to N pages discovered by links, aggregated by mean/worst score and recurring signals (1 = single page)',
880
+ ('a11y_audit_url', 'timeout'): 'Fetch timeout in seconds per page (default 30)',
881
+ ('a11y_audit_dom', 'url'): 'Page URL to load in Chromium (http/https or file:// for local fixtures)',
882
+ ('a11y_audit_dom', 'timeout'): 'Page load timeout in seconds (default 45)',
883
+ ('a11y_audit_url', 'lang'): 'Output language for findings and remediation (default en)',
884
+ ('a11y_audit_dom', 'lang'): 'Output language for findings and remediation (default en)',
885
+ ('a11y_reflow', 'url'): 'Page URL to test at 320px (http/https or file://)',
886
+ ('a11y_forms', 'url'): 'Page URL containing the form(s) to fill and submit with invalid data',
887
+ ('a11y_hover', 'url'): 'Page URL to test tooltip dismissibility on',
888
+ ('a11y_hover', 'timeout'): 'Page load timeout in seconds (default 45)',
889
+ ('a11y_hover', 'browser'): 'Browser engine (auto = detect the first available)',
890
+ ('a11y_sr_transcript', 'browser'): 'Browser engine (auto = detect the first available)',
891
+ ('a11y_audit_dom', 'browser'): 'Browser engine (auto = detect the first available)',
892
+ ('a11y_reflow', 'browser'): 'Browser engine (auto = detect the first available)',
893
+ ('a11y_keyboard', 'browser'): 'Browser engine (auto = detect the first available)',
894
+ ('a11y_scroll', 'browser'): 'Browser engine (auto = detect the first available)',
895
+ ('a11y_forms', 'browser'): 'Browser engine (auto = detect the first available)',
896
+ ('a11y_sr_transcript', 'url'): 'Page URL to get the screen reader announcement transcript',
897
+ ('a11y_sr_transcript', 'timeout'): 'Page load timeout in seconds (default 45)',
898
+ ('a11y_journey_verdict', 'task'): 'Task the agent attempted blindfolded: {"goal": …, "kind": sign-up|checkout|password-reset|search|custom}',
899
+ ('a11y_journey_verdict', 'steps'): 'Journey steps in order; each friction item is a journey_* pattern key or a raw {criterion, severity, issue}',
900
+ ('a11y_journey_verdict', 'outcome'): 'How the journey ended: completed / gave_up / workaround_used + notes',
901
+ ('a11y_journey_verdict', 'url'): 'Where the journey ran',
902
+ ('a11y_journey_verdict', 'lang'): 'Output language (en|es)',
903
+ ('a11y_journey_verdict', 'output_path'): 'File to write the full verdict JSON (optional)',
904
+ ('a11y_vtt_check', 'url'): 'URL of the .vtt caption file to download and judge',
905
+ ('a11y_vtt_check', 'duration'): 'Media duration in seconds — enables coverage (1.2.2 completeness)',
906
+ ('a11y_audit_pdf', 'path'): 'Local PDF file path to screen (structural pass)',
907
+ ('a11y_docx_screen', 'path'): 'Local .docx file path to screen (structural pass)',
908
+ ('a11y_docx_screen', 'lang'): 'Output language (en|es)',
909
+ ('a11y_reduced_motion', 'url'): 'Page URL to test with and without prefers-reduced-motion',
910
+ ('a11y_reduced_motion', 'auth_state'): 'Playwright storage_state JSON path (behind-login testing)',
911
+ ('a11y_reduced_motion', 'browser'): 'Browser engine (auto = detect the first available)',
912
+ ('a11y_reduced_motion', 'lang'): 'Output language (en|es)',
913
+ ('a11y_reduced_motion', 'timeout'): 'Page load timeout seconds (45 default)',
914
+ ('a11y_forced_colors', 'url'): 'Page URL to test under forced-colors emulation',
915
+ ('a11y_forced_colors', 'auth_state'): 'Playwright storage_state JSON path (behind-login testing)',
916
+ ('a11y_forced_colors', 'browser'): 'Browser engine (auto = detect the first available)',
917
+ ('a11y_forced_colors', 'lang'): 'Output language (en|es)',
918
+ ('a11y_forced_colors', 'timeout'): 'Page load timeout seconds (45 default)',
919
+ ('a11y_disprove', 'url'): 'URL to re-verify findings against',
920
+ ('a11y_disprove', 'report'): 'Existing audit report to verify (optional; audits first if absent)',
921
+ ('a11y_disprove', 'timeout'): 'Fetch timeout seconds (default 30)',
922
+ ('a11y_ledger', 'action'): 'record (add audit), gaps (what is missing), or summary (overview)',
923
+ ('a11y_ledger', 'url'): 'URL being audited (for record/gaps)',
924
+ ('a11y_ledger', 'report'): 'Audit report object (for record action)',
925
+ ('a11y_ledger', 'ledger_path'): 'Path to the ledger JSON file (default: a11y-ledger.json)',
926
+
927
+
928
+ ('a11y_autofix', 'form_errors'): 'Inject the accessible error layer into forms without their own handling (default true)',
929
+ ('a11y_forms', 'timeout'): 'Page load timeout in seconds (default 45)',
930
+ ('a11y_html_validate', 'url'): 'Page URL to validate via the W3C Nu service',
931
+ ('a11y_html_validate', 'html'): 'Raw HTML — its CONTENT is sent to validator.w3.org/nu',
932
+ ('a11y_html_validate', 'base_url'): 'Self-hosted vnu instance base URL for sensitive content',
933
+
934
+
935
+ ('a11y_reflow', 'timeout'): 'Page load timeout in seconds (default 45)',
936
+ ('a11y_reflow', 'lang'): 'Output language (default en)',
937
+ ('a11y_keyboard', 'url'): 'Page URL to Tab-walk (http/https or file://)',
938
+ ('a11y_keyboard', 'lang'): 'Output language (default en)',
939
+ ('a11y_keyboard', 'max_steps'): 'Maximum real Tab presses before giving up (default 60)',
940
+ ('a11y_scroll', 'url'): 'Feed URL to audit (best on feeds you own or can authenticate into)',
941
+ ('a11y_scroll', 'lang'): 'Output language (default en)',
942
+ ('a11y_scroll', 'max_batches'): 'Scroll batches to load and evaluate (default 5)',
943
+ ('a11y_contrast_pair', 'fg'): 'Foreground/text color: #hex, rgb(), hsl() or a CSS color name; alpha composites over bg',
944
+ ('a11y_contrast_pair', 'bg'): 'Background color: same formats; alpha composites over white',
945
+ ('a11y_contrast_image', 'path'): 'Local path to the screenshot/image the text sits on (PNG/JPG/PPM)',
946
+ ('a11y_contrast_image', 'text_color'): 'The text color as rendered over the image (must be opaque)',
947
+ ('a11y_contrast_image', 'region'): 'Text bounding box as "x,y,width,height" in pixels (strongly recommended: defines what to sample)',
948
+ ('a11y_contrast_image', 'sample'): 'Pixel step: 4 samples every 4px (auto-raised for huge regions)',
949
+ ('a11y_contrast_image', 'lang'): 'Output language (default en)',
950
+ ('a11y_suggest_color', 'fg'): 'The failing foreground color to fix',
951
+ ('a11y_suggest_color', 'bg'): 'The background it must pass against',
952
+ ('a11y_suggest_color', 'target'): 'Ratio to reach: 4.5 normal text, 3.0 large text/UI, 7.0 AAA (default 4.5)',
953
+ ('a11y_generate_declaration', 'entity'): 'Legal entity name as it should appear in the statement (company, body…)',
954
+ ('a11y_generate_declaration', 'url'): 'Website URL the statement covers',
955
+ ('a11y_generate_declaration', 'status'): 'Compliance state: full | partial | not_conformant (partial is the honest default when findings exist)',
956
+ ('a11y_generate_declaration', 'inaccessible_content'): 'Non-accessible content list: one string per item, ideally criterion + reason + alternative',
957
+ ('a11y_generate_declaration', 'review_date'): 'ISO date of the next scheduled review',
958
+ ('a11y_generate_declaration', 'feedback'): 'Contact channel for accessibility feedback (email or URL)',
959
+ ('a11y_generate_declaration', 'framework'): 'Legal framework: rd1112 (Spanish public sector, art. 10) or eaa (European Accessibility Act / private sector)',
960
+ ('a11y_generate_declaration', 'output_path'): 'Local path to save the statement HTML (omit to receive it inline)',
961
+ ('a11y_generate_declaration', 'lang'): 'Statement language (default en; es uses the Spanish legal wording)',
962
+ ('a11y_snapshot', 'url'): 'Page URL to snapshot (http/https or file://)',
963
+ ('a11y_diff', 'a'): 'BEFORE snapshot: inline JSON (starts with {) or path to the snapshot file',
964
+ ('a11y_diff', 'b'): 'AFTER snapshot: inline JSON or file path',
965
+ ('a11y_diff_urls', 'url_a'): 'First URL (usually staging)',
966
+ ('a11y_diff_urls', 'url_b'): 'Second URL (usually production)',
967
+ ('a11y_autofix', 'html'): 'Raw HTML to apply the closed allowlist of deterministic fixes to',
968
+ ('a11y_autofix', 'lang'): 'BCP-47 language to set on <html> ONLY if it is missing (e.g. "es")',
969
+ ('a11y_autofix', 'title'): 'Page title to set ONLY if <title> is empty',
970
+ ('a11y_badge', 'score'): '0-100 score from an audit result (int/float)',
971
+ ('a11y_badge', 'date'): 'ISO date shown on the badge (today by default)',
972
+ ('a11y_badge', 'lang'): 'Badge language (default en)',
973
+ ('a11y_criterion', 'code'): 'WCAG criterion number, e.g. "1.4.3", "2.5.8" — or pass signal instead',
974
+ ('a11y_criterion', 'signal'): 'Signal id from any finding (e.g. img_no_alt): resolves its criterion and published ACT rules with w3.org links',
975
+ ('a11y_criterion', 'lang'): 'Explanation language (default en)',
976
+ ('a11y_evidence', 'reports'): 'Audit report objects to bundle (any mode: static, rendered, reflow, keyboard, scroll)',
977
+ ('a11y_evidence', 'snapshot'): 'Optional a11y_snapshot output to include as an artifact',
978
+ ('a11y_evidence', 'reviewer'): 'Optional prefill for the signature block: {"name":…, "credential":…, "review_date":…}',
979
+ ('a11y_aria_live_snippet', 'lang'): 'Monitor panel language (default en)',
980
+ ('a11y_generate_vpat', 'product'): 'Product name as it must appear in the VPAT title and header',
981
+ ('a11y_generate_vpat', 'pack'): 'a11y_evidence output (evidence pack); alternative to reports',
982
+ ('a11y_generate_vpat', 'reports'): 'Audit report objects to bundle (when pack is not given, the pack is built here first)',
983
+ ('a11y_generate_vpat', 'report_date'): 'VPAT report date ISO (default: today)',
984
+ ('a11y_generate_vpat', 'product_description'): 'Product description paragraph',
985
+ ('a11y_generate_vpat', 'contact'): 'Contact information for questions about this VPAT',
986
+ ('a11y_generate_vpat', 'methods'): 'Evaluation methods used (default: honest automated-screening note)',
987
+ ('a11y_generate_vpat', 'notes'): 'Additional notes to include',
988
+ ('a11y_generate_vpat', 'overrides'): 'Criterion → conformance level set by a qualified human: {"1.1.1": "supports", "1.2.2": "not_applicable", …}',
989
+ ('a11y_generate_vpat', 'reviewer'): '{"name":…, "credential":…, "review_date":…} to prefill the signature block',
990
+ ('a11y_generate_vpat', 'output_path'): 'Local path to save the VPAT HTML (omit to receive it inline)',
991
+ ('a11y_generate_vpat', 'lang'): 'Document language (default en)',
992
+ ('a11y_generate_openacr', 'product'): 'Product name as it must appear in the OpenACR',
993
+ ('a11y_generate_openacr', 'pack'): 'a11y_evidence output (evidence pack); alternative to reports',
994
+ ('a11y_generate_openacr', 'reports'): 'Audit report objects to bundle (when pack is not given, the pack is built here first)',
995
+ ('a11y_generate_openacr', 'product_version'): 'Product version',
996
+ ('a11y_generate_openacr', 'report_date'): 'ACR report date ISO (default: today)',
997
+ ('a11y_generate_openacr', 'product_description'): 'Product description paragraph',
998
+ ('a11y_generate_openacr', 'author'): '{"name":…, "company":…, "email":…, "website":…} — the ACR author block',
999
+ ('a11y_generate_openacr', 'contact'): 'Contact email (author.email fallback)',
1000
+ ('a11y_generate_openacr', 'methods'): 'Evaluation methods used (default: honest automated-screening note)',
1001
+ ('a11y_generate_openacr', 'notes'): 'Additional notes to include',
1002
+ ('a11y_generate_openacr', 'overrides'): 'Criterion → adherence level set by a qualified human: {"1.1.1": "supports", "1.2.2": "not_applicable", …} (hyphenated forms accepted)',
1003
+ ('a11y_generate_openacr', 'output_path'): 'Local path to save the OpenACR YAML (omit to receive it inline)',
1004
+ ('a11y_generate_openacr', 'lang'): 'Document language (default en)',
1005
+ ('a11y_contrast_dom', 'url'): 'Page URL where the element lives (http/https or file://)',
1006
+ ('a11y_contrast_dom', 'selector'): 'CSS selector of the text element to measure',
1007
+ ('a11y_contrast_dom', 'text_color'): 'Text color (default: computed from the element)',
1008
+ ('a11y_contrast_dom', 'sample'): 'Pixel step (default 4)',
1009
+ ('a11y_contrast_dom', 'lang'): 'Output language (default en)',
1010
+ ('a11y_contrast_dom', 'timeout'): 'Page load timeout in seconds (default 45)',
1011
+ ('a11y_contrast_dom', 'auth_state'): 'Path to a Playwright storage_state JSON to measure behind login — stays local',
1012
+ ('a11y_contrast_dom', 'browser'): 'Browser engine (auto = detect the first available)',
1013
+ }
1014
+
1015
+ # Routing guidance: one "prefer sibling X" sentence per tool (TDQS dimension).
1016
+ _ROUTING = {
1017
+ 'a11y_audit_url': 'Prefer a11y_audit_dom when JS renders the content or contrast/2.5.8/focus matter; use pages for light multi-page sampling. Static CANNOT measure class/var() CSS contrast (1.4.3): the report\'s not_measured says so — a 100 is never \'contrast is fine\'.',
1018
+ 'a11y_audit_dom': 'Use instead of a11y_audit_url on JS-heavy pages; needs local Playwright.',
1019
+ 'a11y_reflow': 'Scope: 320px reflow only (1.4.10); for the full rendered pass use a11y_audit_dom.',
1020
+ 'a11y_keyboard': 'Scope: keyboard traps (2.1.2); focus visibility is part of a11y_audit_dom.',
1021
+ 'a11y_scroll': 'For paginated feeds only; general page audit is a11y_audit_url/dom.',
1022
+ 'a11y_contrast_pair': 'For flat pairs; text over images needs a11y_contrast_image.',
1023
+ 'a11y_contrast_image': 'Use instead of a11y_contrast_pair whenever the background is a photo/gradient.',
1024
+ 'a11y_suggest_color': 'The fixer companion to a11y_contrast_pair failures.',
1025
+ 'a11y_snapshot': 'Capture half of the watch loop; compare with a11y_diff (or a11y_diff_urls for two live URLs).',
1026
+ 'a11y_diff': 'Compares two existing snapshots; a11y_diff_urls snapshots both for you.',
1027
+ 'a11y_diff_urls': 'Convenience for staging-vs-production; manual control is snapshot + a11y_diff.',
1028
+ 'a11y_autofix': 'Only the closed allowlist of provably safe fixes; judgment fixes come back as not_applied with remediation.',
1029
+ 'a11y_badge': 'Scope: the honest SVG seal for audited sites; the machine-readable bundle is a11y_evidence.',
1030
+ 'a11y_criterion': 'Knowledge lookup; does not fetch or audit anything — includes the official Understanding WCAG 2.2 link for the criterion.',
1031
+ 'a11y_evidence': 'The tier-3 handoff object; feed it every audit report you have.',
1032
+ 'a11y_aria_live_snippet': 'Diagnostics aid to inject in a browser; not an audit by itself.',
1033
+ 'a11y_generate_declaration': 'Legal statement generator; drive inaccessible_content from audit findings and a11y_evidence.',
1034
+ 'a11y_generate_vpat': 'The US/ADA counterpart of a11y_generate_declaration; feed it the a11y_evidence pack — levels stay Not Evaluated until a qualified human sets them.',
1035
+ 'a11y_generate_openacr': 'The machine-readable (GSA OpenACR YAML) sibling of a11y_generate_vpat — emit both from the same pack: humans read the VPAT, procurement systems parse the OpenACR.',
1036
+ 'a11y_contrast_dom': 'Use instead of a11y_contrast_image when the text lives in a live page (captures and measures it automatically); for flat pairs use a11y_contrast_pair.',
1037
+ }
1038
+
1039
+ for _t in TOOLS:
1040
+ _props = _t['inputSchema'].get('properties', {})
1041
+ for _p, _desc in _PARAM_DOCS.items():
1042
+ if _p[0] == _t['name'] and _p[1] in _props:
1043
+ _props[_p[1]].setdefault('description', _desc)
1044
+ if _t['name'] in _ROUTING and _ROUTING[_t['name']] not in _t['description']:
1045
+ _t['description'] += ' — ' + _ROUTING[_t['name']]
1046
+
1047
+ # Títulos UI + annotations (MCP spec 2025-11-25): los clientes pueden aprobar
1048
+ # automáticamente las tools de solo lectura → menos fricción en cada uso.
1049
+ _ANN = {
1050
+ 'a11y_audit_url': ('Express WCAG audit', True, True),
1051
+ 'a11y_audit_dom': ('Rendered WCAG audit', True, True),
1052
+ 'a11y_reflow': ('320px reflow check', True, True),
1053
+ 'a11y_keyboard': ('Keyboard-trap detector', True, True),
1054
+ 'a11y_html_validate': ('W3C Nu validation', True, True),
1055
+ 'a11y_forms': ('Form error testing', True, True),
1056
+ 'a11y_scroll': ('Infinite-scroll audit', True, True),
1057
+ 'a11y_snapshot': ('A11y snapshot + tab order', True, True),
1058
+ 'a11y_diff': ('Snapshot regression diff', True, False),
1059
+ 'a11y_diff_urls': ('Staging vs production diff', True, True),
1060
+ 'a11y_contrast_pair': ('Contrast ratio + verdicts', True, False),
1061
+ 'a11y_contrast_image': ('Text-over-image contrast', True, False),
1062
+ 'a11y_suggest_color': ('Nearest passing color', True, False),
1063
+ 'a11y_generate_declaration': ('Accessibility statement (EAA/RD 1112)', False, False),
1064
+ 'a11y_autofix': ('Deterministic safe auto-fixes', True, False),
1065
+ 'a11y_aria_live_snippet': ('aria-live monitor snippet', True, False),
1066
+ 'a11y_badge': ('Honest SVG badge', True, False),
1067
+ 'a11y_evidence': ('Evidence pack (verifiable handoff)', True, False),
1068
+ 'a11y_hover': ('Hover dismissibility (1.4.13)', True, True),
1069
+ 'a11y_sr_transcript': ('Screen reader transcript', True, True),
1070
+ 'a11y_disprove': ('Disprover: re-verify findings', True, True),
1071
+ 'a11y_ledger': ('Coverage ledger (persistent)', True, False),
1072
+ 'a11y_criterion': ('WCAG criterion explained', True, False),
1073
+ 'a11y_journey_verdict': ('Blindfold journey verdict', True, False),
1074
+ 'a11y_generate_vpat': ('VPAT 2.5 report (WCAG edition)', False, False),
1075
+ 'a11y_generate_openacr': ('OpenACR YAML report (GSA)', False, False),
1076
+ 'a11y_contrast_dom': ('Live-element contrast sampling', True, True),
1077
+ 'a11y_vtt_check': ('WebVTT caption quality', True, True),
1078
+ 'a11y_audit_pdf': ('PDF accessibility screening', True, False),
1079
+ 'a11y_docx_screen': ('DOCX accessibility screening', True, False),
1080
+ 'a11y_reduced_motion': ('prefers-reduced-motion honored?', True, True),
1081
+ 'a11y_forced_colors': ('forced-colors survival heuristic', True, True),
1082
+ 'a11y_wcag3_preview': ('WCAG 3 draft preview (no score)', True, False),
1083
+ 'a11y_route': ('Tool router (goal or page to steps)', True, True),
1084
+ }
1085
+ # TDQS hygiene: annotations must match reality, and every description states
1086
+ # its return shape and when (not) to use the tool. a11y_ledger.record mutates
1087
+ # a persistent file and a11y_forms really submits forms — neither is
1088
+ # read-only, and neither is idempotent.
1089
+ _RO_OVERRIDE = {'a11y_ledger': False, 'a11y_forms': False}
1090
+ _IDEM_OVERRIDE = {'a11y_ledger': False, 'a11y_forms': False}
1091
+ _RETURNS = {
1092
+ 'a11y_audit_url': 'Returns JSON: {mode, url|file, score 0-100, findings [{criterion, severity, signal, issue, remediation}], summary {high, medium, low}, limits, score_note, overlay_widgets? (detected third-party overlay scripts — data, not a WCAG finding)}.',
1093
+ 'a11y_audit_dom': 'Returns JSON: {mode, url, score 0-100, findings [{criterion, severity, signal, issue, remediation}], summary, score_note} — same shape as the static audit.',
1094
+ 'a11y_contrast_pair': 'Returns JSON: {text, background, ratio, verdicts [{criterion, level, threshold, passes}], aa_suggestion?}.',
1095
+ 'a11y_contrast_image': 'Returns JSON: {worst_ratio, median_ratio, p95_ratio, area_passes_aa_normal_text_4_5, worst_zone, sampled_pixels}.',
1096
+ 'a11y_suggest_color': 'Returns JSON: {color, ratio, action} — the nearest opaque color reaching the target.',
1097
+ 'a11y_snapshot': 'Returns JSON: {url, ts, elements [{tag, role, name, ref…}], focus_order}.',
1098
+ 'a11y_diff': 'Returns JSON: {ok, added, removed, renamed, focus_order_changed, first_differences} — ok:false means a regression to review.',
1099
+ 'a11y_diff_urls': 'Returns the same diff shape as a11y_diff, for two live URLs.',
1100
+ 'a11y_aria_live_snippet': 'Returns the injectable JavaScript as text (bookmarklet or page.evaluate).',
1101
+ 'a11y_badge': 'Returns the honest SVG badge; writes a file only when output_path is given.',
1102
+ 'a11y_autofix': 'Returns JSON: {fixed_html, applied [{fix, …}], not_applied [{issue, remediation}]} — writes a file only when output_path is given.',
1103
+ 'a11y_reflow': 'Returns JSON: {url, viewport, horizontal_scroll, offenders [{selector, width}]}.',
1104
+ 'a11y_keyboard': 'Returns JSON: {tab_stops, trap_detected, escape_releases, findings}.',
1105
+ 'a11y_scroll': 'Returns JSON: {mode, url, score, findings [{criterion, severity, signal, issue, remediation}], summary} — same shape as the audits.',
1106
+ 'a11y_forms': 'Returns JSON: per-field error judgments {field, submitted_value_class, error_identified, announced, suggestion_present} plus an overall 3.3.1/3.3.3 verdict.',
1107
+ 'a11y_html_validate': 'Returns JSON: Nu validator messages mapped to WCAG criteria where they overlap.',
1108
+ 'a11y_hover': 'Returns JSON: {candidates, dismissed_on_escape, findings}.',
1109
+ 'a11y_sr_transcript': 'Returns JSON: {url, total, announcements [{time, politeness, role, text}] — the linearized reading order}.',
1110
+ 'a11y_disprove': 'Returns JSON: {confirmed, rejected, score} — a fresh score over confirmed findings only.',
1111
+ 'a11y_ledger': 'record returns the stored entry; gaps returns criteria never checked; summary returns {entries, active_signals, resolved, mean_score}.',
1112
+ 'a11y_criterion': 'Returns JSON: {criterion, level, understanding, toolkit_signals, requires, typical_failures, how_to_check} — signal mode adds {signal, act_rules [{id, name, status, url}]}; {error, …} for unknown codes.',
1113
+ 'a11y_evidence': 'Returns the pack JSON (a11y-evidence-pack/2); writes a file only when output_path is given.',
1114
+ 'a11y_journey_verdict': 'Returns JSON: {verdict pass|partial|fail|blocked, score 0-100, findings [{criterion, severity, signal, issue, remediation, step}], summary, rules} — writes a file only when output_path is given.',
1115
+ 'a11y_generate_declaration': 'Returns {html, summary} — the accessible legal statement; writes a file only when output_path is given.',
1116
+ 'a11y_generate_vpat': 'Returns {html, summary {level: count}, levels {code: level}, pack_sha256, draft} — the VPAT draft; writes a file only when output_path is given.',
1117
+ 'a11y_generate_openacr': 'Returns {yaml, summary {level: count}, levels {code: level}, pack_sha256, format, draft} — the OpenACR YAML draft; writes a file only when output_path is given.',
1118
+ 'a11y_contrast_dom': 'Returns JSON: {url, selector, text_color, worst_ratio, median_ratio, p95_ratio, area_passes_aa_normal_text_4_5, worst_zone?, sampled_pixels, interpretation}.',
1119
+ 'a11y_wcag3_preview': 'Returns JSON: {mode, draft, disclaimer, mapping_note, no_score, conformance_model, outcomes [{outcome, draft_url, findings, severity, signals, criteria_22}], counts, unmapped} — never a score.',
1120
+ 'a11y_route': 'Returns JSON: {route, steps [{step, tool, why}], alternates, prompts, cli, note} — the ordered tool sequence for the goal. Diagnosis mode (url/html passed): {mode: diagnose, vitals {score, summary, signals}, symptoms [{symptom, evidence}], steps [...], guarantee} — evidence orders the exams, severity breaks ties.',
1121
+ }
1122
+ _USAGE = {
1123
+ 'a11y_forms': 'Use on test/staging forms, or forms you own: invalid data is REALLY submitted. Do not run against production forms that trigger real emails, orders or leads.',
1124
+ 'a11y_ledger': 'record after every audit run; gaps before planning the next pass. The ledger file accumulates across runs — give each project its own ledger_path.',
1125
+ 'a11y_keyboard': 'Run on pages with modals, dialogs or embedded apps; a plain content page has nothing to trap.',
1126
+ 'a11y_reflow': 'Run once per template, not per page: fixed-width layouts are a property of the template.',
1127
+ 'a11y_journey_verdict': 'Run only after a real blindfold attempt (the blindfold-task prompt): the verdict prices the walk, it does not replace it.',
1128
+ 'a11y_evidence': 'Run after the audits you trust, and pass verified codes from the manual checklist — agent-verified never erases an automated-fail.',
1129
+ 'a11y_generate_vpat': 'Run after the audits you trust; a qualified human must set the final levels (overrides) and sign before publishing — the machine fills Remarks, never the claim.',
1130
+ 'a11y_generate_openacr': 'Run after the audits you trust; validate and render in the GSA OpenACR editor (gsa.github.io/openacr-editor) — a qualified human must set the final adherence levels before publishing.',
1131
+ 'a11y_wcag3_preview': 'Run after any audit when the team asks "what about WCAG 3?"; re-baseline on each W3C draft publication (roughly March/September).',
1132
+ }
1133
+ for _t in TOOLS:
1134
+ _title, _ro, _ow = _ANN[_t['name']]
1135
+ _title_ro = _RO_OVERRIDE.get(_t['name'], _ro)
1136
+ _title_same = _IDEM_OVERRIDE.get(_t['name'], True)
1137
+ _t['title'] = 'a11y-toolkit: ' + _title
1138
+ _t['annotations'] = {'readOnlyHint': _title_ro, 'destructiveHint': not _title_ro,
1139
+ 'idempotentHint': _title_same, 'openWorldHint': _ow}
1140
+ if _t['name'] in _RETURNS:
1141
+ _t['description'] += ' ' + _RETURNS[_t['name']]
1142
+ if _t['name'] in _USAGE:
1143
+ _t['description'] += ' ' + _USAGE[_t['name']]
1144
+
1145
+
1146
+
1147
+ def _content(obj):
1148
+ r = {'content': [{'type': 'text', 'text': json.dumps(obj, ensure_ascii=False, indent=1)}]}
1149
+ if isinstance(obj, dict) and 'error' in obj:
1150
+ r['isError'] = True
1151
+ return r
1152
+
1153
+
1154
+ def invoke(name, args):
1155
+ args = {PARAM_ALIASES.get(k, k): v for k, v in (args or {}).items()}
1156
+ if name == 'a11y_contrast_pair':
1157
+ return _content(pair_fn(args['fg'], args['bg'], lang=args.get('lang', 'en')))
1158
+ if name == 'a11y_contrast_image':
1159
+ return _content(image_contrast(args['path'], args['text_color'],
1160
+ region=args.get('region'), sample=args.get('sample', 4), lang=args.get('lang', 'en')))
1161
+ if name == 'a11y_suggest_color':
1162
+ fg, bg = parse_color(args['fg']), parse_color(args['bg'])
1163
+ if not fg or not bg:
1164
+ return _content({'error': 'invalid color'})
1165
+ return _content(suggest(fg, bg, float(args.get('target', 4.5)), args.get('lang', 'en')) or {'result': None})
1166
+ if name == 'a11y_generate_declaration':
1167
+ res = statement_fn(
1168
+ args['entity'], args['url'], args['status'],
1169
+ inaccessible_content=args.get('inaccessible_content'),
1170
+ method=args.get('method'), evaluation_date=args.get('evaluation_date'),
1171
+ review_date=args.get('review_date'), feedback=args.get('feedback'),
1172
+ complaints=args.get('complaints'), framework=args.get('framework', 'rd1112'),
1173
+ alternative_format=args.get('alternative_format'),
1174
+ lang=args.get('lang', 'en'))
1175
+ if 'error' in res:
1176
+ return {'content': [{'type': 'text', 'text': res['error']}], 'isError': True}
1177
+ output = args.get('output_path')
1178
+ if output:
1179
+ with open(output, 'w', encoding='utf-8') as f:
1180
+ f.write(res['html'])
1181
+ return _content({'saved_to': output, 'summary': res['summary']})
1182
+ return {'content': [{'type': 'text', 'text': res['html']}]}
1183
+ if name == 'a11y_audit_url':
1184
+ try:
1185
+ if args.get('html'):
1186
+ return _content(audit_html_fn(args['html'], args.get('url') or '(html)',
1187
+ lang=args.get('lang', 'en')))
1188
+ if args.get('pages', 1) > 1:
1189
+ return _content(audit_site_fn(args['url'], max_pages=args['pages'],
1190
+ timeout=args.get('timeout', 30),
1191
+ lang=args.get('lang', 'en')))
1192
+ return _content(audit_url_fn(args['url'], timeout=args.get('timeout', 30),
1193
+ lang=args.get('lang', 'en')))
1194
+ except Exception as e: # noqa: BLE001
1195
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1196
+ if name == 'a11y_audit_dom':
1197
+ try:
1198
+ return _content(audit_dom_url(args['url'], timeout=args.get('timeout', 45),
1199
+ lang=args.get('lang', 'en'),
1200
+ auth_state=args.get('auth_state'),
1201
+ browser=args.get('browser', 'auto'),
1202
+ color_scheme=args.get('color_scheme', 'light')))
1203
+ except ImportError:
1204
+ return {'content': [{'type': 'text',
1205
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium (or use a11y_audit_url for the zero-dependency static audit)'}],
1206
+ 'isError': True}
1207
+ except Exception as e: # noqa: BLE001
1208
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1209
+ if name == 'a11y_snapshot':
1210
+ try:
1211
+ return _content(snapshot_fn(args['url'], auth_state=args.get('auth_state')))
1212
+ except ImportError:
1213
+ return {'content': [{'type': 'text',
1214
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1215
+ 'isError': True}
1216
+ except Exception as e: # noqa: BLE001
1217
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1218
+ if name == 'a11y_diff':
1219
+ def _load(v):
1220
+ v = v.strip()
1221
+ if v.startswith('{'):
1222
+ return json.loads(v)
1223
+ with open(v, encoding='utf-8') as f:
1224
+ return json.load(f)
1225
+ try:
1226
+ return _content(diff_fn(_load(args['a']), _load(args['b'])))
1227
+ except Exception as e: # noqa: BLE001
1228
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1229
+ if name == 'a11y_diff_urls':
1230
+ try:
1231
+ return _content(diff_fn(snapshot_fn(args['url_a'], auth_state=args.get('auth_state')),
1232
+ snapshot_fn(args['url_b'], auth_state=args.get('auth_state'))))
1233
+ except ImportError:
1234
+ return {'content': [{'type': 'text',
1235
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1236
+ 'isError': True}
1237
+ except Exception as e: # noqa: BLE001
1238
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1239
+ if name == 'a11y_scroll':
1240
+ try:
1241
+ return _content(audit_scroll(args['url'], max_batches=args.get('max_batches', 5),
1242
+ lang=args.get('lang', 'en'),
1243
+ auth_state=args.get('auth_state')))
1244
+ except ImportError:
1245
+ return {'content': [{'type': 'text',
1246
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1247
+ 'isError': True}
1248
+ except Exception as e: # noqa: BLE001
1249
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1250
+ if name == 'a11y_keyboard':
1251
+ try:
1252
+ return _content(audit_keyboard(args['url'], max_steps=args.get('max_steps', 60),
1253
+ lang=args.get('lang', 'en'),
1254
+ auth_state=args.get('auth_state'),
1255
+ browser=args.get('browser', 'auto')))
1256
+ except ImportError:
1257
+ return {'content': [{'type': 'text',
1258
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1259
+ 'isError': True}
1260
+ except Exception as e: # noqa: BLE001
1261
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1262
+ if name == 'a11y_forms':
1263
+ try:
1264
+ return _content(audit_forms(args['url'], timeout=args.get('timeout', 45),
1265
+ lang=args.get('lang', 'en'),
1266
+ auth_state=args.get('auth_state')))
1267
+ except ImportError:
1268
+ return {'content': [{'type': 'text',
1269
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1270
+ 'isError': True}
1271
+ except Exception as e: # noqa: BLE001
1272
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1273
+ if name == 'a11y_evidence':
1274
+ try:
1275
+ return _content(build_pack_fn(args['reports'], snapshot=args.get('snapshot'),
1276
+ reviewer=args.get('reviewer'),
1277
+ verified=args.get('verified')))
1278
+ except Exception as e: # noqa: BLE001
1279
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1280
+ if name == 'a11y_autofix':
1281
+ return _content(autofix_fn(args['html'], lang=args.get('lang'),
1282
+ title=args.get('title'), url=args.get('url') or '(html)',
1283
+ form_errors=args.get('form_errors', True)))
1284
+ if name == 'a11y_reflow':
1285
+ try:
1286
+ return _content(audit_reflow(args['url'], timeout=args.get('timeout', 45),
1287
+ lang=args.get('lang', 'en'),
1288
+ auth_state=args.get('auth_state'),
1289
+ browser=args.get('browser', 'auto')))
1290
+ except ImportError:
1291
+ return {'content': [{'type': 'text',
1292
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1293
+ 'isError': True}
1294
+ except Exception as e: # noqa: BLE001
1295
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1296
+ if name == 'a11y_html_validate':
1297
+ try:
1298
+ if args.get('html'):
1299
+ return _content(validate_html(args['html'], lang=args.get('lang', 'en'),
1300
+ base_url=args.get('base_url')))
1301
+ return _content(validate_url(args['url'], lang=args.get('lang', 'en'),
1302
+ base_url=args.get('base_url')))
1303
+ except Exception as e: # noqa: BLE001
1304
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1305
+ if name == 'a11y_hover':
1306
+ try:
1307
+ return _content(audit_hover(args['url'], timeout=args.get('timeout', 45),
1308
+ lang=args.get('lang', 'en'),
1309
+ auth_state=args.get('auth_state')))
1310
+ except ImportError:
1311
+ return {'content': [{'type': 'text', 'text': 'Playwright not installed'}], 'isError': True}
1312
+ except Exception as e:
1313
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1314
+ if name == 'a11y_sr_transcript':
1315
+ try:
1316
+ return _content(sr_transcript(args['url'], timeout=args.get('timeout', 45),
1317
+ lang=args.get('lang', 'en'),
1318
+ auth_state=args.get('auth_state'),
1319
+ browser=args.get('browser', 'auto')))
1320
+ except ImportError:
1321
+ return {'content': [{'type': 'text', 'text': 'Playwright not installed'}], 'isError': True}
1322
+ except Exception as e:
1323
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1324
+ if name == 'a11y_disprove':
1325
+ try:
1326
+ return _content(disprove_fn(args['url'], report=args.get('report'),
1327
+ timeout=args.get('timeout', 30),
1328
+ lang=args.get('lang', 'en')))
1329
+ except Exception as e:
1330
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1331
+ if name == 'a11y_ledger':
1332
+ try:
1333
+ path = args.get('ledger_path', 'a11y-ledger.json')
1334
+ action = args['action']
1335
+ if action == 'record':
1336
+ if not args.get('url') or not args.get('report'):
1337
+ return _content({'error': 'record requires url + report'})
1338
+ from .a11yledger import record as _rec
1339
+ return _content(_rec(args['url'], args['report'], path=path))
1340
+ if action == 'gaps':
1341
+ if not args.get('url'):
1342
+ return _content({'error': 'gaps requires url'})
1343
+ from .a11yledger import gaps as _gaps
1344
+ return _content(_gaps(args['url'], path=path))
1345
+ if action == 'summary':
1346
+ from .a11yledger import summary as _sum
1347
+ return _content(_sum(path=path))
1348
+ except Exception as e:
1349
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1350
+ if name == 'a11y_criterion':
1351
+ if not args.get('code') and not args.get('signal'):
1352
+ return _content({'error': 'give a criterion code or a finding signal'})
1353
+ return _content(criterion_fn(args.get('code'), lang=args.get('lang', 'en'),
1354
+ signal=args.get('signal')))
1355
+ if name == 'a11y_journey_verdict':
1356
+ res = journey_verdict_fn(args['task'], args['steps'], args['outcome'],
1357
+ url=args.get('url', ''), lang=args.get('lang', 'en'))
1358
+ if args.get('output_path') and 'error' not in res:
1359
+ with open(args['output_path'], 'w', encoding='utf-8') as f:
1360
+ f.write(json.dumps(res, ensure_ascii=False, indent=1) + '\n')
1361
+ return _content({'out': args['output_path'], 'verdict': res['verdict'],
1362
+ 'score': res['score'], 'high': res['summary']['high'],
1363
+ 'medium': res['summary']['medium'], 'low': res['summary']['low']})
1364
+ return _content(res)
1365
+ if name == 'a11y_vtt_check':
1366
+ try:
1367
+ return _content(vtt_check_fn(args['url'], duration=args.get('duration'),
1368
+ lang=args.get('lang', 'en')))
1369
+ except Exception as e:
1370
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1371
+ if name == 'a11y_docx_screen':
1372
+ try:
1373
+ return _content(docx_screen_fn(args['path'], lang=args.get('lang', 'en')))
1374
+ except Exception as e:
1375
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1376
+ if name == 'a11y_reduced_motion':
1377
+ try:
1378
+ return _content(reduced_motion_fn(args['url'], timeout=args.get('timeout', 45),
1379
+ lang=args.get('lang', 'en'),
1380
+ auth_state=args.get('auth_state'),
1381
+ browser=args.get('browser', 'auto')))
1382
+ except ImportError:
1383
+ return {'content': [{'type': 'text', 'text': 'Playwright not installed'}], 'isError': True}
1384
+ except Exception as e:
1385
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1386
+ if name == 'a11y_forced_colors':
1387
+ try:
1388
+ return _content(forced_colors_fn(args['url'], timeout=args.get('timeout', 45),
1389
+ lang=args.get('lang', 'en'),
1390
+ auth_state=args.get('auth_state'),
1391
+ browser=args.get('browser', 'auto')))
1392
+ except ImportError:
1393
+ return {'content': [{'type': 'text', 'text': 'Playwright not installed'}], 'isError': True}
1394
+ except Exception as e:
1395
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1396
+ if name == 'a11y_audit_pdf':
1397
+ try:
1398
+ return _content(pdf_screen_fn(args['path'], lang=args.get('lang', 'en')))
1399
+ except Exception as e:
1400
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1401
+ if name == 'a11y_generate_vpat':
1402
+ try:
1403
+ res = vpat_fn(pack=args.get('pack'), reports=args.get('reports'),
1404
+ product=args['product'], report_date=args.get('report_date'),
1405
+ description=args.get('product_description'),
1406
+ contact=args.get('contact'), methods=args.get('methods'),
1407
+ notes=args.get('notes'), overrides=args.get('overrides'),
1408
+ reviewer=args.get('reviewer'), lang=args.get('lang', 'en'),
1409
+ output_path=args.get('output_path'))
1410
+ if 'error' in res:
1411
+ return {'content': [{'type': 'text', 'text': res['error']}], 'isError': True}
1412
+ if args.get('output_path'):
1413
+ return _content({'saved_to': args['output_path'],
1414
+ 'summary': res['summary'],
1415
+ 'pack_sha256': res['pack_sha256'], 'draft': True})
1416
+ return {'content': [{'type': 'text', 'text': res['html']}]}
1417
+ except Exception as e: # noqa: BLE001
1418
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1419
+ if name == 'a11y_generate_openacr':
1420
+ try:
1421
+ res = openacr_fn(pack=args.get('pack'), reports=args.get('reports'),
1422
+ product=args['product'],
1423
+ product_version=args.get('product_version'),
1424
+ report_date=args.get('report_date'),
1425
+ description=args.get('product_description'),
1426
+ author=args.get('author'), contact=args.get('contact'),
1427
+ methods=args.get('methods'), notes=args.get('notes'),
1428
+ overrides=args.get('overrides'), lang=args.get('lang', 'en'),
1429
+ output_path=args.get('output_path'))
1430
+ if 'error' in res:
1431
+ return {'content': [{'type': 'text', 'text': res['error']}], 'isError': True}
1432
+ if args.get('output_path'):
1433
+ return _content({'saved_to': args['output_path'],
1434
+ 'summary': res['summary'],
1435
+ 'pack_sha256': res['pack_sha256'], 'draft': True})
1436
+ return {'content': [{'type': 'text', 'text': res['yaml']}]}
1437
+ except Exception as e: # noqa: BLE001
1438
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1439
+ if name == 'a11y_contrast_dom':
1440
+ try:
1441
+ return _content(contrast_dom_fn(args['url'], args['selector'],
1442
+ text_color=args.get('text_color'),
1443
+ sample=args.get('sample', 4),
1444
+ lang=args.get('lang', 'en'),
1445
+ timeout=args.get('timeout', 45),
1446
+ auth_state=args.get('auth_state'),
1447
+ browser=args.get('browser', 'auto')))
1448
+ except ImportError:
1449
+ return {'content': [{'type': 'text',
1450
+ 'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
1451
+ 'isError': True}
1452
+ except Exception as e: # noqa: BLE001
1453
+ return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1454
+ if name == 'a11y_route':
1455
+ return _content(route_fn(args.get('goal') or '', lang=args.get('lang', 'en'),
1456
+ url=args.get('url'), html=args.get('html')))
1457
+ if name == 'a11y_wcag3_preview':
1458
+ if not isinstance(args.get('report'), dict):
1459
+ return _content({'error': 'report must be an audit report object '
1460
+ '(from a11y_audit_url, a11y_audit_dom, …)'})
1461
+ return _content(wcag3_preview_fn(args['report'], lang=args.get('lang', 'en')))
1462
+ if name == 'a11y_badge':
1463
+ svg = badge_fn(args['score'], date=args.get('date'),
1464
+ lang=args.get('lang', 'en'))
1465
+ return {'content': [{'type': 'text', 'text': svg}]}
1466
+ if name == 'a11y_aria_live_snippet':
1467
+ if ARIALIVE_JS is not None:
1468
+ js = ARIALIVE_JS
1469
+ else:
1470
+ with open(os.path.join(HERE, 'arialive.js'), encoding='utf-8') as f:
1471
+ js = f.read()
1472
+ if args.get('lang') == 'en':
1473
+ js = "window.ALM_LANG='en';\n" + js
1474
+ return {'content': [{'type': 'text', 'text': js}]}
1475
+ raise ValueError(f'unknown tool: {name}')
1476
+
1477
+
1478
+ def main():
1479
+ for line in sys.stdin:
1480
+ line = line.strip()
1481
+ if not line:
1482
+ continue
1483
+ try:
1484
+ msg = json.loads(line)
1485
+ except json.JSONDecodeError:
1486
+ # JSON-RPC 2.0: parse error con id null (nunca silencio)
1487
+ print(json.dumps({'jsonrpc': '2.0', 'id': None,
1488
+ 'error': {'code': -32700, 'message': 'Parse error'}}), flush=True)
1489
+ continue
1490
+ if not isinstance(msg, dict):
1491
+ print(json.dumps({'jsonrpc': '2.0', 'id': None,
1492
+ 'error': {'code': -32600, 'message': 'Invalid Request'}}), flush=True)
1493
+ continue
1494
+ method = msg.get('method', '')
1495
+ mid = msg.get('id')
1496
+ if mid is None:
1497
+ continue # notificación: sin respuesta
1498
+ try:
1499
+ if method == 'initialize':
1500
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': {
1501
+ 'protocolVersion': msg.get('params', {}).get('protocolVersion', '2024-11-05'),
1502
+ 'capabilities': {'tools': {}, 'prompts': {}},
1503
+ 'serverInfo': {'name': 'a11y-toolkit', 'version': VERSION},
1504
+ 'instructions': INSTRUCTIONS,
1505
+ }}
1506
+ elif method == 'ping':
1507
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': {}}
1508
+ elif method == 'tools/list':
1509
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': {'tools': TOOLS}}
1510
+ elif method == 'tools/call':
1511
+ p = msg.get('params', {})
1512
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': invoke(p.get('name'), p.get('arguments') or {})}
1513
+ elif method == 'prompts/list':
1514
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': {'prompts': _PROMPTS}}
1515
+ elif method in ('prompts/get', 'prompts/call'): # get = spec method (2024-11-05); call kept as alias
1516
+ p = msg.get('params', {})
1517
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': _prompt(p.get('name'), p.get('arguments') or {})}
1518
+ else:
1519
+ resp = {'jsonrpc': '2.0', 'id': mid,
1520
+ 'error': {'code': -32601, 'message': f'unknown method: {method}'}}
1521
+ except Exception as e: # noqa: BLE001
1522
+ resp = {'jsonrpc': '2.0', 'id': mid, 'result': {
1523
+ 'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}}
1524
+ sys.stdout.write(json.dumps(resp, ensure_ascii=False) + '\n')
1525
+ sys.stdout.flush()
1526
+
1527
+
1528
+ if __name__ == '__main__':
1529
+ main()