Token导航 LogoToken导航TokenDH.com
Playwright Accessibility Testing MCP Server logo
开发工具未说明官方级别未说明来源级核验

Playwright Accessibility Testing MCP Server

MCP Server

一个基于Playwright和axe-core的生产级无障碍测试服务,用于全面检测网页应用的WCAG 2.0/2.1合规性。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
JavaScriptClaude自动化测试Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

PashaBoiko

提供方

PashaBoiko

最后核验

2026/5/17 20:19

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

剧作家可访问性测试MCP服务器

一个生产就绪的模型上下文协议(MCP)服务器,用于使用Playwright和axe-core进行全面的可访问性测试。轻松测试web应用程序是否符合WCAG 2.0/2.1。

特性

  • 全面的WCAG测试:测试WCAG 2.0/2.1 A级/AA合规性和最佳实践
  • 自然语言测试:按可见文本查找元素-不需要CSS选择器
  • 自动发现:自动发现和测试所有交互元素
  • 交互式组件测试:在不同状态下进行测试(下拉、模态等)
  • 电脑屏幕截图工具:测试区域的视觉记录
  • 预定义提示:常见测试场景的快速启动模板
  • 生产准备就绪:模块化架构、TypeScript、全面的错误处理

安装

npm install
npm run build

配置

添加到MCP客户端配置文件中:

克劳德桌面版 (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "playwright-a11y": {
      "command": "node",
      "args": ["/absolute/path/to/playwright-axe-mcp/dist/server.js"]
    }
  }
}

克劳德代码 (.claude/config.json 在您的项目中):

{
  "mcpServers": {
    "playwright-a11y": {
      "command": "node",
      "args": ["/absolute/path/to/playwright-axe-mcp/dist/server.js"]
    }
  }
}

配置后重新启动MCP客户端。

快速开始

使用预定义提示(最简单!)

最快的测试方法是 综合a11y测试 提示:

Use comprehensive-a11y-test prompt:
- url: https://example.com
- block: Rewards account
- steps: open menu, select provider, input value, click apply

参数:

  • url (必填):要测试的URL
  • block (可选):节名称(例如“导航”、“用户配置文件”)
  • steps (可选):逗号分隔的交互步骤

它的作用:

  1. 导航到URL
  2. 运行完全可访问性审核
  3. 使用自动发现或自定义步骤测试指定部分
  4. 生成人类可读的报告,包括:

- 执行摘要 - 关键/严重/中等/次要问题 - 优先修复建议

可用工具

1. a11y_scanUrl

扫描URL以查看是否存在可访问性违规。

参数:

{
  url: string;              // Required: URL to scan
  selector?: string;        // Optional: CSS selector to scan specific element
  waitForSelector?: string; // Optional: Wait for this element before scanning
  captureScreenshot?: boolean; // Optional: Capture screenshot (default: false)
  timeout?: number;         // Optional: Navigation timeout in ms (default: 30000)
}

例子:

{
  "url": "https://example.com",
  "selector": "header nav",
  "captureScreenshot": true
}

2. a11y_scanInteractiveByText

使用自然语言测试组件-不需要CSS选择器!

参数:

{
  url: string;              // Required: URL to navigate to
  containerText: string;    // Required: Visible text to find section (e.g., "Rewards")
  autoDiscover?: boolean;   // Optional: Auto-discover interactions (default: true)
  customInteractions?: Array;
  captureScreenshots?: boolean; // Optional: Screenshot each state
  timeout?: number;         // Optional: Navigation timeout in ms
}

示例:自动发现一切

{
  "url": "https://example.com",
  "containerText": "User Menu",
  "autoDiscover": true,
  "captureScreenshots": true
}

示例:自定义交互

{
  "url": "https://example.com",
  "containerText": "Rewards",
  "customInteractions": [
    {
      "stateName": "After opening menu",
      "elementText": "View Details",
      "action": "click"
    }
  ]
}

响应格式

扫描结果

{
  "url": "https://example.com",
  "timestamp": "2025-01-28T...",
  "summary": {
    "violations": 3,
    "passes": 12,
    "incomplete": 1
  },
  "violations": [
    {
      "id": "color-contrast",
      "impact": "serious",
      "description": "Elements must have sufficient color contrast",
      "help": "Ensure contrast ratio is at least 4.5:1",
      "helpUrl": "https://dequeuniversity.com/rules/axe/4.4/color-contrast",
      "tags": ["wcag2aa", "wcag21aa"],
      "nodes": [
        {
          "html": "Submit",
          "target": [".btn"],
          "failureSummary": "..."
        }
      ]
    }
  ],
  "screenshotPath": "/path/to/screenshot.png"
}

交互式扫描结果

{
  "url": "https://example.com",
  "containerText": "Rewards",
  "totalStates": 3,
  "states": [
    {
      "stateName": "Initial State",
      "summary": {"violations": 0, "passes": 5, "incomplete": 0},
      "violations": []
    },
    {
      "stateName": "After interacting with buttons: \"View Details\"",
      "action": "click",
      "elementText": "View Details",
      "summary": {"violations": 2, "passes": 8, "incomplete": 1},
      "violations": [...]
    }
  ]
}

项目结构

server/
├── constants/          # Configuration and constants
│   ├── config.ts      # Application configuration
│   ├── selectors.ts   # Interactive element selectors
│   └── wcag-tags.ts   # WCAG compliance tags
├── types/             # TypeScript type definitions
│   └── scan-result.ts # Scan result interfaces
├── utils/             # Utility functions
│   ├── axe-scanner.ts      # Axe configuration and scanning
│   ├── browser.ts          # Browser management
│   ├── container-finder.ts # Find elements by text
│   └── screenshot.ts       # Screenshot utilities
├── tools/             # Tool implementations
│   ├── scan-url.ts                   # URL scanning tool
│   └── scan-interactive-by-text.ts   # Interactive testing tool
├── prompts/           # Prompt templates
│   └── comprehensive-a11y-test.ts    # Predefined test prompt
└── server.ts          # Main MCP server entry point

WCAG合规性

此服务器测试:

  • WCAG 2.0 A级 (wcag2a)
  • WCAG 2.0 AA级 (wcag2aa)
  • WCAG 2.1 A级 (wcag21a)
  • WCAG 2.1 AA级 (wcag21aa)
  • 最佳实践 (best-practice)

影响程度

违规行为按严重程度分类:

  • 关键的:完全阻止访问-立即修复
  • 严肃的:造成重大障碍-发布前修复
  • 适度:注意到的问题-很快修复
  • 次要的:小改进-可以积压

输出文件

所有截图都保存到: ./accessibility-screenshots/

  • scan-{timestamp}.png -全页截图
  • {name}-{timestamp}.png -命名截图

使用示例

测试一个简单的页面

User: "Check accessibility of https://example.com"
Claude: → Calls a11y_scanUrl
        → Returns: 3 violations (2 serious, 1 moderate)

按名称测试特定部分

User: "Test the Navigation menu on https://example.com"
Claude: → Calls a11y_scanInteractiveByText with containerText="Navigation"
        → Auto-discovers all interactive elements
        → Returns: Issues found in different states

使用自定义交互进行测试

User: "Test the Rewards section - click 'View Details' then 'Redeem'"
Claude: → Parses your request
        → Calls a11y_scanInteractiveByText with custom interactions
        → Returns: Accessibility analysis for each state

发展

# Build TypeScript
npm run build

# Watch mode for development
npm run watch

# Start server directly (for testing)
npm start

添加新工具

  1. 在中创建工具文件 server/tools/
  2. 定义模式和执行函数
  3. 注册 server/server.ts

添加新实用程序

  1. 在中创建实用程序文件 server/utils/
  2. 导出函数
  3. 在需要的地方进口

最佳实践

  1. 始终使用屏幕截图进行测试 在初始开发阶段:
   {"captureScreenshot": true}
  1. 等待动态内容 关于SPA:
   {"waitForSelector": ".content-loaded"}
  1. 测试交互式组件 在不同的州:

- 初始状态 - 用户交互后 - 错误状态 - 成功状态

  1. 使用自然语言测试 当你不知道选择器时:
   {"containerText": "User Menu", "autoDiscover": true}

故障排除

服务器未启动

npm run build
# Check config path is absolute
# Restart MCP client

未找到元素

  • 验证页面上是否存在文本
  • 尝试更短、更具体的文本
  • 检查内容是否已加载(使用 waitForSelector)

超时错误

{"timeout": 60000}  // Increase to 60 seconds

需求

  • Node.js 18+
  • Playwright(自动安装浏览器)

许可证

ISC

贡献

  1. 遵循模块化架构
  2. 为新功能添加TypeScript类型
  3. 在README中记录新工具
  4. 更新常量而不是硬编码值

______________________________________________________________________

采用模块化、可维护的架构,专为生产使用而构建。

目录标签

目录标签

JavaScriptClaude自动化测试无障碍测试本地部署WCAG合规网页可访问性Playwright集成

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明nonelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP