MCP Web可访问性工具
使用axe-core和Puppeteer提供网页可访问性分析和色盲模拟,能够根据WCAG指南进行详细的可访问性检查和视觉模拟。
可用工具 (2 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
check_accessibility 3 个参数 需填 1 项
Check web accessibility of a given URL using axe-core
必填参数:url
simulate_colorblind 4 个参数 需填 2 项
Simulate how a webpage looks for colorblind users
必填参数:url、type
服务介绍
Web Accessibility MCP 服务器
这是一个使用 axe-core 和 Puppeteer 提供网页无障碍分析功能的 MCP(Model Context Protocol)服务器。
功能
- 使用 axe-core 分析任何 URL 的网页无障碍性
- 使用颜色矩阵模拟色盲(红盲、绿盲、蓝盲)
- 详细的无障碍违规报告
- 支持自定义用户代理和选择器
- 用于故障排除的调试日志
- 基于 WCAG 指南的全面无障碍检查
先决条件
- Node.js (v14 或更高版本)
- npm
安装
通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 Web Accessibility MCP 服务器:
npx -y @smithery/cli install @bilhasry-deriv/mcp-web-a11y --client claude
手动安装
- 克隆仓库:
git clone [repository-url]
cd mcp-web-a11y
- 安装依赖项:
npm install
- 构建服务器:
npm run build
配置
将服务器添加到您的 MCP 设置文件中(通常位于 ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json):
{
"mcpServers": {
"web-a11y": {
"command": "node",
"args": ["/path/to/mcp-web-a11y/build/index.js"],
"disabled": false,
"autoApprove": [],
"env": {
"MCP_OUTPUT_DIR": "/path/to/output/directory"
}
}
}
}
环境变量
MCP_OUTPUT_DIR: 截图输出保存的目录- 对于
simulate_colorblind工具是必需的 - 如果未指定,默认为相对于当前工作目录的 './output'
- 在 MCP 设置中配置时必须是绝对路径
- 对于
使用
该服务器提供了两个工具:check_accessibility 用于分析网页无障碍性,simulate_colorblind 用于模拟色盲。
工具:check_accessibility
使用 axe-core 检查给定 URL 的无障碍性。
参数
url(必需): 要分析的 URLwaitForSelector(可选): 在分析前等待的 CSS 选择器userAgent(可选): 请求的自定义用户代理字符串
示例用法
<use_mcp_tool>
<server_name>mcp-web-a11y</server_name>
<tool_name>check_accessibility</tool_name>
<arguments>
{
"url": "https://example.com",
"waitForSelector": ".main-content",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
</arguments>
</use_mcp_tool>
工具:simulate_colorblind
使用颜色矩阵变换模拟不同类型色盲用户看到的网页外观。
色盲类型
该工具支持三种类型的色盲模拟:
-
Protanopia (红盲) - 使用矩阵:
0.567, 0.433, 0 0.558, 0.442, 0 0, 0.242, 0.758 -
Deuteranopia (绿盲) - 使用矩阵:
0.625, 0.375, 0 0.7, 0.3, 0 0, 0.3, 0.7 -
Tritanopia (蓝盲) - 使用矩阵:
0.95, 0.05, 0 0, 0.433, 0.567 0, 0.475, 0.525
参数
url(必需): 要捕获的 URLtype(必需): 要模拟的色盲类型 ('protanopia', 'deuteranopia' 或 'tritanopia')outputPath(可选): 截图输出的自定义路径userAgent(可选): 请求的自定义用户代理字符串
示例用法
<use_mcp_tool>
<server_name>mcp-web-a11y</server_name>
<tool_name>simulate_colorblind</tool_name>
<arguments>
{
"url": "https://example.com",
"type": "deuteranopia",
"outputPath": "colorblind_simulation.png"
}
</arguments>
</use_mcp_tool>
响应格式
check_accessibility 响应
{
"url": "analyzed-url",
"timestamp": "ISO-timestamp",
"violations": [
{
"impact": "serious|critical|moderate|minor",
"description": "Description of the violation",
"help": "Help text explaining the issue",
"helpUrl": "URL to detailed documentation",
"nodes": [
{
"html": "HTML of the affected element",
"failureSummary": "Summary of what needs to be fixed"
}
]
}
],
"passes": 42,
"inapplicable": 45,
"incomplete": 3
}
simulate_colorblind 响应
{
"url": "analyzed-url",
"type": "colorblind-type",
"outputPath": "path/to/screenshot.png",
"timestamp": "ISO-timestamp",
"message": "Screenshot saved with [type] simulation"
}
错误处理
服务器包括针对常见场景的全面错误处理:
- 网络错误
- 无效 URL
- 超时问题
- DNS 解析问题
错误响应将包含详细的错误信息以帮助诊断问题。
开发
项目结构
mcp-web-a11y/
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled JavaScript
├── output/ # Generated screenshots
├── package.json # Project dependencies and scripts
└── tsconfig.json # TypeScript configuration
构建
npm run build
这将:
- 将 TypeScript 编译为 JavaScript
- 使输出文件可执行
- 将编译后的文件放置在
build目录中
调试
服务器包括详细的调试日志,可以在控制台输出中查看。这包括:
- 网络请求和响应
- 页面加载状态
- 选择器等待状态
- 分析页面中的任何控制台消息
- 颜色模拟进度
常见问题及解决方案
-
超时错误
- 在代码中增加超时值
- 检查网络连接
- 验证 URL 是否可访问
-
DNS 解析错误
- 验证 URL 是否正确
- 检查网络连接
- 尝试使用 www 子域名
-
选择器未找到
- 验证选择器是否存在于页面上
- 等待动态内容加载
- 检查页面源代码以获取正确的选择器
-
颜色模拟问题
- 确保页面的颜色以支持的格式(RGB、RGBA 或 HEX)指定
- 检查页面是否使用了动态颜色变化(可能需要额外的等待时间)
- 验证截图输出目录存在且可写
贡献
- 叉取仓库
- 创建功能分支
- 提交更改
- 推送到分支
- 创建 Pull Request
许可证
该项目根据 MIT 许可证授权 - 详情请参阅 LICENSE 文件。