@storybook/addon-mcp 11.0.0-beta.1 → 11.0.0-beta.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_az3l6xmq8mt from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_az3l6xmq8mt from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_az3l6xmq8mt from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_az3l6xmq8mt.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_az3l6xmq8mt.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_az3l6xmq8mt.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-beta.
|
|
21
|
+
version: "11.0.0-beta.2",
|
|
22
22
|
description: "Help agents automatically write and test stories for your UI components",
|
|
23
23
|
keywords: [
|
|
24
24
|
"ai",
|
|
@@ -170,118 +170,6 @@ function withFriendlyErrors(schema) {
|
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
// src/tools/get-storybook-story-instructions.ts
|
|
174
|
-
import { resolveSkillInputs } from "storybook/internal/core-server";
|
|
175
|
-
import { buildStoryInstructions } from "storybook/internal/skills";
|
|
176
|
-
|
|
177
|
-
// src/utils/errors.ts
|
|
178
|
-
var errorToMCPContent = (error) => ({
|
|
179
|
-
content: [
|
|
180
|
-
{
|
|
181
|
-
type: "text",
|
|
182
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
183
|
-
}
|
|
184
|
-
],
|
|
185
|
-
isError: !0
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// src/tools/tool-names.ts
|
|
189
|
-
import { toMcpToolName } from "storybook/open-service";
|
|
190
|
-
var PREVIEW_STORIES_TOOL_NAME = toMcpToolName("stories.preview"), GET_CHANGED_STORIES_TOOL_NAME = toMcpToolName("stories.changed"), GET_STORIES_BY_COMPONENT_TOOL_NAME = toMcpToolName("stories.findByComponent"), RUN_STORY_TESTS_TOOL_NAME = toMcpToolName("test.run"), DISPLAY_REVIEW_TOOL_NAME = toMcpToolName("review.create"), GET_UI_BUILDING_INSTRUCTIONS_TOOL_NAME = "get-storybook-story-instructions";
|
|
191
|
-
|
|
192
|
-
// src/tools/get-storybook-story-instructions.ts
|
|
193
|
-
async function addGetUIBuildingInstructionsTool(server, enabled = () => server.ctx.custom?.toolsets?.dev ?? !0, {
|
|
194
|
-
docsEnabled = !1,
|
|
195
|
-
addonVitestAvailable = !1
|
|
196
|
-
} = {}) {
|
|
197
|
-
server.tool(
|
|
198
|
-
{
|
|
199
|
-
name: GET_UI_BUILDING_INSTRUCTIONS_TOOL_NAME,
|
|
200
|
-
title: "Storybook Story Development Instructions",
|
|
201
|
-
get description() {
|
|
202
|
-
let testSupported = (server.ctx.custom?.toolsets?.test ?? !0) && addonVitestAvailable, a11yAvailable = testSupported && (server.ctx.custom?.a11yEnabled ?? !1);
|
|
203
|
-
return getStorybookStoryInstructionsDescription({
|
|
204
|
-
testSupported,
|
|
205
|
-
a11yAvailable
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
enabled
|
|
209
|
-
},
|
|
210
|
-
async () => {
|
|
211
|
-
try {
|
|
212
|
-
let { options, disableTelemetry: disableTelemetry2 } = server.ctx.custom ?? {};
|
|
213
|
-
if (!options)
|
|
214
|
-
throw new Error("Options are required in addon context");
|
|
215
|
-
return disableTelemetry2 || await collectTelemetry({
|
|
216
|
-
event: "tool:getUIBuildingInstructions",
|
|
217
|
-
server,
|
|
218
|
-
toolset: "dev"
|
|
219
|
-
}), {
|
|
220
|
-
content: [{ type: "text", text: await buildStorybookStoryInstructions(options, {
|
|
221
|
-
toolsets: server.ctx.custom?.toolsets,
|
|
222
|
-
a11yEnabled: server.ctx.custom?.a11yEnabled,
|
|
223
|
-
addonVitestAvailable,
|
|
224
|
-
docsEnabled
|
|
225
|
-
}) }]
|
|
226
|
-
};
|
|
227
|
-
} catch (error) {
|
|
228
|
-
return errorToMCPContent(error);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
function getStorybookStoryInstructionsDescription({
|
|
234
|
-
testSupported,
|
|
235
|
-
a11yAvailable
|
|
236
|
-
}) {
|
|
237
|
-
return `Get comprehensive instructions for writing, testing, and fixing Storybook stories (.stories.tsx, .stories.ts, .stories.jsx, .stories.js, .stories.svelte, .stories.vue files).
|
|
238
|
-
|
|
239
|
-
CRITICAL: You MUST call this tool before:
|
|
240
|
-
- Creating new Storybook stories or story files
|
|
241
|
-
- Updating or modifying existing Storybook stories
|
|
242
|
-
- Adding new story variants or exports to story files
|
|
243
|
-
- Editing any file matching *.stories.* patterns
|
|
244
|
-
- Writing components that will need stories
|
|
245
|
-
- Editing anything that changes how the UI looks \u2014 components, styles, CSS, themes, colors, or design tokens; a shared file with no stories of its own still changes its consumers' stories${testSupported ? `
|
|
246
|
-
- Running story tests or fixing test failures` : ""}${a11yAvailable ? `
|
|
247
|
-
- Handling accessibility (a11y) violations in stories (fix semantic issues directly; ask before visual/design changes)` : ""}
|
|
248
|
-
|
|
249
|
-
This tool provides essential Storybook-specific guidance including:
|
|
250
|
-
- How to structure stories correctly for Storybook 9
|
|
251
|
-
- Required imports (Meta, StoryObj from framework package)
|
|
252
|
-
- Test utility imports (from 'storybook/test')
|
|
253
|
-
- Story naming conventions and best practices
|
|
254
|
-
- Play function patterns for interactive testing
|
|
255
|
-
- Mocking strategies for external dependencies
|
|
256
|
-
- Story variants and coverage requirements${testSupported ? `
|
|
257
|
-
- How to handle test failures${a11yAvailable ? " and accessibility violations" : ""}` : ""}
|
|
258
|
-
|
|
259
|
-
Even if you're familiar with Storybook, call this tool to ensure you're following the correct patterns, import paths, and conventions for this specific Storybook setup.`;
|
|
260
|
-
}
|
|
261
|
-
function getStorybookStoryInstructionsToolMetadata(options) {
|
|
262
|
-
return {
|
|
263
|
-
name: GET_UI_BUILDING_INSTRUCTIONS_TOOL_NAME,
|
|
264
|
-
title: "Storybook Story Development Instructions",
|
|
265
|
-
description: getStorybookStoryInstructionsDescription(options)
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
async function buildStorybookStoryInstructions(options, {
|
|
269
|
-
toolsets,
|
|
270
|
-
a11yEnabled: a11yEnabled2,
|
|
271
|
-
addonVitestAvailable,
|
|
272
|
-
docsEnabled
|
|
273
|
-
} = {}) {
|
|
274
|
-
let inputs = await resolveSkillInputs(options);
|
|
275
|
-
return buildStoryInstructions({
|
|
276
|
-
transport: "mcp",
|
|
277
|
-
framework: inputs.framework,
|
|
278
|
-
renderer: inputs.renderer,
|
|
279
|
-
testSupported: (toolsets?.test ?? !0) && (addonVitestAvailable ?? inputs.testSupported),
|
|
280
|
-
a11yEnabled: a11yEnabled2 ?? inputs.a11yEnabled,
|
|
281
|
-
docsEnabled: (toolsets?.docs ?? !0) && (docsEnabled ?? inputs.docsEnabled)
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
173
|
// src/tools/preview-stories.ts
|
|
286
174
|
import url from "node:url";
|
|
287
175
|
import fs from "node:fs/promises";
|
|
@@ -361,6 +249,10 @@ var preview_stories_app_template_default = `<!doctype html>
|
|
|
361
249
|
</html>
|
|
362
250
|
`;
|
|
363
251
|
|
|
252
|
+
// src/tools/tool-names.ts
|
|
253
|
+
import { toMcpToolName } from "storybook/open-service";
|
|
254
|
+
var PREVIEW_STORIES_TOOL_NAME = toMcpToolName("stories.preview"), GET_CHANGED_STORIES_TOOL_NAME = toMcpToolName("stories.changed"), GET_STORIES_BY_COMPONENT_TOOL_NAME = toMcpToolName("stories.findByComponent"), RUN_STORY_TESTS_TOOL_NAME = toMcpToolName("test.run"), DISPLAY_REVIEW_TOOL_NAME = toMcpToolName("review.create");
|
|
255
|
+
|
|
364
256
|
// src/tools/preview-stories.ts
|
|
365
257
|
var PREVIEW_STORIES_RESOURCE_URI = `ui://${PREVIEW_STORIES_TOOL_NAME}/preview.html`;
|
|
366
258
|
async function addPreviewStoriesResource(server) {
|
|
@@ -419,6 +311,17 @@ import {
|
|
|
419
311
|
toMcpToolName as toMcpToolName2
|
|
420
312
|
} from "storybook/open-service";
|
|
421
313
|
|
|
314
|
+
// src/utils/errors.ts
|
|
315
|
+
var errorToMCPContent = (error) => ({
|
|
316
|
+
content: [
|
|
317
|
+
{
|
|
318
|
+
type: "text",
|
|
319
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
isError: !0
|
|
323
|
+
});
|
|
324
|
+
|
|
422
325
|
// src/utils/base-url.ts
|
|
423
326
|
function toBaseUrl(origin, basePath) {
|
|
424
327
|
return `${origin}${basePath.replace(/\/$/, "")}`;
|
|
@@ -576,21 +479,6 @@ var docsToolDefinitions = [
|
|
|
576
479
|
extras: { _meta: { ui: { resourceUri: PREVIEW_STORIES_RESOURCE_URI } } }
|
|
577
480
|
}
|
|
578
481
|
}),
|
|
579
|
-
{
|
|
580
|
-
name: GET_UI_BUILDING_INSTRUCTIONS_TOOL_NAME,
|
|
581
|
-
toolset: "dev",
|
|
582
|
-
getMetadata: ({ availability, toolsets }) => {
|
|
583
|
-
let testSupported = isToolsetEnabled("test", toolsets) && availability.testSupported;
|
|
584
|
-
return getStorybookStoryInstructionsToolMetadata({
|
|
585
|
-
testSupported,
|
|
586
|
-
a11yAvailable: testSupported && availability.a11yEnabled
|
|
587
|
-
});
|
|
588
|
-
},
|
|
589
|
-
register: (server, { availability, toolsets }, enabled) => addGetUIBuildingInstructionsTool(server, enabled, {
|
|
590
|
-
docsEnabled: isToolsetEnabled("docs", toolsets) && availability.docsEnabled,
|
|
591
|
-
addonVitestAvailable: availability.testSupported
|
|
592
|
-
})
|
|
593
|
-
},
|
|
594
482
|
fromToolset({
|
|
595
483
|
toolset: "dev",
|
|
596
484
|
options: { method: "stories.changed", mcpEventName: "tool:getChangedStories" }
|
|
@@ -646,11 +534,9 @@ var transport, initialize, disableTelemetry, a11yEnabled, initializeMCPServer =
|
|
|
646
534
|
adapter: new ValibotJsonSchemaAdapter(),
|
|
647
535
|
get instructions() {
|
|
648
536
|
return buildServerInstructions({
|
|
649
|
-
transport: "mcp",
|
|
650
537
|
devEnabled: server?.ctx.custom?.toolsets?.dev ?? !0,
|
|
651
538
|
testSupported: (server?.ctx.custom?.toolsets?.test ?? !0) && availability.testSupported,
|
|
652
|
-
docsEnabled: (server?.ctx.custom?.toolsets?.docs ?? !0) && availability.docsEnabled
|
|
653
|
-
moduleGraphSupported: availability.moduleGraphSupported
|
|
539
|
+
docsEnabled: (server?.ctx.custom?.toolsets?.docs ?? !0) && availability.docsEnabled
|
|
654
540
|
});
|
|
655
541
|
},
|
|
656
542
|
capabilities: {
|
|
@@ -999,7 +885,6 @@ var template_default = `<!doctype html>
|
|
|
999
885
|
</div>
|
|
1000
886
|
<ul class="toolset-tools">
|
|
1001
887
|
<li><code>stories-preview</code></li>
|
|
1002
|
-
<li><code>get-storybook-story-instructions</code></li>
|
|
1003
888
|
<li><code>stories-changed</code></li>
|
|
1004
889
|
<li>
|
|
1005
890
|
<code>stories-find-by-component</code>
|
|
@@ -1421,12 +1306,13 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1421
1306
|
).replace("{{A11Y_BADGE}}", a11yBadge);
|
|
1422
1307
|
res.end(html);
|
|
1423
1308
|
}), app;
|
|
1424
|
-
}, features = async (existingFeatures) => ({
|
|
1309
|
+
}, mcpToolsets = async (_value, options) => v3.parse(AddonOptions, { toolsets: options.toolsets ?? {} }).toolsets, features = async (existingFeatures) => ({
|
|
1425
1310
|
...existingFeatures,
|
|
1426
1311
|
componentsManifest: !0
|
|
1427
1312
|
});
|
|
1428
1313
|
export {
|
|
1429
1314
|
experimental_devServer,
|
|
1430
1315
|
features,
|
|
1316
|
+
mcpToolsets,
|
|
1431
1317
|
previewAnnotations
|
|
1432
1318
|
};
|
|
@@ -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-beta.
|
|
7
|
+
version: "11.0.0-beta.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-beta.
|
|
3
|
+
"version": "11.0.0-beta.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-beta.
|
|
46
|
-
"@storybook/addon-vitest": "11.0.0-beta.
|
|
47
|
-
"storybook": "11.0.0-beta.
|
|
45
|
+
"@storybook/addon-a11y": "11.0.0-beta.2",
|
|
46
|
+
"@storybook/addon-vitest": "11.0.0-beta.2",
|
|
47
|
+
"storybook": "11.0.0-beta.2",
|
|
48
48
|
"typescript": "^6.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@storybook/addon-vitest": "^11.0.0-beta.
|
|
52
|
-
"storybook": "^11.0.0-beta.
|
|
51
|
+
"@storybook/addon-vitest": "^11.0.0-beta.2",
|
|
52
|
+
"storybook": "^11.0.0-beta.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@storybook/addon-vitest": {
|