@storybook/addon-mcp 11.0.0-alpha.1 → 11.0.0-alpha.2
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_uhpf58tqxaa from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_uhpf58tqxaa from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_uhpf58tqxaa from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_uhpf58tqxaa.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_uhpf58tqxaa.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_uhpf58tqxaa.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.2",
|
|
22
22
|
description: "Help agents automatically write and test stories for your UI components",
|
|
23
23
|
keywords: [
|
|
24
24
|
"ai",
|
|
@@ -224,8 +224,7 @@ async function addGetUIBuildingInstructionsTool(server, enabled = () => server.c
|
|
|
224
224
|
toolsets: server.ctx.custom?.toolsets,
|
|
225
225
|
a11yEnabled: server.ctx.custom?.a11yEnabled,
|
|
226
226
|
addonVitestAvailable,
|
|
227
|
-
docsEnabled
|
|
228
|
-
reviewEnabled: server.ctx.custom?.reviewEnabled
|
|
227
|
+
docsEnabled
|
|
229
228
|
}) }]
|
|
230
229
|
};
|
|
231
230
|
} catch (error) {
|
|
@@ -273,8 +272,7 @@ async function buildStorybookStoryInstructions(options, {
|
|
|
273
272
|
toolsets,
|
|
274
273
|
a11yEnabled: a11yEnabled2,
|
|
275
274
|
addonVitestAvailable,
|
|
276
|
-
docsEnabled
|
|
277
|
-
reviewEnabled: reviewEnabledOverride
|
|
275
|
+
docsEnabled
|
|
278
276
|
} = {}) {
|
|
279
277
|
let inputs = await resolveSkillInputs(options);
|
|
280
278
|
return buildStoryInstructions({
|
|
@@ -282,7 +280,7 @@ async function buildStorybookStoryInstructions(options, {
|
|
|
282
280
|
framework: inputs.framework,
|
|
283
281
|
renderer: inputs.renderer,
|
|
284
282
|
changeDetectionEnabled: inputs.changeDetectionEnabled,
|
|
285
|
-
reviewEnabled:
|
|
283
|
+
reviewEnabled: inputs.reviewEnabled,
|
|
286
284
|
testSupported: (toolsets?.test ?? !0) && (addonVitestAvailable ?? inputs.testSupported),
|
|
287
285
|
a11yEnabled: a11yEnabled2 ?? inputs.a11yEnabled,
|
|
288
286
|
docsEnabled: (toolsets?.docs ?? !0) && (docsEnabled ?? inputs.docsEnabled)
|
|
@@ -516,7 +514,7 @@ function registerToolsetTool(server, options, enabled) {
|
|
|
516
514
|
// src/tools/tool-registry.ts
|
|
517
515
|
var isToolsetEnabled = (toolset, toolsets) => toolsets?.[toolset] ?? !0, isToolAvailable = (definition, context) => definition.available?.(context) ?? !0, isMetadataToolEnabled = (definition, context) => isToolsetEnabled(definition.toolset, context.toolsets) && isToolAvailable(definition, context), createToolsetEnabled = (server, toolset) => () => server.ctx.custom?.toolsets?.[toolset] ?? !0;
|
|
518
516
|
function fromToolset(definition) {
|
|
519
|
-
let { options, available,
|
|
517
|
+
let { options, available, ...rest } = definition;
|
|
520
518
|
return {
|
|
521
519
|
...rest,
|
|
522
520
|
// Read from the constant, not the registry: this array is built at import time, while toolsets
|
|
@@ -527,8 +525,8 @@ function fromToolset(definition) {
|
|
|
527
525
|
name: toMcpToolName3(options.method),
|
|
528
526
|
available: (context) => available?.(context) ?? !0,
|
|
529
527
|
getMetadata: () => getToolsetToolMetadata(options),
|
|
530
|
-
register: async (server,
|
|
531
|
-
registerToolsetTool(server, options,
|
|
528
|
+
register: async (server, _context, enabled) => {
|
|
529
|
+
registerToolsetTool(server, options, enabled);
|
|
532
530
|
}
|
|
533
531
|
};
|
|
534
532
|
}
|
|
@@ -596,8 +594,7 @@ var docsToolDefinitions = [
|
|
|
596
594
|
toolsets,
|
|
597
595
|
a11yEnabled: availability.a11yEnabled,
|
|
598
596
|
addonVitestAvailable: availability.testSupported,
|
|
599
|
-
docsEnabled: isToolsetEnabled("docs", toolsets) && availability.docsEnabled
|
|
600
|
-
reviewEnabled: availability.reviewEnabled
|
|
597
|
+
docsEnabled: isToolsetEnabled("docs", toolsets) && availability.docsEnabled
|
|
601
598
|
}) }] })
|
|
602
599
|
})
|
|
603
600
|
},
|
|
@@ -613,11 +610,7 @@ var docsToolDefinitions = [
|
|
|
613
610
|
}),
|
|
614
611
|
fromToolset({
|
|
615
612
|
toolset: "dev",
|
|
616
|
-
|
|
617
|
-
// context (explicit flag, or the trusted local-client header) decides whether a given MCP
|
|
618
|
-
// client actually sees the tool.
|
|
619
|
-
available: ({ availability }) => availability.reviewEnabledForCli,
|
|
620
|
-
wrapEnabled: (server, { availability }, enabled) => async () => (await enabled?.() ?? !0) && (server.ctx.custom?.reviewEnabled ?? availability.reviewEnabled),
|
|
613
|
+
available: ({ availability }) => availability.reviewEnabled,
|
|
621
614
|
options: {
|
|
622
615
|
method: "review.create",
|
|
623
616
|
mcpEventName: "tool:displayReview",
|
|
@@ -681,14 +674,11 @@ async function registerAddonMcpTools(server, context) {
|
|
|
681
674
|
}
|
|
682
675
|
|
|
683
676
|
// src/mcp-handler.ts
|
|
684
|
-
var transport, origin, initialize, disableTelemetry, a11yEnabled,
|
|
677
|
+
var transport, origin, initialize, disableTelemetry, a11yEnabled, initializeMCPServer = async (options, multiSource) => {
|
|
685
678
|
let core = await options.presets.apply("core", {}), features2 = await options.presets.apply("features", {});
|
|
686
679
|
disableTelemetry = core?.disableTelemetry ?? !1;
|
|
687
680
|
let rawAvailability = await getToolAvailability(options, { features: features2 }), availability = getEffectiveToolAvailability(rawAvailability, { multiSource });
|
|
688
|
-
a11yEnabled = availability.a11yEnabled
|
|
689
|
-
reviewEnabled: availability.reviewEnabled,
|
|
690
|
-
reviewEnabledForCli: availability.reviewEnabledForCli
|
|
691
|
-
};
|
|
681
|
+
a11yEnabled = availability.a11yEnabled;
|
|
692
682
|
let server, serverOptions = {
|
|
693
683
|
adapter: new ValibotJsonSchemaAdapter(),
|
|
694
684
|
get instructions() {
|
|
@@ -699,7 +689,7 @@ var transport, origin, initialize, disableTelemetry, a11yEnabled, reviewGates, i
|
|
|
699
689
|
docsEnabled: (server?.ctx.custom?.toolsets?.docs ?? !0) && availability.docsEnabled,
|
|
700
690
|
changeDetectionEnabled: availability.changeDetectionEnabled,
|
|
701
691
|
moduleGraphSupported: availability.moduleGraphSupported,
|
|
702
|
-
reviewEnabled:
|
|
692
|
+
reviewEnabled: availability.reviewEnabled
|
|
703
693
|
});
|
|
704
694
|
},
|
|
705
695
|
capabilities: {
|
|
@@ -736,7 +726,6 @@ var transport, origin, initialize, disableTelemetry, a11yEnabled, reviewGates, i
|
|
|
736
726
|
options,
|
|
737
727
|
endpoint,
|
|
738
728
|
toolsets: getToolsets(webRequest, addonOptions),
|
|
739
|
-
reviewEnabled: isReviewEnabledForRequest(webRequest, reviewGates),
|
|
740
729
|
cliClient: webRequest.headers.get(STORYBOOK_MCP_PROXY_HEADER) === "true",
|
|
741
730
|
origin,
|
|
742
731
|
disableTelemetry,
|
|
@@ -782,9 +771,6 @@ async function webResponseToServerResponse(webResponse, nodeResponse) {
|
|
|
782
771
|
}
|
|
783
772
|
nodeResponse.end();
|
|
784
773
|
}
|
|
785
|
-
function isReviewEnabledForRequest(request, gates) {
|
|
786
|
-
return gates.reviewEnabled || gates.reviewEnabledForCli && request.headers.get(STORYBOOK_MCP_PROXY_HEADER) === "true";
|
|
787
|
-
}
|
|
788
774
|
function getToolsets(request, addonOptions) {
|
|
789
775
|
let toolsetHeader = request.headers.get("X-MCP-Toolsets");
|
|
790
776
|
if (!toolsetHeader || toolsetHeader.trim() === "")
|
|
@@ -1332,31 +1318,9 @@ function extractBearerToken(authHeader) {
|
|
|
1332
1318
|
}
|
|
1333
1319
|
|
|
1334
1320
|
// src/auth/resolve-composition-sources.ts
|
|
1321
|
+
import { getRefsFromConfig } from "storybook/internal/core-server";
|
|
1335
1322
|
import { ComponentManifestMap as ComponentManifestMap2 } from "storybook/internal/toolsets-docs";
|
|
1336
1323
|
import * as v3 from "valibot";
|
|
1337
|
-
|
|
1338
|
-
// src/auth/get-refs-from-config.ts
|
|
1339
|
-
async function getRefsFromConfig(options) {
|
|
1340
|
-
try {
|
|
1341
|
-
let refs = await options.presets.apply("refs", {});
|
|
1342
|
-
return !refs || typeof refs != "object" ? [] : Object.entries(refs).flatMap(([key, value]) => {
|
|
1343
|
-
if (!value || typeof value != "object")
|
|
1344
|
-
return [];
|
|
1345
|
-
let { title, url: url2, disable } = value;
|
|
1346
|
-
return disable || typeof url2 != "string" || url2.length === 0 ? [] : [
|
|
1347
|
-
{
|
|
1348
|
-
id: key,
|
|
1349
|
-
title: typeof title == "string" && title.length > 0 ? title : key,
|
|
1350
|
-
url: url2.replace(/\/$/, "")
|
|
1351
|
-
}
|
|
1352
|
-
];
|
|
1353
|
-
});
|
|
1354
|
-
} catch {
|
|
1355
|
-
return [];
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
// src/auth/resolve-composition-sources.ts
|
|
1360
1324
|
var MANIFEST_PROBE_TIMEOUT_MS = 3e3;
|
|
1361
1325
|
async function resolveCompositionSources(options) {
|
|
1362
1326
|
let refs = await getRefsFromConfig(options), compositionAuth = new CompositionAuth();
|
|
@@ -1433,13 +1397,10 @@ async function buildStorybookAiMetadata(options, existingMetadata) {
|
|
|
1433
1397
|
let toolsets = v4.parse(AddonOptions, {
|
|
1434
1398
|
endpoint: options.endpoint,
|
|
1435
1399
|
toolsets: options.toolsets ?? {}
|
|
1436
|
-
}).toolsets, features2 = await options.presets.apply("features", {}), devEnabled = toolsets?.dev ?? !0, moduleGraphSupported = await isModuleGraphSupportedByBuilder(options),
|
|
1400
|
+
}).toolsets, features2 = await options.presets.apply("features", {}), devEnabled = toolsets?.dev ?? !0, moduleGraphSupported = await isModuleGraphSupportedByBuilder(options), availability = await getToolAvailability2(options, {
|
|
1437
1401
|
features: features2,
|
|
1438
1402
|
moduleGraphSupported
|
|
1439
|
-
}), availability = {
|
|
1440
|
-
...rawAvailability,
|
|
1441
|
-
reviewEnabled: rawAvailability.reviewEnabledForCli
|
|
1442
|
-
}, testSupported = (toolsets?.test ?? !0) && availability.testSupported, docsToolsetEnabled = toolsets?.docs ?? !0, multiSource = docsToolsetEnabled ? (await resolveServerlessCompositionSources(options)).multiSource : !1, registryAvailability = getEffectiveToolAvailability2(availability, { multiSource }), docsEnabled = docsToolsetEnabled && registryAvailability.docsEnabled, registryContext = { availability: registryAvailability, multiSource, toolsets }, toolMetadata = getAddonToolMetadata(registryContext), localTools = {
|
|
1403
|
+
}), testSupported = (toolsets?.test ?? !0) && availability.testSupported, docsToolsetEnabled = toolsets?.docs ?? !0, multiSource = docsToolsetEnabled ? (await resolveServerlessCompositionSources(options)).multiSource : !1, registryAvailability = getEffectiveToolAvailability2(availability, { multiSource }), docsEnabled = docsToolsetEnabled && registryAvailability.docsEnabled, registryContext = { availability: registryAvailability, multiSource, toolsets }, toolMetadata = getAddonToolMetadata(registryContext), localTools = {
|
|
1443
1404
|
...existingMetadata?.localTools,
|
|
1444
1405
|
...getAddonLocalTools({ ...registryContext, options })
|
|
1445
1406
|
};
|
|
@@ -1555,7 +1516,6 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1555
1516
|
moduleGraphSupported,
|
|
1556
1517
|
changeDetectionEnabled,
|
|
1557
1518
|
reviewEnabled,
|
|
1558
|
-
reviewEnabledForCli,
|
|
1559
1519
|
docsEnabled,
|
|
1560
1520
|
docsHasManifests,
|
|
1561
1521
|
docsFeatureEnabled,
|
|
@@ -1591,12 +1551,11 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1591
1551
|
!a11yEnabled2 && 'Add <code>@storybook/addon-a11y</code> for accessibility testing. <a target="_blank" href="https://storybook.js.org/docs/writing-tests/accessibility-testing">Learn more</a>'
|
|
1592
1552
|
].filter(Boolean), testNotice = testNoticeLines.length ? `<div class="toolset-notice">${testNoticeLines.join("<br>")}</div>` : "", a11yBadge = a11yEnabled2 ? ' <span class="toolset-status enabled">+ accessibility</span>' : "", devNoticeLines = isDevEnabled ? [
|
|
1593
1553
|
!moduleGraphSupported && "<code>stories-find-by-component</code> requires a dev server with a builder that supports the module graph (Vite or Webpack 5).",
|
|
1594
|
-
!changeDetectionEnabled && "<code>stories-changed</code>
|
|
1595
|
-
!reviewEnabled && (reviewEnabledForCli ? "<code>review-create</code> is enabled for <code>storybook ai</code> CLI clients (the Claude/Codex plugins); direct MCP clients need the <code>experimentalReview</code> feature flag." : "<code>review-create</code> requires the <code>changeDetection</code> feature flag and is off when <code>experimentalReview</code> is set to <code>false</code>.")
|
|
1554
|
+
!changeDetectionEnabled && "<code>stories-changed</code> and <code>review-create</code> require enabling the <code>changeDetection</code> feature flag."
|
|
1596
1555
|
].filter(Boolean) : ["The <code>dev</code> toolset is disabled via addon options."], devNotice = devNoticeLines.length ? `<div class="toolset-notice">${devNoticeLines.join("<br>")}</div>` : "", statusWord = (enabled) => enabled ? "enabled" : "disabled", html = template_default.replaceAll("{{DEV_STATUS}}", isDevEnabled ? "enabled" : "disabled").replaceAll(
|
|
1597
1556
|
"{{STORIES_BY_COMPONENT_STATUS}}",
|
|
1598
1557
|
statusWord(isDevEnabled && moduleGraphSupported)
|
|
1599
|
-
).replaceAll("{{CHANGE_DETECTION_STATUS}}", statusWord(isDevEnabled && changeDetectionEnabled)).replaceAll("{{REVIEW_STATUS}}", statusWord(isDevEnabled &&
|
|
1558
|
+
).replaceAll("{{CHANGE_DETECTION_STATUS}}", statusWord(isDevEnabled && changeDetectionEnabled)).replaceAll("{{REVIEW_STATUS}}", statusWord(isDevEnabled && reviewEnabled)).replace("{{DEV_NOTICE}}", devNotice).replaceAll("{{DOCS_STATUS}}", isDocsEnabled ? "enabled" : "disabled").replace("{{DOCS_NOTICE}}", docsNotice).replaceAll("{{TEST_STATUS}}", isTestEnabled ? "enabled" : "disabled").replace("{{TEST_NOTICE}}", testNotice).replace(
|
|
1600
1559
|
"{{MANIFEST_DEBUGGER_LINK}}",
|
|
1601
1560
|
rawAvailability.docsEnabled ? '<p>View the <a href="/manifests/components.html">component manifest debugger</a>.</p>' : ""
|
|
1602
1561
|
).replace("{{A11Y_BADGE}}", a11yBadge);
|
|
@@ -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.2",
|
|
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.2",
|
|
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.2",
|
|
46
|
+
"@storybook/addon-vitest": "11.0.0-alpha.2",
|
|
47
|
+
"storybook": "11.0.0-alpha.2",
|
|
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.2",
|
|
52
|
+
"storybook": "^11.0.0-alpha.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@storybook/addon-vitest": {
|