scan_page
Identify accessibility violations on web pages by scanning with Axe. Use tags to filter specific WCAG compliance issues and generate detailed reports for remediation.
Instructions
Scan the current page for accessibility violations using Axe
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| violationsTag | Yes | Array of tags to filter violations by. If not specified, all violations are returned. |
Implementation Reference
- src/tools/snapshot.ts:67-89 (handler)The main handler function for the 'scan_page' tool. It uses AxeBuilder to scan the current browser tab for accessibility violations filtered by the provided tags, deduplicates nodes, and streams results to the response including URL summary and detailed violations.handle: async (context, params, response) => { const tab = context.currentTabOrDie(); const axe = new AxeBuilder({ page: tab.page }).withTags(params.violationsTag); const results = await axe.analyze(); response.addResult([ `URL: ${results.url}`, '', `Violations: ${results.violations.length}, Incomplete: ${results.incomplete.length}, Passes: ${results.passes.length}, Inapplicable: ${results.inapplicable.length}`, ].join('\n')); results.violations.forEach(violation => { const uniqueNodes = dedupeViolationNodes(violation.nodes); response.addResult([ '', `Tags : ${violation.tags}`, `Violations: ${JSON.stringify(uniqueNodes, null, 2)}`, ].join('\n')); }); },
- src/tools/snapshot.ts:33-39 (schema)Zod schema defining the input parameters for the 'scan_page' tool, specifically the 'violationsTag' array for filtering Axe violations.const scanPageSchema = z.object({ violationsTag: z .array(z.enum(tagValues)) .min(1) .default([...tagValues]) .describe('Array of tags to filter violations by. If not specified, all violations are returned.') });
- src/tools/snapshot.ts:59-65 (registration)Tool metadata registration within defineTool, specifying name 'scan_page', title, description, input schema reference, and type.schema: { name: 'scan_page', title: 'Scan page for accessibility violations', description: 'Scan the current page for accessibility violations using Axe', inputSchema: scanPageSchema, type: 'destructive', },
- src/tools/snapshot.ts:229-236 (registration)Default export array including the scanPage tool, allowing its registration in the MCP server by importing this module.export default [ snapshot, click, drag, hover, selectOption, scanPage ];
- src/tools/snapshot.ts:45-55 (helper)Helper function used in the handler to deduplicate Axe violation nodes based on their target and HTML content to avoid redundant reporting.const dedupeViolationNodes = (nodes: AxeNode[]): AxeNode[] => { const seen = new Set<string>(); return nodes.filter(node => { const key = JSON.stringify({ target: node.target ?? [], html: node.html ?? '' }); if (seen.has(key)) return false; seen.add(key); return true; }); };