@storybook/addon-mcp 10.6.1 → 10.6.3

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_m4mfx79ksbq from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_m4mfx79ksbq from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_m4mfx79ksbq from "node:module";
1
+ import CJS_COMPAT_NODE_URL_d74g6oer3t5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_d74g6oer3t5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_d74g6oer3t5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_m4mfx79ksbq.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_m4mfx79ksbq.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_m4mfx79ksbq.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_d74g6oer3t5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_d74g6oer3t5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_d74g6oer3t5.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.1",
21
+ version: "10.6.3",
22
22
  description: "Help agents automatically write and test stories for your UI components",
23
23
  keywords: [
24
24
  "ai",
@@ -838,8 +838,10 @@ import {
838
838
  createLocalDocsAccess,
839
839
  getEffectiveToolAvailability as getEffectiveToolAvailability3,
840
840
  getToolAvailability as getToolAvailability3,
841
+ isValidHost,
841
842
  loadManifests
842
843
  } from "storybook/internal/core-server";
844
+ import { isWebContainer } from "storybook/internal/common";
843
845
 
844
846
  // src/template.html
845
847
  var template_default = `<!doctype html>
@@ -1514,7 +1516,24 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
1514
1516
  let addonOptions = v5.parse(AddonOptions, {
1515
1517
  endpoint: options.endpoint,
1516
1518
  toolsets: options.toolsets ?? {}
1517
- }), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT, { refs, compositionAuth, sources, multiSource } = await resolveCompositionSources(options), rawAvailability = await getToolAvailability3(options), localAccess = rawAvailability.docgenServer && refs.length > 0 ? createLocalDocsAccess({
1519
+ }), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT, core = await options.presets.apply("core", {}), hostValidation = {
1520
+ host: options.host,
1521
+ allowedHosts: core?.allowedHosts,
1522
+ localAddress: options.localAddress,
1523
+ networkAddress: options.networkAddress
1524
+ }, skipOriginValidation = isWebContainer(), rejectDisallowedOrigin = (req, res) => {
1525
+ if (skipOriginValidation)
1526
+ return !1;
1527
+ let { origin: requestOrigin } = req.headers;
1528
+ if (!requestOrigin)
1529
+ return !1;
1530
+ try {
1531
+ if (isValidHost(new URL(requestOrigin).host, hostValidation))
1532
+ return !1;
1533
+ } catch {
1534
+ }
1535
+ return res.writeHead(403, { "Content-Type": "text/plain" }), res.end("Invalid origin"), !0;
1536
+ }, rejectNonJsonBody = (req, res) => req.headers["content-type"]?.split(";")[0].trim().toLowerCase() === "application/json" ? !1 : (res.writeHead(415, { "Content-Type": "text/plain" }), res.end("Unsupported Media Type: Content-Type must be application/json"), !0), { refs, compositionAuth, sources, multiSource } = await resolveCompositionSources(options), rawAvailability = await getToolAvailability3(options), localAccess = rawAvailability.docgenServer && refs.length > 0 ? createLocalDocsAccess({
1518
1537
  storyIndex: { getIndex: () => getStoryIndex(options) },
1519
1538
  getManifests: () => loadManifests(options.presets)
1520
1539
  }) : void 0, createManifestProvider;
@@ -1539,7 +1558,7 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
1539
1558
  }), res.end("401 - Unauthorized"), !0) : !1;
1540
1559
  };
1541
1560
  app.post(endpoint, (req, res) => {
1542
- if (!requireAuth(req, res))
1561
+ if (!rejectDisallowedOrigin(req, res) && !requireAuth(req, res) && !rejectNonJsonBody(req, res))
1543
1562
  return mcpServerHandler({
1544
1563
  req,
1545
1564
  res,
@@ -1563,6 +1582,7 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
1563
1582
  a11yEnabled: a11yEnabled2
1564
1583
  } = getEffectiveToolAvailability3(rawAvailability, { multiSource }), isDevEnabled = addonOptions.toolsets?.dev ?? !0, isDocsEnabled = docsEnabled && (addonOptions.toolsets?.docs ?? !0), isTestEnabled = testSupported && (addonOptions.toolsets?.test ?? !0);
1565
1584
  return app.get(endpoint, (req, res) => {
1585
+ if (rejectDisallowedOrigin(req, res)) return;
1566
1586
  if (!req.headers.accept?.includes("text/html"))
1567
1587
  return requireAuth(req, res) ? void 0 : mcpServerHandler({
1568
1588
  req,
@@ -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.1",
7
+ version: "10.6.3",
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.1",
3
+ "version": "10.6.3",
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.1",
46
- "@storybook/addon-vitest": "10.6.1",
47
- "storybook": "10.6.1",
45
+ "@storybook/addon-a11y": "10.6.3",
46
+ "@storybook/addon-vitest": "10.6.3",
47
+ "storybook": "10.6.3",
48
48
  "typescript": "^6.0.3"
49
49
  },
50
50
  "peerDependencies": {
51
- "@storybook/addon-vitest": "^10.6.1",
52
- "storybook": "^10.6.1"
51
+ "@storybook/addon-vitest": "^10.6.3",
52
+ "storybook": "^10.6.3"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@storybook/addon-vitest": {