@storybook/mcp 11.0.0-alpha.3 → 11.0.0-alpha.5

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
@@ -5,6 +5,13 @@ import { McpServer } from "tmcp";
5
5
  //#region code/core/dist/shared/open-service/toolsets/docs/public.d.ts
6
6
  //#endregion
7
7
  //#region code/core/.dts-emit/code/core/src/shared/open-service/toolsets/docs/instructions.d.ts
8
+ /**
9
+ * Server instructions for an MCP server that only serves the docs tools (`@storybook/mcp`).
10
+ *
11
+ * This is the workflow an agent should follow across the three tools, which no single tool
12
+ * description can state: discover ids first, then fetch, and never invent a prop. It names its
13
+ * tools through {@link getToolName} so the prose cannot drift from what is registered.
14
+ */
8
15
  declare const DOCS_TOOLSET_INSTRUCTIONS: string; //#endregion
9
16
  //#region code/core/.dts-emit/code/core/src/shared/open-service/toolsets/docs/manifest-formatter/manifest-types.d.ts
10
17
  declare const StorySchema: v.ObjectSchema<{
@@ -529,7 +536,7 @@ type DocgenJsDocTags = Record<string, string[]>;
529
536
  * Docgen payload returned by `core/docgen`'s `docgen` query.
530
537
  *
531
538
  * Component-only fields (props, descriptions, subcomponents). Story snippets and file-level
532
- * imports live in `core/story-docs` when `experimentalDocgenServer` is enabled.
539
+ * imports live in `core/story-docs` when `docgenServer` is enabled.
533
540
  */
534
541
  interface DocgenPayload {
535
542
  id: string;
@@ -585,7 +592,7 @@ type MdxDoc = {
585
592
  }; //#endregion
586
593
  //#region code/core/.dts-emit/code/core/src/shared/open-service/toolsets/docs/manifest-formatter/adapt-core-manifest.d.ts
587
594
  /**
588
- * Adapts the `experimentalDocgenServer` open-service payloads into the manifest formatter's
595
+ * Adapts the `docgenServer` open-service payloads into the manifest formatter's
589
596
  * {@link ComponentManifest}/{@link Doc} shapes.
590
597
  *
591
598
  * Only `argTypes` is dropped: the props section comes from `apiDescription` when the framework
@@ -689,7 +696,7 @@ type StorybookContext = {
689
696
  })) => void | Promise<void>;
690
697
  /**
691
698
  * Optional in-process resolver for a single component or docs entry, used in
692
- * Storybook's dev server when `experimentalDocgenServer` is enabled. When set,
699
+ * Storybook's dev server when `docgenServer` is enabled. When set,
693
700
  * single-entry tools (`docs-show`, `docs-show-story`) call
694
701
  * this instead of fetching the (potentially all-component) manifest index, so a
695
702
  * single lookup never triggers docgen extraction for every component.
@@ -713,7 +720,7 @@ type ResolvedEntry = {
713
720
  };
714
721
  /**
715
722
  * Open-service payload contracts (the "core format") that Storybook's
716
- * `experimentalDocgenServer` mode produces. `@storybook/mcp` adapts these into its
723
+ * `docgenServer` mode produces. `@storybook/mcp` adapts these into its
717
724
  * internal {@link ComponentManifest}/{@link Doc} shapes in one place
718
725
  * (`adaptCoreComponent`/`adaptCoreDoc`). Defined structurally (not as schemas) so
719
726
  * the addon can build them in-process without importing Storybook core.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_ve4nsqf8lo9 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_ve4nsqf8lo9 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_ve4nsqf8lo9 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_i1a2q53j96 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_i1a2q53j96 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_i1a2q53j96 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_ve4nsqf8lo9.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_ve4nsqf8lo9.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_ve4nsqf8lo9.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_i1a2q53j96.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_i1a2q53j96.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_i1a2q53j96.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.3",
27
+ version: "11.0.0-alpha.5",
28
28
  description: "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
29
29
  keywords: [
30
30
  "mcp",
@@ -129,31 +129,21 @@ function getToolName(context) {
129
129
  };
130
130
  }
131
131
 
132
- // ../../core/dist/_browser-chunks/chunk-PMPHKUPK.js
132
+ // ../../core/dist/_browser-chunks/chunk-7OC3MZ62.js
133
+ function defineToolset(definition) {
134
+ for (let [methodName, method] of Object.entries(definition.methods)) {
135
+ let input = method.input;
136
+ if (input["~standard"].vendor === "valibot" && input.type !== "strict_object")
137
+ throw new Error(
138
+ `Toolset method "${definition.id}.${methodName}" must declare its input with v.strictObject, got a valibot "${String(input.type)}" schema. Undeclared arguments would otherwise be silently dropped or passed through instead of rejected.`
139
+ );
140
+ }
141
+ return definition;
142
+ }
133
143
  function resolveToolsetDescription(description3, context) {
134
144
  return typeof description3 == "function" ? description3(context) : description3;
135
145
  }
136
146
 
137
- // ../../core/dist/_browser-chunks/chunk-DJVLGLRX.js
138
- function getDocsToolsetInstructions(transport) {
139
- let ref = getToolName({ transport });
140
- return `## Documentation Workflow
141
-
142
- **CRITICAL: Never hallucinate component properties!** Before using ANY property on a component (even common-sounding ones like \`shadow\`), you MUST verify it is documented via these tools. If it is not documented, it does not exist \u2014 never assume props from naming conventions or other libraries; report it to the user instead.
143
-
144
- 1. Call **${ref("docs.list")}** once at the start of the task to discover available component and docs IDs.
145
- 2. Call **${ref("docs.show")}** with an \`id\` from that list to retrieve full component docs, props, usage examples, and stories.
146
- 3. Call **${ref("docs.showStory")}** for extra docs on a story variant not covered by the component docs.
147
-
148
- Only use properties explicitly documented or shown in example stories. Only reference IDs returned by these tools; never guess IDs.
149
-
150
- ## Multi-Source Requests
151
-
152
- - With multiple sources configured, **${ref("docs.list")}** returns entries from every source; pass \`storybookId\` to **${ref("docs.show")}** to scope one.
153
- `;
154
- }
155
- var DOCS_TOOLSET_INSTRUCTIONS = getDocsToolsetInstructions("mcp");
156
-
157
147
  // ../../core/dist/_browser-chunks/chunk-T36TEMM7.js
158
148
  var store$4, DEFAULT_CONFIG = {
159
149
  lang: void 0,
@@ -835,6 +825,20 @@ var __require2 = ((x) => typeof __require < "u" ? __require : typeof Proxy < "u"
835
825
  });
836
826
 
837
827
  // ../../core/dist/shared/open-service/toolsets/docs/public.js
828
+ var ref = getToolName({ transport: "mcp" }), DOCS_TOOLSET_INSTRUCTIONS = `## Documentation Workflow
829
+
830
+ **CRITICAL: Never hallucinate component properties!** Before using ANY property on a component (even common-sounding ones like \`shadow\`), you MUST verify it is documented via these tools. If it is not documented, it does not exist \u2014 never assume props from naming conventions or other libraries; report it to the user instead.
831
+
832
+ 1. Call **${ref("docs.list")}** once at the start of the task to discover available component and docs IDs.
833
+ 2. Call **${ref("docs.show")}** with an \`id\` from that list to retrieve full component docs, props, usage examples, and stories.
834
+ 3. Call **${ref("docs.showStory")}** for extra docs on a story variant not covered by the component docs.
835
+
836
+ Only use properties explicitly documented or shown in example stories. Only reference IDs returned by these tools; never guess IDs.
837
+
838
+ ## Multi-Source Requests
839
+
840
+ - With multiple sources configured, **${ref("docs.list")}** returns entries from every source; pass \`storybookId\` to **${ref("docs.show")}** to scope one.
841
+ `;
838
842
  function emptyManifests() {
839
843
  return { componentManifest: { v: 1, components: {} } };
840
844
  }
@@ -1338,8 +1342,8 @@ async function fetchManifests(request, manifestProvider, source) {
1338
1342
  });
1339
1343
  return { componentManifest, docsManifest };
1340
1344
  }
1341
- function parseManifestRef(ref) {
1342
- let [filePath = "", hash = ""] = ref.split("#"), manifestDir = COMPONENT_MANIFEST_PATH.replace(/^\.\//, "").replace(/[^/]+$/, ""), resolved = new URL(filePath, `https://localhost/${manifestDir}`).pathname.replace(
1345
+ function parseManifestRef(ref2) {
1346
+ let [filePath = "", hash = ""] = ref2.split("#"), manifestDir = COMPONENT_MANIFEST_PATH.replace(/^\.\//, "").replace(/[^/]+$/, ""), resolved = new URL(filePath, `https://localhost/${manifestDir}`).pathname.replace(
1343
1347
  /^\//,
1344
1348
  ""
1345
1349
  ), pointer = hash.split("/").filter(Boolean).map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
@@ -1363,13 +1367,13 @@ var jsonObject = (schema) => pipe(
1363
1367
  ), MdxRefPayload = jsonObject(
1364
1368
  looseObject({ id: optional(string()), name: optional(string()) })
1365
1369
  );
1366
- async function fetchRefValue(ref, request, provider, source, schema) {
1367
- let { path, pointer } = parseManifestRef(ref), jsonString = await provider(request, path, source), target;
1370
+ async function fetchRefValue(ref2, request, provider, source, schema) {
1371
+ let { path, pointer } = parseManifestRef(ref2), jsonString = await provider(request, path, source), target;
1368
1372
  try {
1369
1373
  target = JSON.parse(jsonString);
1370
1374
  } catch (error) {
1371
1375
  throw new ManifestGetError(
1372
- `Failed to parse externalized payload referenced by "${ref}"`,
1376
+ `Failed to parse externalized payload referenced by "${ref2}"`,
1373
1377
  path,
1374
1378
  error instanceof Error ? error : void 0
1375
1379
  );
@@ -1379,13 +1383,13 @@ async function fetchRefValue(ref, request, provider, source, schema) {
1379
1383
  target = target[key];
1380
1384
  else
1381
1385
  throw new ManifestGetError(
1382
- `Reference "${ref}" could not be resolved: missing "${key}".`,
1386
+ `Reference "${ref2}" could not be resolved: missing "${key}".`,
1383
1387
  path
1384
1388
  );
1385
1389
  let parsed = safeParse(schema, target);
1386
1390
  if (!parsed.success)
1387
1391
  throw new ManifestGetError(
1388
- `Payload referenced by "${ref}" is not a valid manifest payload.`,
1392
+ `Payload referenced by "${ref2}" is not a valid manifest payload.`,
1389
1393
  path
1390
1394
  );
1391
1395
  return parsed.output;
@@ -1441,10 +1445,10 @@ async function resolveComponentStories(component, request, manifestProvider, sou
1441
1445
  };
1442
1446
  }
1443
1447
  async function resolveDocEntry(doc, request, manifestProvider, source) {
1444
- let ref = "mdx" in doc ? doc.mdx?.$ref : void 0;
1445
- if (!ref)
1448
+ let ref2 = "mdx" in doc ? doc.mdx?.$ref : void 0;
1449
+ if (!ref2)
1446
1450
  return doc;
1447
- let payload = await fetchRefValue(ref, request, manifestProvider ?? defaultManifestProvider, source, MdxRefPayload);
1451
+ let payload = await fetchRefValue(ref2, request, manifestProvider ?? defaultManifestProvider, source, MdxRefPayload);
1448
1452
  return adaptCoreDoc({
1449
1453
  ...payload,
1450
1454
  id: payload.id ?? doc.id,
@@ -1713,7 +1717,7 @@ function createDocsToolset(options) {
1713
1717
  )
1714
1718
  )
1715
1719
  }, showStorySchema = multiSource ? strictObject({ ...showStoryFields, ...storybookIdField }) : strictObject(showStoryFields), access = (storybookId, ctx2) => multiSource ? selectSource(sources, storybookId, ctx2) : { access: docsAccess };
1716
- return {
1720
+ return defineToolset({
1717
1721
  id: DOCS_TOOLSET_ID,
1718
1722
  description: "Storybook component and docs documentation.",
1719
1723
  methods: {
@@ -1782,7 +1786,7 @@ function createDocsToolset(options) {
1782
1786
  }
1783
1787
  }
1784
1788
  }
1785
- };
1789
+ });
1786
1790
  }
1787
1791
 
1788
1792
  // src/utils/error-to-mcp-content.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/mcp",
3
- "version": "11.0.0-alpha.3",
3
+ "version": "11.0.0-alpha.5",
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.3",
52
+ "storybook": "11.0.0-alpha.5",
53
53
  "tinyexec": "^1.0.2",
54
54
  "typescript": "^6.0.3"
55
55
  },