ai-ccesibility 0.1.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/EXAMPLES.md +595 -0
- package/LICENSE +21 -0
- package/README.md +233 -0
- package/USAGE.md +498 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +2177 -0
- package/dist/server.js.map +1 -0
- package/package.json +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# AI-ccesibility
|
|
2
|
+
|
|
3
|
+
Servidor MCP para orquestación de herramientas de accesibilidad web (axe-core, Pa11y, eslint-plugin-vuejs-accessibility).
|
|
4
|
+
|
|
5
|
+
## 📚 Documentación
|
|
6
|
+
|
|
7
|
+
- **[USAGE.md](./USAGE.md)** - Guía completa de uso, workflows y prompts efectivos
|
|
8
|
+
- **[EXAMPLES.md](./EXAMPLES.md)** - Ejemplos concretos de inputs/outputs para cada herramienta
|
|
9
|
+
- **[README.md](./README.md)** - Este archivo (configuración y reference rápida)
|
|
10
|
+
|
|
11
|
+
## Herramientas Disponibles
|
|
12
|
+
|
|
13
|
+
### `analyze-with-axe`
|
|
14
|
+
|
|
15
|
+
Analiza una página web o contenido HTML para detectar problemas de accesibilidad usando axe-core.
|
|
16
|
+
|
|
17
|
+
**Parámetros:**
|
|
18
|
+
|
|
19
|
+
| Parámetro | Tipo | Requerido | Descripción |
|
|
20
|
+
|-----------|------|-----------|-------------|
|
|
21
|
+
| `url` | string | url o html | URL de la página a analizar |
|
|
22
|
+
| `html` | string | url o html | Contenido HTML raw a analizar |
|
|
23
|
+
| `options.wcagLevel` | "A" \| "AA" \| "AAA" | No | Nivel WCAG a verificar (default: AA) |
|
|
24
|
+
| `options.rules` | string[] | No | IDs de reglas axe específicas a ejecutar |
|
|
25
|
+
| `options.excludeRules` | string[] | No | IDs de reglas axe a excluir |
|
|
26
|
+
| `options.includeIncomplete` | boolean | No | Incluir resultados "needs-review" (default: false) |
|
|
27
|
+
| `options.browser.waitForSelector` | string | No | Selector CSS a esperar antes del análisis |
|
|
28
|
+
| `options.browser.viewport` | object | No | Dimensiones del viewport |
|
|
29
|
+
|
|
30
|
+
**Ejemplo de respuesta:**
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"success": true,
|
|
35
|
+
"target": "https://example.com",
|
|
36
|
+
"issueCount": 3,
|
|
37
|
+
"issues": [
|
|
38
|
+
{
|
|
39
|
+
"id": "axe-0",
|
|
40
|
+
"ruleId": "image-alt",
|
|
41
|
+
"tool": "axe-core",
|
|
42
|
+
"severity": "critical",
|
|
43
|
+
"wcag": {
|
|
44
|
+
"criterion": "1.1.1",
|
|
45
|
+
"level": "A",
|
|
46
|
+
"principle": "perceivable"
|
|
47
|
+
},
|
|
48
|
+
"location": {
|
|
49
|
+
"selector": "img",
|
|
50
|
+
"snippet": "<img src=\"logo.png\">"
|
|
51
|
+
},
|
|
52
|
+
"message": "Images must have alternate text",
|
|
53
|
+
"affectedUsers": ["screen-reader"]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"summary": {
|
|
57
|
+
"total": 3,
|
|
58
|
+
"bySeverity": { "critical": 1, "serious": 2, "moderate": 0, "minor": 0 }
|
|
59
|
+
},
|
|
60
|
+
"duration": 1234
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### `analyze-with-pa11y`
|
|
65
|
+
|
|
66
|
+
Analiza una página web o contenido HTML usando Pa11y.
|
|
67
|
+
|
|
68
|
+
**Parámetros similares a axe**, con `options.standard` para elegir el estándar WCAG (WCAG2AA, WCAG21AA, etc.).
|
|
69
|
+
|
|
70
|
+
### `analyze-with-eslint`
|
|
71
|
+
|
|
72
|
+
Analiza archivos Vue.js para problemas de accesibilidad mediante análisis estático.
|
|
73
|
+
|
|
74
|
+
**Parámetros:**
|
|
75
|
+
- `files`: Array de rutas de archivos .vue
|
|
76
|
+
- `directory`: Directorio a analizar recursivamente
|
|
77
|
+
- `code`: Código Vue inline a analizar
|
|
78
|
+
|
|
79
|
+
### `analyze-all` ⭐
|
|
80
|
+
|
|
81
|
+
**Tool de síntesis para análisis web** que ejecuta axe-core y Pa11y en paralelo y combina los resultados.
|
|
82
|
+
|
|
83
|
+
**Parámetros:**
|
|
84
|
+
- `url` o `html`: Target web a analizar (requerido)
|
|
85
|
+
- `tools`: Array de tools a ejecutar (default: `['axe-core', 'pa11y']`)
|
|
86
|
+
- `options.deduplicateResults`: Eliminar issues duplicados (default: `true`)
|
|
87
|
+
- `options.wcagLevel`: Nivel WCAG (default: `'AA'`)
|
|
88
|
+
|
|
89
|
+
**Respuesta incluye:**
|
|
90
|
+
- `issues`: Issues combinados y deduplicados
|
|
91
|
+
- `issuesByWCAG`: Issues agrupados por criterio WCAG
|
|
92
|
+
- `summary.byTool`: Conteo de issues por herramienta
|
|
93
|
+
- `individualResults`: Resultados completos de cada tool
|
|
94
|
+
- `deduplicatedCount`: Número de duplicados eliminados
|
|
95
|
+
|
|
96
|
+
**Nota:** Para análisis de código Vue, usa `analyze-with-eslint` por separado. Esta herramienta está especializada en análisis web dinámico.
|
|
97
|
+
|
|
98
|
+
## Contexto Humano Enriquecido ✨
|
|
99
|
+
|
|
100
|
+
Todos los issues incluyen automáticamente:
|
|
101
|
+
|
|
102
|
+
- **Descripción expandida** del criterio WCAG violado
|
|
103
|
+
- **Impacto en usuarios reales** con ejemplos concretos
|
|
104
|
+
- **Usuarios afectados** (screen-reader, keyboard-only, low-vision, etc.)
|
|
105
|
+
- **Prioridad de remediación** (critical, high, medium, low)
|
|
106
|
+
- **Esfuerzo de corrección** (low, medium, high)
|
|
107
|
+
- **Soluciones sugeridas** paso a paso
|
|
108
|
+
|
|
109
|
+
Ejemplo de issue enriquecido:
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"ruleId": "image-alt",
|
|
113
|
+
"severity": "serious",
|
|
114
|
+
"humanContext": "**Contenido no textual (WCAG 1.1.1 - Nivel A)**\n\nLos usuarios de lectores de pantalla...",
|
|
115
|
+
"suggestedActions": ["Añadir atributo alt descriptivo a imágenes", ...],
|
|
116
|
+
"affectedUsers": ["screen-reader", "low-vision"],
|
|
117
|
+
"priority": "critical",
|
|
118
|
+
"remediationEffort": "low"
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Los datos WCAG se mantienen en `src/data/wcag-criteria.json` y son fácilmente actualizables.
|
|
123
|
+
|
|
124
|
+
## Estructura del Proyecto
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
src/
|
|
128
|
+
├── server.ts # Entry point MCP
|
|
129
|
+
├── data/
|
|
130
|
+
│ └── wcag-criteria.json # Base de conocimiento WCAG (10 criterios)
|
|
131
|
+
├── adapters/
|
|
132
|
+
│ ├── base.ts # Clase base para adaptadores
|
|
133
|
+
│ ├── axe.ts # Adaptador axe-core con Puppeteer
|
|
134
|
+
│ ├── pa11y.ts # Adaptador Pa11y
|
|
135
|
+
│ └── eslint.ts # Adaptador ESLint Vue a11y
|
|
136
|
+
├── tools/
|
|
137
|
+
│ ├── base.ts # Utilidades para tools MCP
|
|
138
|
+
│ ├── axe.ts # Tool analyze-with-axe
|
|
139
|
+
│ ├── pa11y.ts # Tool analyze-with-pa11y
|
|
140
|
+
│ ├── eslint.ts # Tool analyze-with-eslint
|
|
141
|
+
│ └── analyze-all.ts # Tool de síntesis multi-herramienta
|
|
142
|
+
├── types/ # Schemas Zod (inputs, outputs, validación)
|
|
143
|
+
├── normalizers/ # Transformación a formato unificado
|
|
144
|
+
└── utils/ # Logger, contexto WCAG
|
|
145
|
+
|
|
146
|
+
tests/
|
|
147
|
+
├── adapters/ # Tests unitarios de adaptadores
|
|
148
|
+
├── tools/ # Tests de integración de tools
|
|
149
|
+
├── fixtures/ # HTML con problemas de accesibilidad conocidos
|
|
150
|
+
└── helpers/ # Utilidades para tests (mock server, etc.)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Scripts
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pnpm build # Compila a dist/
|
|
157
|
+
pnpm dev # Watch mode
|
|
158
|
+
pnpm typecheck # Verifica tipos
|
|
159
|
+
pnpm start # Levanta servidor
|
|
160
|
+
pnpm format # Formatea código con Prettier
|
|
161
|
+
pnpm format:check # Verifica formato
|
|
162
|
+
pnpm test # Ejecuta tests
|
|
163
|
+
pnpm test:watch # Tests en modo watch
|
|
164
|
+
pnpm test:coverage # Tests con reporte de cobertura
|
|
165
|
+
pnpm inspect. # Lanzar el inspector de mcp para debuggear herramientas de mcp
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Usar Claude Desktop o Cursor
|
|
169
|
+
|
|
170
|
+
Añade el servidor a tu configuración:
|
|
171
|
+
|
|
172
|
+
**Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"mcpServers": {
|
|
177
|
+
"ai-ccesibility": {
|
|
178
|
+
"command": "node",
|
|
179
|
+
"args": ["<RUTA_AL_PROYECTO>/dist/server.js"],
|
|
180
|
+
"env": {
|
|
181
|
+
"LOG_LEVEL": "info"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
> ⚠️ Reemplaza `<RUTA_AL_PROYECTO>` con la ruta absoluta a tu proyecto (ej: `/Users/tu-usuario/Proyectos/ai-ccesibility`)
|
|
189
|
+
|
|
190
|
+
**Cursor** (`.cursor/mcp.json` en el directorio del proyecto):
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"mcpServers": {
|
|
195
|
+
"ai-ccesibility": {
|
|
196
|
+
"command": "node",
|
|
197
|
+
"args": ["dist/server.js"],
|
|
198
|
+
"cwd": "<RUTA_AL_PROYECTO>"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
> ⚠️ Reemplaza `<RUTA_AL_PROYECTO>` con la ruta absoluta a tu proyecto
|
|
205
|
+
|
|
206
|
+
Luego puedes usar prompts como:
|
|
207
|
+
- "Analiza la accesibilidad de https://example.com con axe-core y Pa11y"
|
|
208
|
+
- "Revisa este HTML para problemas de accesibilidad: `<img src='foto.jpg'>`"
|
|
209
|
+
- "Analiza los archivos Vue en src/components/ para problemas de accesibilidad" (usa analyze-with-eslint)
|
|
210
|
+
- "Compara los resultados de axe-core y Pa11y en mi landing page" (usa analyze-all)
|
|
211
|
+
|
|
212
|
+
## Configuración
|
|
213
|
+
|
|
214
|
+
| Variable | Default | Descripción |
|
|
215
|
+
|-------------|---------|----------------------------------|
|
|
216
|
+
| `LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error` |
|
|
217
|
+
|
|
218
|
+
## Requisitos
|
|
219
|
+
|
|
220
|
+
- Node.js ≥ 20
|
|
221
|
+
- pnpm
|
|
222
|
+
- Chrome/Chromium (descargado automáticamente por Puppeteer)
|
|
223
|
+
|
|
224
|
+
## Dependencias Principales
|
|
225
|
+
|
|
226
|
+
- `@modelcontextprotocol/sdk` - SDK para servidores MCP
|
|
227
|
+
- `puppeteer` - Control de navegador headless
|
|
228
|
+
- `@axe-core/puppeteer` - Integración axe-core con Puppeteer
|
|
229
|
+
- `axe-core` - Motor de análisis de accesibilidad
|
|
230
|
+
- `pa11y` - Herramienta de testing de accesibilidad
|
|
231
|
+
- `eslint` + `eslint-plugin-vuejs-accessibility` - Linting estático de Vue.js
|
|
232
|
+
- `zod` - Validación de schemas
|
|
233
|
+
- `pino` - Logging estructurado
|