@storybook/mcp 0.6.2 → 0.8.0

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
@@ -260,10 +260,24 @@ type SourceManifests = {
260
260
  componentManifest: ComponentManifestMap;
261
261
  docsManifest?: DocsManifestMap;
262
262
  error?: string;
263
+ notice?: RequiresOwnMcpNotice;
263
264
  };
264
265
  ```
265
266
 
266
- Represents fetched manifests (or an error) for a single source.
267
+ Represents fetched manifests, an error, or non-error routing guidance for a single source.
268
+
269
+ #### `RequiresOwnMcpNotice`
270
+
271
+ Type:
272
+
273
+ ```ts
274
+ type RequiresOwnMcpNotice = {
275
+ kind: 'requires-own-mcp';
276
+ endpoint: string;
277
+ };
278
+ ```
279
+
280
+ Indicates that a composed Storybook source cannot be read through the local MCP proxy and should be accessed through its own MCP endpoint instead.
267
281
 
268
282
  #### Tool registration exports
269
283
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as instructions_default } from "./instructions-Cl0vcW2j.js";
1
+ import { t as instructions_default } from "./instructions-CiOmp0JI.js";
2
2
  import { McpServer } from "tmcp";
3
3
  import * as v from "valibot";
4
4
 
@@ -11,6 +11,10 @@ type Source = {
11
11
  title: string; /** Remote URL, undefined for local source */
12
12
  url?: string;
13
13
  };
14
+ type RequiresOwnMcpNotice = {
15
+ kind: 'requires-own-mcp';
16
+ endpoint: string;
17
+ };
14
18
  /**
15
19
  * All manifests for a single source.
16
20
  */
@@ -18,7 +22,8 @@ type SourceManifests = {
18
22
  source: Source;
19
23
  componentManifest: ComponentManifestMap;
20
24
  docsManifest?: DocsManifestMap; /** Error message if fetching this source failed */
21
- error?: string;
25
+ error?: string; /** Non-error guidance for sources that must be accessed through their own MCP endpoint */
26
+ notice?: RequiresOwnMcpNotice;
22
27
  };
23
28
  /**
24
29
  * Custom context passed to MCP server and tools.
@@ -35,7 +40,7 @@ type StorybookContext = {
35
40
  * The function receives the request object, a path to the manifest file, and optionally
36
41
  * a source (in multi-source mode).
37
42
  * The default provider requires a request object and constructs the manifest URL from the request origin,
38
- * replacing /mcp with /manifests/components.json.
43
+ * using the top-level manifest path such as /manifests/components.json.
39
44
  * Custom providers can use the request parameter to determine the manifest source, or ignore it entirely.
40
45
  */
41
46
  manifestProvider?: (request: Request | undefined, path: string, source?: Source) => Promise<string>;
@@ -71,29 +76,60 @@ type StorybookContext = {
71
76
  foundDocumentation?: never;
72
77
  resultText?: never;
73
78
  })) => void | Promise<void>;
79
+ /**
80
+ * Optional in-process resolver for a single component or docs entry, used in
81
+ * Storybook's dev server when `experimentalDocgenServer` is enabled. When set,
82
+ * single-entry tools (`get-documentation`, `get-documentation-for-story`) call
83
+ * this instead of fetching the (potentially all-component) manifest index, so a
84
+ * single lookup never triggers docgen extraction for every component.
85
+ *
86
+ * Returns the fully-resolved component or doc in `@storybook/mcp`'s internal
87
+ * shape (already adapted from the open-service payloads), or `undefined` when the
88
+ * id is unknown.
89
+ */
90
+ resolveEntry?: (id: string, source?: Source) => Promise<ResolvedEntry | undefined>;
74
91
  };
75
92
  /**
76
- * A docs entry represents MDX documentation that can be attached to a component
77
- * or standalone (unattached).
93
+ * Result of resolving a single id via {@link StorybookContext.resolveEntry}: either a
94
+ * fully-resolved component manifest or a standalone docs entry.
78
95
  */
79
- declare const Doc: v.ObjectSchema<{
96
+ type ResolvedEntry = {
97
+ kind: 'component';
98
+ component: ComponentManifest;
99
+ } | {
100
+ kind: 'doc';
101
+ doc: Doc;
102
+ };
103
+ declare const Story: v.ObjectSchema<{
104
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
105
+ readonly snippet: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
106
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
107
+ readonly name: v.StringSchema<undefined>;
108
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
109
+ readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
110
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
111
+ readonly name: v.StringSchema<undefined>;
112
+ readonly message: v.StringSchema<undefined>;
113
+ }, undefined>, undefined>;
114
+ }, undefined>;
115
+ type Story = v.InferOutput<typeof Story>;
116
+ /** Inline (v0) docs entry: the full MDX `content` is embedded. */
117
+ declare const DocV0: v.ObjectSchema<{
80
118
  readonly id: v.StringSchema<undefined>;
81
119
  readonly name: v.StringSchema<undefined>;
82
- readonly title: v.StringSchema<undefined>;
83
- readonly path: v.StringSchema<undefined>;
84
- readonly content: v.StringSchema<undefined>;
120
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
121
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
122
+ readonly content: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
85
123
  readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
86
124
  readonly error: v.OptionalSchema<v.ObjectSchema<{
87
125
  readonly name: v.StringSchema<undefined>;
88
126
  readonly message: v.StringSchema<undefined>;
89
127
  }, undefined>, undefined>;
90
128
  }, undefined>;
91
- type Doc = v.InferOutput<typeof Doc>;
92
- declare const ComponentManifest: v.ObjectSchema<{
129
+ type DocV0 = v.InferOutput<typeof DocV0>;
130
+ /** Inline (v0) component: docgen, stories and attached docs are all embedded. */
131
+ declare const ComponentManifestV0: v.ObjectSchema<{
93
132
  readonly id: v.StringSchema<undefined>;
94
- readonly path: v.StringSchema<undefined>;
95
- readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
96
- readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
97
133
  readonly stories: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
98
134
  readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
99
135
  readonly snippet: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -106,21 +142,39 @@ declare const ComponentManifest: v.ObjectSchema<{
106
142
  readonly message: v.StringSchema<undefined>;
107
143
  }, undefined>, undefined>;
108
144
  }, undefined>, undefined>, undefined>;
109
- readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
110
- readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
111
- readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
145
+ readonly subcomponents: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
146
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
147
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
148
+ readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
149
+ readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
150
+ readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
151
+ readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
152
+ readonly name: v.StringSchema<undefined>;
153
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
154
+ readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
155
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
156
+ readonly name: v.StringSchema<undefined>;
157
+ readonly message: v.StringSchema<undefined>;
158
+ }, undefined>, undefined>;
159
+ }, undefined>, undefined>, undefined>;
112
160
  readonly docs: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
113
161
  readonly id: v.StringSchema<undefined>;
114
162
  readonly name: v.StringSchema<undefined>;
115
- readonly title: v.StringSchema<undefined>;
116
- readonly path: v.StringSchema<undefined>;
117
- readonly content: v.StringSchema<undefined>;
163
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
164
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
165
+ readonly content: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
118
166
  readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
119
167
  readonly error: v.OptionalSchema<v.ObjectSchema<{
120
168
  readonly name: v.StringSchema<undefined>;
121
169
  readonly message: v.StringSchema<undefined>;
122
170
  }, undefined>, undefined>;
123
171
  }, undefined>, undefined>, undefined>;
172
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
173
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
174
+ readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
175
+ readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
176
+ readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
177
+ readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
124
178
  readonly name: v.StringSchema<undefined>;
125
179
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
126
180
  readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
@@ -129,14 +183,65 @@ declare const ComponentManifest: v.ObjectSchema<{
129
183
  readonly message: v.StringSchema<undefined>;
130
184
  }, undefined>, undefined>;
131
185
  }, undefined>;
132
- type ComponentManifest = v.InferOutput<typeof ComponentManifest>;
133
- declare const ComponentManifestMap: v.ObjectSchema<{
134
- readonly v: v.NumberSchema<undefined>;
135
- readonly components: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
186
+ type ComponentManifestV0 = v.InferOutput<typeof ComponentManifestV0>;
187
+ /**
188
+ * Shallow (v1) docs entry. The full MDX payload (title/path/content) lives behind
189
+ * `mdx.$ref`; `mdx` is optional because Storybook's in-process dev index omits it
190
+ * (those entries are resolved in-process via {@link StorybookContext.resolveEntry}).
191
+ */
192
+ declare const DocV1: v.ObjectSchema<{
193
+ readonly id: v.StringSchema<undefined>;
194
+ readonly name: v.StringSchema<undefined>;
195
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
196
+ readonly mdx: v.OptionalSchema<v.ObjectSchema<{
197
+ readonly $ref: v.StringSchema<undefined>;
198
+ }, undefined>, undefined>;
199
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
200
+ readonly name: v.StringSchema<undefined>;
201
+ readonly message: v.StringSchema<undefined>;
202
+ }, undefined>, undefined>;
203
+ }, undefined>;
204
+ type DocV1 = v.InferOutput<typeof DocV1>;
205
+ /**
206
+ * Shallow (v1) component index row. Identity + summary are inlined for cheap
207
+ * listing; docgen and story-docs live behind `$ref`s, attached docs behind nested
208
+ * `mdx.$ref`s. `docgen`/`stories` are optional (the in-process dev index omits
209
+ * `docgen`, and docs-only components have neither).
210
+ */
211
+ declare const ComponentManifestV1: v.ObjectSchema<{
212
+ readonly id: v.StringSchema<undefined>;
213
+ readonly name: v.StringSchema<undefined>;
214
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
215
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
216
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
217
+ readonly name: v.StringSchema<undefined>;
218
+ readonly message: v.StringSchema<undefined>;
219
+ }, undefined>, undefined>;
220
+ readonly docgen: v.OptionalSchema<v.ObjectSchema<{
221
+ readonly $ref: v.StringSchema<undefined>;
222
+ }, undefined>, undefined>;
223
+ readonly stories: v.OptionalSchema<v.ObjectSchema<{
224
+ readonly $ref: v.StringSchema<undefined>;
225
+ }, undefined>, undefined>;
226
+ readonly docs: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
136
227
  readonly id: v.StringSchema<undefined>;
137
- readonly path: v.StringSchema<undefined>;
228
+ readonly name: v.StringSchema<undefined>;
138
229
  readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
139
- readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
230
+ readonly mdx: v.OptionalSchema<v.ObjectSchema<{
231
+ readonly $ref: v.StringSchema<undefined>;
232
+ }, undefined>, undefined>;
233
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
234
+ readonly name: v.StringSchema<undefined>;
235
+ readonly message: v.StringSchema<undefined>;
236
+ }, undefined>, undefined>;
237
+ }, undefined>, undefined>, undefined>;
238
+ }, undefined>;
239
+ type ComponentManifestV1 = v.InferOutput<typeof ComponentManifestV1>;
240
+ /** `components.json`, discriminated on `v` (0 = inline, 1 = split/ref). */
241
+ declare const ComponentManifestMap: v.VariantSchema<"v", [v.ObjectSchema<{
242
+ readonly v: v.LiteralSchema<0, undefined>;
243
+ readonly components: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
244
+ readonly id: v.StringSchema<undefined>;
140
245
  readonly stories: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
141
246
  readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
142
247
  readonly snippet: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -149,21 +254,39 @@ declare const ComponentManifestMap: v.ObjectSchema<{
149
254
  readonly message: v.StringSchema<undefined>;
150
255
  }, undefined>, undefined>;
151
256
  }, undefined>, undefined>, undefined>;
152
- readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
153
- readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
154
- readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
257
+ readonly subcomponents: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
258
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
259
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
260
+ readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
261
+ readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
262
+ readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
263
+ readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
264
+ readonly name: v.StringSchema<undefined>;
265
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
266
+ readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
267
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
268
+ readonly name: v.StringSchema<undefined>;
269
+ readonly message: v.StringSchema<undefined>;
270
+ }, undefined>, undefined>;
271
+ }, undefined>, undefined>, undefined>;
155
272
  readonly docs: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
156
273
  readonly id: v.StringSchema<undefined>;
157
274
  readonly name: v.StringSchema<undefined>;
158
- readonly title: v.StringSchema<undefined>;
159
- readonly path: v.StringSchema<undefined>;
160
- readonly content: v.StringSchema<undefined>;
275
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
276
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
277
+ readonly content: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
161
278
  readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
162
279
  readonly error: v.OptionalSchema<v.ObjectSchema<{
163
280
  readonly name: v.StringSchema<undefined>;
164
281
  readonly message: v.StringSchema<undefined>;
165
282
  }, undefined>, undefined>;
166
283
  }, undefined>, undefined>, undefined>;
284
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
285
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
286
+ readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
287
+ readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
288
+ readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
289
+ readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
167
290
  readonly name: v.StringSchema<undefined>;
168
291
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
169
292
  readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
@@ -172,55 +295,268 @@ declare const ComponentManifestMap: v.ObjectSchema<{
172
295
  readonly message: v.StringSchema<undefined>;
173
296
  }, undefined>, undefined>;
174
297
  }, undefined>, undefined>;
175
- }, undefined>;
298
+ }, undefined>, v.ObjectSchema<{
299
+ readonly v: v.LiteralSchema<1, undefined>;
300
+ readonly components: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
301
+ readonly id: v.StringSchema<undefined>;
302
+ readonly name: v.StringSchema<undefined>;
303
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
304
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
305
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
306
+ readonly name: v.StringSchema<undefined>;
307
+ readonly message: v.StringSchema<undefined>;
308
+ }, undefined>, undefined>;
309
+ readonly docgen: v.OptionalSchema<v.ObjectSchema<{
310
+ readonly $ref: v.StringSchema<undefined>;
311
+ }, undefined>, undefined>;
312
+ readonly stories: v.OptionalSchema<v.ObjectSchema<{
313
+ readonly $ref: v.StringSchema<undefined>;
314
+ }, undefined>, undefined>;
315
+ readonly docs: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
316
+ readonly id: v.StringSchema<undefined>;
317
+ readonly name: v.StringSchema<undefined>;
318
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
319
+ readonly mdx: v.OptionalSchema<v.ObjectSchema<{
320
+ readonly $ref: v.StringSchema<undefined>;
321
+ }, undefined>, undefined>;
322
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
323
+ readonly name: v.StringSchema<undefined>;
324
+ readonly message: v.StringSchema<undefined>;
325
+ }, undefined>, undefined>;
326
+ }, undefined>, undefined>, undefined>;
327
+ }, undefined>, undefined>;
328
+ }, undefined>], undefined>;
176
329
  type ComponentManifestMap = v.InferOutput<typeof ComponentManifestMap>;
177
330
  /**
178
- * Manifest for unattached/standalone documentation entries.
179
- * Served at /manifests/docs.json
331
+ * `docs.json` for unattached/standalone documentation entries (served at
332
+ * `/manifests/docs.json`), discriminated on `v`.
180
333
  */
181
- declare const DocsManifestMap: v.ObjectSchema<{
182
- readonly v: v.NumberSchema<undefined>;
334
+ declare const DocsManifestMap: v.VariantSchema<"v", [v.ObjectSchema<{
335
+ readonly v: v.LiteralSchema<0, undefined>;
183
336
  readonly docs: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
184
337
  readonly id: v.StringSchema<undefined>;
185
338
  readonly name: v.StringSchema<undefined>;
186
- readonly title: v.StringSchema<undefined>;
187
- readonly path: v.StringSchema<undefined>;
188
- readonly content: v.StringSchema<undefined>;
339
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
340
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
341
+ readonly content: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
189
342
  readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
190
343
  readonly error: v.OptionalSchema<v.ObjectSchema<{
191
344
  readonly name: v.StringSchema<undefined>;
192
345
  readonly message: v.StringSchema<undefined>;
193
346
  }, undefined>, undefined>;
194
347
  }, undefined>, undefined>;
195
- }, undefined>;
348
+ }, undefined>, v.ObjectSchema<{
349
+ readonly v: v.LiteralSchema<1, undefined>;
350
+ readonly docs: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
351
+ readonly id: v.StringSchema<undefined>;
352
+ readonly name: v.StringSchema<undefined>;
353
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
354
+ readonly mdx: v.OptionalSchema<v.ObjectSchema<{
355
+ readonly $ref: v.StringSchema<undefined>;
356
+ }, undefined>, undefined>;
357
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
358
+ readonly name: v.StringSchema<undefined>;
359
+ readonly message: v.StringSchema<undefined>;
360
+ }, undefined>, undefined>;
361
+ }, undefined>, undefined>;
362
+ }, undefined>], undefined>;
196
363
  type DocsManifestMap = v.InferOutput<typeof DocsManifestMap>;
364
+ /**
365
+ * A component index row as it appears in either format: inline (v0) or shallow
366
+ * ref (v1). This is what {@link resolveComponentEntry} consumes before following any
367
+ * `$ref`s.
368
+ */
369
+ type ComponentManifestEntry = ComponentManifestV0 | ComponentManifestV1;
370
+ /** A docs index row as it appears in either format: inline (v0) or shallow ref (v1). */
371
+ type DocEntry = DocV0 | DocV1;
372
+ /**
373
+ * A fully-resolved component, as consumed by the tools and formatters: inline shape
374
+ * (stories as an array, attached docs with `content`, docgen inlined). Identical to
375
+ * the v0 shape — v1 rows are resolved into it by following their `$ref`s
376
+ * (`resolveComponentEntry`) or built in-process (`adaptCoreComponent`).
377
+ */
378
+ type ComponentManifest = ComponentManifestV0;
379
+ /** A fully-resolved docs entry (inline `content`), as consumed by tools and formatters. */
380
+ type Doc = DocV0;
197
381
  type AllManifests = {
198
382
  componentManifest: ComponentManifestMap;
199
383
  docsManifest?: DocsManifestMap;
200
384
  };
385
+ /**
386
+ * Open-service payload contracts (the "core format") that Storybook's
387
+ * `experimentalDocgenServer` mode produces. `@storybook/mcp` adapts these into its
388
+ * internal {@link ComponentManifest}/{@link Doc} shapes in one place
389
+ * (`adaptCoreComponent`/`adaptCoreDoc`). Defined structurally (not as schemas) so
390
+ * the addon can build them in-process without importing Storybook core.
391
+ */
392
+ /** One story snippet from the `core/story-docs` service. */
393
+ type CoreStoryDoc = {
394
+ id: string;
395
+ name: string;
396
+ snippet?: string;
397
+ description?: string;
398
+ summary?: string;
399
+ error?: {
400
+ name: string;
401
+ message: string;
402
+ };
403
+ };
404
+ /** One MDX doc from the `addon-docs/mdx` service. */
405
+ type CoreMdxDoc = {
406
+ id: string;
407
+ name: string;
408
+ path?: string;
409
+ title?: string;
410
+ content?: string;
411
+ summary?: string;
412
+ error?: {
413
+ name: string;
414
+ message: string;
415
+ };
416
+ };
417
+ /**
418
+ * Payload returned by the `addon-docs/mdx` service for a component or standalone
419
+ * docs entry.
420
+ */
421
+ type CoreMdxPayload = {
422
+ id: string;
423
+ name: string;
424
+ docs: Record<string, CoreMdxDoc>;
425
+ };
426
+ /** Payload returned by the `core/story-docs` service for one component. */
427
+ type CoreStoryDocsPayload = {
428
+ id: string;
429
+ name: string;
430
+ path: string;
431
+ import?: string;
432
+ stories: Record<string, CoreStoryDoc>;
433
+ error?: {
434
+ name: string;
435
+ message: string;
436
+ };
437
+ };
438
+ /**
439
+ * Payload returned by the `core/docgen` service for one component. `argTypes` (a
440
+ * UI-normalized view) is intentionally ignored by the adapter; prop types come
441
+ * from `reactComponentMeta`/`react*` fields.
442
+ */
443
+ type CoreDocgenPayload = {
444
+ id: string;
445
+ name: string;
446
+ path?: string;
447
+ description?: string;
448
+ summary?: string;
449
+ jsDocTags?: Record<string, string[]>;
450
+ import?: string;
451
+ reactComponentMeta?: unknown;
452
+ reactDocgen?: unknown;
453
+ reactDocgenTypescript?: unknown;
454
+ subcomponents?: Record<string, unknown>;
455
+ error?: {
456
+ name: string;
457
+ message: string;
458
+ };
459
+ [key: string]: unknown;
460
+ };
461
+ /**
462
+ * A component assembled from the `core/docgen` payload plus the `core/story-docs`
463
+ * stories and resolved attached MDX docs.
464
+ */
465
+ type CoreDocgenComponent = CoreDocgenPayload & {
466
+ import?: string; /** Story snippets, either as a story-docs record or an already-resolved array. */
467
+ stories?: Record<string, CoreStoryDoc> | Story[]; /** Attached docs keyed by doc id (resolved MDX payloads). */
468
+ docs?: Record<string, CoreMdxDoc>;
469
+ };
201
470
  //#endregion
202
471
  //#region src/tools/list-all-documentation.d.ts
203
472
  declare const LIST_TOOL_NAME = "list-all-documentation";
473
+ declare function getListAllDocumentationToolMetadata(): {
474
+ name: string;
475
+ title: string;
476
+ description: string;
477
+ schema: v.ObjectSchema<{
478
+ readonly withStoryIds: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "When true, includes story sub-bullets under each component with story name and story ID. Use this to discover IDs for downstream story-focused workflows without filesystem lookup.">]>, false>;
479
+ }, undefined>;
480
+ };
204
481
  declare function addListAllDocumentationTool(server: McpServer<any, StorybookContext>, enabled?: Parameters<McpServer<any, StorybookContext>['tool']>[0]['enabled']): Promise<void>;
205
482
  //#endregion
206
483
  //#region src/tools/get-documentation.d.ts
207
484
  declare const GET_TOOL_NAME = "get-documentation";
485
+ declare function getDocumentationToolMetadata(options?: {
486
+ multiSource?: boolean;
487
+ }): {
488
+ name: string;
489
+ title: string;
490
+ description: string;
491
+ schema: v.ObjectSchema<{
492
+ readonly storybookId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The Storybook source ID (e.g., \"local\", \"tetra\"). Required when multiple Storybooks are composed. See list-all-documentation for available sources.">]>;
493
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The component or docs entry ID (e.g., \"button\")">]>;
494
+ }, undefined> | v.ObjectSchema<{
495
+ id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The component or docs entry ID (e.g., \"button\")">]>;
496
+ }, undefined>;
497
+ };
208
498
  declare function addGetDocumentationTool(server: McpServer<any, StorybookContext>, enabled?: Parameters<McpServer<any, StorybookContext>['tool']>[0]['enabled'], options?: {
209
499
  multiSource?: boolean;
210
500
  }): Promise<void>;
211
501
  //#endregion
212
502
  //#region src/tools/get-documentation-for-story.d.ts
213
503
  declare const GET_STORY_TOOL_NAME = "get-documentation-for-story";
504
+ declare function getStoryDocumentationToolMetadata(options?: {
505
+ multiSource?: boolean;
506
+ }): {
507
+ name: string;
508
+ title: string;
509
+ description: string;
510
+ schema: v.ObjectSchema<{
511
+ readonly storybookId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The Storybook source ID (e.g., \"local\", \"tetra\"). Required when multiple Storybooks are composed. See list-all-documentation for available sources.">]>;
512
+ readonly componentId: v.StringSchema<undefined>;
513
+ readonly storyName: v.StringSchema<undefined>;
514
+ }, undefined> | v.ObjectSchema<{
515
+ componentId: v.StringSchema<undefined>;
516
+ storyName: v.StringSchema<undefined>;
517
+ }, undefined>;
518
+ };
214
519
  declare function addGetStoryDocumentationTool(server: McpServer<any, StorybookContext>, enabled?: Parameters<McpServer<any, StorybookContext>['tool']>[0]['enabled'], options?: {
215
520
  multiSource?: boolean;
216
521
  }): Promise<void>;
217
522
  //#endregion
218
523
  //#region src/utils/get-manifest.d.ts
524
+ type SourceWithUrl = Source & {
525
+ url: string;
526
+ };
527
+ type ManifestProvider = (request: Request | undefined, path: string, source?: Source) => Promise<string>;
219
528
  /**
220
529
  * The paths to the manifest files relative to the Storybook build
221
530
  */
222
531
  declare const COMPONENT_MANIFEST_PATH = "./manifests/components.json";
223
532
  declare const DOCS_MANIFEST_PATH = "./manifests/docs.json";
533
+ declare class RequiresOwnMcpError extends Error {
534
+ readonly source: SourceWithUrl;
535
+ readonly endpoint: string;
536
+ constructor(source: SourceWithUrl);
537
+ }
538
+ /**
539
+ * Resolves a component index entry into a full component manifest by following any
540
+ * `$ref`s it carries (docgen, story-docs, attached MDX docs), then adapting the
541
+ * core-format payloads into `@storybook/mcp`'s internal shape.
542
+ *
543
+ * Refs are read verbatim from the entry — never fabricated from an id — so a
544
+ * provider is only ever asked for top-level manifest paths or paths a manifest
545
+ * already pointed at. Components without any `$ref` (inline/v0 format, or entries
546
+ * already resolved in-process) are returned unchanged.
547
+ */
548
+ declare function resolveComponentEntry(component: ComponentManifestEntry, request?: Request, manifestProvider?: ManifestProvider, source?: Source): Promise<ComponentManifest>;
549
+ /**
550
+ * Resolves only a component's stories `$ref` (story-docs payload) into a `Story[]`,
551
+ * leaving docgen/docs refs untouched. Used by `list-all-documentation` when story
552
+ * ids are requested, so listing doesn't pay for docgen/MDX resolution it won't show.
553
+ */
554
+ declare function resolveComponentStories(component: ComponentManifestEntry, request?: Request, manifestProvider?: ManifestProvider, source?: Source): Promise<ComponentManifest>;
555
+ /**
556
+ * Resolves a standalone docs entry, following its `mdx.$ref` when present.
557
+ * Inline docs (v0) are returned unchanged.
558
+ */
559
+ declare function resolveDoc(doc: DocEntry, request?: Request, manifestProvider?: ManifestProvider, source?: Source): Promise<Doc>;
224
560
  /**
225
561
  * Gets manifests from multiple sources.
226
562
  * Returns an array of source manifests, each containing the source info and its manifests.
@@ -234,6 +570,14 @@ declare const DOCS_MANIFEST_PATH = "./manifests/docs.json";
234
570
  */
235
571
  declare function getMultiSourceManifests(sources: Source[], request?: Request, manifestProvider?: (request: Request | undefined, path: string, source?: Source) => Promise<string>): Promise<SourceManifests[]>;
236
572
  //#endregion
573
+ //#region src/utils/adapt-core-manifest.d.ts
574
+ /** Converts the story-docs `stories` record (or an already-resolved array) into `Story[]`. */
575
+ declare function adaptCoreStories(stories: CoreDocgenComponent['stories']): Story[] | undefined;
576
+ /** Adapts one MDX service payload into a {@link Doc}. */
577
+ declare function adaptCoreDoc(doc: CoreMdxDoc): Doc;
578
+ /** Adapts a core-format component (docgen + story-docs + attached MDX) into a {@link ComponentManifest}. */
579
+ declare function adaptCoreComponent(core: CoreDocgenComponent): ComponentManifest;
580
+ //#endregion
237
581
  //#region src/index.d.ts
238
582
  type InitializeRequestParams = {
239
583
  protocolVersion: string;
@@ -272,4 +616,4 @@ interface StorybookMcpHandlerOptions extends StorybookContext {
272
616
  type Handler = (req: Request, context?: StorybookContext) => Promise<Response>;
273
617
  declare const createStorybookMcpHandler: (options?: StorybookMcpHandlerOptions) => Promise<Handler>;
274
618
  //#endregion
275
- export { COMPONENT_MANIFEST_PATH, type ComponentManifest, ComponentManifestMap, DOCS_MANIFEST_PATH, DocsManifestMap, GET_STORY_TOOL_NAME, GET_TOOL_NAME, LIST_TOOL_NAME, instructions_default as STORYBOOK_MCP_INSTRUCTIONS, type Source, type SourceManifests, type StorybookContext, StorybookMcpHandlerOptions, addGetDocumentationTool, addGetStoryDocumentationTool, addListAllDocumentationTool, createStorybookMcpHandler, getMultiSourceManifests };
619
+ export { COMPONENT_MANIFEST_PATH, type ComponentManifest, ComponentManifestMap, type CoreDocgenComponent, type CoreDocgenPayload, type CoreMdxDoc, type CoreMdxPayload, type CoreStoryDoc, type CoreStoryDocsPayload, DOCS_MANIFEST_PATH, type Doc, DocsManifestMap, GET_STORY_TOOL_NAME, GET_TOOL_NAME, LIST_TOOL_NAME, RequiresOwnMcpError, type RequiresOwnMcpNotice, type ResolvedEntry, instructions_default as STORYBOOK_MCP_INSTRUCTIONS, type Source, type SourceManifests, type Story, type StorybookContext, StorybookMcpHandlerOptions, adaptCoreComponent, adaptCoreDoc, adaptCoreStories, addGetDocumentationTool, addGetStoryDocumentationTool, addListAllDocumentationTool, createStorybookMcpHandler, getDocumentationToolMetadata, getListAllDocumentationToolMetadata, getMultiSourceManifests, getStoryDocumentationToolMetadata, resolveComponentEntry, resolveComponentStories, resolveDoc };