Skip to content

Skills M4 (3/9): run preview-stories on the shared stories toolset - #35729

Closed
valentinpalkovic wants to merge 1 commit into
valentin/m4-02-stories-find-by-componentfrom
valentin/m4-03-stories-preview
Closed

valentinpalkovic wants to merge 1 commit into
valentin/m4-02-stories-find-by-componentfrom
valentin/m4-03-stories-preview

Conversation

@valentinpalkovic

Copy link
Copy Markdown
Contributor

Closes #

Part 3 of 9 of the Skills M4 migration. Stacked on #35728, replaces #35677.

What I did

The preview-stories tool builds the URLs an agent hands back to a human so they can look at a story in the browser. It now runs on the shared stories toolset in core, and the hand-written implementation in the MCP addon is deleted. What stays behind there is only the small app resource that renders the preview inside the client, plus one dependency that the deletion made unnecessary.

The tool's input descriptions are carried over word for word. They are tuned for how models choose and fill this tool, so treat any wording difference in review as a bug rather than a cleanup.

This one is mostly deletion.

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

Caution

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

  1. Build the monorepo packages with yarn nx run-many -t compile.
  2. In test-storybooks/mcp, run yarn install and then yarn storybook. The MCP endpoint comes up at http://localhost:6006/mcp.
  3. Point an MCP client at that endpoint and call preview-stories with a couple of story IDs. You should get one preview URL per story, in the same shape and order as before, and opening one of them in the browser should land on that story.
  4. Call it with args or with a story that does not exist, and confirm the responses match the previous behavior.
  5. In a client that renders MCP app resources, confirm the preview surface still opens.

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 PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

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

Serves the preview-stories tool from the shared stories toolset and deletes the
hand-written implementation. Only the MCP app resource stays in the addon, since
serving that HTML to the client is transport-level work rather than part of the
tool call.

The story selector's eval-tuned prose moves into core with it, and now names the
documentation tools it points at from the frozen tool-name map instead of
repeating the strings.

Drops the picoquery dependency: the query-string builder that used it was the
only consumer, and preview URLs are now built in core.
@valentinpalkovic valentinpalkovic added the maintenance User-facing maintenance tasks label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫

PR is not labeled with one of: ["ci:normal","ci:merged","ci:daily","ci:docs"]

🚫

PR is not labeled with one of: ["qa:needed","qa:skip","qa:success"]

🚫 PR title must be in the format of "Area: Summary", With both Area and Summary starting with a capital letter Good examples: - "Docs: Describe Canvas Doc Block" - "Svelte: Support Svelte v4" Bad examples: - "add new api docs" - "fix: Svelte 4 support" - "Vue: improve docs"
🚫 This PR needs an approving review from a Storybook Core or Developer Experience team member before it can be merged.
Warnings
⚠️

This PR targets valentin/m4-02-stories-find-by-component. The default branch for contributions is next. Please make sure you are targeting the correct branch.

Generated by 🚫 dangerJS against 605c51b

@coderabbitai

coderabbitai Bot commented Aug 3, 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: a5101965-e856-499a-9b0a-d2e18e2b9f1a

📥 Commits

Reviewing files that changed from the base of the PR and between 97e8b23 and 605c51b.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (14)
  • code/addons/mcp/package.json
  • code/addons/mcp/src/tools/preview-stories.test.ts
  • code/addons/mcp/src/tools/preview-stories.ts
  • code/addons/mcp/src/tools/preview-stories/preview-stories-app-script.ts
  • code/addons/mcp/src/tools/tool-registry.test.ts
  • code/addons/mcp/src/tools/tool-registry.ts
  • code/addons/mcp/src/tools/toolset-tools.ts
  • code/addons/mcp/src/utils/build-args-param.test.ts
  • code/addons/mcp/src/utils/build-args-param.ts
  • code/core/src/core-server/index.ts
  • code/core/src/shared/open-service/toolsets/stories/definition.test.ts
  • code/core/src/shared/open-service/toolsets/stories/definition.ts
  • code/core/src/shared/open-service/toolsets/stories/format.ts
  • code/core/src/shared/open-service/toolsets/stories/story-input.ts
💤 Files with no reviewable changes (4)
  • code/addons/mcp/package.json
  • code/addons/mcp/src/utils/build-args-param.ts
  • code/addons/mcp/src/tools/preview-stories.test.ts
  • code/addons/mcp/src/utils/build-args-param.test.ts

Walkthrough

The preview-stories MCP tool moved from the addon into the shared stories toolset. The addon now registers only the preview resource. Shared logic adds review-aware descriptions, MCP formatting, telemetry, origin validation, and story input fields.

Changes

Preview toolset migration

Layer / File(s) Summary
Shared preview flow
code/core/src/shared/open-service/toolsets/stories/*, code/core/src/core-server/index.ts
The shared stories.preview method now resolves URLs with ctx.origin, records telemetry, supports props and globals, and formats CLI and MCP results separately. Review-aware guidance references review.create.
MCP addon wiring
code/addons/mcp/src/tools/preview-stories.ts, code/addons/mcp/src/tools/preview-stories/preview-stories-app-script.ts, code/addons/mcp/src/tools/tool-registry.ts, code/addons/mcp/src/tools/toolset-tools.ts
The addon retains preview resource registration and maps stories.preview to the shared toolset. MCP-only metadata can now be supplied through extras.
Registry migration validation
code/addons/mcp/src/tools/tool-registry.test.ts
Registry tests cover migrated tools, unavailable toolsets, failure logging, metadata filtering, and published titles.

The addon package no longer includes picoquery. The standalone preview implementation, argument encoder, and related tests were removed.

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant ToolRegistry
  participant StoriesPreview
  participant PreviewFormatter
  MCPClient->>ToolRegistry: Invoke stories.preview
  ToolRegistry->>StoriesPreview: Resolve shared toolset method
  StoriesPreview->>PreviewFormatter: Format resolved stories and errors
  PreviewFormatter-->>MCPClient: Return MCP preview blocks
Loading

Possibly related issues

Possibly related PRs

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance User-facing maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant