@storybook/addon-mcp 10.6.0-alpha.9 → 10.6.0-beta.1

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/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3qkmgvteapu from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3qkmgvteapu from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3qkmgvteapu from "node:module";
1
+ import CJS_COMPAT_NODE_URL_es7cmh0y1nl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_es7cmh0y1nl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_es7cmh0y1nl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3qkmgvteapu.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3qkmgvteapu.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3qkmgvteapu.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_es7cmh0y1nl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_es7cmh0y1nl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_es7cmh0y1nl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -18,7 +18,7 @@ import { HttpTransport } from "@tmcp/transport-http";
18
18
  // package.json
19
19
  var package_default = {
20
20
  name: "@storybook/addon-mcp",
21
- version: "10.6.0-alpha.9",
21
+ version: "10.6.0-beta.1",
22
22
  description: "Help agents automatically write and test stories for your UI components",
23
23
  keywords: [
24
24
  "ai",
@@ -1124,7 +1124,19 @@ var OAuthResourceMetadata = v2.object({
1124
1124
  for (let ref of refs)
1125
1125
  try {
1126
1126
  let result = await this.#checkRef(ref.url);
1127
- if (result === "no-manifest" || (this.#refsWithManifests.push(ref), result === "public")) continue;
1127
+ if (result === "manifest-not-found") {
1128
+ logger5.warn(
1129
+ `[addon-mcp] Skipping composed ref "${ref.title}" (${ref.url}): components manifest not found at ${ref.url}/manifests/components.json. Enable the \`componentsManifest\` feature on that Storybook to compose it into MCP.`
1130
+ );
1131
+ continue;
1132
+ }
1133
+ if (result === "manifest-invalid") {
1134
+ logger5.warn(
1135
+ `[addon-mcp] Skipping composed ref "${ref.title}" (${ref.url}): its components manifest failed validation. This usually means a version mismatch between the composed Storybook and this one \u2014 upgrade the older side.`
1136
+ );
1137
+ continue;
1138
+ }
1139
+ if (this.#refsWithManifests.push(ref), result === "public") continue;
1128
1140
  if (this.#authRequiredUrls.push(ref.url), !this.#authRequirement)
1129
1141
  this.#authRequirement = result;
1130
1142
  else {
@@ -1135,7 +1147,7 @@ var OAuthResourceMetadata = v2.object({
1135
1147
  }
1136
1148
  } catch (error) {
1137
1149
  logger5.warn(
1138
- `[addon-mcp] Failed to check auth for composed ref "${ref.title}" (${ref.url}): ${error instanceof Error ? error.message : String(error)}. Skipping this ref.`
1150
+ `[addon-mcp] Skipping composed ref "${ref.title}" (${ref.url}): the ref could not be reached (${error instanceof Error ? error.message : String(error)}). Refs are only checked at dev-server boot \u2014 restart Storybook once the ref is reachable.`
1139
1151
  );
1140
1152
  }
1141
1153
  }
@@ -1185,7 +1197,7 @@ var OAuthResourceMetadata = v2.object({
1185
1197
  */
1186
1198
  createManifestProvider(localOrigin) {
1187
1199
  return async (request, path2, source) => {
1188
- let token = extractBearerToken(request?.headers.get("Authorization")), remoteSource = source?.url ? { ...source, url: source.url } : void 0, baseUrl = remoteSource?.url ?? localOrigin, manifestUrl = `${baseUrl}${path2.replace("./", "/")}`, isRemote = !!remoteSource, tokenForRequest = isRemote && this.#isAuthRequiredUrl(baseUrl) ? token : null;
1200
+ let token = extractBearerToken(request?.headers.get("Authorization")), remoteSource = source?.url ? { ...source, url: source.url } : void 0, baseUrl = remoteSource?.url ?? localOrigin, manifestUrl = `${baseUrl}${path2.replace(/^\.\//, "/")}`, isRemote = !!remoteSource, tokenForRequest = isRemote && this.#isAuthRequiredUrl(baseUrl) ? token : null;
1189
1201
  if (token && token !== this.#lastToken && (this.#manifestCache.clear(), this.#lastToken = token), isRemote) {
1190
1202
  let cached = this.#manifestCache.get(manifestUrl);
1191
1203
  if (cached)
@@ -1231,20 +1243,26 @@ var OAuthResourceMetadata = v2.object({
1231
1243
  /**
1232
1244
  * Check a ref to determine if it has a manifest and whether it requires auth.
1233
1245
  * Returns 'public' if the ref has a valid manifest without auth,
1234
- * 'no-manifest' if no manifest is available, or an AuthRequirement if auth is needed.
1246
+ * an AuthRequirement if auth is needed, or the reason the ref has no usable manifest:
1247
+ * 'manifest-not-found' for a non-OK or non-JSON response (SPA fallback pages land here),
1248
+ * 'manifest-invalid' for real JSON that fails the manifest schema.
1235
1249
  */
1236
1250
  async #checkRef(refUrl) {
1237
1251
  let response = await fetch(`${refUrl}/manifests/components.json`, {
1238
1252
  headers: { Accept: "application/json" }
1239
1253
  }), authReq = await this.#parseAuthFromResponse(response);
1240
1254
  if (authReq) return authReq;
1255
+ let noManifestReason = "manifest-not-found";
1241
1256
  if (response.ok) {
1242
- let text = await response.text();
1243
- if (v2.safeParse(v2.pipe(v2.string(), v2.parseJson(), ComponentManifestMap), text).success)
1244
- return "public";
1257
+ let text = await response.text(), json = v2.safeParse(v2.pipe(v2.string(), v2.parseJson()), text);
1258
+ if (json.success) {
1259
+ if (v2.safeParse(ComponentManifestMap, json.output).success)
1260
+ return "public";
1261
+ noManifestReason = "manifest-invalid";
1262
+ }
1245
1263
  }
1246
1264
  let mcpAuth = await this.#checkMcpAuth(refUrl);
1247
- return mcpAuth || "no-manifest";
1265
+ return mcpAuth || noManifestReason;
1248
1266
  }
1249
1267
  /** Check /mcp endpoint for 401 auth requirement. */
1250
1268
  async #checkMcpAuth(refUrl) {
@@ -1315,12 +1333,12 @@ async function getRefsFromConfig(options) {
1315
1333
  return !refs || typeof refs != "object" ? [] : Object.entries(refs).flatMap(([key, value]) => {
1316
1334
  if (!value || typeof value != "object")
1317
1335
  return [];
1318
- let { title, url: url2 } = value;
1319
- return typeof url2 != "string" || url2.length === 0 ? [] : [
1336
+ let { title, url: url2, disable } = value;
1337
+ return disable || typeof url2 != "string" || url2.length === 0 ? [] : [
1320
1338
  {
1321
1339
  id: key,
1322
1340
  title: typeof title == "string" && title.length > 0 ? title : key,
1323
- url: url2
1341
+ url: url2.replace(/\/$/, "")
1324
1342
  }
1325
1343
  ];
1326
1344
  });
@@ -4,7 +4,7 @@ var MCP_APP_PARAM = "mcp-app", MCP_APP_SIZE_CHANGED_EVENT = "storybook-mcp:size-
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "@storybook/addon-mcp",
7
- version: "10.6.0-alpha.9",
7
+ version: "10.6.0-beta.1",
8
8
  description: "Help agents automatically write and test stories for your UI components",
9
9
  keywords: [
10
10
  "ai",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-mcp",
3
- "version": "10.6.0-alpha.9",
3
+ "version": "10.6.0-beta.1",
4
4
  "description": "Help agents automatically write and test stories for your UI components",
5
5
  "keywords": [
6
6
  "ai",
@@ -42,14 +42,14 @@
42
42
  "valibot": "^1.4.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@storybook/addon-a11y": "10.6.0-alpha.9",
46
- "@storybook/addon-vitest": "10.6.0-alpha.9",
47
- "storybook": "10.6.0-alpha.9",
45
+ "@storybook/addon-a11y": "10.6.0-beta.1",
46
+ "@storybook/addon-vitest": "10.6.0-beta.1",
47
+ "storybook": "10.6.0-beta.1",
48
48
  "typescript": "^6.0.3"
49
49
  },
50
50
  "peerDependencies": {
51
- "@storybook/addon-vitest": "^10.6.0-alpha.9",
52
- "storybook": "^10.6.0-alpha.9"
51
+ "@storybook/addon-vitest": "^10.6.0-beta.1",
52
+ "storybook": "^10.6.0-beta.1"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@storybook/addon-vitest": {