@storybook/mcp 0.6.2 → 0.7.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/dist/index.d.ts CHANGED
@@ -91,9 +91,6 @@ declare const Doc: v.ObjectSchema<{
91
91
  type Doc = v.InferOutput<typeof Doc>;
92
92
  declare const ComponentManifest: v.ObjectSchema<{
93
93
  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
94
  readonly stories: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
98
95
  readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
99
96
  readonly snippet: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -106,9 +103,21 @@ declare const ComponentManifest: v.ObjectSchema<{
106
103
  readonly message: v.StringSchema<undefined>;
107
104
  }, undefined>, undefined>;
108
105
  }, 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>;
106
+ 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
+ readonly name: v.StringSchema<undefined>;
114
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
115
+ readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
116
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
117
+ readonly name: v.StringSchema<undefined>;
118
+ readonly message: v.StringSchema<undefined>;
119
+ }, undefined>, undefined>;
120
+ }, undefined>, undefined>, undefined>;
112
121
  readonly docs: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
113
122
  readonly id: v.StringSchema<undefined>;
114
123
  readonly name: v.StringSchema<undefined>;
@@ -121,6 +130,12 @@ declare const ComponentManifest: v.ObjectSchema<{
121
130
  readonly message: v.StringSchema<undefined>;
122
131
  }, undefined>, undefined>;
123
132
  }, undefined>, undefined>, undefined>;
133
+ readonly path: v.StringSchema<undefined>;
134
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
135
+ readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
136
+ readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
137
+ readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
138
+ readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
124
139
  readonly name: v.StringSchema<undefined>;
125
140
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
126
141
  readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
@@ -134,9 +149,6 @@ declare const ComponentManifestMap: v.ObjectSchema<{
134
149
  readonly v: v.NumberSchema<undefined>;
135
150
  readonly components: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
136
151
  readonly id: v.StringSchema<undefined>;
137
- readonly path: v.StringSchema<undefined>;
138
- readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
139
- readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
140
152
  readonly stories: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
141
153
  readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
142
154
  readonly snippet: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -149,9 +161,21 @@ declare const ComponentManifestMap: v.ObjectSchema<{
149
161
  readonly message: v.StringSchema<undefined>;
150
162
  }, undefined>, undefined>;
151
163
  }, 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>;
164
+ 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
+ readonly name: v.StringSchema<undefined>;
172
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
173
+ readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
174
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
175
+ readonly name: v.StringSchema<undefined>;
176
+ readonly message: v.StringSchema<undefined>;
177
+ }, undefined>, undefined>;
178
+ }, undefined>, undefined>, undefined>;
155
179
  readonly docs: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
156
180
  readonly id: v.StringSchema<undefined>;
157
181
  readonly name: v.StringSchema<undefined>;
@@ -164,6 +188,12 @@ declare const ComponentManifestMap: v.ObjectSchema<{
164
188
  readonly message: v.StringSchema<undefined>;
165
189
  }, undefined>, undefined>;
166
190
  }, undefined>, undefined>, undefined>;
191
+ readonly path: v.StringSchema<undefined>;
192
+ readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
193
+ readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
194
+ readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
195
+ readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
196
+ readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
167
197
  readonly name: v.StringSchema<undefined>;
168
198
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
169
199
  readonly jsDocTags: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import * as v from "valibot";
6
6
 
7
7
  //#region package.json
8
8
  var name = "@storybook/mcp";
9
- var version = "0.6.2";
9
+ var version = "0.7.0";
10
10
  var description = "MCP server that serves knowledge about your components based on your Storybook stories and documentation";
11
11
 
12
12
  //#endregion
@@ -41,16 +41,21 @@ const Doc = v.object({
41
41
  summary: v.optional(v.string()),
42
42
  error: v.optional(Error$1)
43
43
  });
44
- const ComponentManifest = v.object({
44
+ const BaseComponentProperties = v.object({
45
45
  ...BaseManifest.entries,
46
- id: v.string(),
47
46
  path: v.string(),
48
47
  summary: v.optional(v.string()),
49
48
  import: v.optional(v.string()),
50
- stories: v.optional(v.array(Story)),
51
49
  reactDocgen: v.optional(v.any()),
52
50
  reactDocgenTypescript: v.optional(v.any()),
53
- reactComponentMeta: v.optional(v.any()),
51
+ reactComponentMeta: v.optional(v.any())
52
+ });
53
+ const SubcomponentManifest = v.object({ ...BaseComponentProperties.entries });
54
+ const ComponentManifest = v.object({
55
+ ...BaseComponentProperties.entries,
56
+ id: v.string(),
57
+ stories: v.optional(v.array(Story)),
58
+ subcomponents: v.optional(v.record(v.string(), SubcomponentManifest)),
54
59
  docs: v.optional(v.record(v.string(), Doc))
55
60
  });
56
61
  const ComponentManifestMap = v.object({
@@ -411,6 +416,77 @@ function formatStoryContent(story, importStatement) {
411
416
  parts.push("```");
412
417
  return parts;
413
418
  }
419
+ function formatPropsSection(parsedDocgen, options = {}) {
420
+ const propEntries = parsedDocgen ? Object.entries(parsedDocgen.props) : [];
421
+ if (propEntries.length === 0) return [];
422
+ const title = options.title ?? "## Props";
423
+ const typeName = options.typeName ?? "Props";
424
+ const parts = [];
425
+ parts.push(title);
426
+ parts.push("");
427
+ parts.push("```");
428
+ parts.push(`export type ${typeName} = {`);
429
+ for (const [propName, propInfo] of propEntries) {
430
+ const type = propInfo.type ?? "any";
431
+ const isRequired = propInfo.required ?? true;
432
+ const hasDefault = propInfo.defaultValue !== void 0;
433
+ if (propInfo.description !== void 0) {
434
+ parts.push(" /**");
435
+ parts.push(` ${propInfo.description}`);
436
+ parts.push(" */");
437
+ }
438
+ let propLine = ` ${propName}`;
439
+ if (!isRequired) propLine += "?";
440
+ propLine += `: ${type}`;
441
+ if (hasDefault) propLine += ` = ${propInfo.defaultValue}`;
442
+ propLine += ";";
443
+ parts.push(propLine);
444
+ }
445
+ parts.push("}");
446
+ parts.push("```");
447
+ parts.push("");
448
+ return parts;
449
+ }
450
+ function formatSubcomponentsSection(subcomponents) {
451
+ if (!subcomponents || Object.keys(subcomponents).length === 0) return [];
452
+ const parts = [];
453
+ parts.push("## Subcomponents");
454
+ parts.push("");
455
+ for (const [key, subcomponent] of Object.entries(subcomponents)) {
456
+ parts.push(`### ${subcomponent.name || key}`);
457
+ parts.push("");
458
+ if (subcomponent.summary) {
459
+ parts.push(subcomponent.summary);
460
+ parts.push("");
461
+ }
462
+ if (subcomponent.description) {
463
+ parts.push(subcomponent.description);
464
+ parts.push("");
465
+ }
466
+ if (subcomponent.import) {
467
+ parts.push("```");
468
+ parts.push(subcomponent.import);
469
+ parts.push("```");
470
+ parts.push("");
471
+ }
472
+ if (subcomponent.error) {
473
+ parts.push(`Error: ${subcomponent.error.name}`);
474
+ parts.push("");
475
+ parts.push("```");
476
+ parts.push(subcomponent.error.message);
477
+ parts.push("```");
478
+ parts.push("");
479
+ continue;
480
+ }
481
+ const parsedDocgen = getParsedDocgen(subcomponent);
482
+ const typeName = `${(subcomponent.name || key).replace(/\W+/g, "")}Props`;
483
+ parts.push(...formatPropsSection(parsedDocgen, {
484
+ title: "#### Props",
485
+ typeName
486
+ }));
487
+ }
488
+ return parts;
489
+ }
414
490
  /**
415
491
  * Format a single component manifest into markdown.
416
492
  */
@@ -424,6 +500,7 @@ function formatComponentManifest(componentManifest) {
424
500
  parts.push(componentManifest.description);
425
501
  parts.push("");
426
502
  }
503
+ parts.push(...formatSubcomponentsSection(componentManifest.subcomponents));
427
504
  const parsedDocgen = getParsedDocgen(componentManifest);
428
505
  if (componentManifest.stories && componentManifest.stories.length > 0) {
429
506
  parts.push("## Stories");
@@ -454,34 +531,7 @@ function formatComponentManifest(componentManifest) {
454
531
  parts.push("");
455
532
  }
456
533
  }
457
- if (parsedDocgen) {
458
- const propEntries = Object.entries(parsedDocgen.props);
459
- if (propEntries.length > 0) {
460
- parts.push("## Props");
461
- parts.push("");
462
- parts.push("```");
463
- parts.push("export type Props = {");
464
- for (const [propName, propInfo] of propEntries) {
465
- const type = propInfo.type ?? "any";
466
- const isRequired = propInfo.required ?? true;
467
- const hasDefault = propInfo.defaultValue !== void 0;
468
- if (propInfo.description !== void 0) {
469
- parts.push(" /**");
470
- parts.push(` ${propInfo.description}`);
471
- parts.push(" */");
472
- }
473
- let propLine = ` ${propName}`;
474
- if (!isRequired) propLine += "?";
475
- propLine += `: ${type}`;
476
- if (hasDefault) propLine += ` = ${propInfo.defaultValue}`;
477
- propLine += ";";
478
- parts.push(propLine);
479
- }
480
- parts.push("}");
481
- parts.push("```");
482
- parts.push("");
483
- }
484
- }
534
+ parts.push(...formatPropsSection(parsedDocgen));
485
535
  if (componentManifest.docs && Object.keys(componentManifest.docs).length > 0) {
486
536
  const docsWithContent = Object.values(componentManifest.docs).filter((doc) => doc.content.trim().length > 0);
487
537
  if (docsWithContent.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/mcp",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
5
5
  "keywords": [
6
6
  "mcp",