@adobe/design-data-mcp 1.7.35 → 1.7.37

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/README.md CHANGED
@@ -51,6 +51,11 @@ package version — there's no separate data update to run. Pin `@latest` (as ab
51
51
  fetches the newest published version rather than reusing whatever it last cached; `-y` alone
52
52
  only skips the install confirmation, it doesn't force a re-fetch. Call `design-data-primer` and
53
53
  check `provenance.designDataVersion` to see which dataset version is embedded.
54
+ `design-data-primer` also does a best-effort check against the latest published
55
+ `@adobe/spectrum-design-data` version — if the embedded dataset is behind, it adds a
56
+ `provenance.datasetStatus` field and logs a one-line warning to stderr. This is silent on
57
+ any network failure (offline/air-gapped use is unaffected); set
58
+ `DESIGN_DATA_SKIP_VERSION_CHECK=1` to disable the check entirely.
54
59
 
55
60
  ## Tools
56
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/design-data-mcp",
3
- "version": "1.7.35",
3
+ "version": "1.7.37",
4
4
  "description": "MCP server for Spectrum design tokens, component schemas, and design guidelines (embedded, offline)",
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.7.0",
32
- "@adobe/spectrum-design-data": "2.7.0"
32
+ "@adobe/spectrum-design-data": "3.0.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@anthropic-ai/mcpb": "^2.1.2",
@@ -0,0 +1,95 @@
1
+ // Copyright 2026 Adobe. All rights reserved.
2
+ // This file is licensed to you under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License. You may obtain a copy
4
+ // of the License at http://www.apache.org/licenses/LICENSE-2.0
5
+ //
6
+ // Unless required by applicable law or agreed to in writing, software distributed under
7
+ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ // OF ANY KIND, either express or implied. See the License for the specific language
9
+ // governing permissions and limitations under the License.
10
+
11
+ /**
12
+ * Best-effort runtime check that the embedded dataset (provenance.designDataVersion,
13
+ * baked into @adobe/design-data-wasm at build time) isn't behind the latest published
14
+ * @adobe/spectrum-design-data. See spectrum-design-data-9fe.5 — a plain `npx -y <pkg>`
15
+ * (no @latest tag) can silently reuse a cached older wasm build.
16
+ *
17
+ * Deliberately silent on any failure (offline, registry down, timeout): this is a
18
+ * courtesy signal, never a reason to break the primer response.
19
+ */
20
+
21
+ const REGISTRY_URL =
22
+ "https://registry.npmjs.org/@adobe/spectrum-design-data/latest";
23
+ const TIMEOUT_MS = 1500;
24
+
25
+ /**
26
+ * Numeric major.minor.patch compare. ponytail: ignores prerelease/build tags;
27
+ * add real semver only if a data prerelease ships.
28
+ */
29
+ export function isBehind(embedded, latest) {
30
+ const a = String(embedded).split(".").map(Number);
31
+ const b = String(latest).split(".").map(Number);
32
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
33
+ const x = a[i] ?? 0;
34
+ const y = b[i] ?? 0;
35
+ if (x !== y) return x < y;
36
+ }
37
+ return false;
38
+ }
39
+
40
+ let warned = false;
41
+ let cached; // Promise<status|null>, memoized per process — cleared on failure so a
42
+ // transient network blip doesn't permanently disable the check (see fetchLatest).
43
+
44
+ /**
45
+ * @param {string} embeddedVersion - provenance.designDataVersion from ds.primer()
46
+ * @returns {Promise<{latestVersion: string, isStale: boolean, message?: string}|null>}
47
+ */
48
+ export function checkDatasetFreshness(embeddedVersion) {
49
+ if (!embeddedVersion || process.env.DESIGN_DATA_SKIP_VERSION_CHECK) {
50
+ return Promise.resolve(null);
51
+ }
52
+ if (!cached) {
53
+ cached = fetchLatest(embeddedVersion).then((status) => {
54
+ // A null result means the check failed (offline/timeout/registry error) —
55
+ // don't memoize failure, so the next primer call retries instead of being
56
+ // stuck with no freshness signal for the rest of the process.
57
+ if (status === null) cached = undefined;
58
+ return status;
59
+ });
60
+ }
61
+ return cached;
62
+ }
63
+
64
+ async function fetchLatest(embeddedVersion) {
65
+ const controller = new AbortController();
66
+ const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
67
+ try {
68
+ const res = await fetch(REGISTRY_URL, { signal: controller.signal });
69
+ if (!res.ok) return null;
70
+ const { version: latestVersion } = await res.json();
71
+ const isStale = isBehind(embeddedVersion, latestVersion);
72
+ const status = { latestVersion, isStale };
73
+ if (isStale) {
74
+ status.message =
75
+ `Embedded dataset (${embeddedVersion}) is behind the latest published ` +
76
+ `@adobe/spectrum-design-data (${latestVersion}). Reinstall with ` +
77
+ `npx -y @adobe/design-data-mcp@latest to pick up the newer snapshot.`;
78
+ if (!warned) {
79
+ warned = true;
80
+ console.error(`[design-data] ${status.message}`);
81
+ }
82
+ }
83
+ return status;
84
+ } catch {
85
+ return null;
86
+ } finally {
87
+ clearTimeout(timer);
88
+ }
89
+ }
90
+
91
+ /** Test-only: clear the memoized check + warn-once flag between cases. */
92
+ export function __resetFreshnessCache() {
93
+ warned = false;
94
+ cached = undefined;
95
+ }
@@ -20,6 +20,8 @@ import { createRequire } from "module";
20
20
  import { readFileSync, existsSync } from "fs";
21
21
  import { join, dirname, resolve, sep } from "path";
22
22
 
23
+ import { checkDatasetFreshness } from "../dataset-freshness.js";
24
+
23
25
  let _wasm;
24
26
  /** Lazy-load and cache the wasm module (nodejs target, no init() required). */
25
27
  async function getWasm() {
@@ -136,6 +138,11 @@ export function createDesignDataTools() {
136
138
  // Provenance carries source + designDataVersion (the @adobe/spectrum-design-data
137
139
  // package version baked into the wasm at build time via EMBEDDED_DATA_VERSION).
138
140
  const { provenance } = ds.primer();
141
+ // Best-effort staleness check (spectrum-design-data-9fe.5) — silent on
142
+ // failure, never blocks the primer response.
143
+ const datasetStatus = await checkDatasetFreshness(
144
+ provenance.designDataVersion,
145
+ );
139
146
 
140
147
  return {
141
148
  // top-level source is the legacy skill-contract field; provenance.source
@@ -155,7 +162,9 @@ export function createDesignDataTools() {
155
162
  components: wasm.getFieldValues("component") ?? [],
156
163
  properties: wasm.getFieldValues("property") ?? [],
157
164
  guidelines: guidelinesSummary,
158
- provenance,
165
+ provenance: datasetStatus
166
+ ? { ...provenance, datasetStatus }
167
+ : provenance,
159
168
  };
160
169
  },
161
170
  },