Skip to content

Clarify /mcp test-toolset requirements and replace auto-redirect with manual manifest link#179

Merged
JReinhold merged 6 commits intomainfrom
copilot/fix-mcp-addon-vitest-detection
Mar 5, 2026
Merged

Clarify /mcp test-toolset requirements and replace auto-redirect with manual manifest link#179
JReinhold merged 6 commits intomainfrom
copilot/fix-mcp-addon-vitest-detection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

  • Review new PR comments and identify actionable feedback addressed to @copilot
  • Update the fragile GET handler capture in packages/addon-mcp/src/preset.test.ts to explicitly select /mcp
  • Run targeted tests for preset.test.ts (and addon package tests if needed)
  • Capture/confirm screenshot reference for UI context
  • Run final review/security checks and reply on the addressed comment thread
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] MCP addon cannot detect the vitest addon and countdown goes into negative</issue_title>
<issue_description>### Describe the bug

I am running the latest Storybook 10.2.13 and mcp addon 0.3.3. I have the vitest addon configured (with a bunch of tests written already) but this is what I see on /mcp:

Image

vitest addon being imported:
Image

Also notice that the redirect did not happen in time and the countdown goes to negative number 😄.

Expected behavior

Vitest addon detection + redirection when countdown reaches 0.

Environment

  • OS: Windows 11
  • Node.js version: v24.13.1
  • NPM version: 11.11.0
  • Browser (if applicable): Edge</issue_description>

<agent_instructions>Follow my instructions in the issue comment. Remember to run tests and update them if necessary. Do not stop until npmx run check is green, as that is a proxy for CI being green.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@JReinhold Thanks for reporting @thobas-dnvgl The message about missing addon-vitest is sort of misleading, it's actually because it requires Storybook (and addons) version 10.3.0-alpha.8 and above: https://github.com/storybookjs/storybook/releases/tag/v10.3.0-alpha.8

The redirect countdown timer is pretty rudimentary.

The proper fixes here are:

  1. Change the wording on the missing addon-vitest message to specifically mention it must be 10.3.0 or above (omit the prerelease part)
  2. Remove the automated redirect in favor of just having a manual link that users can follow to the manifest debugger.</comment_new>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 2, 2026

🦋 Changeset detected

Latest commit: e559378

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 Patch

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

Copilot AI and others added 2 commits March 2, 2026 13:02
Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MCP addon detection for vitest and countdown issue Clarify /mcp test-toolset requirements and replace auto-redirect with manual manifest link Mar 2, 2026
@JReinhold JReinhold marked this pull request as ready for review March 3, 2026 08:18
Copilot AI review requested due to automatic review settings March 3, 2026 08:18
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 3, 2026

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

commit: e559378

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
437 1 436 0
View the full list of 1 ❄️ flaky test(s)
apps/internal-storybook/tests/check-deps.e2e.test.ts > Storybook Dependencies > should be using latest versions from registry

Flake rate in main: 28.57% (Passed 45 times, Failed 18 times)

Stack Traces | 4.77s run time
Error: Storybook dependencies are outdated. Update the catalog in pnpm-workspace.yaml:

  sed -i '' 's/10\.3\.0-alpha\.12/10.3.0-alpha.14/g' pnpm-workspace.yaml && pnpm install

Outdated packages:
  - @storybook/addon-docs: 10.3.0-alpha.12 → 10.3.0-alpha.14
  - @storybook/react-vite: 10.3.0-alpha.12 → 10.3.0-alpha.14
  - storybook: 10.3.0-alpha.12 → 10.3.0-alpha.14
 ❯ tests/check-deps.e2e.test.ts:42:10

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

This PR updates the /mcp landing page UX in @storybook/addon-mcp by clarifying the “test” toolset requirements (Storybook 10.3.0+ with @storybook/addon-vitest) and removing the countdown-based auto-redirect in favor of a manual link to the manifest debugger when available.

Changes:

  • Replaces the old redirect meta/script injection with a {{MANIFEST_DEBUGGER_LINK}} placeholder that renders a manual link only when manifests are available.
  • Updates the “test” toolset notice text to explicitly mention the Storybook 10.3.0+ requirement.
  • Adds/updates a unit test to assert the new requirement message and presence of the manual manifest debugger link.

Reviewed changes

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

File Description
packages/addon-mcp/src/template.html Removes redirect markup/script and introduces {{MANIFEST_DEBUGGER_LINK}} injection point.
packages/addon-mcp/src/preset.ts Removes meta-refresh redirect injection; adds manual manifest debugger link injection; updates vitest toolset requirement copy.
packages/addon-mcp/src/preset.test.ts Adds a test covering the updated requirement copy + manual manifest debugger link rendering.

Comment thread packages/addon-mcp/src/preset.test.ts
Comment thread packages/addon-mcp/src/preset.test.ts
@JReinhold
Copy link
Copy Markdown
Contributor

I manually tested this out with a Storybook version 10.2.14, which correctly showed like this:

image

@JReinhold JReinhold requested a review from kasperpeulen March 3, 2026 08:25
Comment thread packages/addon-mcp/src/preset.test.ts Outdated

let getHandler: any;
mockApp.get = vi.fn((path, handler) => {
getHandler = handler;
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.

Nit: This captures the last registered GET handler, which happens to be /mcp today — but only because it's registered after /.well-known/... in preset.ts. If a future change adds another app.get() call after /mcp, this test would silently test the wrong handler.

Other tests in this same file already use a more robust pattern (e.g. line 144):

const handlers: Record<string, any> = {};
mockApp.get = vi.fn((path: string, handler: any) => {
  handlers[path] = handler;
});

await (experimental_devServer as any)(mockApp, manifestEnabledOptions);

const mcpHandler = handlers['/mcp'];
await mcpHandler(mockReq, mockRes);

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.

@copilot this comment makes sense to me, fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the test to capture GET handlers by route and explicitly invoke handlers['/mcp'] instead of relying on the last registered handler. This is in commit e559378, and preset.test.ts passes with the change. Screenshot reference: https://github.com/user-attachments/assets/768de4e3-cc8b-4b37-ad64-5e125c70a42f

Copy link
Copy Markdown
Member

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

One comment

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2026

Bundle Report

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

Detailed changes
Bundle name Size Change
@storybook/mcp-esm (removed) -42.85kB (-100.0%) ⬇️
@storybook/addon-mcp-esm (removed) -5.05kB (-100.0%) ⬇️

Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 5, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ds.example.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/mcp/mcp/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/mcp/mcp/node_modules/vitest/dist/workers/forks.js (dns block)
  • my-lib.example.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/mcp/mcp/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/mcp/mcp/node_modules/vitest/dist/workers/forks.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@JReinhold JReinhold merged commit b3ca930 into main Mar 5, 2026
8 of 9 checks passed
@JReinhold JReinhold deleted the copilot/fix-mcp-addon-vitest-detection branch March 5, 2026 10:26
@storybook-app-bot storybook-app-bot bot mentioned this pull request Mar 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.

[Bug] MCP addon cannot detect the vitest addon and countdown goes into negative

4 participants