Skip to content

Add get-setup-instructions tool backed by tagged docs entries#198

Draft
Copilot wants to merge 11 commits intomainfrom
copilot/add-get-setup-instructions-tool
Draft

Add get-setup-instructions tool backed by tagged docs entries#198
Copilot wants to merge 11 commits intomainfrom
copilot/add-get-setup-instructions-tool

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

This adds a dedicated get-setup-instructions MCP tool so agents can fetch project/bootstrap guidance directly from Storybook docs instead of inferring setup from general component documentation. The tool is exposed only when the docs manifest contains docs entries tagged setup-instructions.

  • New docs tool

    • Adds get-setup-instructions to @storybook/mcp
    • Returns the content of all docs entries tagged setup-instructions, with each entry isolated in its own text tool content
    • Describes the intended use clearly: installation, providers/wrappers, theming/bootstrap, CSS/tokens, app-root wiring
    • Keeps get-documentation focused on component APIs and examples
  • Dynamic tool visibility

    • Uses tmcp's async enabled callback to inspect manifests at tools/list time
    • Hides the tool when no tagged setup docs exist
    • Preserves request-scoped behavior, including custom manifest providers
    • The manifest-backed enabled check is evaluated during tools/list, not at server initialization
  • Manifest typing

    • Extends docs manifest typing to accept optional tags?: string[]
    • Updates fixtures to include tagged setup docs so behavior can be exercised ahead of the upstream Storybook manifest change
  • Multi-source support

    • Supports composed Storybooks via storybookId, following the same source-selection pattern as other docs tools
    • Resolves setup instructions per selected source
  • Integration surface

    • Registers and exports the tool from packages/mcp/src/index.ts
    • Wires the tool into the stdio server (packages/mcp/bin.ts)
    • Reuses the tool from @storybook/addon-mcp so addon consumers get the same behavior
  • Eval coverage

    • Adds a new eval task, 916-follow-setup-instructions
    • Seeds a fake design-system package plus multiple tagged setup docs with specific requirements
    • Verifies agents both call get-setup-instructions and actually apply the returned setup guidance in generated code
    • Prompts the agent to implement a separate MissionControl component while relying on a pre-seeded static story so the result is visible in the eval trial's Storybook
    • Generates the grading-only test inside the trial during preGrade so it is used for eval validation without being picked up by the repo-level Vitest config
  • Docs and contract updates

    • Updates MCP instructions and README to call out setup guidance as a distinct workflow
    • Adds a changeset for the new user-facing tool

Example manifest entries:

{
  "docs": {
    "entry-setup": {
      "id": "entry-setup",
      "name": "Entry Setup",
      "title": "Entry Setup",
      "path": "docs/entry-setup.mdx",
      "tags": ["setup-instructions"],
      "content": "# Entry Setup\n\nImport `@acme/ui/styles.css` exactly once from the app entry file before rendering any Acme UI components."
    },
    "provider-setup": {
      "id": "provider-setup",
      "name": "Provider Setup",
      "title": "Provider Setup",
      "path": "docs/provider-setup.mdx",
      "tags": ["setup-instructions"],
      "content": "# Provider Setup\n\nWrap the rendered app in `<AcmeProvider theme=\"midnight\" density=\"comfortable\">`.\n\nPlace your UI inside an element with `data-acme-app=\"true\"`."
    }
  }
}

> [!WARNING]
>
>

Original prompt

This section details on the original issue you should resolve

<issue_title>Add get-setup-instructions tool powered by docs entry tags</issue_title>
<issue_description>We want a new MCP tool named get-setup-instructions.

The purpose of this tool is to give agents a dedicated way to fetch project or design-system setup instructions from Storybook docs, instead of forcing them to infer setup details from general component documentation.

The contract is:

  • Storybook authors mark a docs entry with the setup-instructions tag
  • @storybook/mcp detects that tagged docs entry from the docs manifest
  • @storybook/mcp exposes a get-setup-instructions tool when such an entry exists
  • agents can call that tool to retrieve setup guidance such as installation, providers, theming, initialization, or required project wiring

Why this matters

Today the MCP package already offers:

  • list-all-documentation
  • get-documentation
  • get-documentation-for-story

Those tools are useful for component APIs and example usage, but they are not explicit about project-level setup.

For design systems and component libraries, setup instructions are often the first thing an agent needs:

  • package installation
  • CSS or token imports
  • provider setup
  • theme/bootstrap configuration
  • framework-specific wiring
  • app/root initialization requirements

We want agents to have an explicit tool for this instead of hoping they discover the right docs page through broader docs browsing.

Current state / code pointers

Relevant files in this repo:

  • packages/mcp/src/index.ts
    • creates the server in createStorybookMcpHandler()
    • currently registers 3 tools
    • exports tool registration helpers for reuse by addon-mcp
  • packages/mcp/src/types.ts
    • defines the Doc schema used for docs manifest entries
    • currently does not include tags
  • packages/mcp/src/tools/get-documentation.ts
    • good reference for tool shape, schema, descriptions, multi-source handling, and manifest loading
  • packages/mcp/src/tools/list-all-documentation.ts
    • good reference for loading manifests and formatting responses
  • packages/mcp/src/index.test.ts
    • currently expects exactly 3 tools
    • good place to add top-level visibility assertions for the new tool
  • packages/mcp/fixtures/small-docs-manifest.fixture.json
    • easiest place to temporarily fake docs tags for development/tests

Important upstream dependency

Storybook core is being changed separately to expose docs-entry tags in generated manifests.

That work is the real source of truth, but this issue should still proceed now.

For parallelization:

  • fake tags into MCP fixtures/tests first
  • implement the MCP behavior against that expected manifest shape
  • once Storybook core lands, final integration should work without changing the MCP tool contract

Tracked upstream in: storybookjs/storybook#34149

Requested behavior

Add a new tool named get-setup-instructions.

Expected behavior:

  1. Look through available docs entries for one tagged with setup-instructions
  2. Return that docs entry’s content in a form optimized for agent consumption
  3. Expose the tool only when a tagged docs entry exists
  4. Make the tool description explicit enough that agents know to call it when they need setup/bootstrap guidance

Tool semantics

The tool should be for setup guidance, not general component reference.

The tool description should make it clear that this is the right tool when the agent needs:

  • installation steps
  • required providers or wrappers
  • theming/bootstrap setup
  • CSS/font/token initialization
  • framework or app-root integration steps
  • any project-level preparation required before using the component library

The tool description should also make clear that:

  • get-documentation remains the main tool for component APIs and examples
  • get-setup-instructions is specifically for environment/library setup

Open design point to resolve early

The product requirement is that the tool should be dynamically enabled/disabled based on whether the setup doc exists.

Please resolve this early in the implementation:

  • determine how tmcp evaluates tool visibility via enabled
  • determine whether request-scoped manifest inspection can drive visibility directly
  • if that is awkward or impossible, choose the closest implementation that still preserves the required user-facing behavior and document the tradeoff in the PR/issue

There is already an existing conditional-exposure pattern in the repo using enabled, but it currently relies on synchronous context flags rather than manifest inspection.

Proposed implementation direction

  1. Extend docs manifest typing in packages/mcp/src/types.ts
    • allow optional docs-entry tags?: string[]
  2. Add a new tool implementation, likely packages/mcp/src/tools/get-setup-instructions.ts
  3. Register and export the tool from packages/mcp/src/index.ts
  4. ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 16, 2026

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

Name Link
🔨 Latest commit f3ccf1d
🔍 Latest deploy log https://app.netlify.com/projects/storybook-mcp-self-host-example/deploys/69c13a9d6e18330008930597

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: f3ccf1d

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

Copilot AI and others added 2 commits March 16, 2026 09:00
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] Add get-setup-instructions tool powered by docs entry tags Add get-setup-instructions tool backed by tagged docs entries Mar 16, 2026
Copilot AI requested a review from JReinhold March 16, 2026 09:06
Copy link
Copy Markdown
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

@copilot

  1. In the case where multiple docs have the setup-instructions tag, instead of only returning the first entry found, return all of the entries, isolated in separate text tool contents
  2. We need an eval task that evaluates the effectiveness of the setup instructions. Look through the existing 9xx eval tasks and see how they are set up, and create a new one that evaluates if the agents reliably know to fetch the setup instructions in appropriate scenarios, and that they actually reacts to the content. That probably means the instructions should have something specific, that we can grade against afterwads.

Copilot AI and others added 3 commits March 16, 2026 14:09
Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot

  1. In the case where multiple docs have the setup-instructions tag, instead of only returning the first entry found, return all of the entries, isolated in separate text tool contents...

Addressed in b03b6ed. get-setup-instructions now returns all tagged setup docs as separate text contents, and I added eval task 916-follow-setup-instructions to verify agents both call the setup tool and apply the returned setup requirements in code.

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:

Copilot AI requested a review from JReinhold March 16, 2026 14:15
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 19, 2026

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

commit: f3ccf1d

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
457 2 455 0
View the full list of 2 ❄️ flaky test(s)
apps/internal-storybook/tests/mcp-composition-auth.e2e.test.ts > MCP Composition Auth E2E Tests > Auth Gate > should reject requests without valid token

Flake rate in main: 20.00% (Passed 4 times, Failed 1 times)

Stack Traces | 0.746s run time
AssertionError: expected 401 to be 200 // Object.is equality

- Expected
+ Received

- 200
+ 401

 ❯ tests/mcp-composition-auth.e2e.test.ts:95:28
apps/internal-storybook/tests/mcp-composition-auth.e2e.test.ts > MCP Composition Auth E2E Tests > Multi-Source with Auth > should list tools with storybookId parameter when authenticated

Flake rate in main: 20.00% (Passed 4 times, Failed 1 times)

Stack Traces | 0.292s run time
TypeError: Cannot read properties of undefined (reading 'replace')
 ❯ parseMCPResponse tests/helpers.ts:17:29
 ❯ tests/mcp-composition-auth.e2e.test.ts:103:17

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Bundle Report

Changes will decrease total bundle size by 401 bytes (-0.81%) ⬇️. This is within the configured threshold ✅

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

Affected Assets, Files, and Routes:

view changes for bundle: @storybook/mcp-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 3.65kB 33.62kB 12.19% ⚠️
index.d.ts 824 bytes 13.89kB 6.3% ⚠️
instructions-o-UPO8qy.js (New) 1.37kB 1.37kB 100.0% 🚀
instructions-Cl0vcW2j.js (Deleted) -1.2kB 0 bytes -100.0% 🗑️

Files in index.js:

  • ./src/types.ts → Total Size: 1.82kB

  • ./src/index.ts → Total Size: 843 bytes

  • ./package.json → Total Size: 214 bytes

  • ./src/tools/get-setup-instructions.ts → Total Size: 3.51kB

Files in instructions-o-UPO8qy.js:

  • ./src/instructions.md → Total Size: 1.33kB

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 it seems that this test file is being picked up by the repo global test config, but it shouldn't. FIx that, it is causing tests to fail.

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.

Fixed in 5f99616. The grading test is no longer stored as a repo-visible *.test.ts file; it now gets copied into the generated trial project during preGrade, so the repo-level Vitest config won’t pick it up anymore.


Requirements:

1. Implement this directly in `src/main.tsx`
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 to make the eval trial's Storybook slightly more useful, we should instead prompt the agent to write this to a separate component file that we have static stories for, just so we can see the component in the Storybook.

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 in 5f99616. Task 916 now asks the agent to implement src/components/MissionControl.tsx, updates src/main.tsx to render it, and includes a static MissionControl story so the component is visible in the eval trial’s Storybook.

Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Copilot AI requested a review from JReinhold March 19, 2026 19:39
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.

Add get-setup-instructions tool powered by docs entry tags

2 participants