@adobe/design-data-mcp 1.2.0 → 1.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/package.json +2 -2
- package/src/tools/design-data.js +5 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/design-data-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "MCP server for Spectrum design tokens and component schemas via the design-data CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
31
|
-
"@adobe/design-data-wasm": "0.
|
|
31
|
+
"@adobe/design-data-wasm": "0.3.0",
|
|
32
32
|
"@adobe/spectrum-design-data": "0.3.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
package/src/tools/design-data.js
CHANGED
|
@@ -42,37 +42,6 @@ async function getDataset() {
|
|
|
42
42
|
return _dataset;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/**
|
|
46
|
-
* Score tokens by keyword-overlap against an intent string.
|
|
47
|
-
*
|
|
48
|
-
* Pure function — accepts the token array so it can be tested independently.
|
|
49
|
-
*
|
|
50
|
-
* @param {object[]} tokens - Array of token result objects with a `name` string.
|
|
51
|
-
* @param {string} intent - Natural-language intent to match against.
|
|
52
|
-
* @param {number} limit - Maximum results to return.
|
|
53
|
-
* @returns {{ name: string, confidence: number, uuid: string, raw: unknown }[]}
|
|
54
|
-
*/
|
|
55
|
-
export function scoreTokensByKeyword(tokens, intent, limit = 5) {
|
|
56
|
-
const words = intent.toLowerCase().split(/\s+/).filter(Boolean);
|
|
57
|
-
if (words.length === 0) return [];
|
|
58
|
-
return tokens
|
|
59
|
-
.map((token) => {
|
|
60
|
-
const nameStr = token.name?.toLowerCase() ?? "";
|
|
61
|
-
const matches = words.filter((w) => nameStr.includes(w)).length;
|
|
62
|
-
const confidence = matches / words.length;
|
|
63
|
-
return { token, confidence };
|
|
64
|
-
})
|
|
65
|
-
.filter(({ confidence }) => confidence > 0)
|
|
66
|
-
.sort((a, b) => b.confidence - a.confidence)
|
|
67
|
-
.slice(0, limit)
|
|
68
|
-
.map(({ token, confidence }) => ({
|
|
69
|
-
name: token.name,
|
|
70
|
-
confidence: Math.round(confidence * 100) / 100,
|
|
71
|
-
uuid: token.uuid,
|
|
72
|
-
raw: token.raw,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
45
|
/** Return the @adobe/spectrum-design-data package root directory, or null. */
|
|
77
46
|
function resolveSpectrumDataPackage() {
|
|
78
47
|
try {
|
|
@@ -149,10 +118,10 @@ export function createDesignDataTools() {
|
|
|
149
118
|
{
|
|
150
119
|
name: "design-data-suggest",
|
|
151
120
|
description:
|
|
152
|
-
"Suggest Spectrum tokens matching a natural-language intent using
|
|
153
|
-
"scoring
|
|
154
|
-
"
|
|
155
|
-
"
|
|
121
|
+
"Suggest Spectrum tokens matching a natural-language intent using Jaccard similarity " +
|
|
122
|
+
"scoring over token name segments, name-object fields, and description text. " +
|
|
123
|
+
"Returns matches ranked by confidence with token name, layer, value, and name object. " +
|
|
124
|
+
"Use when the user describes what they need rather than knowing the token name.",
|
|
156
125
|
inputSchema: {
|
|
157
126
|
type: "object",
|
|
158
127
|
properties: {
|
|
@@ -172,8 +141,7 @@ export function createDesignDataTools() {
|
|
|
172
141
|
},
|
|
173
142
|
async handler({ intent, limit = 5 }) {
|
|
174
143
|
const ds = await getDataset();
|
|
175
|
-
|
|
176
|
-
return scoreTokensByKeyword(allTokens, intent, limit);
|
|
144
|
+
return ds.suggest(intent, undefined, limit);
|
|
177
145
|
},
|
|
178
146
|
},
|
|
179
147
|
|