Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

This PR integrates the reactDocgen parsing functionality (added in #37) into the @storybook/mcp package architecture, enabling the get-component-documentation tool to display React component prop information in a structured XML format.

What changed

Type System

Added an optional reactDocgen field to the ComponentManifest valibot schema to accept raw react-docgen output from Storybook's component analysis.

XML Formatting

Enhanced formatComponentManifest() to generate a <props> section when reactDocgen is present:

<props>
  <prop>
    <prop_name>variant</prop_name>
    <prop_type>"primary" | "secondary"</prop_type>
    <prop_required>false</prop_required>
    <prop_default>"primary"</prop_default>
    <prop_description>
      Button style variant
    </prop_description>
  </prop>
</props>

The formatting includes all optional fields (type, required, default, description) only when they have defined values, providing AI agents with rich component prop metadata.

Testing

  • Added 5 unit tests in format-manifest.test.ts covering various scenarios (full props, minimal props, missing reactDocgen)
  • Added 1 integration test in get-component-documentation.test.ts verifying end-to-end flow
  • Increased test count from 61 to 67 tests, all passing
  • Maintained >91% overall coverage, 100% on format-manifest.ts

Documentation

Updated Copilot instructions with a comprehensive "Component Manifest and ReactDocgen Support" section explaining:

  • How reactDocgen data flows through the system
  • Type serialization examples (unions, functions, objects, arrays, generics)
  • XML output format
  • When optional fields are included

Why this matters

This enhancement allows AI agents using the MCP server to access detailed React component prop information, including TypeScript types, default values, required status, and descriptions. This makes it significantly easier for agents to understand component APIs and generate correct usage examples.

Verification

  • ✅ All 67 tests passing
  • ✅ >91% statement coverage
  • ✅ Builds successfully
  • ✅ Type checking passes
  • ✅ Code review: No issues
  • ✅ Security scan: No vulnerabilities
Original prompt

This branch - described in PR #37 - adds support for parsing the reactDocgen property of a component manifest.
Now we need to wire it up to the rest of the architecture in the @storybook/mcp package.
the get-component-documentation tool should include the parsed props too in the result, with their optional fields.

remember unit tests, test coverage, updating valibot validations, the xml formatting and updating Copilot instructions.


💡 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.

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

🦋 Changeset detected

Latest commit: fc83cd1

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

This PR includes changesets to release 2 packages
Name Type
@storybook/addon-mcp Patch
@storybook/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 3 commits October 24, 2025 14:52
- Add reactDocgen field to ComponentManifest type
- Import and use parseReactDocgen in format-manifest
- Format props section with XML structure including all optional fields
- Add comprehensive tests for props formatting
- All tests passing with 100% coverage on format-manifest.ts

Co-authored-by: JReinhold <[email protected]>
- Document Component Manifest and ReactDocgen support section
- Add details about parsing and formatting flow
- Include XML output format examples
- Update file structure to reflect current state
- Update key components list

Co-authored-by: JReinhold <[email protected]>
- Test that props section is included when reactDocgen is present
- Verify end-to-end flow from manifest to XML output
- All 67 tests passing with >91% coverage

Co-authored-by: JReinhold <[email protected]>
Copilot AI changed the title [WIP] Add parsing support for reactDocgen in component manifest Wire up reactDocgen parsing to component documentation tool Oct 24, 2025
Copilot AI requested a review from JReinhold October 24, 2025 15:01
Copilot finished work on behalf of JReinhold October 24, 2025 15:01
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 24, 2025

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

commit: fc83cd1

@JReinhold JReinhold requested a review from Copilot October 24, 2025 21:18
@JReinhold JReinhold marked this pull request as ready for review October 24, 2025 21:18
@JReinhold JReinhold changed the base branch from kasper/parse-react-docgen to main October 24, 2025 21:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates reactDocgen parsing functionality into the @storybook/mcp package, enabling the get-component-documentation tool to display React component prop information in a structured XML format. The changes wire up the previously added parsing utilities to the component documentation workflow, making prop metadata accessible to AI agents.

Key changes:

  • Added reactDocgen field to ComponentManifest schema for accepting react-docgen output
  • Enhanced XML formatting to include <props> sections with detailed prop metadata
  • Added comprehensive test coverage (6 new tests) verifying the integration

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/mcp/src/utils/parse-react-docgen.ts Consolidated import statements for react-docgen types
packages/mcp/src/utils/format-manifest.ts Added logic to parse and format reactDocgen data into XML props section
packages/mcp/src/utils/format-manifest.test.ts Added 5 unit tests covering various prop formatting scenarios
packages/mcp/src/types.ts Updated ComponentManifest schema to include optional reactDocgen field
packages/mcp/src/tools/get-component-documentation.test.ts Added integration test verifying end-to-end reactDocgen flow
packages/mcp/fixtures/*.json Updated fixture data to use react-docgen format instead of JSON schema
packages/addon-mcp/package.json Bumped version and specified minimum Storybook version
packages/addon-mcp/README.md Enhanced documentation with component documentation tools section
packages/addon-mcp/CHANGELOG.md Added changelog entry for version 0.0.9
README.md Updated testing documentation and added debugging instructions
.github/instructions/mcp.instructions.md Added comprehensive ReactDocgen support documentation

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@JReinhold JReinhold merged commit bd5046e into main Oct 27, 2025
10 checks passed
@JReinhold JReinhold deleted the copilot/add-react-docgen-support branch October 27, 2025 09:03
@github-actions github-actions bot mentioned this pull request Oct 27, 2025
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.

3 participants