Skip to content

Cli: Install MCP when upgrade is ran by agent - #35215

Merged
kasperpeulen merged 4 commits into
nextfrom
feat/addon-mcp-agent-upgrade
Jun 19, 2026
Merged

kasperpeulen merged 4 commits into
nextfrom
feat/addon-mcp-agent-upgrade

Conversation

@huang-julien

@huang-julien huang-julien commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #

What I did

This PR add addon-mcp upgrade/installation when upgrade command is run through AI.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

verify upgrade command from AI correctly installs addon-mcp or update it

Tested with Claude OK.

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Declare whether manual QA will be needed for this PR during the next release, through qa:needed or qa:skip

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-35215-sha-cf433ce6. Try it out in a new sandbox by running npx storybook@0.0.0-pr-35215-sha-cf433ce6 sandbox or in an existing project with npx storybook@0.0.0-pr-35215-sha-cf433ce6 upgrade.

More information
Published version 0.0.0-pr-35215-sha-cf433ce6
Triggered by @huang-julien
Repository storybookjs/storybook
Branch feat/addon-mcp-agent-upgrade
Commit cf433ce6
Datetime Thu Jun 18 15:29:08 UTC 2026 (1781796548)
Workflow run 27770466961

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=35215

Summary by CodeRabbit

  • New Features

    • Enhanced Storybook upgrades to automatically ensure the MCP support addon (@storybook/addon-mcp) is present when an AI-powered agent is detected, installing or refreshing it as needed.
  • Tests

    • Added a Vitest suite covering the upgrade automation flow, including agent-detection scenarios and verification that addon installation is skipped in dry-run mode.

@huang-julien huang-julien added feature request cli ci:normal Run our default set of CI jobs (choose this for most PRs). labels Jun 18, 2026
@huang-julien huang-julien changed the title Cli: install MCP when upgrade is ran by agent Cli: Install MCP when upgrade is ran by agent Jun 18, 2026
@huang-julien huang-julien added the qa:needed Pull Requests that will need manual QA prior to release. label Jun 18, 2026
@huang-julien
huang-julien marked this pull request as ready for review June 18, 2026 15:47
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a770b986-9784-46b1-8749-800e9144a076

📥 Commits

Reviewing files that changed from the base of the PR and between cf433ce and 84cf052.

📒 Files selected for processing (1)
  • code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts

📝 Walkthrough

Walkthrough

Adds a new addonMcp automigration fix that detects AI coding agents during storybook upgrade, checks whether @storybook/addon-mcp is already configured, and installs or updates it via the shared add() helper. The fix is registered in allFixes, and a Vitest suite covers all check and run scenarios.

Changes

addonMcp automigration fix

Layer / File(s) Summary
addonMcp fix: contract, check, prompt, run, and registration
code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.ts, code/lib/cli-storybook/src/automigrate/fixes/index.ts
Defines AddonMcpOptions (agentName, isInstalled), implements check using detectAgent and addon list inspection, prompt generating a user message, and run calling add() with skipInstall/skipPostinstall/yes flags while respecting dryRun. Registers addonMcp in the exported allFixes array.
check and run phase tests
code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts
Mocks detectAgent and a package manager; asserts check returns null when no agent is detected, returns { agentName, isInstalled: false } when addon is absent, and isInstalled: true for both string and object addon config forms. Verifies add is called with correct flags for install and force-update, and is not called in dryRun mode.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts`:
- Line 10: The `vi.mock()` calls for mocking the add module and another module
are missing the required `spy: true` option. Update both `vi.mock()`
declarations to include the `spy: true` option in their configuration objects to
ensure the original implementation is preserved for unmocked exports, as per the
Vitest mocking guidelines. Find the mock declarations around lines 10 and 13
where the add module is being mocked and apply the same `spy: true`
configuration to both calls.
- Around line 38-82: The mock implementations for detectAgent are currently set
inline within each test case in the check phase describe block. Move the
detectAgent.mockReturnValue() calls from inside each test (in "returns null when
no AI agent is detected", "returns isInstalled: false when an agent is detected
and addon-mcp is missing", "returns isInstalled: true when addon-mcp is already
configured", and "detects addon-mcp when configured as an object") into
appropriate beforeEach blocks. Create separate beforeEach blocks before each
test or group tests by their shared mock behavior, so that mock setups are
declared before the test runs rather than inline within the test case.
- Around line 1-14: The test file is missing mocks for dependencies that the
addonMcp module uses. You need to add vi.mock() calls for the modules that
export getAddonNames and logger, following the same pattern as the existing
vi.hoisted() mock for detectAgent. Once the mocks are declared, implement the
mock behaviors in the beforeEach hook using vi.fn() to create spy functions for
getAddonNames and logger. This ensures that when addonMcp accesses these
dependencies during testing, it receives controlled mock implementations rather
than the actual modules.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17b54268-80f9-469b-9391-7cc98b833e23

📥 Commits

Reviewing files that changed from the base of the PR and between 1688451 and cf433ce.

📒 Files selected for processing (3)
  • code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts
  • code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.ts
  • code/lib/cli-storybook/src/automigrate/fixes/index.ts

Comment thread code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts Outdated
Comment thread code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts Outdated
Comment thread code/lib/cli-storybook/src/automigrate/fixes/addon-mcp.test.ts
Follow .cursor/rules/spy-mocking.mdc: use vi.mock(..., { spy: true }) for all
deps the subject touches (add, common, node-logger, telemetry), and move mock
behaviors into beforeEach blocks grouped by scenario.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@storybook-app-bot

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: 84cf052, ran on 19 June 2026 at 10:02:24 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 72 72 0
Self size 21.12 MB 21.08 MB 🎉 -47 KB 🎉
Dependency size 36.42 MB 36.42 MB 0 B
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 204 204 0
Self size 820 KB 804 KB 🎉 -16 KB 🎉
Dependency size 91.48 MB 91.42 MB 🎉 -56 KB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 197 197 0
Self size 32 KB 32 KB 🚨 +36 B 🚨
Dependency size 89.96 MB 89.91 MB 🎉 -47 KB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 73 73 0
Self size 1.09 MB 1.08 MB 🎉 -10 KB 🎉
Dependency size 57.55 MB 57.50 MB 🎉 -47 KB 🎉
Bundle Size Analyzer node node

This was referenced Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal Run our default set of CI jobs (choose this for most PRs). cli feature request qa:success Pull Requests that were successfully QA'ed by the release team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants