@storybook/mcp 10.6.6 → 10.6.8

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 (3) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +42 -20
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -330,6 +330,8 @@ await addGetStoryDocumentationTool(server);
330
330
 
331
331
  After registration, wire your own transport and pass `StorybookContext` per request so tools can resolve manifests (`request`, `manifestProvider`, and optional `sources`).
332
332
 
333
+ Each tool's input schema follows the `sources` of the request being served: when they compose several Storybooks (at least one source has a `url`), `docs-show` and `docs-show-story` take an optional `storybookId`; otherwise they do not. Pass `options.multiSource` to fix the shape at registration instead.
334
+
333
335
  #### `addListAllDocumentationTool`
334
336
 
335
337
  Type:
@@ -355,7 +357,7 @@ Type:
355
357
 
356
358
  Registers [documentation lookup](https://storybook.js.org/docs/next/ai/mcp/overview/#docs-show) by component/docs `id`.
357
359
 
358
- When `options.multiSource` is `true`, the tool schema requires `storybookId` input.
360
+ When `options.multiSource` is `true`, the tool schema takes an optional `storybookId` input, defaulting to `local`. When it is omitted, the schema follows the request's `sources`.
359
361
 
360
362
  #### `addGetStoryDocumentationTool`
361
363
 
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_00xmzkokzlk2 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_00xmzkokzlk2 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_00xmzkokzlk2 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_unuvi609t0o from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_unuvi609t0o from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_unuvi609t0o from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_00xmzkokzlk2.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_00xmzkokzlk2.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_00xmzkokzlk2.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_unuvi609t0o.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_unuvi609t0o.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_unuvi609t0o.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.6",
27
+ version: "10.6.8",
28
28
  description: "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
29
29
  keywords: [
30
30
  "mcp",
@@ -1574,18 +1574,20 @@ function renderShowStory(resolution, data, ctx2) {
1574
1574
  }
1575
1575
  }
1576
1576
  var storybookIdField = {
1577
- storybookId: pipe(
1578
- string(),
1579
- description('The ID of the Storybook source to query (e.g., "local", "design-system")')
1577
+ storybookId: optional(
1578
+ pipe(
1579
+ string(),
1580
+ description(
1581
+ 'The ID of the Storybook source to query (e.g., "local", "design-system"). Defaults to "local", this Storybook.'
1582
+ )
1583
+ ),
1584
+ "local"
1580
1585
  )
1581
1586
  };
1582
1587
  function selectSource(sources, storybookId, ctx2) {
1583
1588
  if (!sources?.length)
1584
1589
  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);
1590
+ 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
1591
  return match ? { access: match.access } : {
1590
1592
  sourceError: `Storybook source not found: "${storybookId}". Available sources: ${available}. ${listRef}`
1591
1593
  };
@@ -1734,9 +1736,12 @@ var LIST_TOOL_NAME = toMcpToolName("docs.list"), GET_TOOL_NAME = toMcpToolName("
1734
1736
  throw new Error("Open services are not available in a hosted Storybook.");
1735
1737
  }
1736
1738
  };
1739
+ function isComposition(sources) {
1740
+ return !!sources?.some((source) => source.url);
1741
+ }
1737
1742
  function getSources(context) {
1738
1743
  let sources = context?.sources;
1739
- if (sources?.some((source) => source.url))
1744
+ if (isComposition(sources))
1740
1745
  return createCompositionDocsSources({
1741
1746
  sources,
1742
1747
  manifestProvider: context?.manifestProvider,
@@ -1780,8 +1785,22 @@ function getDocumentationToolMetadata(options) {
1780
1785
  function getStoryDocumentationToolMetadata(options) {
1781
1786
  return toolMetadata("docs.showStory", !!options?.multiSource);
1782
1787
  }
1783
- function registerTool(server, metadata, handler) {
1784
- server.tool(metadata, handler);
1788
+ function requestMetadata(server, method, options) {
1789
+ let single = toolMetadata(method, !1), composed = toolMetadata(method, !0), current = () => options?.multiSource ?? isComposition(server.ctx.custom?.sources) ? composed : single, { name, title, description: description3 } = current();
1790
+ return {
1791
+ name,
1792
+ title,
1793
+ description: description3,
1794
+ get schema() {
1795
+ return current().schema;
1796
+ },
1797
+ get outputSchema() {
1798
+ return current().outputSchema;
1799
+ }
1800
+ };
1801
+ }
1802
+ function registerTool(server, metadata, enabled, handler) {
1803
+ enabled !== void 0 && Object.assign(metadata, { enabled }), server.tool(metadata, handler);
1785
1804
  }
1786
1805
  function outputSchemaOf(definition) {
1787
1806
  return definition.output;
@@ -1829,7 +1848,8 @@ async function call(server, method, input) {
1829
1848
  async function addListAllDocumentationTool(server, enabled, options) {
1830
1849
  registerTool(
1831
1850
  server,
1832
- { ...getListAllDocumentationToolMetadata(options), enabled },
1851
+ requestMetadata(server, "docs.list", options),
1852
+ enabled,
1833
1853
  async (input) => {
1834
1854
  let context = server.ctx.custom, { data, result } = await call(server, "list", input), listing = data, manifests = listing && selectReportedManifests(listing);
1835
1855
  return manifests && await context?.onListAllDocumentation?.({
@@ -1844,7 +1864,8 @@ async function addListAllDocumentationTool(server, enabled, options) {
1844
1864
  async function addGetDocumentationTool(server, enabled, options) {
1845
1865
  registerTool(
1846
1866
  server,
1847
- { ...getDocumentationToolMetadata(options), enabled },
1867
+ requestMetadata(server, "docs.show", options),
1868
+ enabled,
1848
1869
  async (input) => {
1849
1870
  let context = server.ctx.custom, { data, result } = await call(server, "show", input);
1850
1871
  if (data) {
@@ -1865,7 +1886,8 @@ async function addGetDocumentationTool(server, enabled, options) {
1865
1886
  async function addGetStoryDocumentationTool(server, enabled, options) {
1866
1887
  registerTool(
1867
1888
  server,
1868
- { ...getStoryDocumentationToolMetadata(options), enabled },
1889
+ requestMetadata(server, "docs.showStory", options),
1890
+ enabled,
1869
1891
  async (input) => (await call(server, "showStory", input)).result
1870
1892
  );
1871
1893
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/mcp",
3
- "version": "10.6.6",
3
+ "version": "10.6.8",
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.6",
52
+ "storybook": "10.6.8",
53
53
  "tinyexec": "^1.0.2",
54
54
  "typescript": "^6.0.3"
55
55
  },