@storybook/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/README.md CHANGED
@@ -355,7 +355,7 @@ Type:
355
355
 
356
356
  Registers [documentation lookup](https://storybook.js.org/docs/next/ai/mcp/overview/#docs-show) by component/docs `id`.
357
357
 
358
- When `options.multiSource` is `true`, the tool schema requires `storybookId` input.
358
+ When `options.multiSource` is `true`, the tool schema takes an optional `storybookId` input, defaulting to `local`.
359
359
 
360
360
  #### `addGetStoryDocumentationTool`
361
361
 
package/dist/index.d.ts CHANGED
@@ -480,10 +480,10 @@ interface InputType {
480
480
  /** @see https://storybook.js.org/docs/api/arg-types#type */
481
481
  type?: SBType | SBScalarType['name'];
482
482
  /**
483
- * @deprecated Use `table.defaultValue.summary` instead.
484
- * @see https://storybook.js.org/docs/api/arg-types#defaultvalue
483
+ * Removed. Set the story value with `args`, or the docs-table text with `table.defaultValue`.
484
+ * The index signature would otherwise still accept this field.
485
485
  */
486
- defaultValue?: any;
486
+ defaultValue?: never;
487
487
  [key: string]: any;
488
488
  }
489
489
  interface StrictInputType extends InputType {
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_9x9xmw91dxn from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_9x9xmw91dxn from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_9x9xmw91dxn from "node:module";
1
+ import CJS_COMPAT_NODE_URL_wv85m4giz1 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_wv85m4giz1 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_wv85m4giz1 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_9x9xmw91dxn.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_9x9xmw91dxn.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_9x9xmw91dxn.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_wv85m4giz1.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_wv85m4giz1.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_wv85m4giz1.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: "11.0.0-alpha.1",
27
+ version: "11.0.0-alpha.2",
28
28
  description: "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
29
29
  keywords: [
30
30
  "mcp",
@@ -82,16 +82,16 @@ var package_default = {
82
82
  }
83
83
  };
84
84
 
85
- // ../../core/dist/_browser-chunks/chunk-ZF665KZD.js
85
+ // ../../core/dist/_browser-chunks/chunk-IE4ULIOQ.js
86
86
  var CASE_SPLIT_PATTERN = new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+", "gu");
87
87
  function words(str) {
88
88
  return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
89
89
  }
90
-
91
- // ../../core/dist/_browser-chunks/chunk-TYQWMAQX.js
92
90
  function kebabCase(str) {
93
91
  return words(str).map((word) => word.toLowerCase()).join("-");
94
92
  }
93
+
94
+ // ../../core/dist/_browser-chunks/chunk-QQVAH3EE.js
95
95
  function parseToolsetMethodId(methodId) {
96
96
  let separator = methodId.indexOf(".");
97
97
  if (separator <= 0 || separator !== methodId.lastIndexOf(".") || separator === methodId.length - 1)
@@ -129,12 +129,12 @@ function getToolName(context) {
129
129
  };
130
130
  }
131
131
 
132
- // ../../core/dist/_browser-chunks/chunk-WYNCY4CL.js
132
+ // ../../core/dist/_browser-chunks/chunk-PMPHKUPK.js
133
133
  function resolveToolsetDescription(description3, context) {
134
134
  return typeof description3 == "function" ? description3(context) : description3;
135
135
  }
136
136
 
137
- // ../../core/dist/_browser-chunks/chunk-KJ7GNWII.js
137
+ // ../../core/dist/_browser-chunks/chunk-DJVLGLRX.js
138
138
  function getDocsToolsetInstructions(transport) {
139
139
  let ref = getToolName({ transport });
140
140
  return `## Documentation Workflow
@@ -154,7 +154,7 @@ Only use properties explicitly documented or shown in example stories. Only refe
154
154
  }
155
155
  var DOCS_TOOLSET_INSTRUCTIONS = getDocsToolsetInstructions("mcp");
156
156
 
157
- // ../../core/dist/_browser-chunks/chunk-VM65THJG.js
157
+ // ../../core/dist/_browser-chunks/chunk-FMAVANLQ.js
158
158
  var store$4, DEFAULT_CONFIG = {
159
159
  lang: void 0,
160
160
  message: void 0,
@@ -781,7 +781,7 @@ function formatRequiresOwnMcpNotice(source, endpoint, options = {}) {
781
781
  var RequiresOwnMcpError = class extends Error {
782
782
  constructor(source) {
783
783
  let endpoint = getSourceMcpEndpoint(source);
784
- super(`Composed Storybook "${source.title}" requires its own MCP endpoint: ${endpoint}`), this.name = "RequiresOwnMcpError", this.source = source, this.endpoint = endpoint;
784
+ super(formatRequiresOwnMcpNotice(source, endpoint)), this.name = "RequiresOwnMcpError", this.source = source, this.endpoint = endpoint;
785
785
  }
786
786
  }, ManifestGetError = class extends Error {
787
787
  constructor(message, url, cause) {
@@ -1196,7 +1196,10 @@ async function defaultManifestProvider(request, path) {
1196
1196
  throw new ManifestGetError(
1197
1197
  "Request is required when using the default manifest provider. You must either pass the original request forward to the server context, or set a custom manifestProvider that doesn't need the request."
1198
1198
  );
1199
- let manifestUrl = getManifestUrlFromRequest(request, path), response = await fetch(manifestUrl);
1199
+ let manifestUrl = getManifestUrlFromRequest(request, path);
1200
+ return readManifestText(await fetch(manifestUrl), manifestUrl);
1201
+ }
1202
+ async function readManifestText(response, manifestUrl) {
1200
1203
  if (!response.ok)
1201
1204
  throw new ManifestGetError(
1202
1205
  `Failed to fetch manifest: ${response.status} ${response.statusText}`,
@@ -1501,8 +1504,8 @@ function selectReportedManifests({
1501
1504
  }) {
1502
1505
  return manifests ?? sources?.find((listing) => listing.manifests)?.manifests;
1503
1506
  }
1504
- function resolveShow({ entry, sourceError }) {
1505
- return sourceError !== void 0 ? { kind: "source-error", message: sourceError } : entry === void 0 ? { kind: "entry-missing" } : { kind: "found", entry };
1507
+ function resolveShow({ entry, sourceError, notice }) {
1508
+ return sourceError !== void 0 ? { kind: "source-error", message: sourceError } : notice !== void 0 ? { kind: "notice", message: notice } : entry === void 0 ? { kind: "entry-missing" } : { kind: "found", entry };
1506
1509
  }
1507
1510
  function isShowStorySelector({ storyId, componentId, storyName }) {
1508
1511
  return storyId !== void 0 || componentId !== void 0 && storyName !== void 0;
@@ -1512,26 +1515,33 @@ function componentIdOfStoryId(storyId) {
1512
1515
  return separator === -1 ? storyId : storyId.slice(0, separator);
1513
1516
  }
1514
1517
  function resolveShowStory(data) {
1515
- let { entry, storyId, storyName, sourceError } = data;
1518
+ let { entry, storyId, storyName, sourceError, notice } = data;
1516
1519
  if (!isShowStorySelector(data))
1517
1520
  return { kind: "input-invalid" };
1518
1521
  if (sourceError !== void 0)
1519
1522
  return { kind: "source-error", message: sourceError };
1523
+ if (notice !== void 0)
1524
+ return { kind: "notice", message: notice };
1520
1525
  if (entry === void 0 || entry.kind !== "component")
1521
1526
  return { kind: "component-missing" };
1522
1527
  let { component } = entry, story = storyId !== void 0 ? component.stories?.find((candidate) => candidate.id === storyId) : component.stories?.find((candidate) => candidate.name === storyName);
1523
1528
  return story ? { kind: "found", component, story } : { kind: "story-missing", component };
1524
1529
  }
1525
1530
  function isDocsShowError(output) {
1526
- return resolveShow(output).kind !== "found";
1531
+ let { kind } = resolveShow(output);
1532
+ return kind !== "found" && kind !== "notice";
1533
+ }
1534
+ function isDocsShowStoryError(output) {
1535
+ let { kind } = resolveShowStory(output);
1536
+ return kind !== "found" && kind !== "notice";
1527
1537
  }
1528
1538
  function describeList(ctx2) {
1529
- return `List all available UI components and documentation entries from the Storybook, returning the IDs the other documentation tools take as input. Call this first for any UI task \u2014 before writing a new component, check what the design system already provides and build on it instead of hand-rolling a duplicate; before answering any question about props, API, or usage, discover the relevant IDs here rather than reading component source. Then fetch the entries with ${getToolName(ctx2)(DOCS_METHOD_REFS.show)}, referencing only IDs returned here \u2014 never guess IDs. When multiple Storybook sources are configured, entries from every source are included; scope follow-up calls to one source via their \`storybookId\` input. Pass \`withStoryIds: true\` when you need story IDs for other tools.`;
1539
+ return `List all available UI components and documentation entries from the Storybook, returning the IDs the other documentation tools take as input. Call this first for any UI task \u2014 before writing a new component, check what the design system already provides and build on it instead of hand-rolling a duplicate; before answering any question about props, API, or usage, discover the relevant IDs here rather than reading component source. Then fetch the entries with ${getToolName(ctx2)(DOCS_METHOD_REFS.show)}, referencing only IDs returned here \u2014 never guess IDs. When multiple Storybook sources are configured, entries from every source are included; scope follow-up calls to one source via their storybookId input. Pass withStoryIds: true when you need story IDs for other tools.`;
1530
1540
  }
1531
1541
  function describeShow(ctx2) {
1532
1542
  return `Get documentation for a UI component or docs entry.
1533
1543
 
1534
- 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\`.
1544
+ 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.
1535
1545
 
1536
1546
  Example: id="button" returns Primary, Secondary, Large stories with code like <Button variant="primary" size="large"> showing actual prop combinations.`;
1537
1547
  }
@@ -1543,6 +1553,7 @@ function renderShow(data, ctx2) {
1543
1553
  let resolution = resolveShow(data);
1544
1554
  switch (resolution.kind) {
1545
1555
  case "source-error":
1556
+ case "notice":
1546
1557
  return resolution.message;
1547
1558
  case "entry-missing":
1548
1559
  return formatEntryNotFound(data.id, data.storybookId, ctx2);
@@ -1560,6 +1571,7 @@ function renderShowStory(resolution, data, ctx2) {
1560
1571
  case "input-invalid":
1561
1572
  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.`;
1562
1573
  case "source-error":
1574
+ case "notice":
1563
1575
  return resolution.message;
1564
1576
  case "component-missing":
1565
1577
  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.`;
@@ -1574,18 +1586,29 @@ function renderShowStory(resolution, data, ctx2) {
1574
1586
  }
1575
1587
  }
1576
1588
  var storybookIdField = {
1577
- storybookId: pipe(
1578
- string(),
1579
- description('The ID of the Storybook source to query (e.g., "local", "design-system")')
1589
+ storybookId: optional(
1590
+ pipe(
1591
+ string(),
1592
+ description(
1593
+ 'The ID of the Storybook source to query (e.g., "local", "design-system"). Defaults to "local", this Storybook.'
1594
+ )
1595
+ ),
1596
+ "local"
1580
1597
  )
1581
1598
  };
1599
+ async function resolveFromSource(access, id) {
1600
+ try {
1601
+ return { entry: await access.resolve(id) };
1602
+ } catch (error) {
1603
+ if (error instanceof RequiresOwnMcpError)
1604
+ return { notice: error.message };
1605
+ throw error;
1606
+ }
1607
+ }
1582
1608
  function selectSource(sources, storybookId, ctx2) {
1583
1609
  if (!sources?.length)
1584
1610
  return {};
1585
- let available = sources.map(({ source }) => source.id).join(", "), listRef = `Use the ${getToolName(ctx2)(DOCS_METHOD_REFS.list)} tool to see available sources.`;
1586
- if (!storybookId)
1587
- return { sourceError: `storybookId is required. Available sources: ${available}. ${listRef}` };
1588
- let match = sources.find(({ source }) => source.id === storybookId);
1611
+ let available = sources.map(({ source }) => source.id).join(", "), listRef = `Use the ${getToolName(ctx2)(DOCS_METHOD_REFS.list)} tool to see available sources.`, match = sources.find(({ source }) => source.id === storybookId);
1589
1612
  return match ? { access: match.access } : {
1590
1613
  sourceError: `Storybook source not found: "${storybookId}". Available sources: ${available}. ${listRef}`
1591
1614
  };
@@ -1661,7 +1684,7 @@ function createDocsToolset(options) {
1661
1684
  title: "Get Documentation",
1662
1685
  description: describeShow,
1663
1686
  handler: async (input, ctx2) => {
1664
- let { id, storybookId } = input, selected = access(storybookId, ctx2), data = selected.sourceError ? { id, storybookId, sourceError: selected.sourceError } : { id, storybookId, entry: await selected.access.resolve(id) }, markdown = renderShow(data, ctx2), telemetry = {
1687
+ let { id, storybookId } = input, selected = access(storybookId, ctx2), data = selected.sourceError ? { id, storybookId, sourceError: selected.sourceError } : { id, storybookId, ...await resolveFromSource(selected.access, id) }, markdown = renderShow(data, ctx2), telemetry = {
1665
1688
  payload: {
1666
1689
  componentId: id,
1667
1690
  found: data.entry !== void 0,
@@ -1676,7 +1699,7 @@ function createDocsToolset(options) {
1676
1699
  title: "Get Documentation for Story",
1677
1700
  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.",
1678
1701
  handler: async (input, ctx2) => {
1679
- 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 }, resolution = resolveShowStory(data), markdown = renderShowStory(resolution, data, ctx2), telemetry = {
1702
+ 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, ...await resolveFromSource(selected.access, resolveId) } : { ...request, sourceError: selected.sourceError }, resolution = resolveShowStory(data), markdown = renderShowStory(resolution, data, ctx2), telemetry = {
1680
1703
  payload: {
1681
1704
  found: resolution.kind === "found",
1682
1705
  storyId: resolution.kind === "found" ? resolution.story.id : storyId,
@@ -1684,7 +1707,7 @@ function createDocsToolset(options) {
1684
1707
  resultTokenCount: estimateTokens(markdown)
1685
1708
  }
1686
1709
  };
1687
- return resolution.kind === "found" ? { ok: !0, data, markdown, telemetry } : { ok: !1, data, markdown, telemetry };
1710
+ return isDocsShowStoryError(data) ? { ok: !1, data, markdown, telemetry } : { ok: !0, data, markdown, telemetry };
1688
1711
  }
1689
1712
  }
1690
1713
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/mcp",
3
- "version": "11.0.0-alpha.1",
3
+ "version": "11.0.0-alpha.2",
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": "11.0.0-alpha.1",
52
+ "storybook": "11.0.0-alpha.2",
53
53
  "tinyexec": "^1.0.2",
54
54
  "typescript": "^6.0.3"
55
55
  },