a11y-test-mcp 1.0.1 → 1.0.3
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/build/functions.d.ts +14 -0
- package/build/functions.js +9 -7
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -2
- package/build/types.d.ts +17 -0
- package/package.json +11 -4
|
@@ -0,0 +1,14 @@
|
|
|
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/functions.js
CHANGED
|
@@ -38,7 +38,9 @@ const convertWcagTag = (tags) => {
|
|
|
38
38
|
console.warn(`Unrecognized WCAG tag: ${tag}`);
|
|
39
39
|
return '';
|
|
40
40
|
}
|
|
41
|
-
}).filter(tag =>
|
|
41
|
+
}).filter(tag => {
|
|
42
|
+
return tag !== '';
|
|
43
|
+
});
|
|
42
44
|
};
|
|
43
45
|
/**
|
|
44
46
|
* Execute a11y test
|
|
@@ -116,13 +118,13 @@ const convertTestResultToText = (structuredResults) => {
|
|
|
116
118
|
resultTextList.push(` Error: ${result.error}`);
|
|
117
119
|
}
|
|
118
120
|
else {
|
|
119
|
-
resultTextList.push(` Violations: ${result.violations?.length ?? 0}`);
|
|
121
|
+
resultTextList.push(` Violations: ${String(result.violations?.length ?? 0)}`);
|
|
120
122
|
const resultViolationText = result.violations?.map((v) => {
|
|
121
123
|
return [
|
|
122
|
-
` - [${v.impact?.toUpperCase()}] ${v.id}: ${v.description} (Nodes: ${v.nodes.length}, Help: ${v.helpUrl})`,
|
|
124
|
+
` - [${String(v.impact?.toUpperCase() ?? 'N/A')}] ${v.id}: ${v.description} (Nodes: ${String(v.nodes.length)}, Help: ${v.helpUrl})`,
|
|
123
125
|
v.nodes
|
|
124
126
|
.map((node, index) => {
|
|
125
|
-
return ` Node ${index + 1}: ${node.html}`;
|
|
127
|
+
return ` Node ${String(index + 1)}: ${node.html}`;
|
|
126
128
|
})
|
|
127
129
|
.join('\n')
|
|
128
130
|
].join('\n');
|
|
@@ -130,9 +132,9 @@ const convertTestResultToText = (structuredResults) => {
|
|
|
130
132
|
if (resultViolationText !== undefined) {
|
|
131
133
|
resultTextList.push(...resultViolationText);
|
|
132
134
|
}
|
|
133
|
-
resultTextList.push(` Passes: ${result.passesCount ?? 0}`);
|
|
134
|
-
resultTextList.push(` Incomplete: ${result.incompleteCount ?? 0}`);
|
|
135
|
-
resultTextList.push(` Inapplicable: ${result.inapplicableCount ?? 0}`);
|
|
135
|
+
resultTextList.push(` Passes: ${String(result.passesCount ?? 0)}`);
|
|
136
|
+
resultTextList.push(` Incomplete: ${String(result.incompleteCount ?? 0)}`);
|
|
137
|
+
resultTextList.push(` Inapplicable: ${String(result.inapplicableCount ?? 0)}`);
|
|
136
138
|
}
|
|
137
139
|
return resultTextList.join('\n');
|
|
138
140
|
})
|
package/build/index.d.ts
ADDED
package/build/index.js
CHANGED
|
@@ -27,8 +27,8 @@ const main = async () => {
|
|
|
27
27
|
await server.connect(transport);
|
|
28
28
|
console.error('A11y Accessibility MCP server running on stdio');
|
|
29
29
|
};
|
|
30
|
-
process.on('SIGINT',
|
|
31
|
-
|
|
30
|
+
process.on('SIGINT', () => {
|
|
31
|
+
void server.close();
|
|
32
32
|
process.exit(0);
|
|
33
33
|
});
|
|
34
34
|
main().catch(console.error);
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "a11y-test-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc && chmod 755 build/index.js",
|
|
7
|
-
"start": "node build/index.js"
|
|
7
|
+
"start": "node build/index.js",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"format": "npm run lint -- --fix"
|
|
8
10
|
},
|
|
9
11
|
"bin": {
|
|
10
|
-
"a11y-mcp": "build/index.js"
|
|
12
|
+
"a11y-test-mcp": "build/index.js"
|
|
11
13
|
},
|
|
12
14
|
"keywords": [
|
|
13
15
|
"accessibility",
|
|
@@ -38,8 +40,13 @@
|
|
|
38
40
|
"zod": "^3.24.3"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.25.1",
|
|
41
44
|
"@types/node": "^22.15.2",
|
|
42
|
-
"
|
|
45
|
+
"a11y-test-mcp": "^1.0.2",
|
|
46
|
+
"eslint": "^9.25.1",
|
|
47
|
+
"eslint-config-flat-gitignore": "^2.1.0",
|
|
48
|
+
"typescript": "^5.8.3",
|
|
49
|
+
"typescript-eslint": "^8.31.0"
|
|
43
50
|
},
|
|
44
51
|
"volta": {
|
|
45
52
|
"node": "22.15.0",
|