accessibility-server-mcp 1.0.0
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/LICENSE +21 -0
- package/README.md +762 -0
- package/config/wcag-rules.json +252 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +437 -0
- package/dist/index.js.map +1 -0
- package/dist/test-manual.d.ts +6 -0
- package/dist/test-manual.d.ts.map +1 -0
- package/dist/test-manual.js +66 -0
- package/dist/test-manual.js.map +1 -0
- package/dist/tools/accessibility-tester.d.ts +56 -0
- package/dist/tools/accessibility-tester.d.ts.map +1 -0
- package/dist/tools/accessibility-tester.js +317 -0
- package/dist/tools/accessibility-tester.js.map +1 -0
- package/dist/tools/color-contrast.d.ts +49 -0
- package/dist/tools/color-contrast.d.ts.map +1 -0
- package/dist/tools/color-contrast.js +237 -0
- package/dist/tools/color-contrast.js.map +1 -0
- package/dist/tools/wcag-validator.d.ts +43 -0
- package/dist/tools/wcag-validator.d.ts.map +1 -0
- package/dist/tools/wcag-validator.js +249 -0
- package/dist/tools/wcag-validator.js.map +1 -0
- package/dist/tools/website-accessibility-tester.d.ts +103 -0
- package/dist/tools/website-accessibility-tester.d.ts.map +1 -0
- package/dist/tools/website-accessibility-tester.js +228 -0
- package/dist/tools/website-accessibility-tester.js.map +1 -0
- package/dist/types/accessibility.d.ts +172 -0
- package/dist/types/accessibility.d.ts.map +1 -0
- package/dist/types/accessibility.js +5 -0
- package/dist/types/accessibility.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.d.ts +70 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +5 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/utils/browser-manager.d.ts +83 -0
- package/dist/utils/browser-manager.d.ts.map +1 -0
- package/dist/utils/browser-manager.js +292 -0
- package/dist/utils/browser-manager.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +36 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +107 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/report-generator.d.ts +31 -0
- package/dist/utils/report-generator.d.ts.map +1 -0
- package/dist/utils/report-generator.js +252 -0
- package/dist/utils/report-generator.js.map +1 -0
- package/dist/utils/website-crawler.d.ts +66 -0
- package/dist/utils/website-crawler.d.ts.map +1 -0
- package/dist/utils/website-crawler.js +306 -0
- package/dist/utils/website-crawler.js.map +1 -0
- package/package.json +80 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
// Import tools
|
|
7
|
+
import { AccessibilityTester } from './tools/accessibility-tester.js';
|
|
8
|
+
import { ColorContrastTester } from './tools/color-contrast.js';
|
|
9
|
+
import { WCAGValidator } from './tools/wcag-validator.js';
|
|
10
|
+
import { WebsiteAccessibilityTester } from './tools/website-accessibility-tester.js';
|
|
11
|
+
// Import utilities
|
|
12
|
+
import { Logger, BrowserManager } from './utils/index.js';
|
|
13
|
+
// Simplified validation schemas
|
|
14
|
+
const TestAccessibilitySchema = z.object({
|
|
15
|
+
target: z.string().min(1, 'Target URL or HTML is required'),
|
|
16
|
+
type: z.enum(['url', 'html']).default('url'),
|
|
17
|
+
level: z.enum(['basic', 'full']).default('basic'),
|
|
18
|
+
wcagLevel: z.enum(['A', 'AA', 'AAA']).default('AA')
|
|
19
|
+
});
|
|
20
|
+
const ColorContrastSchema = z.object({
|
|
21
|
+
foreground: z.string().min(1, 'Foreground color is required'),
|
|
22
|
+
background: z.string().min(1, 'Background color is required'),
|
|
23
|
+
fontSize: z.number().min(1).default(16),
|
|
24
|
+
isBold: z.boolean().default(false)
|
|
25
|
+
});
|
|
26
|
+
const GetWCAGRulesSchema = z.object({
|
|
27
|
+
wcagLevel: z.enum(['A', 'AA', 'AAA']).optional(),
|
|
28
|
+
category: z.string().optional(),
|
|
29
|
+
search: z.string().optional(),
|
|
30
|
+
limit: z.number().min(1).max(50).default(20)
|
|
31
|
+
});
|
|
32
|
+
const TestWebsiteSchema = z.object({
|
|
33
|
+
baseUrl: z.string().url('Must be a valid URL'),
|
|
34
|
+
wcagLevel: z.enum(['A', 'AA', 'AAA']).default('AA'),
|
|
35
|
+
fullAnalysis: z.boolean().default(false),
|
|
36
|
+
maxPages: z.number().min(1).max(100).default(20),
|
|
37
|
+
maxDepth: z.number().min(1).max(5).default(3),
|
|
38
|
+
concurrency: z.number().min(1).max(5).default(3),
|
|
39
|
+
excludePatterns: z.array(z.string()).default([]),
|
|
40
|
+
includePatterns: z.array(z.string()).default([]),
|
|
41
|
+
continueOnError: z.boolean().default(true),
|
|
42
|
+
respectRobots: z.boolean().default(true),
|
|
43
|
+
delay: z.number().min(0).max(10000).default(1000)
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Unified MCP server class for accessibility testing
|
|
47
|
+
* Supports both simple and full modes
|
|
48
|
+
*/
|
|
49
|
+
export class AccessibilityMCPServer {
|
|
50
|
+
server;
|
|
51
|
+
logger;
|
|
52
|
+
browserManager;
|
|
53
|
+
config;
|
|
54
|
+
// Tool instances (lazy-loaded)
|
|
55
|
+
accessibilityTester;
|
|
56
|
+
colorContrastTester;
|
|
57
|
+
wcagValidator;
|
|
58
|
+
websiteAccessibilityTester;
|
|
59
|
+
constructor(config = { mode: 'full', enableLogging: true }) {
|
|
60
|
+
this.config = config;
|
|
61
|
+
this.logger = config.enableLogging
|
|
62
|
+
? new Logger().child({ component: 'AccessibilityMCPServer' })
|
|
63
|
+
: { info: () => { }, debug: () => { }, warn: () => { }, error: () => { } };
|
|
64
|
+
this.browserManager = new BrowserManager();
|
|
65
|
+
this.server = new Server({
|
|
66
|
+
name: 'accessibility-mcp-server',
|
|
67
|
+
version: '1.0.0',
|
|
68
|
+
}, {
|
|
69
|
+
capabilities: {
|
|
70
|
+
tools: {},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
this.setupHandlers();
|
|
74
|
+
this.setupGracefulShutdown();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get or create accessibility tester (lazy loading)
|
|
78
|
+
*/
|
|
79
|
+
getAccessibilityTester() {
|
|
80
|
+
if (!this.accessibilityTester) {
|
|
81
|
+
this.accessibilityTester = new AccessibilityTester(this.browserManager);
|
|
82
|
+
}
|
|
83
|
+
return this.accessibilityTester;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get or create color contrast tester (lazy loading)
|
|
87
|
+
*/
|
|
88
|
+
getColorContrastTester() {
|
|
89
|
+
if (!this.colorContrastTester) {
|
|
90
|
+
this.colorContrastTester = new ColorContrastTester();
|
|
91
|
+
}
|
|
92
|
+
return this.colorContrastTester;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get or create WCAG validator (lazy loading)
|
|
96
|
+
*/
|
|
97
|
+
getWCAGValidator() {
|
|
98
|
+
if (!this.wcagValidator) {
|
|
99
|
+
this.wcagValidator = new WCAGValidator();
|
|
100
|
+
}
|
|
101
|
+
return this.wcagValidator;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get or create website accessibility tester (lazy loading)
|
|
105
|
+
*/
|
|
106
|
+
getWebsiteAccessibilityTester() {
|
|
107
|
+
if (!this.websiteAccessibilityTester) {
|
|
108
|
+
this.websiteAccessibilityTester = new WebsiteAccessibilityTester(this.browserManager);
|
|
109
|
+
}
|
|
110
|
+
return this.websiteAccessibilityTester;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Centralized error handling for all operations
|
|
114
|
+
*/
|
|
115
|
+
async executeWithErrorHandling(operation, context) {
|
|
116
|
+
const startTime = Date.now();
|
|
117
|
+
try {
|
|
118
|
+
const result = await operation();
|
|
119
|
+
const processingTime = Date.now() - startTime;
|
|
120
|
+
this.logger.info(`${context} completed successfully`, { processingTime });
|
|
121
|
+
return {
|
|
122
|
+
success: true,
|
|
123
|
+
data: result,
|
|
124
|
+
processingTime,
|
|
125
|
+
timestamp: new Date().toISOString()
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const processingTime = Date.now() - startTime;
|
|
130
|
+
this.logger.error(`${context} failed`, error instanceof Error ? error : new Error(String(error)));
|
|
131
|
+
if (error instanceof z.ZodError) {
|
|
132
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid parameters: ${error.issues.map(i => i.message).join(', ')}`);
|
|
133
|
+
}
|
|
134
|
+
if (error instanceof McpError) {
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
const errorResponse = {
|
|
138
|
+
success: false,
|
|
139
|
+
error: {
|
|
140
|
+
type: 'internal',
|
|
141
|
+
message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
142
|
+
details: error instanceof Error ? { name: error.name } : undefined
|
|
143
|
+
},
|
|
144
|
+
processingTime,
|
|
145
|
+
timestamp: new Date().toISOString()
|
|
146
|
+
};
|
|
147
|
+
return errorResponse;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Set up MCP request handlers
|
|
152
|
+
*/
|
|
153
|
+
setupHandlers() {
|
|
154
|
+
// List available tools based on server mode
|
|
155
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
156
|
+
const basicTools = [
|
|
157
|
+
{
|
|
158
|
+
name: 'test_accessibility',
|
|
159
|
+
description: 'Test URL or HTML content for accessibility issues',
|
|
160
|
+
inputSchema: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {
|
|
163
|
+
target: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
description: 'URL to test or HTML content to analyze'
|
|
166
|
+
},
|
|
167
|
+
type: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
enum: ['url', 'html'],
|
|
170
|
+
default: 'url',
|
|
171
|
+
description: 'Type of content to test'
|
|
172
|
+
},
|
|
173
|
+
level: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
enum: ['basic', 'full'],
|
|
176
|
+
default: 'basic',
|
|
177
|
+
description: 'Testing depth level'
|
|
178
|
+
},
|
|
179
|
+
wcagLevel: {
|
|
180
|
+
type: 'string',
|
|
181
|
+
enum: ['A', 'AA', 'AAA'],
|
|
182
|
+
default: 'AA',
|
|
183
|
+
description: 'WCAG compliance level'
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
required: ['target']
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'test_website_accessibility',
|
|
191
|
+
description: 'Test accessibility for an entire website by crawling and testing multiple pages',
|
|
192
|
+
inputSchema: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
baseUrl: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
description: 'Base URL of the website to test'
|
|
198
|
+
},
|
|
199
|
+
wcagLevel: {
|
|
200
|
+
type: 'string',
|
|
201
|
+
enum: ['A', 'AA', 'AAA'],
|
|
202
|
+
default: 'AA',
|
|
203
|
+
description: 'WCAG compliance level'
|
|
204
|
+
},
|
|
205
|
+
fullAnalysis: {
|
|
206
|
+
type: 'boolean',
|
|
207
|
+
default: false,
|
|
208
|
+
description: 'Whether to perform full accessibility analysis'
|
|
209
|
+
},
|
|
210
|
+
maxPages: {
|
|
211
|
+
type: 'number',
|
|
212
|
+
minimum: 1,
|
|
213
|
+
maximum: 100,
|
|
214
|
+
default: 20,
|
|
215
|
+
description: 'Maximum number of pages to test'
|
|
216
|
+
},
|
|
217
|
+
maxDepth: {
|
|
218
|
+
type: 'number',
|
|
219
|
+
minimum: 1,
|
|
220
|
+
maximum: 5,
|
|
221
|
+
default: 3,
|
|
222
|
+
description: 'Maximum crawl depth'
|
|
223
|
+
},
|
|
224
|
+
concurrency: {
|
|
225
|
+
type: 'number',
|
|
226
|
+
minimum: 1,
|
|
227
|
+
maximum: 5,
|
|
228
|
+
default: 3,
|
|
229
|
+
description: 'Number of pages to test simultaneously'
|
|
230
|
+
},
|
|
231
|
+
excludePatterns: {
|
|
232
|
+
type: 'array',
|
|
233
|
+
items: { type: 'string' },
|
|
234
|
+
description: 'URL patterns to exclude from testing'
|
|
235
|
+
},
|
|
236
|
+
includePatterns: {
|
|
237
|
+
type: 'array',
|
|
238
|
+
items: { type: 'string' },
|
|
239
|
+
description: 'URL patterns to include (if specified, only these will be tested)'
|
|
240
|
+
},
|
|
241
|
+
continueOnError: {
|
|
242
|
+
type: 'boolean',
|
|
243
|
+
default: true,
|
|
244
|
+
description: 'Whether to continue testing if individual pages fail'
|
|
245
|
+
},
|
|
246
|
+
delay: {
|
|
247
|
+
type: 'number',
|
|
248
|
+
minimum: 0,
|
|
249
|
+
maximum: 10000,
|
|
250
|
+
default: 1000,
|
|
251
|
+
description: 'Delay between page requests in milliseconds'
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
required: ['baseUrl']
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'check_color_contrast',
|
|
259
|
+
description: 'Check color combinations for WCAG compliance',
|
|
260
|
+
inputSchema: {
|
|
261
|
+
type: 'object',
|
|
262
|
+
properties: {
|
|
263
|
+
foreground: {
|
|
264
|
+
type: 'string',
|
|
265
|
+
description: 'Foreground color (hex, rgb, hsl, or color name)'
|
|
266
|
+
},
|
|
267
|
+
background: {
|
|
268
|
+
type: 'string',
|
|
269
|
+
description: 'Background color (hex, rgb, hsl, or color name)'
|
|
270
|
+
},
|
|
271
|
+
fontSize: {
|
|
272
|
+
type: 'number',
|
|
273
|
+
minimum: 1,
|
|
274
|
+
default: 16,
|
|
275
|
+
description: 'Font size in pixels'
|
|
276
|
+
},
|
|
277
|
+
isBold: {
|
|
278
|
+
type: 'boolean',
|
|
279
|
+
default: false,
|
|
280
|
+
description: 'Whether the text is bold'
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
required: ['foreground', 'background']
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
];
|
|
287
|
+
const fullTools = [
|
|
288
|
+
...basicTools,
|
|
289
|
+
{
|
|
290
|
+
name: 'get_wcag_rules',
|
|
291
|
+
description: 'Get information about WCAG accessibility rules',
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
wcagLevel: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
enum: ['A', 'AA', 'AAA'],
|
|
298
|
+
description: 'Filter rules by WCAG level'
|
|
299
|
+
},
|
|
300
|
+
category: {
|
|
301
|
+
type: 'string',
|
|
302
|
+
description: 'Filter rules by category'
|
|
303
|
+
},
|
|
304
|
+
search: {
|
|
305
|
+
type: 'string',
|
|
306
|
+
description: 'Search term for rule titles/descriptions'
|
|
307
|
+
},
|
|
308
|
+
limit: {
|
|
309
|
+
type: 'number',
|
|
310
|
+
minimum: 1,
|
|
311
|
+
maximum: 50,
|
|
312
|
+
default: 20,
|
|
313
|
+
description: 'Maximum number of rules to return'
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
];
|
|
319
|
+
return {
|
|
320
|
+
tools: this.config.mode === 'simple' ? basicTools : fullTools
|
|
321
|
+
};
|
|
322
|
+
});
|
|
323
|
+
// Handle tool calls with centralized error handling
|
|
324
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
325
|
+
const { name, arguments: args } = request.params;
|
|
326
|
+
this.logger.info(`Executing tool: ${name}`, { args });
|
|
327
|
+
let result;
|
|
328
|
+
switch (name) {
|
|
329
|
+
case 'test_accessibility': {
|
|
330
|
+
const params = TestAccessibilitySchema.parse(args);
|
|
331
|
+
result = await this.executeWithErrorHandling(() => this.getAccessibilityTester().testTarget(params), 'Accessibility test');
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case 'check_color_contrast': {
|
|
335
|
+
const params = ColorContrastSchema.parse(args);
|
|
336
|
+
result = await this.executeWithErrorHandling(() => this.getColorContrastTester().checkContrast(params), 'Color contrast check');
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
case 'test_website_accessibility': {
|
|
340
|
+
const params = TestWebsiteSchema.parse(args);
|
|
341
|
+
result = await this.executeWithErrorHandling(() => this.getWebsiteAccessibilityTester().testWebsite(params.baseUrl, params), 'Website accessibility test');
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case 'get_wcag_rules': {
|
|
345
|
+
if (this.config.mode === 'simple') {
|
|
346
|
+
throw new McpError(ErrorCode.MethodNotFound, 'WCAG rules not available in simple mode');
|
|
347
|
+
}
|
|
348
|
+
const params = GetWCAGRulesSchema.parse(args || {});
|
|
349
|
+
result = await this.executeWithErrorHandling(() => this.getWCAGValidator().getRules(params), 'WCAG rules retrieval');
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
default:
|
|
353
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
content: [
|
|
357
|
+
{
|
|
358
|
+
type: 'text',
|
|
359
|
+
text: JSON.stringify(result, null, 2)
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
};
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Set up graceful shutdown handling
|
|
367
|
+
*/
|
|
368
|
+
setupGracefulShutdown() {
|
|
369
|
+
const shutdown = async (signal) => {
|
|
370
|
+
this.logger.info(`Received ${signal}, shutting down gracefully...`);
|
|
371
|
+
try {
|
|
372
|
+
await this.cleanup();
|
|
373
|
+
this.logger.info('Graceful shutdown completed');
|
|
374
|
+
process.exit(0);
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
this.logger.error('Error during shutdown', error instanceof Error ? error : new Error(String(error)));
|
|
378
|
+
process.exit(1);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
382
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
383
|
+
process.on('uncaughtException', (error) => {
|
|
384
|
+
this.logger.error('Uncaught exception', error);
|
|
385
|
+
shutdown('uncaughtException').catch(() => process.exit(1));
|
|
386
|
+
});
|
|
387
|
+
process.on('unhandledRejection', (reason) => {
|
|
388
|
+
this.logger.error('Unhandled rejection', reason instanceof Error ? reason : new Error(String(reason)));
|
|
389
|
+
shutdown('unhandledRejection').catch(() => process.exit(1));
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Start the MCP server
|
|
394
|
+
*/
|
|
395
|
+
async run() {
|
|
396
|
+
try {
|
|
397
|
+
const transport = new StdioServerTransport();
|
|
398
|
+
await this.server.connect(transport);
|
|
399
|
+
this.logger.info('Accessibility MCP Server started successfully on stdio');
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
this.logger.error('Failed to start server', error instanceof Error ? error : new Error(String(error)));
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Clean up resources
|
|
408
|
+
*/
|
|
409
|
+
async cleanup() {
|
|
410
|
+
try {
|
|
411
|
+
await this.browserManager.cleanup();
|
|
412
|
+
this.logger.info('Cleanup completed successfully');
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
this.logger.error('Error during cleanup', error instanceof Error ? error : new Error(String(error)));
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// Start the server if this file is run directly
|
|
421
|
+
import { pathToFileURL } from 'url';
|
|
422
|
+
const scriptPath = process.argv[1];
|
|
423
|
+
if (scriptPath && import.meta.url === pathToFileURL(scriptPath).href) {
|
|
424
|
+
// Set MCP mode environment variable when running as MCP server
|
|
425
|
+
process.env.MCP_MODE = 'true';
|
|
426
|
+
// Determine server mode from environment or command line
|
|
427
|
+
const mode = process.env.ACCESSIBILITY_MCP_MODE ||
|
|
428
|
+
(process.argv.includes('--simple') ? 'simple' : 'full');
|
|
429
|
+
// Set MCP mode to disable console logging when running as MCP server
|
|
430
|
+
const enableLogging = !process.env.MCP_MODE;
|
|
431
|
+
const server = new AccessibilityMCPServer({ mode, enableLogging });
|
|
432
|
+
server.run().catch(error => {
|
|
433
|
+
process.stderr.write(`Failed to start accessibility MCP server: ${error}\n`);
|
|
434
|
+
process.exit(1);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe;AACf,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,m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AC,GAAG,CAAC,QAAQ,CAAC;IAE5C,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;IAEnE,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6CAA6C,KAAK,IAAI,CAAC,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-manual.d.ts","sourceRoot":"","sources":["../src/test-manual.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manual test script for website accessibility testing
|
|
3
|
+
* Run with: node --loader=tsx/esm src/test-manual.ts
|
|
4
|
+
*/
|
|
5
|
+
import { WebsiteAccessibilityTester } from './tools/website-accessibility-tester.js';
|
|
6
|
+
import { BrowserManager } from './utils/browser-manager.js';
|
|
7
|
+
async function testWebsiteAccessibility() {
|
|
8
|
+
console.log('๐ Starting website accessibility testing demo...\n');
|
|
9
|
+
const browserManager = new BrowserManager({ headless: 'new' });
|
|
10
|
+
const websiteTester = new WebsiteAccessibilityTester(browserManager);
|
|
11
|
+
try {
|
|
12
|
+
// Test a simple, well-known website
|
|
13
|
+
console.log('๐ Testing website: https://example.com');
|
|
14
|
+
console.log('โ๏ธ Configuration: maxPages=2, maxDepth=1, wcagLevel=AA\n');
|
|
15
|
+
const result = await websiteTester.testWebsite('https://example.com', {
|
|
16
|
+
maxPages: 2,
|
|
17
|
+
maxDepth: 1,
|
|
18
|
+
concurrency: 1,
|
|
19
|
+
delay: 2000,
|
|
20
|
+
wcagLevel: 'AA',
|
|
21
|
+
fullAnalysis: false,
|
|
22
|
+
continueOnError: true
|
|
23
|
+
});
|
|
24
|
+
console.log('โ
Test completed successfully!\n');
|
|
25
|
+
console.log('๐ Results Summary:');
|
|
26
|
+
console.log(` โข Pages discovered: ${result.crawlResult.urls.length}`);
|
|
27
|
+
console.log(` โข Pages tested successfully: ${result.summary.totalPages}`);
|
|
28
|
+
console.log(` โข Pages failed: ${result.summary.failedPages}`);
|
|
29
|
+
console.log(` โข Total violations found: ${result.summary.totalViolations}`);
|
|
30
|
+
console.log(` โข Overall accessibility score: ${result.summary.overallScore}/100`);
|
|
31
|
+
console.log(` โข WCAG AA compliance: ${result.summary.compliance.AA ? 'โ
Pass' : 'โ Fail'}`);
|
|
32
|
+
console.log(` โข Crawl time: ${result.summary.performance.crawlTime}ms`);
|
|
33
|
+
console.log(` โข Average page test time: ${Math.round(result.summary.performance.averagePageTestTime)}ms\n`);
|
|
34
|
+
if (result.summary.commonViolations.length > 0) {
|
|
35
|
+
console.log('๐ Most common violations:');
|
|
36
|
+
result.summary.commonViolations.slice(0, 3).forEach((violation, index) => {
|
|
37
|
+
console.log(` ${index + 1}. ${violation.description} (${violation.count} occurrences on ${violation.affectedPages} pages)`);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log('๐ No common violations found across pages!');
|
|
42
|
+
}
|
|
43
|
+
console.log('\n๐ Page-by-page results:');
|
|
44
|
+
result.pageResults.forEach((pageResult, index) => {
|
|
45
|
+
if (pageResult.success && pageResult.result) {
|
|
46
|
+
console.log(` ${index + 1}. ${pageResult.url}`);
|
|
47
|
+
console.log(` Score: ${pageResult.result.summary.score}/100`);
|
|
48
|
+
console.log(` Violations: ${pageResult.result.violations.length}`);
|
|
49
|
+
console.log(` Test time: ${pageResult.duration}ms`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(` ${index + 1}. ${pageResult.url} - FAILED: ${pageResult.error}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error('โ Test failed:', error instanceof Error ? error.message : String(error));
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
await browserManager.cleanup();
|
|
61
|
+
console.log('\n๐งน Cleanup completed. Test finished.');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Run the test
|
|
65
|
+
testWebsiteAccessibility().catch(console.error);
|
|
66
|
+
//# sourceMappingURL=test-manual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-manual.js","sourceRoot":"","sources":["../src/test-manual.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,KAAK,UAAU,wBAAwB;IACrC,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAEnE,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAI,0BAA0B,CAAC,cAAc,CAAC,CAAC;IAErE,IAAI,CAAC;QACH,oCAAoC;QACpC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,WAAW,CAAC,qBAAqB,EAAE;YACpE,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,CAAC;YACX,WAAW,EAAE,CAAC;YACd,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,0BAA0B,MAAM,CAAC,WAAW,CAAC,IAAI,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-0,0 +1,56 @@
|
|
|
1
|
+
import { BrowserManager } from '../utils/index.js';
|
|
2
|
+
import { AccessibilityTestResult } from '../types/index.js';
|
|
3
|
+
import type { TestAccessibilityInput } from '../types/mcp.js';
|
|
4
|
+
/**
|
|
5
|
+
* Unified accessibility tester for both URLs and HTML content
|
|
6
|
+
*/
|
|
7
|
+
export declare class AccessibilityTester {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private readonly browserManager;
|
|
10
|
+
constructor(browserManager: BrowserManager);
|
|
11
|
+
/**
|
|
12
|
+
* Test accessibility for either URL or HTML content
|
|
13
|
+
*/
|
|
14
|
+
testTarget(input: TestAccessibilityInput): Promise<AccessibilityTestResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Test URL accessibility using Puppeteer and axe-core
|
|
17
|
+
*/
|
|
18
|
+
private testURL;
|
|
19
|
+
/**
|
|
20
|
+
* Test HTML content using JSDOM and axe-core
|
|
21
|
+
*/
|
|
22
|
+
private testHTML;
|
|
23
|
+
/**
|
|
24
|
+
* Inject axe-core into a Puppeteer page
|
|
25
|
+
*/
|
|
26
|
+
private injectAxeCore;
|
|
27
|
+
/**
|
|
28
|
+
* Get axe-core source code for JSDOM injection
|
|
29
|
+
*/
|
|
30
|
+
private getAxeSource;
|
|
31
|
+
/**
|
|
32
|
+
* Build axe configuration
|
|
33
|
+
*/
|
|
34
|
+
private buildAxeConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Run axe accessibility scan on a page
|
|
37
|
+
*/
|
|
38
|
+
private runAxeScan;
|
|
39
|
+
/**
|
|
40
|
+
* Get page metadata
|
|
41
|
+
*/
|
|
42
|
+
private getPageMetadata;
|
|
43
|
+
/**
|
|
44
|
+
* Transform axe results to our format
|
|
45
|
+
*/
|
|
46
|
+
private transformAxeResults;
|
|
47
|
+
/**
|
|
48
|
+
* Transform axe node to our format
|
|
49
|
+
*/
|
|
50
|
+
private transformNode;
|
|
51
|
+
/**
|
|
52
|
+
* Extract WCAG level from tags
|
|
53
|
+
*/
|
|
54
|
+
private getWcagLevelFromTags;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=accessibility-tester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-tester.d.ts","sourceRoot":"","sources":["../../src/tools/accessibility-tester.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAA2B,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAMxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,sBAAsB,EAAgB,MAAM,iBAAiB,CAAC;AAI5E;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;gBAEpC,cAAc,EAAE,cAAc;IAK1C;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAiCjF;;OAEG;YACW,OAAO;IA+CrB;;OAEG;YACW,QAAQ;IAyDtB;;OAEG;YACW,aAAa;IAoC3B;;OAEG;YACW,YAAY;IAS1B;;OAEG;IACH,OAAO,CAAC,cAAc;IAgCtB;;OAEG;YACW,UAAU;IAQxB;;OAEG;YACW,eAAe;IAa7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAmD3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAK7B"}
|