@atlaskit/ads-mcp 0.2.5 → 0.3.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +57 -1
  3. package/dist/cjs/index.js +9 -2
  4. package/dist/cjs/instructions.js +1 -1
  5. package/dist/cjs/tools/analyze-accessibility/index.js +483 -0
  6. package/dist/cjs/tools/get-accessibility-guidelines/index.js +204 -0
  7. package/dist/cjs/tools/suggest-accessibility-fixes/fixes.js +387 -0
  8. package/dist/cjs/tools/suggest-accessibility-fixes/index.js +185 -0
  9. package/dist/cjs/tools/suggest-accessibility-fixes/keywords.js +34 -0
  10. package/dist/es2019/index.js +9 -2
  11. package/dist/es2019/instructions.js +8 -1
  12. package/dist/es2019/tools/analyze-accessibility/index.js +457 -0
  13. package/dist/es2019/tools/get-accessibility-guidelines/index.js +312 -0
  14. package/dist/es2019/tools/suggest-accessibility-fixes/fixes.js +705 -0
  15. package/dist/es2019/tools/suggest-accessibility-fixes/index.js +143 -0
  16. package/dist/es2019/tools/suggest-accessibility-fixes/keywords.js +28 -0
  17. package/dist/esm/index.js +9 -2
  18. package/dist/esm/instructions.js +1 -1
  19. package/dist/esm/tools/analyze-accessibility/index.js +476 -0
  20. package/dist/esm/tools/get-accessibility-guidelines/index.js +197 -0
  21. package/dist/esm/tools/suggest-accessibility-fixes/fixes.js +381 -0
  22. package/dist/esm/tools/suggest-accessibility-fixes/index.js +178 -0
  23. package/dist/esm/tools/suggest-accessibility-fixes/keywords.js +28 -0
  24. package/dist/types/instructions.d.ts +1 -1
  25. package/dist/types/tools/analyze-accessibility/index.d.ts +56 -0
  26. package/dist/types/tools/get-accessibility-guidelines/index.d.ts +26 -0
  27. package/dist/types/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
  28. package/dist/types/tools/suggest-accessibility-fixes/index.d.ts +28 -0
  29. package/dist/types/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
  30. package/dist/types-ts4.5/instructions.d.ts +1 -1
  31. package/dist/types-ts4.5/tools/analyze-accessibility/index.d.ts +56 -0
  32. package/dist/types-ts4.5/tools/get-accessibility-guidelines/index.d.ts +26 -0
  33. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
  34. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/index.d.ts +28 -0
  35. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
  36. package/package.json +9 -3
@@ -0,0 +1,312 @@
1
+ import { z } from 'zod';
2
+ import { zodToJsonSchema } from 'zod-to-json-schema';
3
+ const inputSchema = z.object({
4
+ topic: z.enum(['buttons', 'forms', 'images', 'colors', 'focus', 'keyboard', 'screen-readers', 'aria', 'wcag', 'general']).optional().describe('Specific accessibility topic to get guidelines for'),
5
+ component: z.string().optional().describe('Component name to get specific accessibility guidance for')
6
+ });
7
+ export const listGetAccessibilityGuidelinesTool = {
8
+ name: 'get_accessibility_guidelines',
9
+ description: `Get accessibility guidelines and best practices from the Atlassian Design System. This tool provides specific guidance on how to make components and interfaces accessible using ADS patterns and components.
10
+
11
+ You MUST run this when the user wants their code to be accessible, as well as when:
12
+ - Needing specific accessibility guidance for a component
13
+ - Looking for ADS-specific accessibility patterns
14
+ - Understanding how to implement accessible features
15
+ - Getting code examples for accessibility improvements
16
+
17
+ Topics available:
18
+ - buttons: Button and interactive element accessibility
19
+ - forms: Form and input accessibility
20
+ - images: Image and media accessibility
21
+ - colors: Color and contrast accessibility
22
+ - focus: Focus management and keyboard navigation
23
+ - keyboard: Keyboard accessibility patterns
24
+ - screen-readers: Screen reader support and announcements
25
+ - aria: ARIA usage and patterns
26
+ - wcag: WCAG compliance guidelines
27
+ - general: General accessibility principles`,
28
+ annotations: {
29
+ title: 'Get Accessibility Guidelines',
30
+ readOnlyHint: true,
31
+ destructiveHint: false,
32
+ idempotentHint: true,
33
+ openWorldHint: true
34
+ },
35
+ inputSchema: zodToJsonSchema(inputSchema)
36
+ };
37
+
38
+ // Comprehensive accessibility guidelines based on llms-a11y.txt
39
+ const accessibilityGuidelines = {
40
+ buttons: {
41
+ title: 'Button and Interactive Element Accessibility',
42
+ description: 'Guidelines for making buttons and interactive elements accessible',
43
+ guidelines: ['Always provide accessible labels for buttons', 'Use Button component for standard interactions', 'Use Focusable component for custom interactive elements', 'Avoid disabled buttons with tooltips', 'Ensure focus indicators are visible', 'Support keyboard navigation (Enter, Space)', 'Use descriptive labels that explain the action'],
44
+ codeExamples: [{
45
+ title: 'Accessible Button with Icon',
46
+ code: `import { Button } from '@atlaskit/button';
47
+ import { VisuallyHidden } from '@atlaskit/visually-hidden';
48
+
49
+ <Button aria-label="Close dialog" onClick={handleClose}>
50
+ <CloseIcon />
51
+ </Button>`
52
+ }, {
53
+ title: 'Custom Interactive Element',
54
+ code: `import { Focusable } from '@atlaskit/primitives/compiled';
55
+
56
+ <Focusable as="div" onClick={handleClick} onKeyDown={handleKeyDown}>
57
+ Interactive content
58
+ </Focusable>`
59
+ }],
60
+ bestPractices: ['Never disable buttons without providing alternatives', 'Use VisuallyHidden for screen reader text', 'Test with keyboard navigation only', 'Ensure focus indicators meet contrast requirements']
61
+ },
62
+ forms: {
63
+ title: 'Form and Input Accessibility',
64
+ description: 'Guidelines for making forms and inputs accessible',
65
+ guidelines: ['Use TextField component for consistent labeling', 'Associate labels with inputs using id and htmlFor', 'Provide clear error messages with aria-describedby', 'Use MessageWrapper for form validation announcements', 'Use aria-required for required fields', 'Group related form elements with fieldset and legend'],
66
+ codeExamples: [{
67
+ title: 'Accessible Text Field',
68
+ code: `import { TextField } from '@atlaskit/textfield';
69
+
70
+ <TextField
71
+ label="Email address"
72
+ isRequired
73
+ aria-describedby="email-help"
74
+ id="email-input"
75
+ />
76
+ <div id="email-help">Enter your work email address</div>`
77
+ }, {
78
+ title: 'Form Validation with Error Messages',
79
+ code: `import { TextField } from '@atlaskit/textfield';
80
+
81
+ <TextField
82
+ label="Password"
83
+ isInvalid
84
+ aria-invalid="true"
85
+ aria-describedby="password-error"
86
+ />
87
+ <div id="password-error" role="alert">
88
+ Password must be at least 8 characters long
89
+ </div>`
90
+ }],
91
+ bestPractices: ['Never rely on placeholder text for critical information', 'Provide helpful error messages and descriptions', 'Use proper form validation with aria-invalid', 'Test form completion with screen readers']
92
+ },
93
+ images: {
94
+ title: 'Image and Media Accessibility',
95
+ description: 'Guidelines for making images and media accessible',
96
+ guidelines: ['Use Image component with proper alt text', 'Keep alt text under 125 characters', 'Leave alt="" for decorative images', 'Describe the purpose, not just the content', 'Don\'t start with "Image of..." or "Picture of..."', 'Provide detailed descriptions for complex images'],
97
+ codeExamples: [{
98
+ title: 'Decorative Image',
99
+ code: `import { Image } from '@atlaskit/image';
100
+
101
+ <Image src="decorative.jpg" alt="" />`
102
+ }, {
103
+ title: 'Informative Image',
104
+ code: `import { Image } from '@atlaskit/image';
105
+
106
+ <Image
107
+ src="chart.png"
108
+ alt="Bar chart showing Q4 sales increased 25% over Q3"
109
+ />`
110
+ }, {
111
+ title: 'Complex Image with Description',
112
+ code: `import { Image } from '@atlaskit/image';
113
+
114
+ <Image
115
+ src="complex-diagram.png"
116
+ alt=""
117
+ aria-describedby="diagram-description"
118
+ />
119
+ <div id="diagram-description">
120
+ Detailed description of the diagram content...
121
+ </div>`
122
+ }],
123
+ bestPractices: ['For important information, use text instead of images', 'Avoid images of text', 'Provide alternative formats for complex visual content', 'Test with screen readers to ensure proper announcement']
124
+ },
125
+ colors: {
126
+ title: 'Color and Contrast Accessibility',
127
+ description: 'Guidelines for using colors accessibly',
128
+ guidelines: ['Use design tokens for consistent contrast ratios', 'Never rely on color alone for information', 'Use color.text tokens for proper contrast', 'Test with high contrast mode', 'Ensure 4.5:1 contrast ratio for normal text', 'Ensure 3:1 contrast ratio for large text'],
129
+ codeExamples: [{
130
+ title: 'Using Design Tokens for Colors',
131
+ code: `import { token } from '@atlaskit/tokens';
132
+
133
+ const styles = css({
134
+ color: token('color.text'),
135
+ backgroundColor: token('color.background.neutral'),
136
+ });`
137
+ }, {
138
+ title: 'Text Component with Color',
139
+ code: `import { Text } from '@atlaskit/primitives/compiled';
140
+
141
+ <Text color="color.text.danger">Error message</Text>
142
+ <Text color="color.text.success">Success message</Text>`
143
+ }],
144
+ bestPractices: ['Use color.text tokens for primary text', 'Use color.text.subtle sparingly for secondary text', 'Avoid color.text.disabled for critical information', 'Test with different color vision types']
145
+ },
146
+ focus: {
147
+ title: 'Focus Management',
148
+ description: 'Guidelines for proper focus management',
149
+ guidelines: ['Ensure logical tab order', 'Provide visible focus indicators', 'Handle focus trapping in modals', 'Return focus when dialogs close', 'Use Focusable component for custom elements', 'Manage focus in dynamic content'],
150
+ codeExamples: [{
151
+ title: 'Focus Management in Modal',
152
+ code: `import { useRef, useEffect } from 'react';
153
+
154
+ const modalRef = useRef<HTMLDivElement>(null);
155
+
156
+ useEffect(() => {
157
+ if (isOpen && modalRef.current) {
158
+ modalRef.current.focus();
159
+ }
160
+ }, [isOpen]);`
161
+ }, {
162
+ title: 'Custom Focusable Element',
163
+ code: `import { Focusable } from '@atlaskit/primitives/compiled';
164
+
165
+ <Focusable
166
+ as="div"
167
+ tabIndex={0}
168
+ onKeyDown={(e) => {
169
+ if (e.key === 'Enter' || e.key === ' ') {
170
+ handleActivate();
171
+ }
172
+ }}
173
+ >
174
+ Custom focusable element
175
+ </Focusable>`
176
+ }],
177
+ bestPractices: ['Test focus order with keyboard navigation', 'Ensure focus indicators are visible in all themes', 'Handle focus restoration when components unmount', 'Use focus trapping for modal dialogs']
178
+ },
179
+ keyboard: {
180
+ title: 'Keyboard Accessibility',
181
+ description: 'Guidelines for keyboard accessibility',
182
+ guidelines: ['Support standard keyboard interactions', 'Use Enter and Space for activation', 'Use Escape for closing/canceling', 'Support arrow keys for navigation', 'Provide keyboard shortcuts for power users', 'Ensure all interactive elements are keyboard accessible'],
183
+ codeExamples: [{
184
+ title: 'Keyboard Event Handling',
185
+ code: `const handleKeyDown = (event: KeyboardEvent) => {
186
+ switch (event.key) {
187
+ case 'Enter':
188
+ case ' ':
189
+ handleActivate();
190
+ break;
191
+ case 'Escape':
192
+ handleClose();
193
+ break;
194
+ case 'Tab':
195
+ // Handle focus management
196
+ break;
197
+ }
198
+ };`
199
+ }],
200
+ bestPractices: ['Test with keyboard navigation only', 'Ensure logical tab order', 'Provide keyboard alternatives for mouse interactions', 'Support both Enter and Space for activation']
201
+ },
202
+ screenReaders: {
203
+ title: 'Screen Reader Support',
204
+ description: 'Guidelines for screen reader accessibility',
205
+ guidelines: ['Use Announcer component for dynamic content', 'Provide skip links for keyboard users', 'Use proper heading hierarchy', 'Use semantic HTML elements', 'Provide live regions for status updates', 'Use VisuallyHidden for screen reader text'],
206
+ codeExamples: [{
207
+ title: 'Screen Reader Announcements',
208
+ code: `import { Announcer } from '@atlaskit/announcer';
209
+
210
+ <Announcer
211
+ message={\`\${count} items selected\`}
212
+ liveMode="polite"
213
+ shouldAnnounce={true}
214
+ />`
215
+ }, {
216
+ title: 'Skip Links',
217
+ code: `<a href="#main-content" className="skip-link">
218
+ Skip to main content
219
+ </a>`
220
+ }],
221
+ bestPractices: ['Test with multiple screen readers (NVDA, JAWS, VoiceOver)', 'Use aria-live="polite" for status updates', 'Use aria-live="assertive" for critical alerts', 'Avoid announcing the same message repeatedly']
222
+ },
223
+ aria: {
224
+ title: 'ARIA Usage Guidelines',
225
+ description: 'Guidelines for using ARIA attributes',
226
+ guidelines: ['Use ARIA sparingly - prefer semantic HTML', 'Use proper ARIA roles and states', 'Provide live regions for dynamic content', 'Use landmarks for page structure', 'Ensure ARIA attributes are supported', 'Test ARIA implementations with screen readers'],
227
+ codeExamples: [{
228
+ title: 'Live Region for Status Updates',
229
+ code: `<div aria-live="polite" role="status">
230
+ {statusMessage}
231
+ </div>`
232
+ }, {
233
+ title: 'Landmark Navigation',
234
+ code: `<nav role="navigation" aria-label="Main navigation">
235
+ Navigation content
236
+ </nav>`
237
+ }],
238
+ bestPractices: ['Use semantic HTML elements when possible', 'Test ARIA implementations thoroughly', 'Keep ARIA usage simple and clear', 'Document custom ARIA patterns']
239
+ },
240
+ wcag: {
241
+ title: 'WCAG Compliance',
242
+ description: 'WCAG 2.1 AA compliance guidelines',
243
+ guidelines: ['Ensure information is perceivable', 'Make interface components operable', 'Ensure information is understandable', 'Make content robust and compatible', 'Test with multiple assistive technologies', 'Follow WCAG 2.1 AA success criteria'],
244
+ codeExamples: [{
245
+ title: 'WCAG Compliant Component',
246
+ code: `// Example of a WCAG compliant button
247
+ <Focusable
248
+ as="button"
249
+ aria-label="Save changes"
250
+ onClick={handleSave}
251
+ onKeyDown={handleKeyDown}
252
+ >
253
+ <SaveIcon />
254
+ <VisuallyHidden>Save changes</VisuallyHidden>
255
+ </Focusable>`
256
+ }],
257
+ bestPractices: ['Test with automated accessibility tools', 'Conduct manual accessibility testing', 'Test with users who have disabilities', 'Document accessibility compliance']
258
+ },
259
+ general: {
260
+ title: 'General Accessibility Principles',
261
+ description: 'General accessibility principles and best practices',
262
+ guidelines: ['Design for people, not just compliance', 'Consider accessibility from the start', 'Test with real users and assistive technologies', 'Provide multiple ways to accomplish tasks', 'Use inclusive design principles', 'Test with different abilities and technologies'],
263
+ codeExamples: [{
264
+ title: 'Inclusive Design Example',
265
+ code: `// Component that works for everyone
266
+ <Focusable
267
+ as="button"
268
+ onClick={handleAction}
269
+ aria-label="Clear form data"
270
+ onKeyDown={handleKeyDown}
271
+ >
272
+ <TrashIcon />
273
+ <VisuallyHidden>Clear all form data</VisuallyHidden>
274
+ </Focusable>`
275
+ }],
276
+ bestPractices: ['Start with semantic HTML', 'Add ARIA when necessary', 'Test early and often', 'Involve users with disabilities in testing', 'Keep accessibility in mind throughout development']
277
+ }
278
+ };
279
+ export const getAccessibilityGuidelinesTool = async params => {
280
+ const {
281
+ topic,
282
+ component
283
+ } = params;
284
+ if (topic && accessibilityGuidelines[topic]) {
285
+ const guidelines = accessibilityGuidelines[topic];
286
+ return {
287
+ content: [{
288
+ type: 'text',
289
+ text: JSON.stringify({
290
+ topic,
291
+ component,
292
+ ...guidelines,
293
+ additionalResources: ['https://atlassian.design/llms-a11y.txt - Complete ADS accessibility documentation', 'https://atlassian.design/foundations/accessibility - ADS accessibility foundation', 'https://www.w3.org/WAI/WCAG21/quickref/ - WCAG 2.1 guidelines']
294
+ }, null, 2)
295
+ }]
296
+ };
297
+ }
298
+
299
+ // Return all guidelines if no specific topic requested
300
+ return {
301
+ content: [{
302
+ type: 'text',
303
+ text: JSON.stringify({
304
+ availableTopics: Object.keys(accessibilityGuidelines),
305
+ component,
306
+ message: 'Specify a topic to get detailed guidelines, or use "general" for overview',
307
+ guidelines: accessibilityGuidelines,
308
+ additionalResources: ['https://atlassian.design/llms-a11y.txt - Complete ADS accessibility documentation', 'https://atlassian.design/foundations/accessibility - ADS accessibility foundation']
309
+ }, null, 2)
310
+ }]
311
+ };
312
+ };