@storybook/mcp 10.6.0 → 10.6.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.
Files changed (2) hide show
  1. package/dist/index.js +48 -42
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_jzv0nukkq2 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jzv0nukkq2 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jzv0nukkq2 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_xmnbliifcv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_xmnbliifcv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_xmnbliifcv from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_jzv0nukkq2.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jzv0nukkq2.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jzv0nukkq2.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_xmnbliifcv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_xmnbliifcv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_xmnbliifcv.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",
27
+ version: "10.6.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,17 +82,6 @@ var package_default = {
82
82
  }
83
83
  };
84
84
 
85
- // ../../core/dist/_browser-chunks/chunk-YMU7DBNR.js
86
- function resolveToolsetDescription(description3, context) {
87
- return typeof description3 == "function" ? description3(context) : description3;
88
- }
89
- async function reportToolsetTelemetry(context, event, payload) {
90
- try {
91
- await context.telemetry?.(event, payload);
92
- } catch {
93
- }
94
- }
95
-
96
85
  // ../../core/dist/_browser-chunks/chunk-ZF665KZD.js
97
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");
98
87
  function words(str) {
@@ -140,6 +129,11 @@ function getToolName(context) {
140
129
  };
141
130
  }
142
131
 
132
+ // ../../core/dist/_browser-chunks/chunk-WYNCY4CL.js
133
+ function resolveToolsetDescription(description3, context) {
134
+ return typeof description3 == "function" ? description3(context) : description3;
135
+ }
136
+
143
137
  // ../../core/dist/_browser-chunks/chunk-KJ7GNWII.js
144
138
  function getDocsToolsetInstructions(transport) {
145
139
  let ref = getToolName({ transport });
@@ -1526,14 +1520,11 @@ function resolveShowStory(data) {
1526
1520
  if (entry === void 0 || entry.kind !== "component")
1527
1521
  return { kind: "component-missing" };
1528
1522
  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 };
1523
+ return story ? { kind: "found", component, story } : { kind: "story-missing", component };
1530
1524
  }
1531
1525
  function isDocsShowError(output) {
1532
1526
  return resolveShow(output).kind !== "found";
1533
1527
  }
1534
- function isDocsShowStoryError(output) {
1535
- return resolveShowStory(output).kind !== "found";
1536
- }
1537
1528
  function describeList(ctx2) {
1538
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
1530
  }
@@ -1564,8 +1555,7 @@ function renderShow(data, ctx2) {
1564
1555
  function formatAvailableStories(stories) {
1565
1556
  return stories?.map((story) => story.id ? `${story.name} (${story.id})` : story.name).join(", ") || "none";
1566
1557
  }
1567
- function renderShowStory(data, ctx2) {
1568
- let resolution = resolveShowStory(data);
1558
+ function renderShowStory(resolution, data, ctx2) {
1569
1559
  switch (resolution.kind) {
1570
1560
  case "input-invalid":
1571
1561
  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.`;
@@ -1578,7 +1568,7 @@ function renderShowStory(data, ctx2) {
1578
1568
  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}`;
1579
1569
  }
1580
1570
  case "found":
1581
- return formatStoryDocumentation(resolution.component, resolution.storyName);
1571
+ return formatStoryDocumentation(resolution.component, resolution.story.name);
1582
1572
  default:
1583
1573
  return resolution;
1584
1574
  }
@@ -1647,15 +1637,23 @@ function createDocsToolset(options) {
1647
1637
  }),
1648
1638
  title: "List All Documentation",
1649
1639
  description: describeList,
1650
- handler: async (input, ctx2) => {
1640
+ handler: async (input) => {
1651
1641
  let { withStoryIds } = input, data = multiSource ? { withStoryIds, sources: await listSources(sources, { withStoryIds }) } : { withStoryIds, manifests: await docsAccess.list({ withStoryIds }) }, markdown = data.sources ? formatMultiSourceManifestsToLists(data.sources, { withStoryIds }) : formatManifestsToLists(data.manifests, { withStoryIds }), counted = selectReportedManifests(data);
1652
- return counted && await reportToolsetTelemetry(ctx2, "tool:listAllDocumentation", {
1653
- toolset: "docs",
1654
- componentCount: Object.keys(counted.componentManifest.components).length,
1655
- docsCount: Object.keys(counted.docsManifest?.docs ?? {}).length,
1656
- resultTokenCount: estimateTokens(markdown),
1657
- sourceCount: data.sources?.length
1658
- }), { ok: !0, data, markdown };
1642
+ return {
1643
+ ok: !0,
1644
+ data,
1645
+ markdown,
1646
+ ...counted ? {
1647
+ telemetry: {
1648
+ payload: {
1649
+ componentCount: Object.keys(counted.componentManifest.components).length,
1650
+ docsCount: Object.keys(counted.docsManifest?.docs ?? {}).length,
1651
+ resultTokenCount: estimateTokens(markdown),
1652
+ sourceCount: data.sources?.length
1653
+ }
1654
+ }
1655
+ } : {}
1656
+ };
1659
1657
  }
1660
1658
  },
1661
1659
  [DOCS_METHOD_NAMES.show]: {
@@ -1663,13 +1661,14 @@ function createDocsToolset(options) {
1663
1661
  title: "Get Documentation",
1664
1662
  description: describeShow,
1665
1663
  handler: async (input, ctx2) => {
1666
- 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);
1667
- return await reportToolsetTelemetry(ctx2, "tool:getDocumentation", {
1668
- toolset: "docs",
1669
- componentId: id,
1670
- found: data.entry !== void 0,
1671
- resultTokenCount: estimateTokens(markdown)
1672
- }), isDocsShowError(data) ? { ok: !1, data, markdown } : { ok: !0, data, markdown };
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 = {
1665
+ payload: {
1666
+ componentId: id,
1667
+ found: data.entry !== void 0,
1668
+ resultTokenCount: estimateTokens(markdown)
1669
+ }
1670
+ };
1671
+ return isDocsShowError(data) ? { ok: !1, data, markdown, telemetry } : { ok: !0, data, markdown, telemetry };
1673
1672
  }
1674
1673
  },
1675
1674
  [DOCS_METHOD_NAMES.showStory]: {
@@ -1677,8 +1676,15 @@ function createDocsToolset(options) {
1677
1676
  title: "Get Documentation for Story",
1678
1677
  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.",
1679
1678
  handler: async (input, 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);
1681
- return isDocsShowStoryError(data) ? { ok: !1, data, markdown } : { ok: !0, data, markdown };
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 = {
1680
+ payload: {
1681
+ found: resolution.kind === "found",
1682
+ storyId: resolution.kind === "found" ? resolution.story.id : storyId,
1683
+ lookup: storyId !== void 0 ? "storyId" : "name",
1684
+ resultTokenCount: estimateTokens(markdown)
1685
+ }
1686
+ };
1687
+ return resolution.kind === "found" ? { ok: !0, data, markdown, telemetry } : { ok: !1, data, markdown, telemetry };
1682
1688
  }
1683
1689
  }
1684
1690
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/mcp",
3
- "version": "10.6.0",
3
+ "version": "10.6.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": "10.6.0",
52
+ "storybook": "10.6.2",
53
53
  "tinyexec": "^1.0.2",
54
54
  "typescript": "^6.0.3"
55
55
  },