@storybook/addon-mcp 0.0.4 → 0.0.6

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 CHANGED
@@ -1,12 +1,16 @@
1
1
  # Storybook MCP Addon
2
2
 
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.
3
+ This Storybook addon runs an MCP (Model Context Protocol) server to help develop UI components more efficiently.
4
+
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
+
7
+ The server currently exposes two tools: one to provide UI development instructions to the agent, and the other to retrieve story URLs directly from your running Storybook.
4
8
 
5
9
  > [!IMPORTANT]
6
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
11
 
8
12
  <div align="center">
9
- <img src="./addon-mcp-claude-code-showcase.gif" alt="Storybook MCP Addon Demo" />
13
+ <img src="https://storybook.js.org/embed/addon-mcp-claude-code-showcase.gif" alt="Storybook MCP Addon Demo" />
10
14
  </div>
11
15
 
12
16
  ## Getting Started
@@ -80,6 +84,8 @@ For clients not listed above, consult their documentation for MCP server configu
80
84
 
81
85
  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
86
 
87
+ **If you are prompting from an IDE like VSCode or Cursor, be sure to use `Agent` mode and `sonnet-4.5` or better.**
88
+
83
89
  ### 1. UI Building Instructions (`get_ui_building_instructions`)
84
90
 
85
91
  Provides agents with standardized instructions for UI component development within your project. This tool returns guidelines for:
@@ -111,24 +117,31 @@ http://localhost:6006/?path=/story/example-button--primary
111
117
 
112
118
  We welcome contributions to improve Storybook's agent integration, within or outside of this addon! Here's how you can help:
113
119
 
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.
120
+ 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.
115
121
 
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.
122
+ 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.
117
123
 
118
124
  3. **Development Setup**:
119
125
 
126
+ This repository uses a monorepo structure with [pnpm workspaces](https://pnpm.io/workspaces) and [Turborepo](https://turborepo.com) for task orchestration.
127
+
120
128
  ```bash
121
129
  # Clone the repository
122
- git clone https://github.com/storybookjs/addon-mcp.git
130
+ git clone https://github.com/storybookjs/mcp.git
123
131
  cd addon-mcp
124
132
 
125
- # Install dependencies
133
+ # Install dependencies (installs for all packages in the workspace)
126
134
  pnpm install
127
135
 
128
- # Start development
136
+ # Build all packages
137
+ pnpm build
138
+
139
+ # Start development (runs the addon-mcp package)
129
140
  pnpm start
130
141
  ```
131
142
 
143
+ The main addon package is located in `packages/addon-mcp`.
144
+
132
145
  4. **Testing**: Run the MCP inspector to test the server functionality (requires that the Storybook dev server is running):
133
146
 
134
147
  ```bash
package/dist/preset.js CHANGED
@@ -16,9 +16,9 @@ var __export = (target, all) => {
16
16
  // package.json
17
17
  var package_default = {
18
18
  name: "@storybook/addon-mcp",
19
- version: "0.0.4"};
19
+ version: "0.0.5"};
20
20
 
21
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
21
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
22
22
  var external_exports = {};
23
23
  __export(external_exports, {
24
24
  BRAND: () => BRAND,
@@ -130,7 +130,7 @@ __export(external_exports, {
130
130
  void: () => voidType
131
131
  });
132
132
 
133
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
133
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
134
134
  var util;
135
135
  (function(util2) {
136
136
  util2.assertEqual = (_) => {
@@ -264,7 +264,7 @@ var getParsedType = (data) => {
264
264
  }
265
265
  };
266
266
 
267
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
267
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
268
268
  var ZodIssueCode = util.arrayToEnum([
269
269
  "invalid_type",
270
270
  "invalid_literal",
@@ -382,7 +382,7 @@ ZodError.create = (issues) => {
382
382
  return error;
383
383
  };
384
384
 
385
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
385
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
386
386
  var errorMap = (issue, _ctx) => {
387
387
  let message;
388
388
  switch (issue.code) {
@@ -485,7 +485,7 @@ var errorMap = (issue, _ctx) => {
485
485
  };
486
486
  var en_default = errorMap;
487
487
 
488
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
488
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
489
489
  var overrideErrorMap = en_default;
490
490
  function setErrorMap(map) {
491
491
  overrideErrorMap = map;
@@ -494,7 +494,7 @@ function getErrorMap() {
494
494
  return overrideErrorMap;
495
495
  }
496
496
 
497
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
497
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
498
498
  var makeIssue = (params) => {
499
499
  const { data, path: path2, errorMaps, issueData } = params;
500
500
  const fullPath = [...path2, ...issueData.path || []];
@@ -604,14 +604,14 @@ var isDirty = (x) => x.status === "dirty";
604
604
  var isValid = (x) => x.status === "valid";
605
605
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
606
606
 
607
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
607
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
608
608
  var errorUtil;
609
609
  (function(errorUtil2) {
610
610
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
611
611
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
612
612
  })(errorUtil || (errorUtil = {}));
613
613
 
614
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
614
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
615
615
  var ParseInputLazyPath = class {
616
616
  constructor(parent, value, path2, key) {
617
617
  this._cachedPath = [];
@@ -4058,7 +4058,7 @@ var coerce = {
4058
4058
  };
4059
4059
  var NEVER = INVALID;
4060
4060
 
4061
- // node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js
4061
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js
4062
4062
  var zod_default = external_exports;
4063
4063
  async function collectTelemetry({
4064
4064
  event,
@@ -4169,7 +4169,7 @@ function registerStoryUrlsTool({
4169
4169
  }
4170
4170
 
4171
4171
  // src/ui-building-instructions.md
4172
- var ui_building_instructions_default = "# Writing User Interfaces\n\nWhen writing UI, prefer breaking larger components up into smaller parts.\n\nALWAYS write a Storybook story for any component written. If editing a component, ensure appropriate changes have been made to stories for that component.\n\n## Storybook 9 Essential Changes for Story Writing\n\n### Package Consolidation\n\n#### `Meta` and `StoryObj` imports\n\nUpdate story imports to use the framework package:\n\n```diff\n- import { Meta, StoryObj } from '{{RENDERER}}';\n+ import { Meta, StoryObj } from '{{FRAMEWORK}}';\n```\n\n#### Test utility imports\n\nUpdate test imports to use `storybook/test` instead of `@storybook/test`\n\n```diff\n- import { fn } from '@storybook/test';\n+ import { fn } from 'storybook/test';\n```\n\n### Global State Changes\n\nThe `globals` annotation has be renamed to `initialGlobals`:\n\n```diff\n// .storybook/preview.js\nexport default {\n- globals: { theme: 'light' }\n+ initialGlobals: { theme: 'light' }\n};\n```\n\n### Autodocs Configuration\n\nInstead of `parameters.docs.autodocs` in main.js, use tags:\n\n```js\n// .storybook/preview.js or in individual stories\nexport default {\n tags: [\"autodocs\"], // generates autodocs for all stories\n};\n```\n\n### Mocking imports in Storybook\n\nTo mock imports in Storybook, use Storybook's mocking features. ALWAYS mock external dependencies to ensure stories render consistently.\n\n1. **Register in the mock in Storybook's preview file**:\n To mock dependendencies, you MUST register a module mock in `.storybook/preview.ts` (or equivalent):\n\n```js\nimport { sb } from \"storybook/test\";\n\n// Full mock (replaces with empty fn functions)\nsb.mock(import(\"some-library\"));\n```\n\n2. **Specify mock values in stories**:\n You can override the behaviour of the mocks per-story using `beforeEach` and the `mocked()` type function:\n\n```js\nimport { expect, mocked, fn } from 'storybook/test';\nimport { library } from 'some-library';\n\nconst meta = {\n component: AuthButton,\n beforeEach: async () => {\n mocked(library).mockResolvedValue({ user: 'data' });\n },\n};\n\nexport const LoggedIn: Story = {\n play: async ({ canvas }) => {\n await expect(library).toHaveBeenCalled();\n },\n};\n```\n\nBefore doing this ensure you have mocked the import in the preview file.\n\n### Key Requirements\n\n- **Node.js 20+**, **TypeScript 4.9+**, **Vite 5+**\n- React Native uses `.rnstorybook` directory\n- `afterEach` hook is now stable (was `experimental_afterEach`)\n\n## Story Linking Agent Behavior\n\n- ALWAYS provide story links after any changes to stories files, including changes to existing stories.\n- After changing any UI components, ALWAYS search for related stories that might cover the changes you've made. If you find any, provide the story links to the user. THIS IS VERY IMPORTANT, as it allows the user to visually inspect the changes you've made. Even later in a session when changing UI components or stories that have already been linked to previously, YOU MUST PROVIDE THE LINKS AGAIN.\n- Use the {{GET_STORY_URLS_TOOL_NAME}} tool to get the correct URLs for links to stories.\n";
4172
+ var ui_building_instructions_default = "# Writing User Interfaces\n\nWhen writing UI, prefer breaking larger components up into smaller parts.\n\nALWAYS write a Storybook story for any component written. If editing a component, ensure appropriate changes have been made to stories for that component.\n\n## Storybook 9 Essential Changes for Story Writing\n\n### Package Consolidation\n\n#### `Meta` and `StoryObj` imports\n\nUpdate story imports to use the framework package:\n\n```diff\n- import { Meta, StoryObj } from '{{RENDERER}}';\n+ import { Meta, StoryObj } from '{{FRAMEWORK}}';\n```\n\n#### Test utility imports\n\nUpdate test imports to use `storybook/test` instead of `@storybook/test`\n\n```diff\n- import { fn } from '@storybook/test';\n+ import { fn } from 'storybook/test';\n```\n\n### Global State Changes\n\nThe `globals` annotation has be renamed to `initialGlobals`:\n\n```diff\n// .storybook/preview.js\nexport default {\n- globals: { theme: 'light' }\n+ initialGlobals: { theme: 'light' }\n};\n```\n\n### Autodocs Configuration\n\nInstead of `parameters.docs.autodocs` in main.js, use tags:\n\n```js\n// .storybook/preview.js or in individual stories\nexport default {\n tags: ['autodocs'], // generates autodocs for all stories\n};\n```\n\n### Mocking imports in Storybook\n\nTo mock imports in Storybook, use Storybook's mocking features. ALWAYS mock external dependencies to ensure stories render consistently.\n\n1. **Register in the mock in Storybook's preview file**:\n To mock dependendencies, you MUST register a module mock in `.storybook/preview.ts` (or equivalent):\n\n```js\nimport { sb } from 'storybook/test';\n\n// Full mock (replaces with empty fn functions)\nsb.mock(import('some-library'));\n```\n\n2. **Specify mock values in stories**:\n You can override the behaviour of the mocks per-story using `beforeEach` and the `mocked()` type function:\n\n```js\nimport { expect, mocked, fn } from 'storybook/test';\nimport { library } from 'some-library';\n\nconst meta = {\n component: AuthButton,\n beforeEach: async () => {\n mocked(library).mockResolvedValue({ user: 'data' });\n },\n};\n\nexport const LoggedIn: Story = {\n play: async ({ canvas }) => {\n await expect(library).toHaveBeenCalled();\n },\n};\n```\n\nBefore doing this ensure you have mocked the import in the preview file.\n\n### Key Requirements\n\n- **Node.js 20+**, **TypeScript 4.9+**, **Vite 5+**\n- React Native uses `.rnstorybook` directory\n- `afterEach` hook is now stable (was `experimental_afterEach`)\n\n## Story Linking Agent Behavior\n\n- ALWAYS provide story links after any changes to stories files, including changes to existing stories.\n- After changing any UI components, ALWAYS search for related stories that might cover the changes you've made. If you find any, provide the story links to the user. THIS IS VERY IMPORTANT, as it allows the user to visually inspect the changes you've made. Even later in a session when changing UI components or stories that have already been linked to previously, YOU MUST PROVIDE THE LINKS AGAIN.\n- Use the {{GET_STORY_URLS_TOOL_NAME}} tool to get the correct URLs for links to stories.\n";
4173
4173
  function registerUIBuildingTool({
4174
4174
  server,
4175
4175
  options
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@storybook/addon-mcp",
3
- "version": "0.0.4",
4
- "description": "everything you need to build a Storybook addon",
3
+ "version": "0.0.6",
4
+ "description": "Help agents automatically write and test stories for your UI components",
5
5
  "keywords": [
6
- "storybook-addons",
6
+ "storybook-addon",
7
7
  "mcp",
8
8
  "ai"
9
9
  ],
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/storybookjs/addon-mcp"
12
+ "url": "https://github.com/storybookjs/mcp.git",
13
+ "directory": "packages/addon-mcp"
13
14
  },
14
15
  "license": "MIT",
15
- "author": "Jeppe Reinhold <jeppe@chromatic.com>, Tom Coleman <tom@chromatic.com>",
16
+ "author": "Storybook Core Team",
16
17
  "type": "module",
17
18
  "exports": {
18
19
  "./preset": "./dist/preset.js",
@@ -28,38 +29,19 @@
28
29
  "@modelcontextprotocol/sdk": "^1.17.3"
29
30
  },
30
31
  "devDependencies": {
31
- "@changesets/changelog-github": "^0.5.1",
32
- "@changesets/cli": "^2.29.6",
33
- "@modelcontextprotocol/inspector": "^0.16.5",
34
- "@storybook/addon-docs": "^10.0.0-0",
35
- "@storybook/icons": "^1.4.0",
36
- "@storybook/react-vite": "^10.0.0-0",
37
32
  "@types/node": "^20",
38
- "@types/react": "^18.2.65",
39
- "@types/react-dom": "^18.2.21",
40
- "@vitejs/plugin-react": "^4.7.0",
41
- "auto": "^11.3.0",
42
- "boxen": "^8.0.1",
43
- "npm-run-all2": "^8.0.4",
44
- "pkg-pr-new": "^0.0.57",
45
- "prettier": "^3.6.2",
46
- "prompts": "^2.4.2",
47
- "react": "^18.2.0",
48
- "react-dom": "^18.2.0",
49
33
  "storybook": "^10.0.0-0",
50
34
  "ts-dedent": "^2.2.0",
51
35
  "tsup": "^8.5.0",
52
36
  "typescript": "^5.8.3",
53
37
  "vite": "^7.0.5",
54
- "zod": "^3.25.76",
55
- "zx": "^8.7.1"
38
+ "zod": "^3.25.76"
56
39
  },
57
40
  "peerDependencies": {
58
41
  "storybook": "*"
59
42
  },
60
43
  "publishConfig": {
61
- "access": "public",
62
- "provenance": true
44
+ "access": "public"
63
45
  },
64
46
  "bundler": {
65
47
  "nodeEntries": [
@@ -83,13 +65,7 @@
83
65
  "scripts": {
84
66
  "prebuild": "node -e \"fs.rmSync('./dist', { recursive: true, force: true })\"",
85
67
  "build": "tsup",
86
- "build-storybook": "storybook build",
87
- "build:watch": "pnpm run build -- --watch",
88
- "changeset": "changeset",
89
- "inspect": "mcp-inspector --transport streamable-http --server-url http://localhost:6006/mcp",
90
- "release": "pnpm run build && pnpm changeset publish",
91
- "start": "run-p build:watch \"storybook --quiet\"",
92
- "storybook": "storybook dev --port 6006 --loglevel debug",
93
- "test": "echo \"Error: no test specified\" && exit 1"
68
+ "dev": "pnpm run build -- --watch",
69
+ "inspect": "mcp-inspector --config ../../.mcp.inspect.json --server storybook-addon-mcp"
94
70
  }
95
71
  }
package/preset.js CHANGED
@@ -1 +1 @@
1
- export * from "./dist/preset.js";
1
+ export * from './dist/preset.js';