@adobe/design-data-mcp 1.4.1 → 1.5.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 +116 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/design-data-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
31
31
|
"@adobe/design-data-wasm": "0.4.0",
|
|
32
|
-
"@adobe/spectrum-design-data": "0.
|
|
32
|
+
"@adobe/spectrum-design-data": "0.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"ava": "^6.0.1"
|
package/src/tools/design-data.js
CHANGED
|
@@ -52,6 +52,45 @@ function resolveSpectrumDataPackage() {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Load a JSON file from a subdirectory of the design-data package.
|
|
57
|
+
* Throws descriptive errors when the package or file is absent.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} subdir - e.g. "components" or "guidelines"
|
|
60
|
+
* @param {string} id - kebab-case slug, e.g. "button" or "colors"
|
|
61
|
+
*/
|
|
62
|
+
function loadDataFile(subdir, id) {
|
|
63
|
+
const pkgRoot = resolveSpectrumDataPackage();
|
|
64
|
+
if (!pkgRoot) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`@adobe/spectrum-design-data is not installed — cannot load ${subdir}/${id}. ` +
|
|
67
|
+
`Install it with: pnpm add @adobe/spectrum-design-data`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const filePath = join(pkgRoot, subdir, `${id}.json`);
|
|
71
|
+
if (!existsSync(filePath)) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Not found: "${id}" in ${subdir}/. ` +
|
|
74
|
+
(subdir === "components"
|
|
75
|
+
? `Call design-data-primer to see available component IDs.`
|
|
76
|
+
: `Call design-data-guideline-list to see available guideline IDs.`),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Load the guidelines/manifest.json catalog.
|
|
84
|
+
* Returns null when the file does not exist (guidelines not yet generated).
|
|
85
|
+
*/
|
|
86
|
+
function loadGuidelineManifest() {
|
|
87
|
+
const pkgRoot = resolveSpectrumDataPackage();
|
|
88
|
+
if (!pkgRoot) return null;
|
|
89
|
+
const manifestPath = join(pkgRoot, "guidelines", "manifest.json");
|
|
90
|
+
if (!existsSync(manifestPath)) return null;
|
|
91
|
+
return JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
92
|
+
}
|
|
93
|
+
|
|
55
94
|
export function createDesignDataTools() {
|
|
56
95
|
return [
|
|
57
96
|
// ── primer ─────────────────────────────────────────────────────────────
|
|
@@ -60,8 +99,8 @@ export function createDesignDataTools() {
|
|
|
60
99
|
description:
|
|
61
100
|
"Get a structural overview of the Spectrum design dataset: token count, " +
|
|
62
101
|
"available mode-sets (color-scheme, scale, contrast), component list, " +
|
|
63
|
-
"taxonomy fields, and data provenance. Call this at the
|
|
64
|
-
"design-token session to understand what data is available.",
|
|
102
|
+
"taxonomy fields, guideline categories, and data provenance. Call this at the " +
|
|
103
|
+
"start of a design-token session to understand what data is available.",
|
|
65
104
|
inputSchema: {
|
|
66
105
|
type: "object",
|
|
67
106
|
properties: {},
|
|
@@ -70,6 +109,16 @@ export function createDesignDataTools() {
|
|
|
70
109
|
async handler() {
|
|
71
110
|
const [wasm, ds] = await Promise.all([getWasm(), getDataset()]);
|
|
72
111
|
|
|
112
|
+
const manifest = loadGuidelineManifest();
|
|
113
|
+
const guidelinesSummary = manifest
|
|
114
|
+
? {
|
|
115
|
+
count: manifest.guidelines.length,
|
|
116
|
+
categories: [
|
|
117
|
+
...new Set(manifest.guidelines.map((g) => g.category)),
|
|
118
|
+
].sort(),
|
|
119
|
+
}
|
|
120
|
+
: null;
|
|
121
|
+
|
|
73
122
|
return {
|
|
74
123
|
source: "embedded",
|
|
75
124
|
tokenCount: ds.tokenCount(),
|
|
@@ -84,6 +133,7 @@ export function createDesignDataTools() {
|
|
|
84
133
|
},
|
|
85
134
|
components: wasm.getFieldValues("component") ?? [],
|
|
86
135
|
properties: wasm.getFieldValues("property") ?? [],
|
|
136
|
+
guidelines: guidelinesSummary,
|
|
87
137
|
};
|
|
88
138
|
},
|
|
89
139
|
},
|
|
@@ -166,21 +216,7 @@ export function createDesignDataTools() {
|
|
|
166
216
|
additionalProperties: false,
|
|
167
217
|
},
|
|
168
218
|
async handler({ id }) {
|
|
169
|
-
|
|
170
|
-
if (!pkgRoot) {
|
|
171
|
-
throw new Error(
|
|
172
|
-
`@adobe/spectrum-design-data is not installed — cannot load component "${id}". ` +
|
|
173
|
-
`Install it with: pnpm add @adobe/spectrum-design-data`,
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
const componentFile = join(pkgRoot, "components", `${id}.json`);
|
|
177
|
-
if (!existsSync(componentFile)) {
|
|
178
|
-
throw new Error(
|
|
179
|
-
`Component not found: "${id}". ` +
|
|
180
|
-
`Call design-data-primer to see available component IDs.`,
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
return JSON.parse(readFileSync(componentFile, "utf-8"));
|
|
219
|
+
return loadDataFile("components", id);
|
|
184
220
|
},
|
|
185
221
|
},
|
|
186
222
|
|
|
@@ -230,5 +266,68 @@ export function createDesignDataTools() {
|
|
|
230
266
|
return result;
|
|
231
267
|
},
|
|
232
268
|
},
|
|
269
|
+
|
|
270
|
+
// ── guideline-list ──────────────────────────────────────────────────────
|
|
271
|
+
{
|
|
272
|
+
name: "design-data-guideline-list",
|
|
273
|
+
description:
|
|
274
|
+
"List available Spectrum design guideline pages. " +
|
|
275
|
+
"Returns catalog entries with slug, title, category, status, and sourceUrl. " +
|
|
276
|
+
"Use this to discover guideline IDs before calling design-data-guideline. " +
|
|
277
|
+
"Optionally filter by category: designing, fundamentals, developing, or support.",
|
|
278
|
+
inputSchema: {
|
|
279
|
+
type: "object",
|
|
280
|
+
properties: {
|
|
281
|
+
category: {
|
|
282
|
+
type: "string",
|
|
283
|
+
enum: ["designing", "fundamentals", "developing", "support"],
|
|
284
|
+
description:
|
|
285
|
+
"Filter results to a specific category (optional). " +
|
|
286
|
+
"Omit to return all guidelines.",
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
additionalProperties: false,
|
|
290
|
+
},
|
|
291
|
+
async handler({ category } = {}) {
|
|
292
|
+
const manifest = loadGuidelineManifest();
|
|
293
|
+
if (!manifest) {
|
|
294
|
+
throw new Error(
|
|
295
|
+
`guidelines/manifest.json not found in @adobe/spectrum-design-data. ` +
|
|
296
|
+
`Run: node tools/s2-docs-to-document-blocks/src/cli.js guideline`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
const entries = category
|
|
300
|
+
? manifest.guidelines.filter((g) => g.category === category)
|
|
301
|
+
: manifest.guidelines;
|
|
302
|
+
return { guidelines: entries, total: entries.length };
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
// ── guideline ───────────────────────────────────────────────────────────
|
|
307
|
+
{
|
|
308
|
+
name: "design-data-guideline",
|
|
309
|
+
description:
|
|
310
|
+
"Get the full guideline document for a Spectrum design page by ID. " +
|
|
311
|
+
"Returns the guideline's title, category, metadata, and documentBlocks body " +
|
|
312
|
+
"(purpose, guideline, accessibility, do-dont, and examples blocks). " +
|
|
313
|
+
"Call design-data-guideline-list first to discover available guideline IDs. " +
|
|
314
|
+
"The `id` is the `slug` value returned by design-data-guideline-list.",
|
|
315
|
+
inputSchema: {
|
|
316
|
+
type: "object",
|
|
317
|
+
properties: {
|
|
318
|
+
id: {
|
|
319
|
+
type: "string",
|
|
320
|
+
description:
|
|
321
|
+
"Guideline ID (kebab-case slug) as returned by design-data-guideline-list, " +
|
|
322
|
+
"e.g. colors, motion, typography-fundamentals",
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
required: ["id"],
|
|
326
|
+
additionalProperties: false,
|
|
327
|
+
},
|
|
328
|
+
async handler({ id }) {
|
|
329
|
+
return loadDataFile("guidelines", id);
|
|
330
|
+
},
|
|
331
|
+
},
|
|
233
332
|
];
|
|
234
333
|
}
|