Add dynamic tools to Available Toolsets#265
Conversation
🦋 Changeset detectedLatest commit: 902debf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
Bundle ReportChanges will increase total bundle size by 31.73kB (19.52%) ⬆️
ℹ️ *Bundle size includes cached data from a previous commit Affected Assets, Files, and Routes:view changes for bundle: @storybook/addon-mcp-esmAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
==========================================
+ Coverage 78.61% 79.03% +0.42%
==========================================
Files 62 63 +1
Lines 1800 1808 +8
Branches 500 510 +10
==========================================
+ Hits 1415 1429 +14
+ Misses 218 213 -5
+ Partials 167 166 -1 ☔ View full report in Codecov by Harness. |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6b48934 to
ca1596f
Compare
✅ Deploy Preview for storybook-mcp-self-host-example canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the @storybook/addon-mcp /mcp landing page so it surfaces tools that are conditionally available at runtime (change-detection, dependency-graph, and review-related tools), and centralizes the tool-availability gating logic so the MCP server and landing page derive availability from the same helper.
Changes:
- Add a shared
getToolAvailability()helper to compute runtime gates (dependency graph support, change detection enablement, and review availability). - Expand the
/mcplanding page “Available Toolsets” list to includeget-changed-stories,get-stories-by-component,display-review, andget-documentation-for-story, with per-tool enabled/disabled badges + explanatory notices. - Update MCP server initialization to reuse the shared availability helper (reducing drift between registered tools and landing-page claims).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/mcp-proxy/src/types/record/v1.ts |
Reorders Valibot pipe validators for pid/port numeric fields. |
packages/addon-mcp/src/utils/get-tool-availability.ts |
New shared helper returning a single “source of truth” for tool gating. |
packages/addon-mcp/src/tools/get-stories-by-component.ts |
Reorders Valibot pipe validators for maxDistance. |
packages/addon-mcp/src/template.html |
Adds the newly surfaced tool names and new placeholders for per-tool badges/notices. |
packages/addon-mcp/src/preset.ts |
Uses getToolAvailability() and fills new HTML placeholders (badges + notices). |
packages/addon-mcp/src/preset.test.ts |
Adds a test ensuring the landing page lists the new tools and no {{...}} placeholders leak. |
packages/addon-mcp/src/mcp-handler.ts |
Switches to getToolAvailability() so server registration and landing page share gating logic. |
.changeset/spotty-toolsets-surface.md |
Changeset documenting the landing page surfacing and the shared gating helper. |
| import { STORYBOOK_MCP_PROXY_HEADER } from './auth/index.ts'; | ||
| import * as mcpHandlerModule from './mcp-handler.ts'; | ||
| import * as runStoryTests from './tools/run-story-tests.ts'; | ||
| import * as changeDetection from './utils/change-detection.ts'; | ||
|
|
| // Lets us flip `@storybook/addon-review` presence so the review tool's gate can be exercised. | ||
| // Keep the real exports (e.g. `normalizeStoryPath`) so unrelated tools still register. | ||
| const { mockGetAddonNames } = vi.hoisted(() => ({ | ||
| mockGetAddonNames: vi.fn(() => [] as string[]), | ||
| })); | ||
| vi.mock('storybook/internal/common', async (importActual) => ({ | ||
| ...(await importActual<typeof import('storybook/internal/common')>()), | ||
| loadMainConfig: vi.fn().mockResolvedValue({}), | ||
| getAddonNames: () => mockGetAddonNames(), | ||
| })); | ||
|
|
| /** Dev-server builder supports the dependency-graph API. Gates `get-stories-by-component`. */ | ||
| dependencyGraphSupported: boolean; |
This adds dynamic tools which were not available in the template, as it was only adding static tools.