@storybook/addon-mcp 11.0.0-alpha.5 → 11.0.0-alpha.6
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_beh7n2jjxhf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_beh7n2jjxhf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_beh7n2jjxhf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_beh7n2jjxhf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_beh7n2jjxhf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_beh7n2jjxhf.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: "11.0.0-alpha.
|
|
21
|
+
version: "11.0.0-alpha.6",
|
|
22
22
|
description: "Help agents automatically write and test stories for your UI components",
|
|
23
23
|
keywords: [
|
|
24
24
|
"ai",
|
|
@@ -780,8 +780,10 @@ import {
|
|
|
780
780
|
createLocalDocsAccess,
|
|
781
781
|
getEffectiveToolAvailability as getEffectiveToolAvailability2,
|
|
782
782
|
getToolAvailability as getToolAvailability2,
|
|
783
|
+
isValidHost,
|
|
783
784
|
loadManifests
|
|
784
785
|
} from "storybook/internal/core-server";
|
|
786
|
+
import { isWebContainer } from "storybook/internal/common";
|
|
785
787
|
|
|
786
788
|
// src/template.html
|
|
787
789
|
var template_default = `<!doctype html>
|
|
@@ -1303,7 +1305,24 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1303
1305
|
let addonOptions = v3.parse(AddonOptions, {
|
|
1304
1306
|
endpoint: options.endpoint,
|
|
1305
1307
|
toolsets: options.toolsets ?? {}
|
|
1306
|
-
}), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT,
|
|
1308
|
+
}), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT, core = await options.presets.apply("core", {}), hostValidation = {
|
|
1309
|
+
host: options.host,
|
|
1310
|
+
allowedHosts: core?.allowedHosts,
|
|
1311
|
+
localAddress: options.localAddress,
|
|
1312
|
+
networkAddress: options.networkAddress
|
|
1313
|
+
}, skipOriginValidation = isWebContainer(), rejectDisallowedOrigin = (req, res) => {
|
|
1314
|
+
if (skipOriginValidation)
|
|
1315
|
+
return !1;
|
|
1316
|
+
let { origin: requestOrigin } = req.headers;
|
|
1317
|
+
if (!requestOrigin)
|
|
1318
|
+
return !1;
|
|
1319
|
+
try {
|
|
1320
|
+
if (isValidHost(new URL(requestOrigin).host, hostValidation))
|
|
1321
|
+
return !1;
|
|
1322
|
+
} catch {
|
|
1323
|
+
}
|
|
1324
|
+
return res.writeHead(403, { "Content-Type": "text/plain" }), res.end("Invalid origin"), !0;
|
|
1325
|
+
}, 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 getToolAvailability2(options), localAccess = rawAvailability.docgenServer && refs.length > 0 ? createLocalDocsAccess({
|
|
1307
1326
|
storyIndex: { getIndex: () => getStoryIndex(options) },
|
|
1308
1327
|
getManifests: () => loadManifests(options.presets)
|
|
1309
1328
|
}) : void 0, createManifestProvider;
|
|
@@ -1328,7 +1347,7 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1328
1347
|
}), res.end("401 - Unauthorized"), !0) : !1;
|
|
1329
1348
|
};
|
|
1330
1349
|
app.post(endpoint, (req, res) => {
|
|
1331
|
-
if (!requireAuth(req, res))
|
|
1350
|
+
if (!rejectDisallowedOrigin(req, res) && !requireAuth(req, res) && !rejectNonJsonBody(req, res))
|
|
1332
1351
|
return mcpServerHandler({
|
|
1333
1352
|
req,
|
|
1334
1353
|
res,
|
|
@@ -1349,6 +1368,7 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1349
1368
|
a11yEnabled: a11yEnabled2
|
|
1350
1369
|
} = getEffectiveToolAvailability2(rawAvailability, { multiSource }), isDevEnabled = addonOptions.toolsets?.dev ?? !0, isDocsEnabled = docsEnabled && (addonOptions.toolsets?.docs ?? !0), isTestEnabled = testSupported && (addonOptions.toolsets?.test ?? !0);
|
|
1351
1370
|
return app.get(endpoint, (req, res) => {
|
|
1371
|
+
if (rejectDisallowedOrigin(req, res)) return;
|
|
1352
1372
|
if (!req.headers.accept?.includes("text/html"))
|
|
1353
1373
|
return requireAuth(req, res) ? void 0 : mcpServerHandler({
|
|
1354
1374
|
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: "11.0.0-alpha.
|
|
7
|
+
version: "11.0.0-alpha.6",
|
|
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": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.6",
|
|
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": "11.0.0-alpha.
|
|
46
|
-
"@storybook/addon-vitest": "11.0.0-alpha.
|
|
47
|
-
"storybook": "11.0.0-alpha.
|
|
45
|
+
"@storybook/addon-a11y": "11.0.0-alpha.6",
|
|
46
|
+
"@storybook/addon-vitest": "11.0.0-alpha.6",
|
|
47
|
+
"storybook": "11.0.0-alpha.6",
|
|
48
48
|
"typescript": "^6.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@storybook/addon-vitest": "^11.0.0-alpha.
|
|
52
|
-
"storybook": "^11.0.0-alpha.
|
|
51
|
+
"@storybook/addon-vitest": "^11.0.0-alpha.6",
|
|
52
|
+
"storybook": "^11.0.0-alpha.6"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@storybook/addon-vitest": {
|