@storybook/mcp 10.6.0-beta.1 → 10.6.0-beta.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/index.js +52 -27
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_znkaxnz7oo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_znkaxnz7oo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_znkaxnz7oo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_znkaxnz7oo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_znkaxnz7oo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_znkaxnz7oo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -24,7 +24,7 @@ import { HttpTransport } from "@tmcp/transport-http";
|
|
|
24
24
|
// package.json
|
|
25
25
|
var package_default = {
|
|
26
26
|
name: "@storybook/mcp",
|
|
27
|
-
version: "10.6.0-beta.
|
|
27
|
+
version: "10.6.0-beta.3",
|
|
28
28
|
description: "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
|
|
29
29
|
keywords: [
|
|
30
30
|
"mcp",
|
|
@@ -1510,17 +1510,23 @@ function selectReportedManifests({
|
|
|
1510
1510
|
function resolveShow({ entry, sourceError }) {
|
|
1511
1511
|
return sourceError !== void 0 ? { kind: "source-error", message: sourceError } : entry === void 0 ? { kind: "entry-missing" } : { kind: "found", entry };
|
|
1512
1512
|
}
|
|
1513
|
-
function
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1513
|
+
function isShowStorySelector({ storyId, componentId, storyName }) {
|
|
1514
|
+
return storyId !== void 0 || componentId !== void 0 && storyName !== void 0;
|
|
1515
|
+
}
|
|
1516
|
+
function componentIdOfStoryId(storyId) {
|
|
1517
|
+
let separator = storyId.indexOf("--");
|
|
1518
|
+
return separator === -1 ? storyId : storyId.slice(0, separator);
|
|
1519
|
+
}
|
|
1520
|
+
function resolveShowStory(data) {
|
|
1521
|
+
let { entry, storyId, storyName, sourceError } = data;
|
|
1522
|
+
if (!isShowStorySelector(data))
|
|
1523
|
+
return { kind: "input-invalid" };
|
|
1518
1524
|
if (sourceError !== void 0)
|
|
1519
1525
|
return { kind: "source-error", message: sourceError };
|
|
1520
1526
|
if (entry === void 0 || entry.kind !== "component")
|
|
1521
1527
|
return { kind: "component-missing" };
|
|
1522
|
-
let { component } = entry;
|
|
1523
|
-
return
|
|
1528
|
+
let { component } = entry, story = storyId !== void 0 ? component.stories?.find((candidate) => candidate.id === storyId) : component.stories?.find((candidate) => candidate.name === storyName);
|
|
1529
|
+
return story ? { kind: "found", component, storyName: story.name } : { kind: "story-missing", component };
|
|
1524
1530
|
}
|
|
1525
1531
|
function isDocsShowError(output) {
|
|
1526
1532
|
return resolveShow(output).kind !== "found";
|
|
@@ -1534,7 +1540,7 @@ function describeList(ctx2) {
|
|
|
1534
1540
|
function describeShow(ctx2) {
|
|
1535
1541
|
return `Get documentation for a UI component or docs entry.
|
|
1536
1542
|
|
|
1537
|
-
Returns the first ${MAX_STORIES_TO_SHOW} stories (including story IDs) with code snippets showing how props are used, plus TypeScript prop definitions. Call this before using a component to avoid hallucinating prop names, types, or valid combinations, and to answer any question about a component's props, API, or usage \u2014 reading or grepping the component source is not a substitute. Stories reveal real prop usage patterns, interactions, and edge cases that type definitions alone don't show. If the example stories don't show the prop you need, use the ${getToolName(ctx2)(DOCS_METHOD_REFS.showStory)} tool to fetch the story documentation for the specific story variant you need
|
|
1543
|
+
Returns the first ${MAX_STORIES_TO_SHOW} stories (including story IDs) with code snippets showing how props are used, plus TypeScript prop definitions. Call this before using a component to avoid hallucinating prop names, types, or valid combinations, and to answer any question about a component's props, API, or usage \u2014 reading or grepping the component source is not a substitute. Stories reveal real prop usage patterns, interactions, and edge cases that type definitions alone don't show. If the example stories don't show the prop you need, use the ${getToolName(ctx2)(DOCS_METHOD_REFS.showStory)} tool to fetch the story documentation for the specific story variant you need \u2014 its story ID can be passed directly as \`storyId\`.
|
|
1538
1544
|
|
|
1539
1545
|
Example: id="button" returns Primary, Secondary, Large stories with code like <Button variant="primary" size="large"> showing actual prop combinations.`;
|
|
1540
1546
|
}
|
|
@@ -1555,19 +1561,24 @@ function renderShow(data, ctx2) {
|
|
|
1555
1561
|
return resolution;
|
|
1556
1562
|
}
|
|
1557
1563
|
}
|
|
1564
|
+
function formatAvailableStories(stories) {
|
|
1565
|
+
return stories?.map((story) => story.id ? `${story.name} (${story.id})` : story.name).join(", ") || "none";
|
|
1566
|
+
}
|
|
1558
1567
|
function renderShowStory(data, ctx2) {
|
|
1559
1568
|
let resolution = resolveShowStory(data);
|
|
1560
1569
|
switch (resolution.kind) {
|
|
1570
|
+
case "input-invalid":
|
|
1571
|
+
return `Provide either \`storyId\`, or both \`componentId\` and \`storyName\`. Story ids are listed by the ${getToolName(ctx2)(DOCS_METHOD_REFS.list)} tool with \`withStoryIds: true\` and in ${getToolName(ctx2)(DOCS_METHOD_REFS.show)} output.`;
|
|
1561
1572
|
case "source-error":
|
|
1562
1573
|
return resolution.message;
|
|
1563
1574
|
case "component-missing":
|
|
1564
|
-
return `Component not found: "${data.componentId}". Use the ${getToolName(ctx2)(DOCS_METHOD_REFS.list)} tool to see available components.`;
|
|
1575
|
+
return data.storyId !== void 0 ? `Story not found: "${data.storyId}". Use the ${getToolName(ctx2)(DOCS_METHOD_REFS.list)} tool with \`withStoryIds: true\` to see available stories and their ids.` : `Component not found: "${data.componentId}". Use the ${getToolName(ctx2)(DOCS_METHOD_REFS.list)} tool to see available components.`;
|
|
1565
1576
|
case "story-missing": {
|
|
1566
|
-
let availableStories = resolution.component.stories
|
|
1567
|
-
return `Story "${data.storyName}" not found for component "${data.componentId}". Available stories: ${availableStories
|
|
1577
|
+
let availableStories = formatAvailableStories(resolution.component.stories);
|
|
1578
|
+
return data.storyId !== void 0 ? `Story not found: "${data.storyId}" for component "${resolution.component.id}". Available stories: ${availableStories}` : `Story "${data.storyName}" not found for component "${data.componentId}". Available stories: ${availableStories}`;
|
|
1568
1579
|
}
|
|
1569
1580
|
case "found":
|
|
1570
|
-
return formatStoryDocumentation(resolution.component,
|
|
1581
|
+
return formatStoryDocumentation(resolution.component, resolution.storyName);
|
|
1571
1582
|
default:
|
|
1572
1583
|
return resolution;
|
|
1573
1584
|
}
|
|
@@ -1598,7 +1609,26 @@ function createDocsToolset(options) {
|
|
|
1598
1609
|
...storybookIdField
|
|
1599
1610
|
}) : object({
|
|
1600
1611
|
id: pipe(string(), description('The component or docs entry ID (e.g., "button")'))
|
|
1601
|
-
}),
|
|
1612
|
+
}), showStoryFields = {
|
|
1613
|
+
storyId: pipe(
|
|
1614
|
+
optional(string()),
|
|
1615
|
+
description(
|
|
1616
|
+
'The story ID, as listed by the docs list tool with withStoryIds: true and shown next to each story in the component documentation (e.g., "button--primary"). Prefer this over componentId + storyName whenever you have a story ID.'
|
|
1617
|
+
)
|
|
1618
|
+
),
|
|
1619
|
+
componentId: pipe(
|
|
1620
|
+
optional(string()),
|
|
1621
|
+
description(
|
|
1622
|
+
'The component ID (e.g., "button"). Use together with storyName, and only when you have no story ID.'
|
|
1623
|
+
)
|
|
1624
|
+
),
|
|
1625
|
+
storyName: pipe(
|
|
1626
|
+
optional(string()),
|
|
1627
|
+
description(
|
|
1628
|
+
'The human-readable story name (e.g., "Primary"). Use together with componentId.'
|
|
1629
|
+
)
|
|
1630
|
+
)
|
|
1631
|
+
}, showStorySchema = multiSource ? object({ ...showStoryFields, ...storybookIdField }) : object(showStoryFields), access = (storybookId, ctx2) => multiSource ? selectSource(sources, storybookId, ctx2) : { access: docsAccess };
|
|
1602
1632
|
return {
|
|
1603
1633
|
id: DOCS_TOOLSET_ID,
|
|
1604
1634
|
description: "Storybook component and docs documentation.",
|
|
@@ -1645,14 +1675,9 @@ function createDocsToolset(options) {
|
|
|
1645
1675
|
[DOCS_METHOD_NAMES.showStory]: {
|
|
1646
1676
|
input: showStorySchema,
|
|
1647
1677
|
title: "Get Documentation for Story",
|
|
1648
|
-
description: "Get detailed documentation for a specific story variant of a UI component. Use this when you need to see more usage examples of a component, via the stories written for it.",
|
|
1678
|
+
description: "Get detailed documentation for a specific story variant of a UI component. Use this when you need to see more usage examples of a component, via the stories written for it. Identify the story by its story ID (preferred), or by componentId plus storyName.",
|
|
1649
1679
|
handler: async (input, ctx2) => {
|
|
1650
|
-
let { componentId, storyName, storybookId } = input, selected = access(storybookId, ctx2), data = selected.
|
|
1651
|
-
componentId,
|
|
1652
|
-
storyName,
|
|
1653
|
-
storybookId,
|
|
1654
|
-
entry: await selected.access.resolve(componentId)
|
|
1655
|
-
}, markdown = renderShowStory(data, ctx2);
|
|
1680
|
+
let { storyId, componentId, storyName, storybookId } = input, request = { storyId, componentId, storyName, storybookId }, resolveId = storyId !== void 0 ? componentIdOfStoryId(storyId) : componentId !== void 0 && storyName !== void 0 ? componentId : void 0, selected = resolveId !== void 0 ? access(storybookId, ctx2) : {}, data = selected.access && resolveId !== void 0 ? { ...request, entry: await selected.access.resolve(resolveId) } : { ...request, sourceError: selected.sourceError }, markdown = renderShowStory(data, ctx2);
|
|
1656
1681
|
return isDocsShowStoryError(data) ? { ok: !1, data, markdown } : { ok: !0, data, markdown };
|
|
1657
1682
|
}
|
|
1658
1683
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/mcp",
|
|
3
|
-
"version": "10.6.0-beta.
|
|
3
|
+
"version": "10.6.0-beta.3",
|
|
4
4
|
"description": "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-docgen": "^8.0.2",
|
|
50
50
|
"react-docgen-typescript": "^2.4.0",
|
|
51
51
|
"srvx": "^0.8.16",
|
|
52
|
-
"storybook": "10.6.0-beta.
|
|
52
|
+
"storybook": "10.6.0-beta.3",
|
|
53
53
|
"tinyexec": "^1.0.2",
|
|
54
54
|
"typescript": "^6.0.3"
|
|
55
55
|
},
|