Skip to main content
Glama
README.md
# a11y-ja-mcp

**日本語で使える、AI エージェント向けのアクセシビリティ検査 MCP サーバー**

Claude Code や Cursor などのエージェントに、ローカルの Chrome を操作してアクセシビリティを検査する道具を渡します。
結果はすべて日本語で返り、WCAG の達成基準番号・日本語名・**JIS X 8341-3 の対象かどうか**が付きます。
同じ検査を **CLI から一括実行**できるので、CI にもそのまま組み込めます。

```
#### 【重大】要素は色のコントラスト比(最低限)の閾値を満たしていなければなりません(1 件)

- ルール: `color-contrast`
- 達成基準: 1.4.3 コントラスト(最低限)(AA・JIS対象)
- `p`
  - 次のいずれかを修正します: 要素のコントラスト比が不十分です 2.84(前景色: #999999、背景色: #ffffff …)
```

## 特徴

- 🇯🇵 **日本語**: axe-core のメッセージ、達成基準名(WAIC 訳)、レポートがすべて日本語
- 📏 **JIS X 8341-3 対応**: `level: "wcag2aa"` で JIS X 8341-3:2016 AA 相当の基準で検査。各指摘に「JIS対象」かどうかを表示
- 🧭 **自動検査 + 構造の確認**: axe-core に加え、Tab 順序(実際に Tab キーを押して記録)、見出し・ランドマーク、画像の代替テキスト、コントラストを確認
- 🤖 **CI 対応**: `npx a11y-ja-mcp audit <url...>` で複数ページを検査し、Markdown / JSON のレポートと終了コードを返す
- 📝 **監査テンプレート**: MCP プロンプト `a11y_audit` と Claude Code 用スキルで、監査の手順とレポートの雛形を提供

## 必要なもの

- Node.js 20 以上
- Google Chrome(または Chromium / Microsoft Edge)
  - 自動で見つからない場合は環境変数 `A11Y_CHROME_PATH` に実行ファイルのパスを指定してください

## セットアップ

### Claude Code

```sh
claude mcp add a11y-ja -- npx -y a11y-ja-mcp
```

### その他の MCP クライアント(Cursor / Claude Desktop など)

```json
{
  "mcpServers": {
    "a11y-ja": {
      "command": "npx",
      "args": ["-y", "a11y-ja-mcp"]
    }
  }
}
```

ブラウザの画面を見ながら使いたい場合は `"env": { "A11Y_HEADLESS": "false" }` を追加してください。

## ツール一覧

| ツール | 内容 |
| --- | --- |
| `navigate` | URL を開く(`http://localhost` や `file://` も可) |
| `click` / `type_text` / `set_checked` / `select_option` | クリック・入力・チェック・選択 |
| `press_key` | キーを押す(`Tab`, `Shift+Tab`, `Enter`, `Escape`, `ArrowDown` など)。押した後のフォーカス先を返す |
| `screenshot` | スクリーンショット |
| `axe_scan` | axe-core で自動検査。基準(WCAG 2.0 AA = JIS 相当 / 2.1 AA / 2.2 AA / 2.2 AAA)と範囲(CSS セレクタ)を指定可 |
| `page_structure` | 見出しのアウトライン、ランドマーク、lang、タイトル、スキップリンク、iframe の title、ラベルのないフォーム部品 |
| `tab_order` | 実際に Tab を押してフォーカス順を記録。見えない要素へのフォーカス、名前のない要素、フォーカス表示の変化なし、正の tabindex、キーボードトラップを指摘 |
| `images` | 画像を「代替テキストあり / 装飾(alt="")/ alt 属性なし / 名前なし」に分類。ファイル名だけの alt、リンク画像の名前抜けなども指摘 |
| `contrast_ratio` | 2 色のコントラスト比と、AA / AAA・通常の文字 / 大きな文字 / UI 部品ごとの合否 |
| `contrast_scan` | ページ内のテキストのコントラストを一括検査。背景画像・グラデーション上の文字は「要目視確認」に分類 |
| `audit_urls` | 複数ページを一括検査して Markdown / JSON のレポートを作成(ファイル保存可) |

**プロンプト**: `a11y_audit`(引数: `url`, `level`)… 上のツールを使った監査手順とレポートのテンプレート

### 使い方の例

> http://localhost:3000 をアクセシビリティ監査して。JIS X 8341-3 の AA が目標です

> お問い合わせフォームを空のまま送信したときのエラー表示を、キーボードだけで確認して

> このボタンの色 #6c757d と白の組み合わせは AA を満たす?

## CLI(CI 向け)

```sh
npx a11y-ja-mcp audit https://example.com https://example.com/about \
  --level wcag22aa --fail-on serious --out a11y-report.md
```

| オプション | 内容 |
| --- | --- |
| `--level` | `wcag2aa`(JIS 相当) / `wcag21aa` / `wcag22aa`(既定) / `wcag22aaa` |
| `--format` | `markdown`(既定) / `json` |
| `--out` | 保存先(省略時は標準出力) |
| `--fail-on` | この深刻度以上の違反があれば終了コード 1。`critical` / `serious`(既定) / `moderate` / `minor` / `none` |
| `--urls-file` | URL を 1 行 1 つで書いたファイル(`#` で始まる行は無視) |
| `--best-practices` | WCAG 外のベストプラクティスも含める |
| `--lang` | `ja`(既定) / `en` |

GitHub Actions の例は [examples/github-actions/a11y.yml](examples/github-actions/a11y.yml) を参照してください。レポートをジョブのサマリーに表示できます。

## Claude Code のスキルとして使う

`skills/a11y-audit/SKILL.md` を `~/.claude/skills/a11y-audit/SKILL.md`(またはプロジェクトの `.claude/skills/`)にコピーすると、
「アクセシビリティ監査して」と頼むだけで手順に沿った監査が始まります。

## 制限事項

- 自動検査で見つかるのは WCAG の問題の**一部**です。スクリーンリーダーでの読み上げ、動画のキャプション、意味的に適切な代替テキストかどうかなどは人の確認が必要です。
- `tab_order` のフォーカス表示の判定は「フォーカス前後で outline などのスタイルが変わったか」で推定しています。最終的にはスクリーンショットで確認してください。
- `contrast_scan` は背景画像・グラデーション・重なった要素の上の文字を正確に判定できません(要目視確認として出力します)。
- JIS X 8341-3:2016 は WCAG 2.0 と同じ内容です。「JIS対象」は WCAG 2.0 の A / AA の達成基準を指します。

## 開発

```sh
npm install
npm test            # ビルド + 単体テスト
node dist/index.js audit "file://$PWD/examples/bad.html" --fail-on none
```

## ライセンス

MIT

---

## English

`a11y-ja-mcp` is an MCP server that gives AI coding agents accessibility testing tools on a local Chrome: axe-core scans, tab order recording, page structure, image alt checks, and WCAG contrast checks. Output is in Japanese by default (`lang: "en"` is available for axe messages), annotated with WCAG success criteria and JIS X 8341-3 applicability. A CLI (`npx a11y-ja-mcp audit <urls...>`) runs batch audits for CI with Markdown/JSON reports and exit codes.

TDQS

B3.4/5.0

Scored across 14 tools

Disambiguation4/5

Most tools have clearly distinct purposes (interaction verbs vs. inspection tools). The main potential confusions are axe_scan vs. audit_urls (single page vs. batch) and contrast_ratio vs. contrast_scan (two colors vs. page-wide), but the descriptions explicitly clarify these boundaries.

Naming Consistency4/5

All names use consistent snake_case, which is highly predictable. There is a minor mix of verb-first (navigate, click, audit_urls) and noun-style (page_structure, tab_order, images) names, but every name remains readable and self-explanatory.

Tool Count5/5

14 tools sit comfortably in the well-scoped 3-15 range. Each tool covers a distinct browser action or accessibility inspection category, so none feel redundant or padded.

Completeness4/5

Coverage is strong: navigation, full interaction set (click, type, check, select, keypress), plus structure, axe, tab order, images, contrast, and batch auditing. Minor gaps exist for dynamic-content waiting, viewport resizing/reflow checks, and reduced-motion inspection, but core a11y workflows are complete.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues