@storybook/mcp 0.2.0 → 0.2.1
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 +8 -2
- package/dist/index.js +8 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ type StorybookContext = {
|
|
|
38
38
|
onListAllDocumentation?: (params: {
|
|
39
39
|
context: StorybookContext;
|
|
40
40
|
manifests: AllManifests;
|
|
41
|
+
resultText: string;
|
|
41
42
|
}) => void | Promise<void>;
|
|
42
43
|
/**
|
|
43
44
|
* Optional handler called when get-component-documentation tool is invoked.
|
|
@@ -48,8 +49,13 @@ type StorybookContext = {
|
|
|
48
49
|
input: {
|
|
49
50
|
id: string;
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
} & ({
|
|
53
|
+
foundDocumentation: ComponentManifest | Doc;
|
|
54
|
+
resultText: string;
|
|
55
|
+
} | {
|
|
56
|
+
foundDocumentation?: never;
|
|
57
|
+
resultText?: never;
|
|
58
|
+
})) => void | Promise<void>;
|
|
53
59
|
};
|
|
54
60
|
/**
|
|
55
61
|
* A docs entry represents MDX documentation that can be attached to a component
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as v from "valibot";
|
|
|
5
5
|
|
|
6
6
|
//#region package.json
|
|
7
7
|
var name = "@storybook/mcp";
|
|
8
|
-
var version = "0.2.
|
|
8
|
+
var version = "0.2.1";
|
|
9
9
|
var description = "MCP server that serves knowledge about your components based on your Storybook stories and documentation";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
@@ -522,7 +522,8 @@ async function addListAllDocumentationTool(server, enabled) {
|
|
|
522
522
|
const lists = formatManifestsToLists(manifests, server.ctx.custom?.format ?? "markdown");
|
|
523
523
|
await server.ctx.custom?.onListAllDocumentation?.({
|
|
524
524
|
context: server.ctx.custom,
|
|
525
|
-
manifests
|
|
525
|
+
manifests,
|
|
526
|
+
resultText: lists
|
|
526
527
|
});
|
|
527
528
|
return { content: [{
|
|
528
529
|
type: "text",
|
|
@@ -564,15 +565,17 @@ async function addGetDocumentationTool(server, enabled) {
|
|
|
564
565
|
};
|
|
565
566
|
}
|
|
566
567
|
const documentation = component ?? docsEntry;
|
|
568
|
+
const format = server.ctx.custom?.format ?? "markdown";
|
|
569
|
+
const text = component ? formatComponentManifest(documentation, format) : formatDocsManifest(documentation, format);
|
|
567
570
|
await server.ctx.custom?.onGetDocumentation?.({
|
|
568
571
|
context: server.ctx.custom,
|
|
569
572
|
input,
|
|
570
|
-
foundDocumentation: documentation
|
|
573
|
+
foundDocumentation: documentation,
|
|
574
|
+
resultText: text
|
|
571
575
|
});
|
|
572
|
-
const format = server.ctx.custom?.format ?? "markdown";
|
|
573
576
|
return { content: [{
|
|
574
577
|
type: "text",
|
|
575
|
-
text
|
|
578
|
+
text
|
|
576
579
|
}] };
|
|
577
580
|
} catch (error) {
|
|
578
581
|
return errorToMCPContent(error);
|