@storybook/addon-mcp 11.0.0-alpha.5 → 11.0.0-alpha.7
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_33mzoiqig3f from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_33mzoiqig3f from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_33mzoiqig3f from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_33mzoiqig3f.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_33mzoiqig3f.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_33mzoiqig3f.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.7",
|
|
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>
|
|
@@ -972,9 +974,11 @@ var template_default = `<!doctype html>
|
|
|
972
974
|
<code>@storybook/addon-mcp</code>.
|
|
973
975
|
</p>
|
|
974
976
|
<p>
|
|
975
|
-
See how to connect to it from your coding agent in
|
|
976
|
-
<a
|
|
977
|
-
|
|
977
|
+
See how to connect to it from your coding agent in the
|
|
978
|
+
<a
|
|
979
|
+
target="_blank"
|
|
980
|
+
href="https://storybook.js.org/docs/ai/mcp/overview#3-add-the-mcp-server-to-your-agent"
|
|
981
|
+
>agent connection setup guide</a
|
|
978
982
|
>.
|
|
979
983
|
</p>
|
|
980
984
|
|
|
@@ -1303,7 +1307,24 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1303
1307
|
let addonOptions = v3.parse(AddonOptions, {
|
|
1304
1308
|
endpoint: options.endpoint,
|
|
1305
1309
|
toolsets: options.toolsets ?? {}
|
|
1306
|
-
}), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT,
|
|
1310
|
+
}), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT, core = await options.presets.apply("core", {}), hostValidation = {
|
|
1311
|
+
host: options.host,
|
|
1312
|
+
allowedHosts: core?.allowedHosts,
|
|
1313
|
+
localAddress: options.localAddress,
|
|
1314
|
+
networkAddress: options.networkAddress
|
|
1315
|
+
}, skipOriginValidation = isWebContainer(), rejectDisallowedOrigin = (req, res) => {
|
|
1316
|
+
if (skipOriginValidation)
|
|
1317
|
+
return !1;
|
|
1318
|
+
let { origin: requestOrigin } = req.headers;
|
|
1319
|
+
if (!requestOrigin)
|
|
1320
|
+
return !1;
|
|
1321
|
+
try {
|
|
1322
|
+
if (isValidHost(new URL(requestOrigin).host, hostValidation))
|
|
1323
|
+
return !1;
|
|
1324
|
+
} catch {
|
|
1325
|
+
}
|
|
1326
|
+
return res.writeHead(403, { "Content-Type": "text/plain" }), res.end("Invalid origin"), !0;
|
|
1327
|
+
}, 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
1328
|
storyIndex: { getIndex: () => getStoryIndex(options) },
|
|
1308
1329
|
getManifests: () => loadManifests(options.presets)
|
|
1309
1330
|
}) : void 0, createManifestProvider;
|
|
@@ -1328,7 +1349,7 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1328
1349
|
}), res.end("401 - Unauthorized"), !0) : !1;
|
|
1329
1350
|
};
|
|
1330
1351
|
app.post(endpoint, (req, res) => {
|
|
1331
|
-
if (!requireAuth(req, res))
|
|
1352
|
+
if (!rejectDisallowedOrigin(req, res) && !requireAuth(req, res) && !rejectNonJsonBody(req, res))
|
|
1332
1353
|
return mcpServerHandler({
|
|
1333
1354
|
req,
|
|
1334
1355
|
res,
|
|
@@ -1349,6 +1370,7 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1349
1370
|
a11yEnabled: a11yEnabled2
|
|
1350
1371
|
} = getEffectiveToolAvailability2(rawAvailability, { multiSource }), isDevEnabled = addonOptions.toolsets?.dev ?? !0, isDocsEnabled = docsEnabled && (addonOptions.toolsets?.docs ?? !0), isTestEnabled = testSupported && (addonOptions.toolsets?.test ?? !0);
|
|
1351
1372
|
return app.get(endpoint, (req, res) => {
|
|
1373
|
+
if (rejectDisallowedOrigin(req, res)) return;
|
|
1352
1374
|
if (!req.headers.accept?.includes("text/html"))
|
|
1353
1375
|
return requireAuth(req, res) ? void 0 : mcpServerHandler({
|
|
1354
1376
|
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.7",
|
|
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.7",
|
|
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.7",
|
|
46
|
+
"@storybook/addon-vitest": "11.0.0-alpha.7",
|
|
47
|
+
"storybook": "11.0.0-alpha.7",
|
|
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.7",
|
|
52
|
+
"storybook": "^11.0.0-alpha.7"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@storybook/addon-vitest": {
|