@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,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
|
+
};
|
|
@@ -10,9 +10,9 @@ const icons = Object.entries(coreIconMetadata).map(([_key, icon]) => ({
|
|
|
10
10
|
type: icon.type,
|
|
11
11
|
shouldRecommendSmallIcon: icon.shouldRecommendSmallIcon
|
|
12
12
|
}));
|
|
13
|
-
export const
|
|
14
|
-
name: '
|
|
15
|
-
description: `You
|
|
13
|
+
export const listGetAllIconsTool = {
|
|
14
|
+
name: 'get_all_icons',
|
|
15
|
+
description: `You SHOULD call this when you need complete guidance on what icons to use, but you SHOULD use the \`search_icons\` tool to find specific icons instead.
|
|
16
16
|
These are the only icons to be used in modern code, though other legacy icons may still be found, these are not to be used by you, but you can keep them if you see them in existing code.
|
|
17
17
|
The resulting icon name and package is often like this:
|
|
18
18
|
\`\`\`tsx
|
|
@@ -35,7 +35,7 @@ import Button from '@atlaskit/button/new';
|
|
|
35
35
|
},
|
|
36
36
|
inputSchema: emptyInputSchema
|
|
37
37
|
};
|
|
38
|
-
export const
|
|
38
|
+
export const getAllIconsTool = async () => ({
|
|
39
39
|
content: icons.map(icon => ({
|
|
40
40
|
// NOTE: Ideally one day the MCP would support structured content…
|
|
41
41
|
// eg. `type: 'object', data: icon`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
import { tokens } from '@atlaskit/tokens/token-metadata';
|
|
4
|
+
const inputSchema = z.object({});
|
|
5
|
+
export const listGetAllTokensTool = {
|
|
6
|
+
name: 'get_all_tokens',
|
|
7
|
+
description: `You SHOULD call this when you need complete guidance on what tokens to use, but you SHOULD use the \`search_tokens\` tool to find specific tokens instead.
|
|
8
|
+
These tokens are used in place of hardcoded values; you should never use a hardcoded value where a token value is appropriate.
|
|
9
|
+
The resulting token name is used inside of the \`token()\` function, eg.:
|
|
10
|
+
\`\`\`tsx
|
|
11
|
+
import { token } from '@atlaskit/tokens';
|
|
12
|
+
const styles = css({ color: token('color.text') });
|
|
13
|
+
\`\`\`
|
|
14
|
+
`,
|
|
15
|
+
annotations: {
|
|
16
|
+
title: 'Get all ADS tokens',
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
idempotentHint: true,
|
|
20
|
+
openWorldHint: true
|
|
21
|
+
},
|
|
22
|
+
inputSchema: zodToJsonSchema(inputSchema)
|
|
23
|
+
};
|
|
24
|
+
export const getAllTokensTool = async () => ({
|
|
25
|
+
content: tokens.map(token => ({
|
|
26
|
+
// NOTE: Ideally one day the MCP would support structured content…
|
|
27
|
+
// eg. `type: 'object', data: token`
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: JSON.stringify({
|
|
30
|
+
name: token.name,
|
|
31
|
+
exampleValue: token.exampleValue
|
|
32
|
+
}, null, 2)
|
|
33
|
+
}))
|
|
34
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
|
+
import { coreIconMetadata } from '@atlaskit/icon/metadata';
|
|
5
|
+
const inputSchema = z.object({
|
|
6
|
+
terms: z.array(z.string()).describe('Search term(s) to find icons by name, keywords, or categorization'),
|
|
7
|
+
limit: z.number().optional().default(1).describe('Maximum number of results per term to return (default: 1)'),
|
|
8
|
+
exactName: z.boolean().optional().default(false).describe('Whether to search for exact match only for the icon name')
|
|
9
|
+
});
|
|
10
|
+
const icons = Object.entries(coreIconMetadata).map(([_key, icon]) => ({
|
|
11
|
+
componentName: icon.componentName,
|
|
12
|
+
package: icon.package,
|
|
13
|
+
categorization: icon.categorization,
|
|
14
|
+
keywords: icon.keywords,
|
|
15
|
+
status: icon.status,
|
|
16
|
+
usage: icon.usage,
|
|
17
|
+
type: icon.type,
|
|
18
|
+
shouldRecommendSmallIcon: icon.shouldRecommendSmallIcon
|
|
19
|
+
})).filter(icon => icon.status === 'published');
|
|
20
|
+
export const listSearchIconsTool = {
|
|
21
|
+
name: 'search_icons',
|
|
22
|
+
description: `You SHOULD Search for Atlassian Design System icons based on multiple query strings (if there's multiple candidates of icon names, categorization or keywords, you SHOULD pass them in a single call). You SHOULD use default \`limit\` value of 1 first and only set a higher limit like 5 or 10 if you can't find the icon you need). Fallback to \`get_all_icons\` if nothing is found). This tool searches through component names, icon names, keywords, categorization, type and usage to find the most relevant design icons.
|
|
23
|
+
|
|
24
|
+
The search will match against:
|
|
25
|
+
- Icon component names (e.g., "AddIcon", "DeleteIcon", "EditIcon")
|
|
26
|
+
- Icon keywords (descriptive terms associated with icons)
|
|
27
|
+
- Icon categorization (e.g., "single-purpose", "multi-purpose", "utility")
|
|
28
|
+
- Icon usage descriptions (usage guidelines for the icon)
|
|
29
|
+
|
|
30
|
+
The results include the icon's component name, package path, and usage guidelines.
|
|
31
|
+
|
|
32
|
+
Usage pattern for found icons:
|
|
33
|
+
\`\`\`tsx
|
|
34
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
35
|
+
|
|
36
|
+
// Usage in isolation
|
|
37
|
+
<AddIcon label="Add" size="small" />
|
|
38
|
+
|
|
39
|
+
// Usage with a button
|
|
40
|
+
import Button from '@atlaskit/button/new';
|
|
41
|
+
<Button iconAfter={AddIcon}>Create</Button>
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
You SHOULD check proper usage (props, example usage, etc.) of the icon component using \`get_component_details\` tool before using this tool.
|
|
45
|
+
`,
|
|
46
|
+
annotations: {
|
|
47
|
+
title: 'Search ADS icons',
|
|
48
|
+
readOnlyHint: true,
|
|
49
|
+
destructiveHint: false,
|
|
50
|
+
idempotentHint: true,
|
|
51
|
+
openWorldHint: true
|
|
52
|
+
},
|
|
53
|
+
inputSchema: zodToJsonSchema(inputSchema)
|
|
54
|
+
};
|
|
55
|
+
const cleanQuery = query => query.trim().toLowerCase().replace(/\s+/g, '');
|
|
56
|
+
export const searchIconsTool = async params => {
|
|
57
|
+
const {
|
|
58
|
+
terms,
|
|
59
|
+
limit = 1,
|
|
60
|
+
exactName = false
|
|
61
|
+
} = params;
|
|
62
|
+
const searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
63
|
+
if (exactName) {
|
|
64
|
+
// for each search term, search for the exact match
|
|
65
|
+
const exactNameMatches = searchTerms.map(term => {
|
|
66
|
+
return icons.find(icon => icon.componentName.toLowerCase() === term.toLowerCase());
|
|
67
|
+
}).filter(Boolean);
|
|
68
|
+
if (exactNameMatches.length > 0) {
|
|
69
|
+
return {
|
|
70
|
+
content: [{
|
|
71
|
+
type: 'text',
|
|
72
|
+
text: JSON.stringify(exactNameMatches)
|
|
73
|
+
}]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// use Fuse.js to fuzzy-search through the icons
|
|
79
|
+
const fuse = new Fuse(icons, {
|
|
80
|
+
keys: [{
|
|
81
|
+
name: 'componentName',
|
|
82
|
+
weight: 3
|
|
83
|
+
}, {
|
|
84
|
+
name: 'iconName',
|
|
85
|
+
weight: 3
|
|
86
|
+
}, {
|
|
87
|
+
name: 'keywords',
|
|
88
|
+
weight: 2
|
|
89
|
+
}, {
|
|
90
|
+
name: 'categorization',
|
|
91
|
+
weight: 1
|
|
92
|
+
}, {
|
|
93
|
+
name: 'type',
|
|
94
|
+
weight: 1
|
|
95
|
+
}, {
|
|
96
|
+
name: 'usage',
|
|
97
|
+
weight: 1
|
|
98
|
+
}],
|
|
99
|
+
threshold: 0.4
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// every search term, search for the results
|
|
103
|
+
const results = searchTerms.map(term => {
|
|
104
|
+
// always search exact match from the icons
|
|
105
|
+
const exactNameMatch = icons.find(icon => icon.componentName.toLowerCase() === term.toLowerCase());
|
|
106
|
+
if (exactNameMatch) {
|
|
107
|
+
return [{
|
|
108
|
+
item: exactNameMatch
|
|
109
|
+
}];
|
|
110
|
+
}
|
|
111
|
+
return fuse.search(term).slice(0, limit);
|
|
112
|
+
}).flat();
|
|
113
|
+
const matchedIcons = results.map(result => {
|
|
114
|
+
return {
|
|
115
|
+
componentName: result.item.componentName,
|
|
116
|
+
package: result.item.package,
|
|
117
|
+
usage: result.item.usage
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
content: [{
|
|
122
|
+
type: 'text',
|
|
123
|
+
text: JSON.stringify(matchedIcons)
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
|
+
import { tokens } from '@atlaskit/tokens/token-metadata';
|
|
5
|
+
const inputSchema = z.object({
|
|
6
|
+
terms: z.array(z.string()).describe('Search term(s) to find tokens by name or description'),
|
|
7
|
+
limit: z.number().optional().default(1).describe('Maximum number of results per term to return (default: 1)'),
|
|
8
|
+
exactName: z.boolean().optional().default(false).describe('Whether to search for exact match only for the token name')
|
|
9
|
+
});
|
|
10
|
+
const cleanQuery = query => query.trim().toLowerCase().replace(/\s+/g, '');
|
|
11
|
+
export const listSearchTokensTool = {
|
|
12
|
+
name: 'search_tokens',
|
|
13
|
+
description: `You SHOULD Search for Atlassian Design System tokens based on multiple query strings (if there's multiple candidates of token names, descriptions or example values, you SHOULD pass them in a single call). You SHOULD use default \`limit\` value of 1 first and only set a higher limit like 5 or 10 if you can't find the token you need). Fallback to \`get_all_tokens\` if nothing is found). This tool searches through token names, descriptions, and example values to find the most relevant design tokens.
|
|
14
|
+
|
|
15
|
+
The search will match against:
|
|
16
|
+
- Token names (e.g., "color.text", "space.100", "border.radius")
|
|
17
|
+
- Token descriptions
|
|
18
|
+
- Token example values (eg. "#2898BD" -> "color.icon.accent.teal")
|
|
19
|
+
|
|
20
|
+
The results include the token's name and example value.
|
|
21
|
+
|
|
22
|
+
Usage pattern for found tokens:
|
|
23
|
+
\`\`\`tsx
|
|
24
|
+
import { token } from '@atlaskit/tokens';
|
|
25
|
+
|
|
26
|
+
const styles = css({
|
|
27
|
+
color: token('color.text'),
|
|
28
|
+
padding: token('space.100'),
|
|
29
|
+
borderRadius: token('border.radius'),
|
|
30
|
+
});
|
|
31
|
+
\`\`\`
|
|
32
|
+
`,
|
|
33
|
+
annotations: {
|
|
34
|
+
title: 'Search ADS tokens',
|
|
35
|
+
readOnlyHint: true,
|
|
36
|
+
destructiveHint: false,
|
|
37
|
+
idempotentHint: true,
|
|
38
|
+
openWorldHint: true
|
|
39
|
+
},
|
|
40
|
+
inputSchema: zodToJsonSchema(inputSchema)
|
|
41
|
+
};
|
|
42
|
+
export const searchTokensTool = async params => {
|
|
43
|
+
const {
|
|
44
|
+
terms,
|
|
45
|
+
limit = 1,
|
|
46
|
+
exactName = false
|
|
47
|
+
} = params;
|
|
48
|
+
const searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
49
|
+
if (exactName) {
|
|
50
|
+
// for each search term, search for the exact match
|
|
51
|
+
const exactNameMatches = searchTerms.map(term => {
|
|
52
|
+
return tokens.find(token => token.name.toLowerCase() === term.toLowerCase());
|
|
53
|
+
}).filter(Boolean);
|
|
54
|
+
if (exactNameMatches.length > 0) {
|
|
55
|
+
return {
|
|
56
|
+
content: [{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: JSON.stringify(exactNameMatches.map(token => ({
|
|
59
|
+
name: token.name,
|
|
60
|
+
exampleValue: token.exampleValue
|
|
61
|
+
})))
|
|
62
|
+
}]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// use Fuse.js to fuzzy-search for the tokens
|
|
68
|
+
const fuse = new Fuse(tokens, {
|
|
69
|
+
keys: [{
|
|
70
|
+
name: 'name',
|
|
71
|
+
weight: 3
|
|
72
|
+
}, {
|
|
73
|
+
name: 'description',
|
|
74
|
+
weight: 2
|
|
75
|
+
}, {
|
|
76
|
+
name: 'exampleValue',
|
|
77
|
+
weight: 1
|
|
78
|
+
}],
|
|
79
|
+
threshold: 0.4
|
|
80
|
+
});
|
|
81
|
+
const results = searchTerms.map(term => {
|
|
82
|
+
return fuse.search(term).slice(0, limit);
|
|
83
|
+
}).flat();
|
|
84
|
+
const matchedTokens = results.map(result => {
|
|
85
|
+
return {
|
|
86
|
+
name: result.item.name,
|
|
87
|
+
exampleValue: result.item.exampleValue
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
content: [{
|
|
92
|
+
type: 'text',
|
|
93
|
+
text: JSON.stringify(matchedTokens)
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
};
|