Skip to content

Add get-changed-stories tool#219

Merged
ghengeveld merged 38 commits intomainfrom
get-changed-stories
Apr 30, 2026
Merged

Add get-changed-stories tool#219
ghengeveld merged 38 commits intomainfrom
get-changed-stories

Conversation

@ghengeveld
Copy link
Copy Markdown
Member

@ghengeveld ghengeveld commented Apr 22, 2026

  • Introduced the get-changed-stories tool to retrieve metadata for stories marked as new, modified, or related.
  • Updated dev-instructions.md and storybook-story-instructions.md to reflect the new workflow for calling get-changed-stories before preview-stories.
  • Added tests for the new tool to ensure correct functionality and output.
  • Updated tool names in relevant files to include the new tool.

Copilot AI review requested due to automatic review settings April 22, 2026 03:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

🦋 Changeset detected

Latest commit: f922ce0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@storybook/addon-mcp Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2026

Deploy Preview for storybook-mcp-self-host-example canceled.

Name Link
🔨 Latest commit f922ce0
🔍 Latest deploy log https://app.netlify.com/projects/storybook-mcp-self-host-example/deploys/69f347d416ead800089f2b72

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
465 3 462 0
View the full list of 3 ❄️ flaky test(s)
apps/internal-storybook/tests/mcp-composition.e2e.test.ts > MCP Composition E2E Tests > Multi-Source Documentation > should list documentation from both local and remote sources

Flake rate in main: 41.18% (Passed 10 times, Failed 7 times)

Stack Traces | 0.436s run time
AssertionError: expected '# Components\n\n- Button (example-but…' to contain '# Local'

- Expected
+ Received

- # Local
+ # Components
+
+ - Button (example-button): A customizable button component for user interactions.
+ - Header (header)
+ - Page (page)
+ - Card (other-ui-card): Card component with title, image, content, and action button
+
+ # Docs
+
+ - getting-started (getting-started--docs): # Getting Started This is the getting started documentation of this design system. ## Usag...

 ❯ tests/mcp-composition.e2e.test.ts:54:17
apps/internal-storybook/tests/mcp-composition.e2e.test.ts > MCP Composition E2E Tests > Multi-Source Documentation > should require storybookId in multi-source mode

Flake rate in main: 41.18% (Passed 10 times, Failed 7 times)

Stack Traces | 0.244s run time
Error: Snapshot `MCP Composition E2E Tests > Multi-Source Documentation > should require storybookId in multi-source mode 1` mismatched

- Expected
+ Received

  {
    "content": [
      {
-       "text": "Invalid arguments for tool get-documentation: [{"kind":"schema","type":"object","expected":"\"storybookId\"","received":"undefined","message":"Invalid key: Expected \"storybookId\" but received undefined","path":[{"type":"object","origin":"key","input":{"id":"example-button"},"key":"storybookId"}]}]",
+       "text": "# Button
+
+ ID: example-button
+
+ Primary UI component for user interaction
+
+ ## Stories
+
+ ### Primary
+
+ Story ID: example-button--primary
+
+ ```
+ import { Button } from "@my-org/my-component-library";
+
+ const Primary = () => <Button onClick={fn()} primary label="Button" />;
+ ```
+
+ ### Secondary
+
+ Story ID: example-button--secondary
+
+ ```
+ import { Button } from "@my-org/my-component-library";
+
+ const Secondary = () => <Button onClick={fn()} label="Button" />;
+ ```
+
+ ### Large
+
+ Story ID: example-button--large
+
+ ```
+ import { Button } from "@my-org/my-component-library";
+
+ const Large = () => <Button onClick={fn()} size="large" label="Button" />;
+ ```
+
+ ### Other Stories
+
+ - Small (example-button--small)
+ - With A 11 Y Violation (example-button--with-a-11-y-violation)
+
+ ## Props
+
+ ```
+ export type Props = {
+   /**
+     Is this the principal call to action on the page?
+   */
+   primary?: boolean = false;
+   /**
+     What background color to use
+   */
+   backgroundColor?: string;
+   /**
+     How large should the button be?
+   */
+   size?: 'small' | 'medium' | 'large' = 'medium';
+   /**
+     Button contents
+   */
+   label: string;
+   /**
+     Optional click handler
+   */
+   onClick?: () => void;
+ }
+ ```
+
+ ## Docs
+
+ ### Additional Information
+
+ import { Meta, Canvas } from '@storybook/addon-docs/blocks';
+ import * as ButtonStories from './Button.stories';
+
+ <Meta of={ButtonStories} name="Additional Information" />
+
+ It is critical when using the Button component, that the string passed to the `label` prop uses the 🍌-emoji instead of spaces.
+
+ Here is the button:
+
+ <Canvas of={ButtonStories.Primary} />",
        "type": "text",
      },
    ],
-   "isError": true,
  }

 ❯ tests/mcp-composition.e2e.test.ts:212:28
apps/internal-storybook/tests/mcp-composition.e2e.test.ts > MCP Composition E2E Tests > Tools Schema > should include storybookId parameter in get-documentation schema

Flake rate in main: 41.18% (Passed 10 times, Failed 7 times)

Stack Traces | 0.00528s run time
AssertionError: expected { id: { type: 'string', …(1) } } to have property "storybookId"
 ❯ tests/mcp-composition.e2e.test.ts:244:46

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new dev tool (get-changed-stories) to the @storybook/addon-mcp MCP server so agents can discover Storybook stories marked as new/modified/affected and then selectively call preview-stories for URLs.

Changes:

  • Introduces get-changed-stories tool + registers it in the addon MCP server.
  • Updates Storybook/agent instruction templates to call get-changed-stories before preview-stories.
  • Adds unit tests covering the new tool’s core behavior (filtering/sorting/fallbacks/error case).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/addon-mcp/src/tools/tool-names.ts Adds the new tool name constant.
packages/addon-mcp/src/tools/get-storybook-story-instructions.ts Injects the new tool name into the instructions template rendering.
packages/addon-mcp/src/tools/get-changed-stories.ts Implements the new tool using Storybook’s status store + story index metadata.
packages/addon-mcp/src/tools/get-changed-stories.test.ts Adds tests for filtering, sorting, fallbacks, and error behavior.
packages/addon-mcp/src/mcp-handler.ts Registers the new tool in server initialization.
packages/addon-mcp/src/instructions/storybook-story-instructions.md Updates workflow guidance to call get-changed-stories first.
packages/addon-mcp/src/instructions/dev-instructions.md Updates dev workflow guidance to incorporate the new tool.

Comment thread packages/addon-mcp/src/mcp-handler.ts
Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts Outdated
Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts Outdated
Comment thread packages/addon-mcp/src/instructions/dev-instructions.md Outdated
Comment thread packages/addon-mcp/src/instructions/storybook-story-instructions.md Outdated
- Introduced the `get-changed-stories` tool to retrieve metadata for stories marked as new, modified, or affected.
- Updated `dev-instructions.md` and `storybook-story-instructions.md` to reflect the new workflow for calling `get-changed-stories` before `preview-stories`.
- Added tests for the new tool to ensure correct functionality and output.
- Updated tool names in relevant files to include the new tool.
@ghengeveld ghengeveld force-pushed the get-changed-stories branch from bfe77f3 to aee78f6 Compare April 22, 2026 10:01
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 22, 2026

npm i https://pkg.pr.new/storybookjs/mcp/@storybook/addon-mcp@219
npm i https://pkg.pr.new/storybookjs/mcp/@storybook/mcp@219

commit: f922ce0

- Updated the shutdown process in `stopStorybook` to handle SIGTERM and escalate to SIGKILL after a grace period.
- Increased the `STARTUP_TIMEOUT` from 30 seconds to 60 seconds in multiple test files to accommodate longer startup times.
- Introduced a check for remote source availability in MCP Composition tests to conditionally assert the presence of documentation components.
- Added a utility function to handle browser launch errors in MCP Endpoint tests, ensuring proper error handling in test assertions.
Copilot AI review requested due to automatic review settings April 22, 2026 14:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 16 changed files in this pull request and generated 4 comments.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment thread packages/addon-mcp/src/instructions/build-server-instructions.test.ts Outdated
Comment thread packages/addon-mcp/src/mcp-handler.ts
Comment thread packages/addon-mcp/src/instructions/storybook-story-instructions.md Outdated
Comment thread packages/addon-mcp/src/instructions/build-server-instructions.test.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Bundle Report

Bundle size has no change ✅

…nce tests

- Updated the `get-changed-stories` tool to return optional story metadata fields (title, name, importPath).
- Improved the output formatting to group stories by their status (new, modified, affected) with detailed inline snapshots in tests.
- Refactored test cases to utilize helper functions for better readability and maintainability.
…tuses are found, enhancing performance and adding corresponding test case.
Extend get-changed-stories tests to cover getAll() and allStatuses/single-status fallback shapes so support for Storybook internal variants is protected from regressions.

Made-with: Cursor
Remove hard line breaks from preview-link guidance and update instruction snapshots so tests assert semantic content instead of incidental whitespace.

Made-with: Cursor
Remove hard-wrapped list formatting and switch the changed-stories fallback URL to a relative path so guidance stays correct across non-default Storybook origins.

Made-with: Cursor
Copilot AI review requested due to automatic review settings April 28, 2026 13:20
@ghengeveld ghengeveld force-pushed the get-changed-stories branch from acf59eb to 6684af6 Compare April 28, 2026 13:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 17 changed files in this pull request and generated 5 comments.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts Outdated
Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts
Comment thread apps/internal-storybook/tests/mcp-endpoint.e2e.test.ts Outdated
Comment thread apps/internal-storybook/tests/helpers.ts
Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts Outdated
Copilot AI review requested due to automatic review settings April 30, 2026 07:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 20 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts Outdated
Copilot AI review requested due to automatic review settings April 30, 2026 08:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 20 changed files in this pull request and generated 2 comments.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment thread packages/addon-mcp/src/instructions/build-server-instructions.ts Outdated
Comment thread .changeset/icy-walls-exist.md
Copilot AI review requested due to automatic review settings April 30, 2026 08:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts
Copilot AI review requested due to automatic review settings April 30, 2026 12:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 19 changed files in this pull request and generated 4 comments.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment thread apps/internal-storybook/tests/helpers.ts
Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts
Comment thread packages/addon-mcp/src/tools/get-changed-stories.ts
…test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 12:15
@ghengeveld ghengeveld merged commit d4c7876 into main Apr 30, 2026
14 of 15 checks passed
@ghengeveld ghengeveld deleted the get-changed-stories branch April 30, 2026 12:18
@storybook-app-bot storybook-app-bot Bot mentioned this pull request Apr 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • apps/internal-storybook/pnpm-lock.yaml: Language not supported
  • eval/pnpm-lock.yaml: Language not supported
  • packages/addon-mcp/pnpm-lock.yaml: Language not supported

Comment on lines +30 to +34
typeId: string;
storyId: string;
title: string;
description: string;
data?: any;
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Status/StatusesByStoryIdAndTypeId typings are stricter than what the status-store objects actually provide (e.g. tests and likely runtime only include value/storyId). Because statusStore.getAll() is force-cast, these required fields (typeId, title, description) can mislead future code into assuming they exist. Consider modeling a minimal shape for this tool (e.g. { storyId: string; value: StatusValue }) or making the extra fields optional; also prefer unknown over any for data if it’s not used here.

Suggested change
typeId: string;
storyId: string;
title: string;
description: string;
data?: any;
storyId: string;
typeId?: string;
title?: string;
description?: string;
data?: unknown;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants