-
Notifications
You must be signed in to change notification settings - Fork 29
Add MCP server-level instructions to both packages #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
282e37e
Initial plan
Copilot c5439b7
feat: add MCP server-level instructions to both packages
Copilot b349dd3
refactor: make addon instructions dynamic and composable
Copilot 799a551
refactor: dynamic instructions getter and named tool in test instruct…
Copilot b17868f
update reshaped-based tasks with configs, RDT manifests
JReinhold cb93700
add concise variant config
JReinhold 25fe7aa
update to Claude Sonnet 4.6 in evals
JReinhold 1f886da
add mcp tool calls as quality metric for 901-907
JReinhold 29419f1
improve composability of server instructions
JReinhold 9fd9130
revert reshaped eval manifest updates
JReinhold 3dd5b2a
Merge branch 'main' into copilot/implement-mcp-server-instructions
JReinhold 79930fc
update storybook deps
JReinhold f6c5470
Merge branch 'copilot/implement-mcp-server-instructions' of https://g…
JReinhold a360f09
cleanup
JReinhold 67fc5d6
update tests, sb deps
JReinhold 8dbd727
fix: return mcpToolsSummary when expectedToolCount is set even if tot…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| '@storybook/mcp': minor | ||
| '@storybook/addon-mcp': minor | ||
| --- | ||
|
|
||
| Add MCP server-level instructions to both packages | ||
|
|
||
| Both `@storybook/mcp` and `@storybook/addon-mcp` now include server instructions in the MCP `initialize` response. These instructions guide agents on how to use the available tools effectively without requiring explicit prompting from users. | ||
|
|
||
| **`@storybook/mcp` instructions include:** | ||
|
|
||
| - Tool workflow: when to use `list-all-documentation` vs `get-documentation` vs `get-documentation-for-story` | ||
| - Anti-hallucination rules: never assume component props or API shape | ||
| - Multi-source behavior guidance | ||
|
|
||
| **`@storybook/addon-mcp` instructions compose the `@storybook/mcp` baseline and add:** | ||
|
|
||
| - Always call `get-storybook-story-instructions` before writing or editing stories | ||
| - `preview-stories` usage expectations | ||
| - `run-story-tests` workflow expectations | ||
| - Toolset availability guidance (`dev`, `docs`, `test`) | ||
|
|
||
| The `@storybook/mcp` package also exports `STORYBOOK_MCP_INSTRUCTIONS` for consumers who want to reuse or extend the base instructions. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/addon-mcp/src/instructions/mcp-server-instructions.md
|
JReinhold marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Storybook Addon MCP Server Instructions | ||
|
|
||
| This server provides tools to help you build, preview, and test Storybook UI components. | ||
|
|
||
| ## Before Writing or Editing Stories | ||
|
|
||
| Always call **get-storybook-story-instructions** first to get framework-specific guidance. This tool returns the correct imports, patterns, and conventions for the current project. Do not skip this step. | ||
|
|
||
| ## Story Preview Workflow | ||
|
|
||
| After writing or modifying a component or story, call **preview-stories** to retrieve the live preview URLs. Always include these URLs in your response so the user can verify the visual output. | ||
|
|
||
| ## Story Testing Workflow | ||
|
|
||
| When tests are available (run-story-tests tool is present), run tests after writing or changing stories. Fix any failures before reporting success. Do not report stories as complete if tests are failing. | ||
|
|
||
| ## Component Documentation Workflow (docs toolset) | ||
|
|
||
| When the docs toolset is available: | ||
|
|
||
| 1. Call **list-all-documentation** once to discover available components and docs IDs. | ||
| 2. Call **get-documentation** with a specific ID to retrieve full component props, usage examples, and stories. | ||
| 3. Call **get-documentation-for-story** when you need documentation scoped to a specific story variant. | ||
| 4. Never assume prop names, variants, or component API — always retrieve documentation first. | ||
| 5. Only reference IDs returned by list-all-documentation. Do not guess IDs. | ||
|
|
||
| ## Toolset Availability | ||
|
|
||
| Tools are grouped into toolsets. Check which tools are available before assuming a workflow is possible: | ||
|
|
||
| - **dev**: preview-stories, get-storybook-story-instructions | ||
| - **docs**: list-all-documentation, get-documentation, get-documentation-for-story | ||
| - **test**: run-story-tests | ||
|
|
||
| Toolsets can be restricted per-request via the `X-MCP-Toolsets` header. When a toolset's tools are not listed, that toolset is disabled for this request. | ||
|
JReinhold marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| # `@storybook/mcp` | ||
|
|
||
| The hype is real. | ||
|
|
||
| ## Server Instructions | ||
|
|
||
| When an MCP client connects to this server, it receives server-level instructions in the `initialize` response. These instructions guide agents on how to use the available tools effectively: | ||
|
|
||
| - **Tool workflow**: When to use `list-all-documentation`, `get-documentation`, and `get-documentation-for-story` | ||
| - **Anti-hallucination rules**: Never assume component props or API shape — always retrieve documentation first | ||
| - **Multi-source behavior**: How to scope requests when multiple Storybook sources are configured | ||
|
JReinhold marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| declare module '*.md' { | ||
| const content: string; | ||
| export default content; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
JReinhold marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Storybook MCP Server Instructions | ||
|
|
||
| This server provides access to Storybook component and documentation manifests. | ||
|
|
||
| ## Tool Workflow | ||
|
|
||
|
JReinhold marked this conversation as resolved.
|
||
| Use tools in this order: | ||
|
|
||
| 1. **list-all-documentation** — Call once at the start of a task to discover available components and docs entries. Use the returned IDs for subsequent calls. Pass `withStoryIds: true` when you also need story IDs (e.g., for use with `preview-stories` or `get-documentation-for-story`) — this adds story sub-entries to the list. | ||
|
|
||
| 2. **get-documentation** — Call with a specific `id` from the list to retrieve full component documentation including props, usage examples, and stories. Prefer this over re-calling list when you already know the ID. | ||
|
|
||
| 3. **get-documentation-for-story** — Call with a story ID when you need documentation scoped to a specific story variant rather than the whole component. | ||
|
|
||
| ## Anti-Hallucination Rules | ||
|
|
||
| - Never assume component props, variants, or API shape. Always retrieve documentation before using a component. | ||
| - If a component or prop is not in the documentation, do not invent it. Tell the user the component was not found. | ||
| - Only reference IDs returned by list-all-documentation. Do not guess IDs. | ||
|
|
||
| ## Multi-Source Behavior | ||
|
|
||
| When multiple Storybook sources are configured, list-all-documentation returns entries from all sources. Use the `storybookId` field in get-documentation to scope requests to a specific source when needed. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.