Add get-changed-stories tool#219
Conversation
🦋 Changeset detectedLatest commit: f922ce0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for storybook-mcp-self-host-example canceled.
|
❌ 3 Tests Failed:
View the full list of 3 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
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-storiestool + registers it in the addon MCP server. - Updates Storybook/agent instruction templates to call
get-changed-storiesbeforepreview-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. |
- 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.
bfe77f3 to
aee78f6
Compare
commit: |
- 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.
There was a problem hiding this comment.
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
Bundle ReportBundle 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
acf59eb to
6684af6
Compare
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
…test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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
| typeId: string; | ||
| storyId: string; | ||
| title: string; | ||
| description: string; | ||
| data?: any; |
There was a problem hiding this comment.
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.
| typeId: string; | |
| storyId: string; | |
| title: string; | |
| description: string; | |
| data?: any; | |
| storyId: string; | |
| typeId?: string; | |
| title?: string; | |
| description?: string; | |
| data?: unknown; |
get-changed-storiestool to retrieve metadata for stories marked as new, modified, or related.dev-instructions.mdandstorybook-story-instructions.mdto reflect the new workflow for callingget-changed-storiesbeforepreview-stories.