@storybook/mcp 10.6.0-alpha.7 → 10.6.0-alpha.9

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.d.ts CHANGED
@@ -508,9 +508,9 @@ interface StoryDoc {
508
508
  description?: string;
509
509
  summary?: string;
510
510
  /**
511
- * Why the snippet is an incomplete example: what a static pass could not resolve, in the source
512
- * text it was written as. A story that carries this still carries a `snippet`; an `error` means
513
- * there is no snippet at all.
511
+ * What a static pass could not resolve, in the source text it was written as. Next to a
512
+ * `snippet` it marks the example as partial; on its own it says why no static snippet could be
513
+ * produced at all. An `error` means the provider itself failed.
514
514
  */
515
515
  warning?: string;
516
516
  error?: StoryDocsError;
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_et7v2wkem2f from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_et7v2wkem2f from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_et7v2wkem2f from "node:module";
1
+ import CJS_COMPAT_NODE_URL_ryr3dir6sll from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_ryr3dir6sll from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_ryr3dir6sll from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_et7v2wkem2f.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_et7v2wkem2f.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_et7v2wkem2f.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_ryr3dir6sll.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_ryr3dir6sll.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_ryr3dir6sll.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-alpha.7",
27
+ version: "10.6.0-alpha.9",
28
28
  description: "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
29
29
  keywords: [
30
30
  "mcp",
@@ -850,9 +850,10 @@ var parseReactDocgen = (reactDocgen) => {
850
850
  ])
851
851
  )
852
852
  };
853
- }, parseComponentDocLike = (componentDoc) => {
854
- let props = componentDoc.props ?? {};
855
- return {
853
+ }, tagValues = (value) => Array.isArray(value) ? value.flatMap(tagValues) : value == null ? [""] : [typeof value == "object" ? JSON.stringify(value) : String(value)], parseComponentDocLike = (componentDoc) => {
854
+ let props = componentDoc.props ?? {}, tags = Object.fromEntries(
855
+ Object.entries(componentDoc.tags ?? {}).map(([tagName, value]) => [tagName, tagValues(value)])
856
+ ), parsedDocgen = {
856
857
  props: Object.fromEntries(
857
858
  Object.entries(props).map(([propName, prop]) => [
858
859
  propName,
@@ -867,7 +868,20 @@ var parseReactDocgen = (reactDocgen) => {
867
868
  ])
868
869
  )
869
870
  };
870
- }, parseReactDocgenTypescript = (reactDocgenTypescript) => parseComponentDocLike(reactDocgenTypescript), parseReactComponentMeta = (reactComponentMeta) => parseComponentDocLike(reactComponentMeta), MAX_STORIES_TO_SHOW = 3;
871
+ return Object.keys(tags).length > 0 && (parsedDocgen.tags = tags), parsedDocgen;
872
+ }, parseReactDocgenTypescript = (reactDocgenTypescript) => parseComponentDocLike(reactDocgenTypescript), parseReactComponentMeta = (reactComponentMeta) => parseComponentDocLike(reactComponentMeta), MAX_STORIES_TO_SHOW = 3, TOP_JSDOC_TAG_NAMES = /* @__PURE__ */ new Set(["deprecated"]), EXAMPLE_JSDOC_TAG_NAME = "example", HIDDEN_JSDOC_TAG_NAMES = /* @__PURE__ */ new Set([
873
+ // Asks for the component to be hidden, so echoing it back is the opposite of the intent.
874
+ "ignore",
875
+ // Consumed by `extractComponentDescription` as the description, which is rendered on its own.
876
+ "desc",
877
+ "description",
878
+ // Storybook's own description override, consumed alongside `desc`.
879
+ "describe",
880
+ // Consumed into the `summary` field, which the component listing already prints.
881
+ "summary",
882
+ // Consumed into the import statement printed above every story snippet.
883
+ "import"
884
+ ]);
871
885
  function formatComponentLine(component) {
872
886
  let summary = component.summary ?? (component.description ? component.description.length > 90 ? `${component.description.slice(0, 90)}...` : component.description : void 0);
873
887
  return summary ? `- ${component.name} (${component.id}): ${summary}` : `- ${component.name} (${component.id})`;
@@ -893,6 +907,42 @@ function getParsedDocgen(componentManifest) {
893
907
  if (componentManifest.reactComponentMeta)
894
908
  return parseReactComponentMeta(componentManifest.reactComponentMeta);
895
909
  }
910
+ function getNonEmptyJsDocTags(jsDocTags) {
911
+ return jsDocTags && Object.keys(jsDocTags).length > 0 ? jsDocTags : void 0;
912
+ }
913
+ function getComponentTags(componentManifest, parsedDocgen) {
914
+ return getNonEmptyJsDocTags(componentManifest.jsDocTags) ?? parsedDocgen?.tags;
915
+ }
916
+ function formatTagName(tagName) {
917
+ return tagName.charAt(0).toUpperCase() + tagName.slice(1);
918
+ }
919
+ function formatJsDocTagBlockquote(tagName, values) {
920
+ let described = values.filter((value) => value.trim());
921
+ return (described.length > 0 ? described : [""]).flatMap((value) => {
922
+ let [firstLine, ...remainingLines] = value.trim().split(`
923
+ `), label = formatTagName(tagName);
924
+ return [
925
+ firstLine ? `> **${label}:** ${firstLine}` : `> **${label}**`,
926
+ ...remainingLines.map((line) => line ? `> ${line}` : ">")
927
+ ];
928
+ });
929
+ }
930
+ function isTopJsDocTag(tagName) {
931
+ return TOP_JSDOC_TAG_NAMES.has(tagName);
932
+ }
933
+ function isGenericJsDocTag(tagName) {
934
+ return !TOP_JSDOC_TAG_NAMES.has(tagName) && tagName !== EXAMPLE_JSDOC_TAG_NAME && !HIDDEN_JSDOC_TAG_NAMES.has(tagName);
935
+ }
936
+ function formatJsDocTags(jsDocTags, includeTag) {
937
+ let parts = [];
938
+ for (let [tagName, values] of Object.entries(jsDocTags ?? {}))
939
+ includeTag(tagName) && parts.push(...formatJsDocTagBlockquote(tagName, values));
940
+ return parts.length > 0 && parts.push(""), parts;
941
+ }
942
+ function formatExampleJsDocTags(jsDocTags) {
943
+ let examples = jsDocTags?.[EXAMPLE_JSDOC_TAG_NAME];
944
+ return !examples || examples.length === 0 ? [] : examples.flatMap((example) => ["**Example:**", "```", example, "```", ""]);
945
+ }
896
946
  function formatStoryContent(story, importStatement) {
897
947
  let parts = [];
898
948
  return story.description && (parts.push(story.description), parts.push("")), parts.push("```"), importStatement && (parts.push(importStatement), parts.push("")), parts.push(story.snippet ?? ""), parts.push("```"), parts;
@@ -924,7 +974,8 @@ function formatSubcomponentsSection(subcomponents) {
924
974
  let parts = [];
925
975
  parts.push("## Subcomponents"), parts.push("");
926
976
  for (let [key, subcomponent] of Object.entries(subcomponents)) {
927
- if (parts.push(`### ${subcomponent.name || key}`), parts.push(""), subcomponent.summary && (parts.push(subcomponent.summary), parts.push("")), subcomponent.description && (parts.push(subcomponent.description), parts.push("")), subcomponent.import && (parts.push("```"), parts.push(subcomponent.import), parts.push("```"), parts.push("")), subcomponent.error) {
977
+ let parsedDocgen = getParsedDocgen(subcomponent), jsDocTags = getComponentTags(subcomponent, parsedDocgen);
978
+ if (parts.push(`### ${subcomponent.name || key}`), parts.push(""), parts.push(...formatJsDocTags(jsDocTags, isTopJsDocTag)), subcomponent.summary && (parts.push(subcomponent.summary), parts.push("")), subcomponent.description && (parts.push(subcomponent.description), parts.push("")), parts.push(...formatJsDocTags(jsDocTags, isGenericJsDocTag)), parts.push(...formatExampleJsDocTags(jsDocTags)), subcomponent.import && (parts.push("```"), parts.push(subcomponent.import), parts.push("```"), parts.push("")), subcomponent.error) {
928
979
  parts.push(`Error: ${subcomponent.error.name}`), parts.push(""), parts.push("```"), parts.push(subcomponent.error.message), parts.push("```"), parts.push("");
929
980
  continue;
930
981
  }
@@ -932,15 +983,15 @@ function formatSubcomponentsSection(subcomponents) {
932
983
  parts.push(demoteHeadings(subcomponent.apiDescription)), parts.push("");
933
984
  continue;
934
985
  }
935
- let parsedDocgen = getParsedDocgen(subcomponent), typeName = `${(subcomponent.name || key).replace(/\W+/g, "")}Props`;
986
+ let typeName = `${(subcomponent.name || key).replace(/\W+/g, "")}Props`;
936
987
  parts.push(...formatPropsSection(parsedDocgen, { title: "#### Props", typeName }));
937
988
  }
938
989
  return parts;
939
990
  }
940
991
  function formatComponentManifest(componentManifest) {
941
- let parts = [];
942
- parts.push(`# ${componentManifest.name}`), parts.push(""), parts.push(`ID: ${componentManifest.id}`), parts.push(""), componentManifest.description && (parts.push(componentManifest.description), parts.push("")), parts.push(...formatSubcomponentsSection(componentManifest.subcomponents));
943
- let parsedDocgen = getParsedDocgen(componentManifest), { apiDescription } = componentManifest;
992
+ let parts = [], parsedDocgen = getParsedDocgen(componentManifest), jsDocTags = getComponentTags(componentManifest, parsedDocgen);
993
+ parts.push(`# ${componentManifest.name}`), parts.push(""), parts.push(`ID: ${componentManifest.id}`), parts.push(""), parts.push(...formatJsDocTags(jsDocTags, isTopJsDocTag)), componentManifest.description && (parts.push(componentManifest.description), parts.push("")), parts.push(...formatJsDocTags(jsDocTags, isGenericJsDocTag)), parts.push(...formatExampleJsDocTags(jsDocTags)), parts.push(...formatSubcomponentsSection(componentManifest.subcomponents));
994
+ let { apiDescription } = componentManifest;
944
995
  apiDescription && (parts.push(apiDescription), parts.push(""));
945
996
  let stories = Array.isArray(componentManifest.stories) ? componentManifest.stories : [];
946
997
  if (stories.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/mcp",
3
- "version": "10.6.0-alpha.7",
3
+ "version": "10.6.0-alpha.9",
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-alpha.7",
52
+ "storybook": "10.6.0-alpha.9",
53
53
  "tinyexec": "^1.0.2",
54
54
  "typescript": "^6.0.3"
55
55
  },