feat: add MCP server support for AI agent integration#849
Merged
Conversation
|
… and implementations
…ive best practices documentation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What I did
rnstorybook10mcp.mp4
Added MCP (Model Context Protocol) server support to
@storybook/react-native, enabling AI agents like Claude Code and Cursor to query component documentation, props, and story snippets directly from your running React Native Storybook.Why
The
@storybook/mcppackage already provides this capability for web Storybook. This brings the same functionality to React Native by reusing the existing@storybook/mcptools and@storybook/react'sexperimental_manifeststo generate the component manifest — no custom manifest generation needed.How it works
buildIndex(already used for story generation) produces aStoryIndexfrom story files on diskexperimental_manifestsfrom@storybook/react/presettransforms those index entries into the component manifest format that@storybook/mcpexpects (including react-docgen prop extraction, code snippets, etc.)@storybook/mcptools (list-all-documentation,get-documentation,get-documentation-for-story) are registered on the MCP serverselect-storytool broadcasts story selection to connected devices via WebSocketget-storybook-story-instructionstool provides React Native-specific guidance for writing storiesChanges
New files:
mcpServer.ts— MCP server setup: lazy-initializes tmcp server, registers tools, converts between Node.js HTTP and Web Request/Response APIsmanifest/storyInstructions.ts— React Native-specific story writing instructionsModified files:
channelServer.ts— AddedPOST/GET /mcpendpoint routingwithStorybook.ts(Metro) — Addedmcp?: booleanoptionrepack/withStorybook.ts— Addedmcp?: booleanoption for consistencypackage.json— Added dependencies:@storybook/mcp,@storybook/react,tmcp,@tmcp/adapter-valibot,@tmcp/transport-http,valibotUsage
Then connect your AI agent to
http://localhost:7007/mcp. For Claude Code:How to test
websockets: 'auto', mcp: true)pnpm examplehttp://localhost:7007/mcpand calllist-all-documentationpnpm test(all pass)