a11y-test-mcp 1.1.0 → 1.1.1
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.
- package/README.md +9 -8
- package/build/constants.js +1 -1
- package/build/functions.js +5 -5
- package/build/index.js +2 -2
- package/package.json +6 -3
- package/build/constants.d.ts +0 -6
- package/build/functions.d.ts +0 -14
- package/build/index.d.ts +0 -2
- package/build/types.d.ts +0 -17
- package/build/types.js +0 -2
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# a11y test MCP
|
|
2
|
+
|
|
2
3
|
An MCP (Model Context Protocol) server for performing a11y test on webpages using playwright axe-core. The results are then used in an agent loop with your favorite AI assistant (Cline/Cursor/GH Copilot) to find problems with a11y and suggest improvements.
|
|
3
4
|
|
|
4
5
|
## Features
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
- Perform detailed accessibility testing on any web pages
|
|
8
|
+
- Get an overview of accessibility issues
|
|
9
|
+
- Violations
|
|
10
|
+
- Provides information on which DOM was at fault
|
|
11
|
+
- Passes
|
|
12
|
+
- Incomplete
|
|
13
|
+
- Inapplicable
|
|
14
|
+
- Can specify specific WCAG criteria(Default WCAG 2.0 level A, WCAG 2.0 level AA, WCAG 2.1 level A, WCAG 2.1 level AA)
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
package/build/constants.js
CHANGED
|
@@ -18,4 +18,4 @@ exports.WCAG_TAG_MAP = {
|
|
|
18
18
|
/** Allow prefixes or tags */
|
|
19
19
|
exports.ALLOWED_PREFIXES_OR_TAGS = ['wcag', 'best-practice', 'section508'];
|
|
20
20
|
/** default WCAG tags */
|
|
21
|
-
exports.DEFAULT_WCAG_TAGS = [
|
|
21
|
+
exports.DEFAULT_WCAG_TAGS = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'];
|
package/build/functions.js
CHANGED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.convertTestResultToText = exports.execTest = void 0;
|
|
7
|
-
const playwright_1 = __importDefault(require("playwright"));
|
|
8
|
-
const playwright_2 =
|
|
7
|
+
const playwright_1 = __importDefault(require("@axe-core/playwright"));
|
|
8
|
+
const playwright_2 = require("playwright");
|
|
9
9
|
const constants_1 = require("./constants");
|
|
10
10
|
/**
|
|
11
11
|
* Enhance WCAG tag conversion
|
|
@@ -45,7 +45,7 @@ const formatViolation = (v) => {
|
|
|
45
45
|
* @returns {AccessibilityTestOutput[]} - Results of the accessibility tests
|
|
46
46
|
*/
|
|
47
47
|
const execTest = async (urls, wcagStandards) => {
|
|
48
|
-
const browser = await
|
|
48
|
+
const browser = await playwright_2.chromium.launch();
|
|
49
49
|
const context = await browser.newContext();
|
|
50
50
|
const tagsToUse = (wcagStandards && wcagStandards.length > 0)
|
|
51
51
|
? convertWcagTag(wcagStandards)
|
|
@@ -56,7 +56,7 @@ const execTest = async (urls, wcagStandards) => {
|
|
|
56
56
|
try {
|
|
57
57
|
page = await context.newPage();
|
|
58
58
|
await page.goto(url, { waitUntil: 'networkidle' });
|
|
59
|
-
const axeBuilder = new
|
|
59
|
+
const axeBuilder = new playwright_1.default({ page });
|
|
60
60
|
axeBuilder.withTags(tagsToUse);
|
|
61
61
|
const axeResults = await axeBuilder.analyze();
|
|
62
62
|
const summarizedViolations = axeResults.violations.map(v => ({
|
|
@@ -64,7 +64,7 @@ const execTest = async (urls, wcagStandards) => {
|
|
|
64
64
|
impact: v.impact === null ? undefined : v.impact,
|
|
65
65
|
description: v.description,
|
|
66
66
|
helpUrl: v.helpUrl,
|
|
67
|
-
nodes: v.nodes
|
|
67
|
+
nodes: v.nodes,
|
|
68
68
|
}));
|
|
69
69
|
return {
|
|
70
70
|
url: url,
|
package/build/index.js
CHANGED
|
@@ -15,8 +15,8 @@ server.tool('exec-a11y-test', 'Obtains a list of specified list of URL and a lis
|
|
|
15
15
|
return {
|
|
16
16
|
content: [{
|
|
17
17
|
type: 'text',
|
|
18
|
-
text: (0, functions_1.convertTestResultToText)(structuredResults)
|
|
19
|
-
}]
|
|
18
|
+
text: (0, functions_1.convertTestResultToText)(structuredResults),
|
|
19
|
+
}],
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
/**
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "a11y-test-mcp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "npx -y playwright install",
|
|
7
7
|
"build": "tsc && chmod 755 build/index.js",
|
|
8
8
|
"start": "node build/index.js",
|
|
9
|
-
"lint": "
|
|
10
|
-
"
|
|
9
|
+
"lint": "npm run lint:e && npm run lint:d",
|
|
10
|
+
"lint:e": "eslint .",
|
|
11
|
+
"lint:d": "dprint check",
|
|
12
|
+
"format": "dprint fmt"
|
|
11
13
|
},
|
|
12
14
|
"bin": {
|
|
13
15
|
"a11y-test-mcp": "build/index.js"
|
|
@@ -43,6 +45,7 @@
|
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@eslint/js": "^9.25.1",
|
|
45
47
|
"@types/node": "^22.15.2",
|
|
48
|
+
"dprint": "^0.49.1",
|
|
46
49
|
"eslint": "^9.25.1",
|
|
47
50
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
48
51
|
"typescript": "^5.8.3",
|
package/build/constants.d.ts
DELETED
package/build/functions.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { AccessibilityTestOutput } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Execute a11y test
|
|
4
|
-
* @param {string[]} urls - URLs
|
|
5
|
-
* @param {string[] | undefined} wcagStandards - WCAG standards to apply
|
|
6
|
-
* @returns {AccessibilityTestOutput[]} - Results of the accessibility tests
|
|
7
|
-
*/
|
|
8
|
-
export declare const execTest: (urls: string[], wcagStandards: string[] | undefined) => Promise<AccessibilityTestOutput[]>;
|
|
9
|
-
/**
|
|
10
|
-
* Convert structured results to text format
|
|
11
|
-
* @param {AccessibilityTestOutput[]} structuredResults - Structured results from the tests
|
|
12
|
-
* @returns {string} - Text representation of the results
|
|
13
|
-
*/
|
|
14
|
-
export declare const convertTestResultToText: (structuredResults: AccessibilityTestOutput[]) => string;
|
package/build/index.d.ts
DELETED
package/build/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { NodeResult } from 'axe-core';
|
|
2
|
-
export interface ViolationSummary {
|
|
3
|
-
id: string;
|
|
4
|
-
impact?: 'minor' | 'moderate' | 'serious' | 'critical';
|
|
5
|
-
description: string;
|
|
6
|
-
helpUrl: string;
|
|
7
|
-
nodes: NodeResult[];
|
|
8
|
-
}
|
|
9
|
-
/** Update the main output structure */
|
|
10
|
-
export interface AccessibilityTestOutput {
|
|
11
|
-
url: string;
|
|
12
|
-
violations?: ViolationSummary[];
|
|
13
|
-
passesCount?: number;
|
|
14
|
-
incompleteCount?: number;
|
|
15
|
-
inapplicableCount?: number;
|
|
16
|
-
error?: string;
|
|
17
|
-
}
|
package/build/types.js
DELETED