Repository navigation
[@storybook/mcp] Let createStorybookMcpHandler pass options to HttpTransport (e.g. sessionManager) #36986
itsRoberOOF
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Is your feature request related to a problem? Please describe.
We self-host the docs toolset with
@storybook/mcp, as the "Sharing your MCP server" docs suggest, inside a Cloudflare Worker next to Storybook's static build.createStorybookMcpHandler()fits that runtime well, since it returns a fetch-style handler.The problem is that the handler creates its transport with fixed options (
code/lib/mcp/src/index.tsonnext):@tmcp/transport-httpaccepts more options, such assessionManager({ streams?, info? }) andgetSessionId, but none of them can be passed through, so the in-memory defaults always apply.InMemoryInfoSessionManagerstores each session'sclientInfoand client capabilities oninitialize, and only drops them onDELETE. Many MCP clients reconnect without sendingDELETE, so in a long-lived process or isolate that map keeps growing. The docs tools never read that per-session state.Describe the solution you'd like
Add an optional
transportOptionsfield toStorybookMcpHandlerOptionsand pass it through, keeping today'spath: nullas the default:Usage, for example with a custom info manager that expires sessions:
It's backwards compatible, and it also lets self-hosters set
getSessionIdor plug in a shared session store.Describe alternatives you've considered
McpServer, the exportedadd*Toolfunctions and our ownHttpTransport. It works, but it duplicates whatcreateStorybookMcpHandlersets up (server name and version, instructions, capabilities, adapter) and drifts with every release.sessionManagerinstead of all the transport options. It's narrower, but it would need another option the next time someone needsgetSessionIdor similar.Are you able to assist to bring the feature to reality?
no
Additional context
@storybook/mcp10.6.1 (10.6.3 has the samenew HttpTransport(server, { path: null }))@tmcp/transport-http0.8.6nodejs_compatAll reactions