Skip to content

Add display-review tool for agentic review#230

Merged
yannbf merged 29 commits into
mainfrom
yann/agentic-review-mcp-integration
May 28, 2026
Merged

Add display-review tool for agentic review#230
yannbf merged 29 commits into
mainfrom
yann/agentic-review-mcp-integration

Conversation

@yannbf
Copy link
Copy Markdown
Member

@yannbf yannbf commented May 19, 2026

The agent pushes a curated review (narrative, labeled clusters with
optional semantic kind, changed files, diff hunks, optional per-story
depth/chain) via this MCP tool. It validates with valibot, caches the
state in memory, broadcasts it over the Storybook channel, and returns
the review-page URL.

Gated behind FEATURES.changeDetection.

Pairs with the @storybook/addon-review Storybook package.

@yannbf yannbf self-assigned this May 19, 2026
Copilot AI review requested due to automatic review settings May 19, 2026 15:58
@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

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

Name Link
🔨 Latest commit 7d424c1
🔍 Latest deploy log https://app.netlify.com/projects/storybook-mcp-self-host-example/deploys/6a17f205b657ab00086beb92

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: 7d424c1

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

npx https://pkg.pr.new/storybookjs/mcp/@storybook/addon-mcp@230
npx https://pkg.pr.new/storybookjs/mcp/@storybook/mcp@230
npx https://pkg.pr.new/storybookjs/mcp/@storybook/mcp-proxy@230

commit: 7d424c1

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Bundle Report

Changes will decrease total bundle size by 3.58kB (-4.33%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@storybook/addon-mcp-esm* 1.48kB -3.58kB (-70.78%) ⬇️

ℹ️ *Bundle size includes cached data from a previous commit

Affected Assets, Files, and Routes:

view changes for bundle: @storybook/addon-mcp-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
preview.js (New) 1.48kB 1.48kB 100.0% 🚀
preview-*.js (Deleted) -5.05kB 0 bytes -100.0% 🗑️

Files in preview.js:

  • ./src/constants.ts → Total Size: 138 bytes

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 87.03704% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.25%. Comparing base (9c26064) to head (7d424c1).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/addon-mcp/src/tools/display-review.ts 86.66% 1 Missing and 3 partials ⚠️
packages/addon-mcp/src/mcp-handler.ts 50.00% 1 Missing and 1 partial ⚠️
...-mcp/src/instructions/build-server-instructions.ts 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #230      +/-   ##
==========================================
+ Coverage   77.77%   78.25%   +0.48%     
==========================================
  Files          55       57       +2     
  Lines        1498     1550      +52     
  Branches      415      430      +15     
==========================================
+ Hits         1165     1213      +48     
  Misses        202      202              
- Partials      131      135       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 an agent-facing MCP tool (apply-review-state) to push a structured “curated review” payload into a running Storybook instance, cache it in-memory, and broadcast it to Storybook tabs so the paired @storybook/addon-review-changes manager page can render it. The tool is only registered when features.changeDetection is enabled, aligning it with the existing “changed stories” workflow.

Changes:

  • Introduces apply-review-state MCP tool with Valibot validation + structured output containing a reviewUrl.
  • Adds an in-memory review state store + Storybook channel event constants and a replay mechanism on tab refresh.
  • Registers the tool under the existing features.changeDetection gate and adds a Changesets entry.

Reviewed changes

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

Show a summary per file
File Description
packages/addon-mcp/src/tools/tool-names.ts Adds the apply-review-state tool name constant.
packages/addon-mcp/src/tools/apply-review-state.ts Implements the new MCP tool (validation, caching, channel broadcast, URL return).
packages/addon-mcp/src/review-state-store.ts Defines the canonical Valibot schema + module-scope cache for the review payload.
packages/addon-mcp/src/preset.ts Replays cached review state to newly mounted/refreshed tabs via Storybook channel events.
packages/addon-mcp/src/mcp-handler.ts Registers the tool when features.changeDetection is enabled.
packages/addon-mcp/src/constants.ts Adds cross-addon channel event names + the manager route constant for the review page.
packages/addon-mcp/LOCAL_STORYBOOK_DEV.md Adds local dev instructions for cross-repo iteration (currently marked “do not merge”).
.changeset/apply-review-state.md Declares a minor release for @storybook/addon-mcp adding the tool.

Comment thread packages/addon-mcp/src/preset.ts Outdated
Comment thread packages/addon-mcp/src/tools/apply-review-state.ts Outdated
Comment thread packages/addon-mcp/src/mcp-handler.ts
Comment thread packages/addon-mcp/LOCAL_STORYBOOK_DEV.md Outdated
Comment thread packages/addon-mcp/LOCAL_STORYBOOK_DEV.md Outdated
Comment thread packages/addon-mcp/src/tools/display-review.ts
Comment thread packages/addon-mcp/src/tools/apply-review-state.ts Outdated
@yannbf yannbf force-pushed the yann/agentic-review-mcp-integration branch from 86ad2bc to 638a168 Compare May 21, 2026 14:07
Copilot AI review requested due to automatic review settings May 21, 2026 14:40
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 15 out of 18 changed files in this pull request and generated no new 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

@yannbf yannbf force-pushed the yann/agentic-review-mcp-integration branch 2 times, most recently from 23849ba to a42bba0 Compare May 21, 2026 15:36
Copilot AI review requested due to automatic review settings May 21, 2026 15:36
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 15 out of 18 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 .changeset/apply-review-state.md Outdated
Comment thread packages/addon-mcp/src/tools/apply-review-state.ts Outdated
Copilot AI review requested due to automatic review settings May 22, 2026 13:50
@yannbf yannbf force-pushed the yann/agentic-review-mcp-integration branch from 96b12bf to 9327b89 Compare May 22, 2026 13:52
yannbf added 3 commits May 22, 2026 15:54
The agent pushes a curated review (narrative, labelled clusters with
optional semantic kind, changed files, diff hunks, optional per-story
depth/chain) via this MCP tool. It validates with valibot, caches the
state in memory, broadcasts it over the Storybook channel, and returns
the review-page URL.

Gated behind FEATURES.changeDetection.

Pairs with the @storybook/addon-review-changes Storybook addon.
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 no new 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

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 15 out of 15 changed files in this pull request and generated 4 comments.

Comment thread packages/addon-mcp/src/mcp-handler.ts
Comment thread packages/addon-mcp/src/mcp-handler.ts Outdated
Comment thread packages/addon-mcp/src/constants.ts Outdated
Comment thread packages/addon-mcp/src/instructions/dev-instructions.md
Copilot AI review requested due to automatic review settings May 27, 2026 13:15
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 15 out of 15 changed files in this pull request and generated 3 comments.

Comment thread packages/addon-mcp/src/tools/display-review.ts
Comment thread packages/addon-mcp/src/tools/display-review.ts Outdated
Comment thread packages/addon-mcp/src/tools/display-review.ts
Copilot AI review requested due to automatic review settings May 27, 2026 14:00
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 15 out of 15 changed files in this pull request and generated 2 comments.

Comment thread packages/addon-mcp/src/mcp-handler.ts Outdated
Comment on lines +29 to +31
/** Default MCP endpoint path. Kept in sync with `DEFAULT_MCP_ENDPOINT` in preset.ts. */
const DEFAULT_ENDPOINT = '/mcp';

Comment thread packages/addon-mcp/src/tools/display-review.ts
Copilot AI review requested due to automatic review settings May 27, 2026 14:24
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 15 out of 15 changed files in this pull request and generated 1 comment.

Comment on lines +138 to +139
// Hand the payload off to @storybook/addon-review
server.ctx.custom?.options?.channel?.emit(PUSH_REVIEW_EVENT, input);
let hasAddon = false;
try {
const mainConfig = await loadMainConfig({ configDir: options.configDir });
hasAddon = getAddonNames(mainConfig).includes(REVIEW_ADDON_NAME);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we use feature detection rather than the presence of an addon? This will break if we decide to merge the addon into core.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good, I’ll make the change!

features?: { changeDetection?: boolean } | undefined;
}

export const getReviewStatus = async (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Name is inconsistent with filename.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I made it consistent with the “is-manifest-available” and getManifestStatus. If I change it I’d have to change both otherwise it’s not consistent across the codebase


Anti-pattern: editing a theme token that only one component reads, then publishing a review with just that one component's story. The token change is visible on every page that renders the component — include those pages.

Always include the returned reviewUrl in your final user-facing response so the user can open it.`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be good to add this clarification, so the agent has a notion of what happens when it submits multiple times:

This tool maintains a single active review state; each call replaces the previously published review.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good one

@yannbf yannbf merged commit b38e71c into main May 28, 2026
16 checks passed
@yannbf yannbf deleted the yann/agentic-review-mcp-integration branch May 28, 2026 08:09
@storybook-app-bot storybook-app-bot Bot mentioned this pull request Jun 5, 2026
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