You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace the `source` property in the context with `request`.
6
+
7
+
Now you don't pass in a source string that might be fetched or handled by your custom `manifestProvider`, but instead you pass in the whole web request. (This is automatically handled if you use the createStorybookMcpHandler() function).
8
+
9
+
The default action is now to fetch the manifest from `../manifests/components.json` assuming the server is running at `./mcp`. Your custom `manifestProvider()`-function then also does not get a source string as an argument, but gets the whole web request, that you can use to get information about where to fetch the manifest from. It also gets a second argument, `path`, which it should use to determine which specific manifest to get from a built Storybook. (Currently always `./manifests/components.json`, but in the future it might be other paths too).
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,8 +61,14 @@ The `@storybook/mcp` package (in `packages/mcp`) is framework-agnostic:
61
61
62
62
- Uses `tmcp` with HTTP transport and Valibot schema validation
63
63
- Factory pattern: `createStorybookMcpHandler()` returns a request handler
64
-
- Context-based: handlers accept `StorybookContext`to override source URLs and provide optional callbacks
64
+
- Context-based: handlers accept `StorybookContext`which includes the HTTP `Request` object and optional callbacks
65
65
-**Exports tools and types** for reuse by `addon-mcp` and other consumers
66
+
-**Request-based manifest loading**: The `request` property in context is passed to tools, which use it to determine the manifest URL (defaults to same origin, replacing `/mcp` with the manifest path)
67
+
-**Optional manifestProvider**: Custom function to override default manifest fetching behavior
- Receives the `Request` object and a `path` parameter (currently always `'./manifests/components.json'`)
70
+
- The provider determines the base URL (e.g., mapping to S3 buckets) while the MCP server handles the path
71
+
- Returns the manifest JSON as a string
66
72
-**Optional handlers**: `StorybookContext` supports optional handlers that are called at various points, allowing consumers to track usage or collect telemetry:
67
73
-`onSessionInitialize`: Called when an MCP session is initialized
68
74
-`onListAllComponents`: Called when the list-all-components tool is invoked
0 commit comments