@atlaskit/ads-mcp 0.9.0 → 0.10.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 +14 -0
- package/dist/cjs/index.js +14 -9
- package/dist/cjs/tools/get-icons/icon-structured-content.codegen.js +2585 -0
- package/dist/cjs/tools/get-icons/index.js +133 -0
- package/dist/cjs/tools/get-tokens/index.js +15 -22
- package/dist/cjs/tools/get-tokens/token-structured-content.codegen.js +2261 -0
- package/dist/es2019/index.js +13 -9
- package/dist/es2019/tools/get-icons/icon-structured-content.codegen.js +2579 -0
- package/dist/es2019/tools/get-icons/index.js +108 -0
- package/dist/es2019/tools/get-tokens/index.js +7 -22
- package/dist/es2019/tools/get-tokens/token-structured-content.codegen.js +2255 -0
- package/dist/esm/index.js +14 -9
- package/dist/esm/tools/get-icons/icon-structured-content.codegen.js +2579 -0
- package/dist/esm/tools/get-icons/index.js +126 -0
- package/dist/esm/tools/get-tokens/index.js +15 -22
- package/dist/esm/tools/get-tokens/token-structured-content.codegen.js +2255 -0
- package/dist/types/index.d.ts +1 -2
- package/dist/types/tools/get-icons/icon-structured-content.codegen.d.ts +13 -0
- package/dist/types/tools/get-icons/index.d.ts +35 -0
- package/dist/types/tools/get-tokens/index.d.ts +6 -4
- package/dist/types/tools/get-tokens/token-structured-content.codegen.d.ts +13 -0
- package/dist/types-ts4.5/index.d.ts +1 -2
- package/dist/types-ts4.5/tools/get-icons/icon-structured-content.codegen.d.ts +13 -0
- package/dist/types-ts4.5/tools/get-icons/index.d.ts +35 -0
- package/dist/types-ts4.5/tools/get-tokens/index.d.ts +6 -4
- package/dist/types-ts4.5/tools/get-tokens/token-structured-content.codegen.d.ts +13 -0
- package/package.json +5 -1
- package/dist/cjs/structured-content/formatters/token.js +0 -11
- package/dist/cjs/structured-content/types.js +0 -1
- package/dist/es2019/structured-content/formatters/token.js +0 -10
- package/dist/es2019/structured-content/types.js +0 -0
- package/dist/esm/structured-content/formatters/token.js +0 -5
- package/dist/esm/structured-content/types.js +0 -0
- package/dist/types/structured-content/formatters/token.d.ts +0 -2
- package/dist/types/structured-content/types.d.ts +0 -20
- package/dist/types-ts4.5/structured-content/formatters/token.d.ts +0 -2
- package/dist/types-ts4.5/structured-content/types.d.ts +0 -20
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { cleanQuery, zodToJsonSchema } from '../../helpers';
|
|
4
|
+
import { iconStructuredContent } from './icon-structured-content.codegen';
|
|
5
|
+
export const getIconsInputSchema = z.object({
|
|
6
|
+
terms: z.array(z.string()).default([]).describe('An array of search terms to find icons by name, keywords, or categorization, eg. `["search", "folder", "user"]`. If empty or not provided, returns all icons.').optional(),
|
|
7
|
+
limit: z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
8
|
+
exactName: z.boolean().default(false).describe('Enable to explicitly search icons by the exact name match (when you know the name, but need more details)').optional()
|
|
9
|
+
});
|
|
10
|
+
export const listGetIconsTool = {
|
|
11
|
+
name: 'ads_get_icons',
|
|
12
|
+
description: `Get Atlassian Design System icons with optional search functionality.
|
|
13
|
+
|
|
14
|
+
- If search parameters are provided, searches for icons matching the criteria.
|
|
15
|
+
- If no search parameters are provided, returns all icons.
|
|
16
|
+
|
|
17
|
+
Example icon usage:
|
|
18
|
+
\`\`\`tsx
|
|
19
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
20
|
+
<AddIcon label="Add work item" size="small" />
|
|
21
|
+
\`\`\``,
|
|
22
|
+
annotations: {
|
|
23
|
+
title: 'Get ADS icons',
|
|
24
|
+
readOnlyHint: true,
|
|
25
|
+
destructiveHint: false,
|
|
26
|
+
idempotentHint: true,
|
|
27
|
+
openWorldHint: true
|
|
28
|
+
},
|
|
29
|
+
inputSchema: zodToJsonSchema(getIconsInputSchema)
|
|
30
|
+
};
|
|
31
|
+
export const getIconsTool = async params => {
|
|
32
|
+
const {
|
|
33
|
+
terms = [],
|
|
34
|
+
limit = 1,
|
|
35
|
+
exactName = false
|
|
36
|
+
} = params;
|
|
37
|
+
const searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
38
|
+
const iconDocs = iconStructuredContent.filter(icon => icon.status === 'published');
|
|
39
|
+
|
|
40
|
+
// If no search terms provided, return all icons formatted as Markdown
|
|
41
|
+
if (searchTerms.length === 0) {
|
|
42
|
+
const allIconsMarkdown = iconDocs.map(icon => icon.content).join('\n\n');
|
|
43
|
+
return {
|
|
44
|
+
content: [{
|
|
45
|
+
type: 'text',
|
|
46
|
+
text: allIconsMarkdown
|
|
47
|
+
}]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Search logic (similar to search-icons)
|
|
52
|
+
if (exactName) {
|
|
53
|
+
// for each search term, search for the exact match
|
|
54
|
+
const exactNameMatches = searchTerms.map(term => {
|
|
55
|
+
return iconDocs.find(icon => icon.componentName.toLowerCase() === term.toLowerCase());
|
|
56
|
+
}).filter(icon => icon !== undefined);
|
|
57
|
+
|
|
58
|
+
// Return exact matches if found, or empty result if exactName is true
|
|
59
|
+
const formattedIcons = exactNameMatches.map(icon => icon.content).join('\n\n');
|
|
60
|
+
return {
|
|
61
|
+
content: [{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: formattedIcons
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// use Fuse.js to fuzzy-search for the icons
|
|
69
|
+
const fuse = new Fuse(iconDocs, {
|
|
70
|
+
keys: [{
|
|
71
|
+
name: 'componentName',
|
|
72
|
+
weight: 3
|
|
73
|
+
}, {
|
|
74
|
+
name: 'keywords',
|
|
75
|
+
weight: 2
|
|
76
|
+
}, {
|
|
77
|
+
name: 'categorization',
|
|
78
|
+
weight: 1
|
|
79
|
+
}, {
|
|
80
|
+
name: 'usage',
|
|
81
|
+
weight: 1
|
|
82
|
+
}],
|
|
83
|
+
threshold: 0.4
|
|
84
|
+
});
|
|
85
|
+
const results = searchTerms.map(term => {
|
|
86
|
+
// always search exact match from the icons
|
|
87
|
+
const exactNameMatch = iconDocs.find(icon => icon.componentName.toLowerCase() === term.toLowerCase());
|
|
88
|
+
if (exactNameMatch) {
|
|
89
|
+
return [{
|
|
90
|
+
item: exactNameMatch
|
|
91
|
+
}];
|
|
92
|
+
}
|
|
93
|
+
return fuse.search(term).slice(0, limit);
|
|
94
|
+
}).flat();
|
|
95
|
+
|
|
96
|
+
// Remove duplicates based on componentName
|
|
97
|
+
const uniqueResults = results.filter((result, index, arr) => {
|
|
98
|
+
return arr.findIndex(r => r.item.componentName === result.item.componentName) === index;
|
|
99
|
+
});
|
|
100
|
+
const matchedIcons = uniqueResults.map(result => result.item);
|
|
101
|
+
const formattedIcons = matchedIcons.map(icon => icon.content).join('\n\n');
|
|
102
|
+
return {
|
|
103
|
+
content: [{
|
|
104
|
+
type: 'text',
|
|
105
|
+
text: formattedIcons
|
|
106
|
+
}]
|
|
107
|
+
};
|
|
108
|
+
};
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
import Fuse from 'fuse.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { zodToJsonSchema } from '
|
|
4
|
-
import {
|
|
5
|
-
import { cleanQuery } from '../../helpers';
|
|
6
|
-
import { tokenToMarkdown } from '../../structured-content/formatters/token';
|
|
7
|
-
// Transform Token[] from token-metadata to TokenSchema[] format
|
|
8
|
-
function transformTokensToSchemas() {
|
|
9
|
-
return tokens.map(token => {
|
|
10
|
-
var _token$exampleValue;
|
|
11
|
-
return {
|
|
12
|
-
contentType: 'token',
|
|
13
|
-
name: token.name,
|
|
14
|
-
path: token.path,
|
|
15
|
-
description: token.description,
|
|
16
|
-
exampleValue: String((_token$exampleValue = token.exampleValue) !== null && _token$exampleValue !== void 0 ? _token$exampleValue : '')
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
}
|
|
3
|
+
import { cleanQuery, zodToJsonSchema } from '../../helpers';
|
|
4
|
+
import { tokenStructuredContent } from './token-structured-content.codegen';
|
|
20
5
|
export const getTokensInputSchema = z.object({
|
|
21
6
|
terms: z.array(z.string()).default([]).describe('An array of search terms to find tokens by name or description, eg. `["spacing", "inverted text", "background primary"]`. If empty or not provided, returns all tokens.').optional(),
|
|
22
7
|
limit: z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
@@ -50,11 +35,11 @@ export const getTokensTool = async params => {
|
|
|
50
35
|
exactName = false
|
|
51
36
|
} = params;
|
|
52
37
|
const searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
53
|
-
const tokenDocs =
|
|
38
|
+
const tokenDocs = tokenStructuredContent;
|
|
54
39
|
|
|
55
40
|
// If no search terms provided, return all tokens formatted as Markdown
|
|
56
41
|
if (searchTerms.length === 0) {
|
|
57
|
-
const allTokensMarkdown = tokenDocs.map(
|
|
42
|
+
const allTokensMarkdown = tokenDocs.map(token => token.content).join('\n\n');
|
|
58
43
|
return {
|
|
59
44
|
content: [{
|
|
60
45
|
type: 'text',
|
|
@@ -68,9 +53,9 @@ export const getTokensTool = async params => {
|
|
|
68
53
|
// for each search term, search for the exact match
|
|
69
54
|
const exactNameMatches = searchTerms.map(term => {
|
|
70
55
|
return tokenDocs.find(token => token.name.toLowerCase() === term.toLowerCase());
|
|
71
|
-
}).filter(
|
|
56
|
+
}).filter(token => token !== undefined);
|
|
72
57
|
if (exactNameMatches.length > 0) {
|
|
73
|
-
const formattedTokens = exactNameMatches.map(
|
|
58
|
+
const formattedTokens = exactNameMatches.map(token => token.content).join('\n\n');
|
|
74
59
|
return {
|
|
75
60
|
content: [{
|
|
76
61
|
type: 'text',
|
|
@@ -103,7 +88,7 @@ export const getTokensTool = async params => {
|
|
|
103
88
|
return arr.findIndex(r => r.item.name === result.item.name) === index;
|
|
104
89
|
});
|
|
105
90
|
const matchedTokens = uniqueResults.map(result => result.item);
|
|
106
|
-
const formattedTokens = matchedTokens.map(
|
|
91
|
+
const formattedTokens = matchedTokens.map(token => token.content).join('\n\n');
|
|
107
92
|
return {
|
|
108
93
|
content: [{
|
|
109
94
|
type: 'text',
|