@storybook/mcp 0.5.0 → 0.6.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 +2 -1
- package/dist/index.js +10 -8
- package/dist/instructions-Cl0vcW2j.js +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as instructions_default } from "./instructions-Cl0vcW2j.js";
|
|
1
2
|
import { McpServer } from "tmcp";
|
|
2
3
|
import * as v from "valibot";
|
|
3
4
|
|
|
@@ -269,4 +270,4 @@ interface StorybookMcpHandlerOptions extends StorybookContext {
|
|
|
269
270
|
type Handler = (req: Request, context?: StorybookContext) => Promise<Response>;
|
|
270
271
|
declare const createStorybookMcpHandler: (options?: StorybookMcpHandlerOptions) => Promise<Handler>;
|
|
271
272
|
//#endregion
|
|
272
|
-
export { COMPONENT_MANIFEST_PATH, type ComponentManifest, ComponentManifestMap, DOCS_MANIFEST_PATH, DocsManifestMap, GET_STORY_TOOL_NAME, GET_TOOL_NAME, LIST_TOOL_NAME, type Source, type SourceManifests, type StorybookContext, StorybookMcpHandlerOptions, addGetDocumentationTool, addGetStoryDocumentationTool, addListAllDocumentationTool, createStorybookMcpHandler, getMultiSourceManifests };
|
|
273
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as instructions_default } from "./instructions-Cl0vcW2j.js";
|
|
1
2
|
import { McpServer } from "tmcp";
|
|
2
3
|
import { ValibotJsonSchemaAdapter } from "@tmcp/adapter-valibot";
|
|
3
4
|
import { HttpTransport } from "@tmcp/transport-http";
|
|
@@ -5,7 +6,7 @@ import * as v from "valibot";
|
|
|
5
6
|
|
|
6
7
|
//#region package.json
|
|
7
8
|
var name = "@storybook/mcp";
|
|
8
|
-
var version = "0.
|
|
9
|
+
var version = "0.6.0";
|
|
9
10
|
var description = "MCP server that serves knowledge about your components based on your Storybook stories and documentation";
|
|
10
11
|
|
|
11
12
|
//#endregion
|
|
@@ -135,7 +136,7 @@ async function getManifests(request, manifestProvider, source) {
|
|
|
135
136
|
const getUrl = (path) => request ? getManifestUrlFromRequest(request, path) : "Unknown manifest source";
|
|
136
137
|
if (componentResult.status === "rejected") {
|
|
137
138
|
const reason = componentResult.reason;
|
|
138
|
-
const hint = reason instanceof ManifestGetError && reason.message.includes("404") ? `\nHint: The Storybook at this URL may not have the component manifest enabled. Add \`features: { experimentalComponentsManifest: true }\` to its main.ts config.` : "";
|
|
139
|
+
const hint = reason instanceof ManifestGetError && reason.message.includes("404") ? `\nHint: The Storybook at this URL may not have the component manifest enabled. Add \`features: { componentsManifest: true }\` (or \`features: { experimentalComponentsManifest: true }\` for older Storybook versions) to its main.ts config.` : "";
|
|
139
140
|
throw new ManifestGetError(`Failed to get component manifest: ${reason instanceof Error ? reason.message : String(reason)}${hint}`, getUrl(COMPONENT_MANIFEST_PATH), reason instanceof Error ? reason : void 0);
|
|
140
141
|
}
|
|
141
142
|
const componentManifest = parseManifest({
|
|
@@ -760,6 +761,7 @@ Example: id="button" returns Primary, Secondary, Large stories with code like <B
|
|
|
760
761
|
//#endregion
|
|
761
762
|
//#region src/index.ts
|
|
762
763
|
const createStorybookMcpHandler = async (options = {}) => {
|
|
764
|
+
const { onSessionInitialize, ...defaultContext } = options;
|
|
763
765
|
const adapter = new ValibotJsonSchemaAdapter();
|
|
764
766
|
const server = new McpServer({
|
|
765
767
|
name,
|
|
@@ -767,22 +769,22 @@ const createStorybookMcpHandler = async (options = {}) => {
|
|
|
767
769
|
description
|
|
768
770
|
}, {
|
|
769
771
|
adapter,
|
|
772
|
+
instructions: instructions_default,
|
|
770
773
|
capabilities: { tools: { listChanged: true } }
|
|
771
774
|
}).withContext();
|
|
772
|
-
if (
|
|
775
|
+
if (onSessionInitialize) server.on("initialize", onSessionInitialize);
|
|
773
776
|
await addListAllDocumentationTool(server);
|
|
774
777
|
await addGetStoryDocumentationTool(server);
|
|
775
778
|
await addGetDocumentationTool(server);
|
|
776
779
|
const transport = new HttpTransport(server, { path: null });
|
|
777
780
|
return (async (req, context) => {
|
|
778
781
|
return await transport.respond(req, {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
onGetDocumentation: context?.onGetDocumentation ?? options.onGetDocumentation
|
|
782
|
+
...defaultContext,
|
|
783
|
+
...context,
|
|
784
|
+
request: req
|
|
783
785
|
});
|
|
784
786
|
});
|
|
785
787
|
};
|
|
786
788
|
|
|
787
789
|
//#endregion
|
|
788
|
-
export { COMPONENT_MANIFEST_PATH, ComponentManifestMap, DOCS_MANIFEST_PATH, DocsManifestMap, GET_STORY_TOOL_NAME, GET_TOOL_NAME, LIST_TOOL_NAME, addGetDocumentationTool, addGetStoryDocumentationTool, addListAllDocumentationTool, createStorybookMcpHandler, getMultiSourceManifests };
|
|
790
|
+
export { COMPONENT_MANIFEST_PATH, ComponentManifestMap, DOCS_MANIFEST_PATH, DocsManifestMap, GET_STORY_TOOL_NAME, GET_TOOL_NAME, LIST_TOOL_NAME, instructions_default as STORYBOOK_MCP_INSTRUCTIONS, addGetDocumentationTool, addGetStoryDocumentationTool, addListAllDocumentationTool, createStorybookMcpHandler, getMultiSourceManifests };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/instructions.md
|
|
2
|
+
var instructions_default = "## Documentation Workflow\n\n1. Call **list-all-documentation** once at the start of the task to discover available component and docs IDs.\n2. Call **get-documentation** with an `id` from that list to retrieve full component docs, props, usage examples, and stories.\n3. Call **get-documentation-for-story** when you need additional docs from a specific story variant that was not included in the initial component documentation.\n\nUse `withStoryIds: true` on **list-all-documentation** when you also need story IDs for inputs to other tools.\n\n## Verification Rules\n\n- Never assume component props, variants, or API shape. Retrieve documentation before using a component.\n- If a component or prop is not documented, do not invent it. Report that it was not found.\n- Only reference IDs returned by **list-all-documentation**. Do not guess IDs.\n\n## Multi-Source Requests\n\n- When multiple Storybook sources are configured, **list-all-documentation** returns entries from all sources.\n- Use `storybookId` in **get-documentation** when you need to scope a request to one source.\n";
|
|
3
|
+
|
|
4
|
+
//#endregion
|
|
5
|
+
export { instructions_default as t };
|