@storybook/mcp 10.6.0-alpha.6 → 10.6.0-alpha.7
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 +9 -1
- package/dist/index.d.ts +22 -2
- package/dist/index.js +31 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,6 +6,11 @@ Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=r
|
|
|
6
6
|
|
|
7
7
|
## Self-hosting `@storybook/mcp`
|
|
8
8
|
|
|
9
|
+
This package is a library: the tarball ships one module and no executable. It declares no `bin`,
|
|
10
|
+
starts no process, and has no CLI. You register its tools on an MCP server you own, using the
|
|
11
|
+
snippets below. If you want a running Storybook MCP server with no code at all, use the dev server
|
|
12
|
+
instead — `storybook dev` serves one at `/mcp` through `@storybook/addon-mcp`.
|
|
13
|
+
|
|
9
14
|
### Prerequisites
|
|
10
15
|
|
|
11
16
|
- Node.js 20+
|
|
@@ -15,7 +20,10 @@ Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=r
|
|
|
15
20
|
|
|
16
21
|
### Example implementation
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
The Storybook repository has a local HTTP server built on this package,
|
|
24
|
+
[`serve.ts`](https://github.com/storybookjs/storybook/blob/next/code/lib/mcp/serve.ts), that loads
|
|
25
|
+
manifests from a directory or URL. It is a development harness and is not part of the published
|
|
26
|
+
package.
|
|
19
27
|
|
|
20
28
|
The snippets below cover the common self-hosting patterns.
|
|
21
29
|
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ declare const ComponentManifestV0: v.ObjectSchema<{
|
|
|
50
50
|
readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
51
51
|
readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
52
52
|
readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
53
|
+
readonly apiDescription: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
54
|
+
readonly renderer: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
53
55
|
readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
|
|
54
56
|
readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
|
|
55
57
|
readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
|
|
@@ -77,6 +79,8 @@ declare const ComponentManifestV0: v.ObjectSchema<{
|
|
|
77
79
|
readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
78
80
|
readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
79
81
|
readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
82
|
+
readonly apiDescription: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
83
|
+
readonly renderer: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
80
84
|
readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
|
|
81
85
|
readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
|
|
82
86
|
readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
|
|
@@ -171,6 +175,8 @@ declare const ComponentManifestMap: v.VariantSchema<"v", [v.ObjectSchema<{
|
|
|
171
175
|
readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
172
176
|
readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
173
177
|
readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
178
|
+
readonly apiDescription: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
179
|
+
readonly renderer: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
174
180
|
readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
|
|
175
181
|
readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
|
|
176
182
|
readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
|
|
@@ -198,6 +204,8 @@ declare const ComponentManifestMap: v.VariantSchema<"v", [v.ObjectSchema<{
|
|
|
198
204
|
readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
199
205
|
readonly summary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
200
206
|
readonly import: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
207
|
+
readonly apiDescription: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
208
|
+
readonly renderer: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
201
209
|
readonly reactDocgen: v.OptionalSchema<v.AnySchema, undefined>;
|
|
202
210
|
readonly reactDocgenTypescript: v.OptionalSchema<v.AnySchema, undefined>;
|
|
203
211
|
readonly reactComponentMeta: v.OptionalSchema<v.AnySchema, undefined>;
|
|
@@ -533,6 +541,14 @@ interface DocgenPayload {
|
|
|
533
541
|
jsDocTags: DocgenJsDocTags;
|
|
534
542
|
/** Renderer-converted argTypes derived from integration-specific docgen data at write time. */
|
|
535
543
|
argTypes?: StrictArgTypes;
|
|
544
|
+
/**
|
|
545
|
+
* Framework-authored API documentation in Markdown, rendered verbatim in place of the props
|
|
546
|
+
* section. Prefer `##` level headings for sections (Inputs, Outputs, Props, Events, Slots) and TS
|
|
547
|
+
* types for structured data.
|
|
548
|
+
*/
|
|
549
|
+
apiDescription?: string;
|
|
550
|
+
/** Renderer id (e.g. `angular`), so a consumer knows which template syntax the component takes. */
|
|
551
|
+
renderer?: string;
|
|
536
552
|
subcomponents?: Record<string, DocgenSubcomponent>;
|
|
537
553
|
error?: DocgenError;
|
|
538
554
|
[key: string]: unknown;
|
|
@@ -547,6 +563,10 @@ interface DocgenSubcomponent {
|
|
|
547
563
|
jsDocTags: DocgenJsDocTags;
|
|
548
564
|
/** Renderer-converted argTypes derived from integration-specific docgen data at write time. */
|
|
549
565
|
argTypes?: StrictArgTypes;
|
|
566
|
+
/** See {@link DocgenPayload.apiDescription}. */
|
|
567
|
+
apiDescription?: string;
|
|
568
|
+
/** See {@link DocgenPayload.renderer}. */
|
|
569
|
+
renderer?: string;
|
|
550
570
|
error?: DocgenError;
|
|
551
571
|
[key: string]: unknown;
|
|
552
572
|
} //#endregion
|
|
@@ -568,8 +588,8 @@ type MdxDoc = {
|
|
|
568
588
|
* Adapts the `experimentalDocgenServer` open-service payloads into the manifest formatter's
|
|
569
589
|
* {@link ComponentManifest}/{@link Doc} shapes.
|
|
570
590
|
*
|
|
571
|
-
* Only `argTypes` is dropped:
|
|
572
|
-
* the `react*` docgen-engine fields
|
|
591
|
+
* Only `argTypes` is dropped: the props section comes from `apiDescription` when the framework
|
|
592
|
+
* authored one, else from the `react*` docgen-engine fields. All of those pass through unchanged.
|
|
573
593
|
*/
|
|
574
594
|
/**
|
|
575
595
|
* A component assembled from the `core/docgen` payload plus the `core/story-docs` stories and
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_et7v2wkem2f from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_et7v2wkem2f from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_et7v2wkem2f from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_et7v2wkem2f.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_et7v2wkem2f.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_et7v2wkem2f.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.0-alpha.
|
|
27
|
+
version: "10.6.0-alpha.7",
|
|
28
28
|
description: "MCP server that serves knowledge about your components based on your Storybook stories and documentation",
|
|
29
29
|
keywords: [
|
|
30
30
|
"mcp",
|
|
@@ -911,6 +911,13 @@ function formatPropsSection(parsedDocgen, options = {}) {
|
|
|
911
911
|
}
|
|
912
912
|
return parts.push("}"), parts.push("```"), parts.push(""), parts;
|
|
913
913
|
}
|
|
914
|
+
var FENCE_LINE = /^\s*(?:```|~~~)/, HEADING_LINE = /^(#{1,4}) /;
|
|
915
|
+
function demoteHeadings(markdown) {
|
|
916
|
+
let inFence = !1;
|
|
917
|
+
return markdown.split(`
|
|
918
|
+
`).map((line) => FENCE_LINE.test(line) ? (inFence = !inFence, line) : inFence ? line : line.replace(HEADING_LINE, "##$1 ")).join(`
|
|
919
|
+
`);
|
|
920
|
+
}
|
|
914
921
|
function formatSubcomponentsSection(subcomponents) {
|
|
915
922
|
if (!subcomponents || Object.keys(subcomponents).length === 0)
|
|
916
923
|
return [];
|
|
@@ -921,6 +928,10 @@ function formatSubcomponentsSection(subcomponents) {
|
|
|
921
928
|
parts.push(`Error: ${subcomponent.error.name}`), parts.push(""), parts.push("```"), parts.push(subcomponent.error.message), parts.push("```"), parts.push("");
|
|
922
929
|
continue;
|
|
923
930
|
}
|
|
931
|
+
if (subcomponent.apiDescription) {
|
|
932
|
+
parts.push(demoteHeadings(subcomponent.apiDescription)), parts.push("");
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
924
935
|
let parsedDocgen = getParsedDocgen(subcomponent), typeName = `${(subcomponent.name || key).replace(/\W+/g, "")}Props`;
|
|
925
936
|
parts.push(...formatPropsSection(parsedDocgen, { title: "#### Props", typeName }));
|
|
926
937
|
}
|
|
@@ -929,14 +940,16 @@ function formatSubcomponentsSection(subcomponents) {
|
|
|
929
940
|
function formatComponentManifest(componentManifest) {
|
|
930
941
|
let parts = [];
|
|
931
942
|
parts.push(`# ${componentManifest.name}`), parts.push(""), parts.push(`ID: ${componentManifest.id}`), parts.push(""), componentManifest.description && (parts.push(componentManifest.description), parts.push("")), parts.push(...formatSubcomponentsSection(componentManifest.subcomponents));
|
|
932
|
-
let parsedDocgen = getParsedDocgen(componentManifest),
|
|
943
|
+
let parsedDocgen = getParsedDocgen(componentManifest), { apiDescription } = componentManifest;
|
|
944
|
+
apiDescription && (parts.push(apiDescription), parts.push(""));
|
|
945
|
+
let stories = Array.isArray(componentManifest.stories) ? componentManifest.stories : [];
|
|
933
946
|
if (stories.length > 0) {
|
|
934
947
|
parts.push("## Stories"), parts.push("");
|
|
935
|
-
let storiesWithSnippets = stories.filter((s) => s.snippet),
|
|
948
|
+
let storiesWithSnippets = stories.filter((s) => s.snippet), storiesToShow = apiDescription || parsedDocgen && Object.keys(parsedDocgen.props).length > 0 ? storiesWithSnippets.slice(0, MAX_STORIES_TO_SHOW) : storiesWithSnippets, shown = new Set(storiesToShow), remainingStories = stories.filter((story) => !shown.has(story));
|
|
936
949
|
for (let story of storiesToShow)
|
|
937
950
|
parts.push(`### ${story.name}`), parts.push(""), story.id && (parts.push(`Story ID: ${story.id}`), parts.push("")), parts.push(...formatStoryContent(story, componentManifest.import)), parts.push("");
|
|
938
951
|
if (remainingStories.length > 0) {
|
|
939
|
-
storiesToShow.length > 0 && parts.push("### Other Stories"), parts.push("");
|
|
952
|
+
storiesToShow.length > 0 && (parts.push("### Other Stories"), parts.push(""));
|
|
940
953
|
for (let story of remainingStories) {
|
|
941
954
|
let summary = extractSummary(story), summaryPart = summary ? `: ${summary}` : "", storyLabel = story.id ? `${story.name} (${story.id})` : story.name;
|
|
942
955
|
parts.push(`- ${storyLabel}${summaryPart}`);
|
|
@@ -944,7 +957,7 @@ function formatComponentManifest(componentManifest) {
|
|
|
944
957
|
parts.push("");
|
|
945
958
|
}
|
|
946
959
|
}
|
|
947
|
-
if (parts.push(...formatPropsSection(parsedDocgen)), componentManifest.docs && Object.keys(componentManifest.docs).length > 0) {
|
|
960
|
+
if (apiDescription || parts.push(...formatPropsSection(parsedDocgen)), componentManifest.docs && Object.keys(componentManifest.docs).length > 0) {
|
|
948
961
|
let docsWithContent = Object.values(componentManifest.docs).filter(
|
|
949
962
|
(doc) => (doc.content ?? "").trim().length > 0
|
|
950
963
|
);
|
|
@@ -1011,11 +1024,12 @@ function formatMultiSourceManifestsToLists(sources, options = {}) {
|
|
|
1011
1024
|
}
|
|
1012
1025
|
function formatStoryDocumentation(componentManifest, storyName) {
|
|
1013
1026
|
let story = Array.isArray(componentManifest.stories) ? componentManifest.stories.find((s) => s.name === storyName) : void 0;
|
|
1014
|
-
if (!story
|
|
1027
|
+
if (!story)
|
|
1015
1028
|
return "";
|
|
1016
1029
|
let parts = [];
|
|
1017
|
-
return parts.push(`# ${componentManifest.name} - ${story.name}`), parts.push(""), parts.push(...formatStoryContent(story, componentManifest.import)), parts.join(`
|
|
1018
|
-
`).trim()
|
|
1030
|
+
return parts.push(`# ${componentManifest.name} - ${story.name}`), parts.push(""), story.snippet ? (parts.push(...formatStoryContent(story, componentManifest.import)), parts.join(`
|
|
1031
|
+
`).trim()) : (story.id && (parts.push(`Story ID: ${story.id}`), parts.push("")), story.description && (parts.push(story.description), parts.push("")), parts.push("No code snippet was extracted for this story."), parts.join(`
|
|
1032
|
+
`).trim());
|
|
1019
1033
|
}
|
|
1020
1034
|
var ARG_TYPES_KEY = "argTypes";
|
|
1021
1035
|
function adaptCoreStories(stories) {
|
|
@@ -1059,6 +1073,9 @@ var JSDocTag = record(string(), array(string())), ManifestErrorSchema = object({
|
|
|
1059
1073
|
path: optional(string()),
|
|
1060
1074
|
summary: optional(string()),
|
|
1061
1075
|
import: optional(string()),
|
|
1076
|
+
// Framework-authored Markdown, rendered in place of the props section derived from `react*`.
|
|
1077
|
+
apiDescription: optional(string()),
|
|
1078
|
+
renderer: optional(string()),
|
|
1062
1079
|
// Mirrors the docgen-engine payloads, which the parsers narrow structurally at runtime.
|
|
1063
1080
|
reactDocgen: optional(any()),
|
|
1064
1081
|
reactDocgenTypescript: optional(any()),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/mcp",
|
|
3
|
-
"version": "10.6.0-alpha.
|
|
3
|
+
"version": "10.6.0-alpha.7",
|
|
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.0-alpha.
|
|
52
|
+
"storybook": "10.6.0-alpha.7",
|
|
53
53
|
"tinyexec": "^1.0.2",
|
|
54
54
|
"typescript": "^6.0.3"
|
|
55
55
|
},
|