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