mcp-accessibility-scanner 1.0.8 → 1.0.9
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/accessibilityChecker.js +3 -4
- package/build/index.js +29 -12
- package/build/server.js +0 -0
- package/package.json +1 -1
|
@@ -17,8 +17,8 @@ const playwright_1 = require("playwright");
|
|
|
17
17
|
const playwright_2 = require("@axe-core/playwright");
|
|
18
18
|
const node_path_1 = __importDefault(require("node:path"));
|
|
19
19
|
const node_os_1 = __importDefault(require("node:os"));
|
|
20
|
-
function scanViolations(url_1,
|
|
21
|
-
return __awaiter(this, arguments, void 0, function* (url,
|
|
20
|
+
function scanViolations(url_1, violationsTags_1) {
|
|
21
|
+
return __awaiter(this, arguments, void 0, function* (url, violationsTags, viewport = { width: 1920, height: 1080 }, shouldRunInHeadless = true) {
|
|
22
22
|
var _a;
|
|
23
23
|
const browser = yield playwright_1.chromium.launch({
|
|
24
24
|
headless: shouldRunInHeadless,
|
|
@@ -71,7 +71,7 @@ function scanViolations(url_1, violationsTag_1) {
|
|
|
71
71
|
}
|
|
72
72
|
`,
|
|
73
73
|
});
|
|
74
|
-
const axe = new playwright_2.AxeBuilder({ page }).withTags(
|
|
74
|
+
const axe = new playwright_2.AxeBuilder({ page }).withTags(violationsTags);
|
|
75
75
|
const results = yield axe.analyze();
|
|
76
76
|
let violationCounter = 1;
|
|
77
77
|
for (const violation of results.violations) {
|
|
@@ -139,7 +139,6 @@ function scanViolations(url_1, violationsTag_1) {
|
|
|
139
139
|
const filePath = node_path_1.default.join(node_path_1.default.join(node_os_1.default.homedir(), "Downloads"), `a11y-report-${Date.now()}.png`);
|
|
140
140
|
const screenshot = yield page.screenshot({
|
|
141
141
|
path: filePath,
|
|
142
|
-
fullPage: true,
|
|
143
142
|
});
|
|
144
143
|
const base64Screenshot = screenshot.toString("base64");
|
|
145
144
|
yield browser.close();
|
package/build/index.js
CHANGED
|
@@ -12,21 +12,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const zod_1 = require("zod");
|
|
13
13
|
const accessibilityChecker_1 = require("./accessibilityChecker");
|
|
14
14
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
15
|
+
// Create an MCP server instance
|
|
15
16
|
const server = new mcp_js_1.McpServer({
|
|
16
|
-
name: "
|
|
17
|
+
name: "AccessibilityTools",
|
|
17
18
|
version: "1.0.0",
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const tagValues = [
|
|
21
|
+
"wcag2a", "wcag2aa", "wcag2aaa", "wcag21a", "wcag21aa", "wcag21aaa",
|
|
22
|
+
"wcag22a", "wcag22aa", "wcag22aaa", "section508", "cat.aria", "cat.color",
|
|
23
|
+
"cat.forms", "cat.keyboard", "cat.language", "cat.name-role-value",
|
|
24
|
+
"cat.parsing", "cat.semantics", "cat.sensory-and-visual-cues",
|
|
25
|
+
"cat.structure", "cat.tables", "cat.text-alternatives", "cat.time-and-media",
|
|
26
|
+
];
|
|
27
|
+
server.registerTool("accessibility-scan", {
|
|
28
|
+
title: "Accessibility Scan",
|
|
29
|
+
description: "Runs an accessibility scan on a URL and returns a JSON report and a screenshot.",
|
|
30
|
+
inputSchema: zod_1.z.object({
|
|
31
|
+
url: zod_1.z.string().url().describe("The public URL to scan for accessibility violations"),
|
|
32
|
+
violationsTag: zod_1.z
|
|
33
|
+
.array(zod_1.z.enum(tagValues))
|
|
34
|
+
.min(1) // Ensure the array is not empty
|
|
35
|
+
.describe("An array of tags for violation types to check"),
|
|
36
|
+
viewport: zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
width: zod_1.z.number().default(1920),
|
|
39
|
+
height: zod_1.z.number().default(1080),
|
|
40
|
+
})
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Optional viewport dimensions for the scan"),
|
|
43
|
+
shouldRunInHeadless: zod_1.z.boolean().default(true).describe("Whether to run the browser in headless mode"),
|
|
44
|
+
}).shape,
|
|
45
|
+
}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const { url, violationsTag, viewport, shouldRunInHeadless } = args;
|
|
30
47
|
const { report, base64Screenshot } = yield (0, accessibilityChecker_1.scanViolations)(url, violationsTag, viewport, shouldRunInHeadless);
|
|
31
48
|
return {
|
|
32
49
|
content: [
|
package/build/server.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-accessibility-scanner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "A Model Context Protocol (MCP) server for performing automated accessibility scans of web pages using Playwright and Axe-core",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|