Skip to content

Fix multi-source documentation tool schemas - #338

Open
ebbsanchez wants to merge 2 commits into
storybookjs:mainfrom
ebbsanchez:fix/multisource-doc-tool-schema
Open

Fix multi-source documentation tool schemas#338
ebbsanchez wants to merge 2 commits into
storybookjs:mainfrom
ebbsanchez:fix/multisource-doc-tool-schema

Conversation

@ebbsanchez

@ebbsanchez ebbsanchez commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Fixes #213.

When createStorybookMcpHandler is created with multiple handler-level sources, it already forwards those sources into the request context, but the two single-documentation tools were still registered with their single-source schemas. That meant storybookId was missing from tools/list and clients could not pass the source selector through.

This change derives multiSource from handler-level sources and passes it into addGetStoryDocumentationTool and addGetDocumentationTool, so both schemas include the required storybookId field for multi-source handlers.

Verification

npx pnpm@10.29.2 install --frozen-lockfile
npx pnpm@10.29.2 vitest run packages/mcp/src/index.test.ts
npx pnpm@10.29.2 exec oxfmt --check packages/mcp/src/index.ts packages/mcp/src/index.test.ts
npx pnpm@10.29.2 exec tsc --noEmit --pretty false

Summary by CodeRabbit

  • Bug Fixes
    • Updated documentation tool schemas to behave correctly for multi-source setups, ensuring storybookId is required when more than one source is configured.
  • Tests
    • Added a Vitest case verifying that get-documentation and get-documentation-for-story include the storybookId property and mark it as required in multi-source mode.

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8c9bd60

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@storybook/mcp Patch
@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

@netlify

netlify Bot commented Jul 3, 2026

Copy link
Copy Markdown

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

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

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

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: ee9ff98d-1111-4889-9773-b14039672526

📥 Commits

Reviewing files that changed from the base of the PR and between ab8ee7e and 8c9bd60.

📒 Files selected for processing (1)
  • .changeset/multi-source-doc-schemas.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/multi-source-doc-schemas.md

📝 Walkthrough

Walkthrough

The handler now derives a multiSource flag from configured sources and passes it to the documentation tool registrations. A new test checks that multi-source schemas require storybookId, and a Changesets entry records the patch release.

Changes

Multi-source documentation tool wiring

Layer / File(s) Summary
Compute and pass multiSource flag
packages/mcp/src/index.ts
createStorybookMcpHandler derives multiSource from defaultContext.sources length and passes { multiSource } to the two documentation tool registrations.
Test multi-source schema requirement
packages/mcp/src/index.test.ts
New test verifies that with multi-source config, get-documentation and get-documentation-for-story schemas include storybookId and mark it required.
Add changeset note
.changeset/multi-source-doc-schemas.md
Adds a patch Changesets entry for @storybook/mcp describing the storybookId requirement fix.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • storybookjs/mcp#308: Validates the same multi-source get-documentation tool schema requiring storybookId, matching this PR's change.

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.

@ebbsanchez

Copy link
Copy Markdown
Author

Hi, gentle follow-up after a couple of weeks. This is still ready on my side; happy to adjust or close if it is not aligned with the project direction.

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] createStorybookMcpHandler does not pass multiSource: true to tool registration when sources are configured

2 participants