feat: add screenshot-story MCP tool#187
Conversation
|
Adds a new `screenshot-story` tool that renders a Storybook story in a headless browser (via Playwright) and returns a PNG screenshot as MCP image content. This closes the visual feedback loop so AI agents can verify rendered components without manual inspection.
94738b7 to
53c4e1f
Compare
|
Thanks for the PR @Larkooo! Can you tell me about the use case you want to support here? What workflow are you envisioning for this? How is this helping you and/or the agent? |
Yes, we're basically trying to automate some workflows that necessitate illustrations of components from our website with agents and found that storybook might be the best way of doing so instead of screenshotting the live website. Storybook allows us to embed mock values so we were thinking of using it with agents for them to provide mock values of their choosing for a certain situation, and retrieve a screenshot that they can then use. Like for eg. an agent exporting illustrations for various situations and then using them for app thumbnails etc. |
commit: |
|
@Larkooo that's a funny use case of this that I haven't heard of before. Have you actually used this workflow in practice successfully, or are you still tinkering with it? I've triggered a preview release of this branch so you can play around with it. |
Yes, well we haven't really used it just yet for any practical reason but I gave it a shot with the preview and it seems to generate those screenshots pretty nicely. Plus the tool is only exposed if playwright is available. That way the agent doesnt need to navigate to storybook with playwright and take the screenshot itself etc.. which on top of that isn't the best since sometimes we want illustrations with specific viewports and only capture the content etc. I'd like to also experiment with exporting little clips of the agent actually interacting with the storybook components (like clicking and seeing the animation) bit I'm not sure if it is too much |
|
Thank you for your input and ideas, much appreciated! However we won't be incorporating this. A tool like this doesn't align with our plans for the MCP or its capabilities. |
Summary
screenshot-storyMCP tool that renders a Storybook story in a headless browser (Playwright) and returns a PNG screenshot as MCP image contentbrowser-managerutility with lazy singleton browser, concurrent-launch protection, and cleanup guardsTest plan
pnpm build— project builds cleanlypnpm vitest --project=@storybook/addon-mcp --run— all 192 tests pass (14 new tests added)pnpm typecheck— no type errorsscreenshot-storywith a story ID and verify a PNG image is returned🤖 Generated with Claude Code