@storybook/addon-mcp 0.0.1 → 0.0.2
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 +134 -1
- package/dist/preset.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
1
1
|
# Storybook MCP Addon
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This Storybook addon provides an MCP (Model Context Protocol) server, enabling AI agents to interact with your Storybook instance. The addon currently allows agents to get UI development instructions and retrieve story URLs directly from your running Storybook.
|
|
4
|
+
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> 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
|
+
|
|
8
|
+
<div align="center">
|
|
9
|
+
<img src="./addon-mcp-claude-code-showcase.gif" alt="Storybook MCP Addon Demo" />
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
### Installation and Setup
|
|
15
|
+
|
|
16
|
+
Use Storybook's CLI to automatically install and configure the addon:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx storybook add @storybook/addon-mcp
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This command will install the addon and add it to your Storybook configuration automatically.
|
|
23
|
+
|
|
24
|
+
Start your Storybook development server:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm run storybook
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The MCP server will be available at `<your_storybook_dev_server_origin>/mcp` when Storybook is running.
|
|
31
|
+
|
|
32
|
+
### Configuring Your Agent
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> 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.
|
|
36
|
+
|
|
37
|
+
#### Claude Code Setup
|
|
38
|
+
|
|
39
|
+
To use this addon with [Claude Code](https://claude.ai/code), use the built-in MCP configuration command:
|
|
40
|
+
|
|
41
|
+
1. **Add the MCP server**: Run the following command in your terminal:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
claude mcp add storybook-mcp --transport http http://localhost:6006/mcp --scope project
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. **Start Storybook**: Make sure your Storybook development server is running:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm run storybook
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. **Connect Claude Code**: Claude Code should automatically detect and connect to the MCP server when it's running. You can verify the connection by asking Claude to use Storybook-related tools.
|
|
54
|
+
|
|
55
|
+
4. **Configure Agent Behavior** (Optional but Recommended): Add the following system or project prompt to ensure your agent uses the Storybook tools when appropriate:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
Before doing any UI, frontend or React development, ALWAYS call the storybook MCP server to get further instructions.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### Other MCP Clients
|
|
62
|
+
|
|
63
|
+
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:
|
|
64
|
+
|
|
65
|
+
- [GitHub Copilot](https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp)
|
|
66
|
+
- [Cursor](https://docs.cursor.com/en/context/mcp#installing-mcp-servers)
|
|
67
|
+
- [opencode](https://opencode.ai/docs/mcp-servers/)
|
|
68
|
+
- [Claude Desktop](https://modelcontextprotocol.io/quickstart/user)
|
|
69
|
+
- [Cline](https://docs.cline.bot/mcp/configuring-mcp-servers)
|
|
70
|
+
- [Zed Editor](https://zed.dev/docs/ai/mcp#as-custom-servers)
|
|
71
|
+
- [Continue](https://docs.continue.dev/customize/deep-dives/mcp#how-to-configure-mcp-servers)
|
|
72
|
+
|
|
73
|
+
For clients not listed above, consult their documentation for MCP server configuration. The server configuration typically requires:
|
|
74
|
+
|
|
75
|
+
- **Server Type**: `http`
|
|
76
|
+
- **URL**: `http://localhost:6006/mcp` (adjust port if your Storybook runs on a different port)
|
|
77
|
+
- ⚠️ Make sure your Storybook development server is running before your agent tries to connect.
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
This addon provides two main 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.
|
|
82
|
+
|
|
83
|
+
### 1. UI Building Instructions (`get_ui_building_instructions`)
|
|
84
|
+
|
|
85
|
+
Provides agents with standardized instructions for UI component development within your project. This tool returns guidelines for:
|
|
86
|
+
|
|
87
|
+
- Writing Storybook stories using CSF3 format
|
|
88
|
+
- Component development best practices
|
|
89
|
+
- Story linking requirements
|
|
90
|
+
|
|
91
|
+
The instructions ensure agents follow your project's conventions when creating or modifying UI components and their corresponding stories.
|
|
92
|
+
|
|
93
|
+
### 2. Get Story URLs (`get_story_urls`)
|
|
94
|
+
|
|
95
|
+
Allows agents to retrieve direct URLs to specific stories in your Storybook. The agent can request URLs for multiple stories by providing:
|
|
96
|
+
|
|
97
|
+
- `absoluteStoryPath`: Absolute path to the story file
|
|
98
|
+
- `exportName`: The export name of the story
|
|
99
|
+
- `explicitStoryName`: Optional explicit story name
|
|
100
|
+
|
|
101
|
+
Example agent usage:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Prompt: I need to see the primary variant of the Button component
|
|
105
|
+
|
|
106
|
+
Agent calls tool, gets response:
|
|
107
|
+
http://localhost:6006/?path=/story/example-button--primary
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
We welcome contributions to improve Storybook's agent integration, within or outside of this addon! Here's how you can help:
|
|
113
|
+
|
|
114
|
+
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/addon-mcp/discussions/new?category=ideas) in this repository.
|
|
115
|
+
|
|
116
|
+
2. **Report Issues**: If you find bugs, please open an issue on our [GitHub repository](https://github.com/storybookjs/addon-mcp), but keep in mind that this is currently highly experimental, explorative and probably filled with bugs.
|
|
117
|
+
|
|
118
|
+
3. **Development Setup**:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Clone the repository
|
|
122
|
+
git clone https://github.com/storybookjs/addon-mcp.git
|
|
123
|
+
cd addon-mcp
|
|
124
|
+
|
|
125
|
+
# Install dependencies
|
|
126
|
+
pnpm install
|
|
127
|
+
|
|
128
|
+
# Start development
|
|
129
|
+
pnpm start
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
4. **Testing**: Run the MCP inspector to test the server functionality (requires that the Storybook dev server is running):
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pnpm run inspect
|
|
136
|
+
```
|
package/dist/preset.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "everything you need to build a Storybook addon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addons",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public",
|
|
62
|
-
"provenance":
|
|
62
|
+
"provenance": true
|
|
63
63
|
},
|
|
64
64
|
"bundler": {
|
|
65
65
|
"nodeEntries": [
|