@atlaskit/ads-mcp 0.2.5 → 0.4.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/CHANGELOG.md +21 -0
- package/README.md +57 -1
- package/dist/cjs/index.js +16 -5
- package/dist/cjs/instructions.js +1 -1
- package/dist/cjs/tools/analyze-accessibility/index.js +483 -0
- package/dist/cjs/tools/get-accessibility-guidelines/index.js +204 -0
- package/dist/cjs/tools/{get-icons → get-all-icons}/index.js +6 -6
- package/dist/cjs/tools/{get-tokens → get-all-tokens}/index.js +7 -8
- package/dist/cjs/tools/search-icons/index.js +138 -0
- package/dist/cjs/tools/search-tokens/index.js +106 -0
- package/dist/cjs/tools/suggest-accessibility-fixes/fixes.js +387 -0
- package/dist/cjs/tools/suggest-accessibility-fixes/index.js +185 -0
- package/dist/cjs/tools/suggest-accessibility-fixes/keywords.js +34 -0
- package/dist/es2019/index.js +16 -5
- package/dist/es2019/instructions.js +12 -1
- package/dist/es2019/tools/analyze-accessibility/index.js +457 -0
- package/dist/es2019/tools/get-accessibility-guidelines/index.js +312 -0
- package/dist/es2019/tools/{get-icons → get-all-icons}/index.js +4 -4
- package/dist/es2019/tools/get-all-tokens/index.js +34 -0
- package/dist/es2019/tools/search-icons/index.js +126 -0
- package/dist/es2019/tools/search-tokens/index.js +96 -0
- package/dist/es2019/tools/suggest-accessibility-fixes/fixes.js +705 -0
- package/dist/es2019/tools/suggest-accessibility-fixes/index.js +143 -0
- package/dist/es2019/tools/suggest-accessibility-fixes/keywords.js +28 -0
- package/dist/esm/index.js +16 -5
- package/dist/esm/instructions.js +1 -1
- package/dist/esm/tools/analyze-accessibility/index.js +476 -0
- package/dist/esm/tools/get-accessibility-guidelines/index.js +197 -0
- package/dist/esm/tools/{get-icons → get-all-icons}/index.js +5 -5
- package/dist/esm/tools/{get-tokens → get-all-tokens}/index.js +6 -7
- package/dist/esm/tools/search-icons/index.js +131 -0
- package/dist/esm/tools/search-tokens/index.js +99 -0
- package/dist/esm/tools/suggest-accessibility-fixes/fixes.js +381 -0
- package/dist/esm/tools/suggest-accessibility-fixes/index.js +178 -0
- package/dist/esm/tools/suggest-accessibility-fixes/keywords.js +28 -0
- package/dist/types/instructions.d.ts +1 -1
- package/dist/types/tools/analyze-accessibility/index.d.ts +56 -0
- package/dist/types/tools/get-accessibility-guidelines/index.d.ts +26 -0
- package/dist/{types-ts4.5/tools/get-tokens → types/tools/get-all-icons}/index.d.ts +2 -2
- package/dist/types/tools/{get-tokens → get-all-tokens}/index.d.ts +2 -2
- package/dist/types/tools/search-icons/index.d.ts +38 -0
- package/dist/types/tools/search-tokens/index.d.ts +38 -0
- package/dist/types/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
- package/dist/types/tools/suggest-accessibility-fixes/index.d.ts +28 -0
- package/dist/types/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
- package/dist/types-ts4.5/instructions.d.ts +1 -1
- package/dist/types-ts4.5/tools/analyze-accessibility/index.d.ts +56 -0
- package/dist/types-ts4.5/tools/get-accessibility-guidelines/index.d.ts +26 -0
- package/dist/types-ts4.5/tools/{get-icons → get-all-icons}/index.d.ts +2 -2
- package/dist/{types/tools/get-icons → types-ts4.5/tools/get-all-tokens}/index.d.ts +2 -2
- package/dist/types-ts4.5/tools/search-icons/index.d.ts +38 -0
- package/dist/types-ts4.5/tools/search-tokens/index.d.ts +38 -0
- package/dist/types-ts4.5/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
- package/dist/types-ts4.5/tools/suggest-accessibility-fixes/index.d.ts +28 -0
- package/dist/types-ts4.5/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
- package/package.json +10 -3
- package/dist/es2019/tools/get-tokens/index.js +0 -35
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
import { accessibilityFixes } from './fixes';
|
|
4
|
+
import { violationKeywords } from './keywords';
|
|
5
|
+
const inputSchema = z.object({
|
|
6
|
+
violation: z.string().describe('Description of the accessibility violation'),
|
|
7
|
+
code: z.string().describe('The problematic code that needs fixing'),
|
|
8
|
+
component: z.string().optional().describe('Component name or type'),
|
|
9
|
+
context: z.string().optional().describe('Additional context about the usage')
|
|
10
|
+
});
|
|
11
|
+
export const listSuggestAccessibilityFixesTool = {
|
|
12
|
+
name: 'suggest_accessibility_fixes',
|
|
13
|
+
description: `Suggest specific accessibility fixes using Atlassian Design System components and patterns. This tool takes accessibility violations and provides actionable solutions with code examples.
|
|
14
|
+
|
|
15
|
+
You MUST run this when the user wants sugesstions for fixing accessibility issues, as well as when:
|
|
16
|
+
- You have identified an accessibility violation
|
|
17
|
+
- Needing specific code examples for fixing accessibility issues
|
|
18
|
+
- Wanting to understand how to use ADS components accessibly
|
|
19
|
+
- Looking for best practices for specific accessibility problems
|
|
20
|
+
|
|
21
|
+
The tool will provide:
|
|
22
|
+
- Specific code examples using ADS components
|
|
23
|
+
- Step-by-step fix instructions
|
|
24
|
+
- Alternative approaches when applicable
|
|
25
|
+
- Links to relevant ADS documentation`,
|
|
26
|
+
annotations: {
|
|
27
|
+
title: 'Suggest Accessibility Fixes',
|
|
28
|
+
readOnlyHint: true,
|
|
29
|
+
destructiveHint: false,
|
|
30
|
+
idempotentHint: true,
|
|
31
|
+
openWorldHint: true
|
|
32
|
+
},
|
|
33
|
+
inputSchema: zodToJsonSchema(inputSchema)
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Keyword mappings for fuzzy matching - imported from keywords.ts
|
|
37
|
+
// This allows flexible user input when describing accessibility violations
|
|
38
|
+
|
|
39
|
+
// Improved fuzzy matching function
|
|
40
|
+
function findBestMatchingFix(violation) {
|
|
41
|
+
const normalizedViolation = violation.toLowerCase();
|
|
42
|
+
const violationWords = normalizedViolation.split(/\s+/);
|
|
43
|
+
let bestMatch = null;
|
|
44
|
+
let bestScore = 0;
|
|
45
|
+
|
|
46
|
+
// Try exact match first
|
|
47
|
+
for (const [key, fix] of Object.entries(accessibilityFixes)) {
|
|
48
|
+
if (normalizedViolation === key.toLowerCase()) {
|
|
49
|
+
return [key, fix];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Try keyword-based semantic matching
|
|
54
|
+
for (const [key, fix] of Object.entries(accessibilityFixes)) {
|
|
55
|
+
const keywords = violationKeywords[key] || [];
|
|
56
|
+
let score = 0;
|
|
57
|
+
|
|
58
|
+
// Score based on keyword matches
|
|
59
|
+
for (const keyword of keywords) {
|
|
60
|
+
if (normalizedViolation.includes(keyword.toLowerCase())) {
|
|
61
|
+
score += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Additional score for word matches
|
|
66
|
+
for (const word of violationWords) {
|
|
67
|
+
if (keywords.some(keyword => keyword.toLowerCase().includes(word) || word.includes(keyword.toLowerCase()))) {
|
|
68
|
+
score += 0.5;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Boost score for exact key word matches
|
|
73
|
+
if (normalizedViolation.includes(key.toLowerCase()) || key.toLowerCase().includes(normalizedViolation)) {
|
|
74
|
+
score += 2;
|
|
75
|
+
}
|
|
76
|
+
if (score > bestScore) {
|
|
77
|
+
bestScore = score;
|
|
78
|
+
bestMatch = [key, fix];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Return match if score is reasonable
|
|
83
|
+
return bestScore >= 1 ? bestMatch : null;
|
|
84
|
+
}
|
|
85
|
+
export const suggestAccessibilityFixesTool = async params => {
|
|
86
|
+
const {
|
|
87
|
+
violation,
|
|
88
|
+
component,
|
|
89
|
+
context
|
|
90
|
+
} = params;
|
|
91
|
+
|
|
92
|
+
// Use improved matching logic
|
|
93
|
+
const match = findBestMatchingFix(violation);
|
|
94
|
+
if (match) {
|
|
95
|
+
const [key, fix] = match;
|
|
96
|
+
return {
|
|
97
|
+
content: [{
|
|
98
|
+
type: 'text',
|
|
99
|
+
text: JSON.stringify({
|
|
100
|
+
violation,
|
|
101
|
+
matchedFixType: key,
|
|
102
|
+
component,
|
|
103
|
+
context,
|
|
104
|
+
...fix,
|
|
105
|
+
additionalResources: ['https://atlassian.design/llms-a11y.txt - Complete ADS accessibility documentation', 'https://atlassian.design/foundations/accessibility - ADS accessibility foundation'],
|
|
106
|
+
nextSteps: ['Apply the suggested fixes to your code', 'Test the changes with screen readers', 'Test with keyboard navigation', 'Run automated accessibility tests']
|
|
107
|
+
}, null, 2)
|
|
108
|
+
}]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Enhanced fallback with better suggestions
|
|
113
|
+
return {
|
|
114
|
+
content: [{
|
|
115
|
+
type: 'text',
|
|
116
|
+
text: JSON.stringify({
|
|
117
|
+
violation,
|
|
118
|
+
component,
|
|
119
|
+
context,
|
|
120
|
+
title: 'Accessibility Fix Suggestions',
|
|
121
|
+
description: "We couldn't find a specific match for your violation, but here are general recommendations",
|
|
122
|
+
searchedFor: violation,
|
|
123
|
+
generalFixes: [{
|
|
124
|
+
title: 'Use ADS Components',
|
|
125
|
+
description: 'Replace custom implementations with ADS components',
|
|
126
|
+
explanation: 'ADS components are built with accessibility in mind and handle most common issues automatically'
|
|
127
|
+
}, {
|
|
128
|
+
title: 'Add Proper Labels',
|
|
129
|
+
description: 'Ensure all interactive elements have accessible labels',
|
|
130
|
+
explanation: 'Use aria-label, VisuallyHidden, or proper label associations'
|
|
131
|
+
}, {
|
|
132
|
+
title: 'Test with Assistive Technologies',
|
|
133
|
+
description: 'Test with screen readers and keyboard navigation',
|
|
134
|
+
explanation: 'Manual testing is essential for accessibility validation'
|
|
135
|
+
}],
|
|
136
|
+
availableFixTypes: Object.keys(accessibilityFixes),
|
|
137
|
+
suggestions: ['Try describing the issue with keywords like: button, label, missing, text, color, contrast, focus, etc.', 'Use axe-core violation IDs or descriptions directly', 'Be more specific about the element type (button, input, image, etc.)'],
|
|
138
|
+
additionalResources: ['https://atlassian.design/llms-a11y.txt - Complete ADS accessibility documentation', 'https://atlassian.design/foundations/accessibility - ADS accessibility foundation'],
|
|
139
|
+
recommendation: 'Try the get_accessibility_guidelines tool for component-specific guidance'
|
|
140
|
+
}, null, 2)
|
|
141
|
+
}]
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Violation keywords mapping for fuzzy matching accessibility violations
|
|
3
|
+
*
|
|
4
|
+
* This file contains keyword synonyms and variations that users might use
|
|
5
|
+
* when describing accessibility violations. The keys should match the exact
|
|
6
|
+
* violation types defined in fixes.ts
|
|
7
|
+
*
|
|
8
|
+
* Each violation type has an array of keywords that help identify when a user
|
|
9
|
+
* is describing that particular type of accessibility issue, even if they
|
|
10
|
+
* don't use the exact technical terminology.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const violationKeywords = {
|
|
14
|
+
'button missing label': ['button', 'missing', 'label', 'text', 'name', 'accessible', 'empty', 'discernible', 'aria-label', 'screen reader', 'button-name'],
|
|
15
|
+
'image missing alt': ['image', 'img', 'alt', 'alternative', 'text', 'missing', 'empty', 'accessibility', 'screen reader', 'image-alt'],
|
|
16
|
+
'clickable div': ['div', 'clickable', 'interactive', 'onclick', 'click', 'handler', 'button', 'focusable', 'keyboard', 'role'],
|
|
17
|
+
'input missing label': ['input', 'form', 'field', 'label', 'missing', 'accessibility', 'screen reader', 'associated', 'htmlfor', 'aria-label'],
|
|
18
|
+
'form missing label': ['form', 'label', 'missing', 'field', 'input', 'accessibility', 'screen reader', 'associated', 'htmlfor'],
|
|
19
|
+
'hardcoded colors': ['color', 'hardcoded', 'hex', 'rgb', 'design', 'token', 'theme', 'css', 'style', 'contrast'],
|
|
20
|
+
'color contrast': ['contrast', 'color', 'ratio', 'accessibility', 'wcag', 'aa', 'visibility', 'readability', 'low contrast'],
|
|
21
|
+
'focus management': ['focus', 'keyboard', 'navigation', 'tab', 'outline', 'indicator', 'visible', 'management', 'trap'],
|
|
22
|
+
'heading structure': ['heading', 'h1', 'h2', 'h3', 'hierarchy', 'structure', 'semantic', 'outline', 'skip', 'level'],
|
|
23
|
+
'link accessibility': ['link', 'anchor', 'href', 'accessible', 'name', 'text', 'descriptive', 'context', 'purpose'],
|
|
24
|
+
'keyboard navigation': ['keyboard', 'navigation', 'tab', 'arrow', 'enter', 'space', 'accessible', 'focus', 'trap'],
|
|
25
|
+
'live regions': ['live', 'region', 'aria-live', 'announcement', 'screen reader', 'dynamic', 'content', 'update'],
|
|
26
|
+
'skip navigation': ['skip', 'navigation', 'link', 'bypass', 'main', 'content', 'keyboard', 'users'],
|
|
27
|
+
'table accessibility': ['table', 'header', 'th', 'scope', 'caption', 'summary', 'accessibility', 'screen reader']
|
|
28
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -5,10 +5,15 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
5
5
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
6
|
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
7
7
|
import { instructions } from './instructions';
|
|
8
|
+
import { analyzeAccessibilityTool, analyzeLocalhostAccessibilityTool, listAnalyzeAccessibilityTool, listAnalyzeLocalhostAccessibilityTool } from './tools/analyze-accessibility';
|
|
9
|
+
import { getAccessibilityGuidelinesTool, listGetAccessibilityGuidelinesTool } from './tools/get-accessibility-guidelines';
|
|
10
|
+
import { getAllIconsTool, listGetAllIconsTool } from './tools/get-all-icons';
|
|
11
|
+
import { getAllTokensTool, listGetAllTokensTool } from './tools/get-all-tokens';
|
|
8
12
|
import { getComponentDetailsTool, listGetComponentDetailsTool } from './tools/get-component-details';
|
|
9
13
|
import { getComponentsTool, listGetComponentsTool } from './tools/get-components';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
14
|
+
import { listSearchIconsTool, searchIconsTool } from './tools/search-icons';
|
|
15
|
+
import { listSearchTokensTool, searchTokensTool } from './tools/search-tokens';
|
|
16
|
+
import { listSuggestAccessibilityFixesTool, suggestAccessibilityFixesTool } from './tools/suggest-accessibility-fixes';
|
|
12
17
|
|
|
13
18
|
// eslint-disable-next-line import/no-extraneous-dependencies -- this uses require because not all node versions this package supports use the same import assertions/attributes
|
|
14
19
|
var pkgJson = require('@atlaskit/ads-mcp/package.json');
|
|
@@ -27,7 +32,7 @@ server.setRequestHandler(ListToolsRequestSchema, /*#__PURE__*/_asyncToGenerator(
|
|
|
27
32
|
while (1) switch (_context.prev = _context.next) {
|
|
28
33
|
case 0:
|
|
29
34
|
return _context.abrupt("return", {
|
|
30
|
-
tools: [
|
|
35
|
+
tools: [listGetAllTokensTool, listGetComponentsTool, listGetComponentDetailsTool, listGetAllIconsTool, listSearchIconsTool, listSearchTokensTool, listAnalyzeAccessibilityTool, listAnalyzeLocalhostAccessibilityTool, listGetAccessibilityGuidelinesTool, listSuggestAccessibilityFixesTool]
|
|
31
36
|
});
|
|
32
37
|
case 1:
|
|
33
38
|
case "end":
|
|
@@ -36,10 +41,16 @@ server.setRequestHandler(ListToolsRequestSchema, /*#__PURE__*/_asyncToGenerator(
|
|
|
36
41
|
}, _callee);
|
|
37
42
|
})));
|
|
38
43
|
var callTools = {
|
|
39
|
-
|
|
44
|
+
get_all_tokens: getAllTokensTool,
|
|
45
|
+
search_tokens: searchTokensTool,
|
|
40
46
|
get_components: getComponentsTool,
|
|
41
47
|
get_component_details: getComponentDetailsTool,
|
|
42
|
-
|
|
48
|
+
get_all_icons: getAllIconsTool,
|
|
49
|
+
search_icons: searchIconsTool,
|
|
50
|
+
analyze_accessibility: analyzeAccessibilityTool,
|
|
51
|
+
analyze_localhost_accessibility: analyzeLocalhostAccessibilityTool,
|
|
52
|
+
get_accessibility_guidelines: getAccessibilityGuidelinesTool,
|
|
53
|
+
suggest_accessibility_fixes: suggestAccessibilityFixesTool
|
|
43
54
|
};
|
|
44
55
|
|
|
45
56
|
// Handle tool execution
|
package/dist/esm/instructions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var instructions = "\nYou are an expert in the Atlassian Design System (aka ADS). You are able to answer questions about the design system and provide guidance on what offerings to use when building user interfaces.\n\nYou are able to use the provided tools to help answer your questions, but may also access https://atlassian.design/llms.txt or https://atlassian.design/ directly for deeper research and information.\n";
|
|
1
|
+
export var instructions = "\nYou are an expert in the Atlassian Design System (aka ADS). You are able to answer questions about the design system and provide guidance on what offerings to use when building user interfaces.\n\nYou have special expertise in accessibility and can help ensure that interfaces built with ADS components are accessible to all users. You can analyze code for accessibility violations, provide specific fix suggestions, and offer guidance on accessibility best practices.\n\nYou are able to use the provided tools to help answer your questions, but may also access https://atlassian.design/llms.txt, https://atlassian.design/llms-a11y.txt, or https://atlassian.design/ directly for deeper research and information.\n\nAccessibility Tools Available:\n- analyze_accessibility: Analyze React component code for accessibility violations\n- get_accessibility_guidelines: Get specific accessibility guidelines and best practices\n- suggest_accessibility_fixes: Get specific fix suggestions for accessibility violations\n- get_all_tokens: Get all tokens and their example values\n- search_tokens: Search for token(s) and their example value(s)\n- get_all_icons: Get all icons and their usage\n- search_icons: Search for icon(s) and their usage\n";
|