@storybook/addon-mcp 0.0.8 → 0.1.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/README.md +43 -39
- package/dist/preset.js +5 -13
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,10 +4,7 @@ This Storybook addon runs an MCP (Model Context Protocol) server to help develop
|
|
|
4
4
|
|
|
5
5
|
It enables a workflow where for each UI component created, the agent will automatically generate and link to example stories. These stories let you visually verify the new UI in each of its key states, and provide documentation and component tests.
|
|
6
6
|
|
|
7
|
-
The
|
|
8
|
-
|
|
9
|
-
> [!IMPORTANT]
|
|
10
|
-
> This addon currently only supports Vite-based Storybook setups, such as [`@storybook/react-vite`](https://storybook.js.org/docs/get-started/frameworks/react-vite), [`@storybook/nextjs-vite`](https://storybook.js.org/docs/get-started/frameworks/nextjs#with-vite), and [`@storybook/sveltekit`](https://storybook.js.org/docs/get-started/frameworks/sveltekit).
|
|
7
|
+
The addon provides tools to improve agents' UI development capabilities, retrieve story URLs, and access component documentation.
|
|
11
8
|
|
|
12
9
|
<div align="center">
|
|
13
10
|
<img src="https://storybook.js.org/embed/addon-mcp-claude-code-showcase.gif" alt="Storybook MCP Addon Demo" />
|
|
@@ -17,6 +14,9 @@ The server currently exposes two tools: one to provide UI development instructio
|
|
|
17
14
|
|
|
18
15
|
### Installation and Setup
|
|
19
16
|
|
|
17
|
+
> [!NOTE]
|
|
18
|
+
> This addon requires Storybook 10.1 or higher, currently only available as the canary version `0.0.0-pr-32810-sha-6e759c7e`.
|
|
19
|
+
|
|
20
20
|
Use Storybook's CLI to automatically install and configure the addon:
|
|
21
21
|
|
|
22
22
|
```bash
|
|
@@ -36,7 +36,7 @@ The MCP server will be available at `<your_storybook_dev_server_origin>/mcp` whe
|
|
|
36
36
|
### Configuring Your Agent
|
|
37
37
|
|
|
38
38
|
> [!NOTE]
|
|
39
|
-
> This addon is primarily tested with Claude Code. While it should work with other MCP clients, Claude Code is our main target for compatibility and testing.
|
|
39
|
+
> This addon is primarily tested with Claude Code and GitHub Copilot. While it should work with other MCP clients, Claude Code is our main target for compatibility and testing.
|
|
40
40
|
|
|
41
41
|
#### Claude Code Setup
|
|
42
42
|
|
|
@@ -64,6 +64,8 @@ Before doing any UI, frontend or React development, ALWAYS call the storybook MC
|
|
|
64
64
|
|
|
65
65
|
#### Other MCP Clients
|
|
66
66
|
|
|
67
|
+
[](https://cursor.com/en-US/install-mcp?name=storybook-mcp&config=eyJ1cmwiOiJodHRwOi8vbG9jYWxob3N0OjYwMDYvbWNwIn0%3D)
|
|
68
|
+
|
|
67
69
|
This addon should work with any MCP-compatible client that supports the `tool` capability and the `streamable-http` transport. Here are setup guides for other popular clients:
|
|
68
70
|
|
|
69
71
|
- [GitHub Copilot](https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp)
|
|
@@ -82,11 +84,15 @@ For clients not listed above, consult their documentation for MCP server configu
|
|
|
82
84
|
|
|
83
85
|
## Usage
|
|
84
86
|
|
|
85
|
-
This addon provides
|
|
87
|
+
This addon provides MCP tools that your agent can use. The goal is that the agent uses these tools automatically when doing UI development, but agents are unreliable and unpredictable, so sometimes you might need to explicitly tell it to use the tools.
|
|
86
88
|
|
|
87
89
|
**If you are prompting from an IDE like VSCode or Cursor, be sure to use `Agent` mode and `sonnet-4.5` or better.**
|
|
88
90
|
|
|
89
|
-
###
|
|
91
|
+
### Core Tools
|
|
92
|
+
|
|
93
|
+
These tools are always available when the addon is installed:
|
|
94
|
+
|
|
95
|
+
#### 1. UI Building Instructions (`get_ui_building_instructions`)
|
|
90
96
|
|
|
91
97
|
Provides agents with standardized instructions for UI component development within your project. This tool returns guidelines for:
|
|
92
98
|
|
|
@@ -96,7 +102,7 @@ Provides agents with standardized instructions for UI component development with
|
|
|
96
102
|
|
|
97
103
|
The instructions ensure agents follow your project's conventions when creating or modifying UI components and their corresponding stories.
|
|
98
104
|
|
|
99
|
-
|
|
105
|
+
#### 2. Get Story URLs (`get_story_urls`)
|
|
100
106
|
|
|
101
107
|
Allows agents to retrieve direct URLs to specific stories in your Storybook. The agent can request URLs for multiple stories by providing:
|
|
102
108
|
|
|
@@ -113,50 +119,48 @@ Agent calls tool, gets response:
|
|
|
113
119
|
http://localhost:6006/?path=/story/example-button--primary
|
|
114
120
|
```
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
### Component Documentation Tools (Experimental)
|
|
117
123
|
|
|
118
|
-
|
|
124
|
+
These additional tools are available when the **experimental** component manifest feature is enabled. They provide agents with detailed documentation about your UI components.
|
|
119
125
|
|
|
120
|
-
|
|
126
|
+
**Requirements:**
|
|
121
127
|
|
|
122
|
-
|
|
128
|
+
- React-based framework (`react-vite`, `nextjs-vite`, `nextjs`, `react-webpack5`)
|
|
129
|
+
- Feature flag `features.experimentalComponentsManifest` set to `true` in `.storybook/main.js`
|
|
130
|
+
|
|
131
|
+
**To enable:**
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
```javascript
|
|
134
|
+
// .storybook/main.js
|
|
135
|
+
export default {
|
|
136
|
+
// ... other config
|
|
137
|
+
features: {
|
|
138
|
+
experimentalComponentsManifest: true,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
```
|
|
125
142
|
|
|
126
|
-
|
|
143
|
+
#### 3. List All Components (`list-all-components`)
|
|
127
144
|
|
|
128
|
-
|
|
129
|
-
# Clone the repository
|
|
130
|
-
git clone https://github.com/storybookjs/mcp.git
|
|
131
|
-
cd addon-mcp
|
|
145
|
+
Returns a list of all available UI components in your component library. Useful for the LLM as discovery and understanding what components are available to use.
|
|
132
146
|
|
|
133
|
-
|
|
134
|
-
pnpm install
|
|
147
|
+
#### 4. Get Component Documentation (`get-component-documentation`)
|
|
135
148
|
|
|
136
|
-
|
|
137
|
-
pnpm build
|
|
149
|
+
Retrieves detailed documentation for specific components, including:
|
|
138
150
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
```
|
|
151
|
+
- Component documentation
|
|
152
|
+
- Usage examples
|
|
142
153
|
|
|
143
|
-
|
|
154
|
+
The agent provides component IDs to retrieve their documentation.
|
|
144
155
|
|
|
145
|
-
|
|
156
|
+
## Contributing
|
|
146
157
|
|
|
147
|
-
|
|
148
|
-
pnpm run inspect
|
|
149
|
-
```
|
|
158
|
+
We welcome contributions to improve Storybook's agent integration, within or outside of this addon! Here's how you can help:
|
|
150
159
|
|
|
151
|
-
|
|
160
|
+
1. **Ideas and feature requests**: If you have ideas for what else we could do to improve the Storybook experience when using agents, please [start a discussion](https://github.com/storybookjs/mcp/discussions/new?category=ideas) in this repository.
|
|
152
161
|
|
|
153
|
-
|
|
154
|
-
# Run tests in watch mode
|
|
155
|
-
pnpm test
|
|
162
|
+
2. **Report Issues**: If you find bugs, please open an issue on our [GitHub repository](https://github.com/storybookjs/mcp), but keep in mind that this is currently highly experimental, explorative and probably filled with bugs.
|
|
156
163
|
|
|
157
|
-
|
|
158
|
-
pnpm test run
|
|
164
|
+
3. **Development**:
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
pnpm test run --coverage
|
|
162
|
-
```
|
|
166
|
+
See [the monorepo readme](https://github.com/storybookjs/mcp#-quick-start).
|
package/dist/preset.js
CHANGED
|
@@ -11,7 +11,7 @@ import { buffer } from "node:stream/consumers";
|
|
|
11
11
|
|
|
12
12
|
//#region package.json
|
|
13
13
|
var name = "@storybook/addon-mcp";
|
|
14
|
-
var version = "0.0
|
|
14
|
+
var version = "0.1.0";
|
|
15
15
|
var description = "Help agents automatically write and test stories for your UI components";
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
@@ -281,18 +281,10 @@ async function webResponseToServerResponse(webResponse, nodeResponse) {
|
|
|
281
281
|
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/preset.ts
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
configureServer(server) {
|
|
288
|
-
server.middlewares.use("/mcp", (req, res, next) => mcpServerHandler(req, res, next, options));
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
return {
|
|
292
|
-
...config,
|
|
293
|
-
plugins: config.plugins.concat(mcpHandlerPlugin)
|
|
294
|
-
};
|
|
284
|
+
const experimental_devServer = (app, options) => {
|
|
285
|
+
app.use("/mcp", (req, res, next) => mcpServerHandler(req, res, next, options));
|
|
286
|
+
return app;
|
|
295
287
|
};
|
|
296
288
|
|
|
297
289
|
//#endregion
|
|
298
|
-
export {
|
|
290
|
+
export { experimental_devServer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-mcp",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Help agents automatically write and test stories for your UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addon",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"@tmcp/transport-http": "^0.7.0",
|
|
31
31
|
"tmcp": "^1.15.2",
|
|
32
32
|
"valibot": "^1.1.0",
|
|
33
|
-
"@storybook/mcp": "0.0.
|
|
33
|
+
"@storybook/mcp": "0.0.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "20.19.0",
|
|
37
37
|
"@vitest/coverage-v8": "3.2.4",
|
|
38
|
-
"storybook": "
|
|
38
|
+
"storybook": "0.0.0-pr-32810-sha-6e759c7e",
|
|
39
39
|
"ts-dedent": "^2.2.0",
|
|
40
40
|
"tsdown": "^0.15.9",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vitest": "^3.2.4"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"storybook": "
|
|
46
|
+
"storybook": "0.0.0-pr-32810-sha-6e759c7e"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|