@mcp-use/inspector 20.0.0-beta.1 → 20.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/README.md +7 -18
  2. package/dist/cdn/{AnimatePresence-B4HhIdgq.js → AnimatePresence-D1bZ5_-l.js} +80 -79
  3. package/dist/cdn/ChatTab-DRn-AnBV.js +6811 -0
  4. package/dist/cdn/{CheckboxIndicator-BF2cKfbA.js → CheckboxIndicator-BjF73mGX.js} +74 -73
  5. package/dist/cdn/ConnectionSettingsForm-CsG61Iyd.js +929 -0
  6. package/dist/cdn/ConnectionSettingsTab-CTJJK4hj.js +151 -0
  7. package/dist/cdn/{ElicitationTab-upPXq2q7.js → ElicitationTab-PEmEDvC5.js} +48 -47
  8. package/dist/cdn/{FormContext-Cl51-7O7.js → FormContext-NtUiZclE.js} +26 -26
  9. package/dist/cdn/{InspectorContext-DzXtgyTx.js → InspectorContext-BBKCdfmK.js} +2 -22
  10. package/dist/cdn/{JSONDisplay-D3RcyO9z.js → JSONDisplay-BJqMz7Ny.js} +23 -23
  11. package/dist/cdn/{ListTabHeader-8lULn-90.js → ListTabHeader-DzmTtN1e.js} +21 -20
  12. package/dist/cdn/{WidgetWrapper-D29YDxIu.js → MCPAppsDebugControls-C5-knSKL.js} +583 -620
  13. package/dist/cdn/{ManufactOAuthCallback-DEM8mhWD.js → ManufactOAuthCallback-ChbbjFIT.js} +3 -3
  14. package/dist/cdn/MarkdownRenderer-uUvyteZT.js +3610 -0
  15. package/dist/cdn/McpAppsViewPanel-Bj-1E9_v.js +56 -0
  16. package/dist/cdn/{NotificationsTab-CWopTIzT.js → NotificationsTab-B7uebqMV.js} +13 -13
  17. package/dist/cdn/{OAuthCallback-k3oeLtIC.js → OAuthCallback-Hdtybeu0.js} +3 -3
  18. package/dist/cdn/PromptsTab-b4UpzPPY.js +902 -0
  19. package/dist/cdn/{ResourcesTab-KfamsM6-.js → ResourcesTab-BCA0_b8c.js} +106 -124
  20. package/dist/cdn/{SamplingTab-vcufuK24.js → SamplingTab-CuPYqFyA.js} +43 -42
  21. package/dist/cdn/{ServerMetadataTab-DS0eiyyD.js → ServerMetadataTab-BM3VhSLf.js} +14 -14
  22. package/dist/cdn/{StatusIcon-BGXOEU2u.js → StatusIcon-Q3n3YRtE.js} +8 -9
  23. package/dist/cdn/{ToolsTab-DRjcZnpu.js → ToolsTab-4lvUZRQq.js} +671 -693
  24. package/dist/cdn/{ViewPreview-B_onhcUB.js → ViewPreview-BGClMNvo.js} +5 -4
  25. package/dist/cdn/{WidgetDebugContext-D4usL_MA.js → WidgetDebugContext-B6yoOVVV.js} +1 -11
  26. package/dist/cdn/WidgetWrapper-BlbQAh_X.js +12 -0
  27. package/dist/cdn/{bell-CGjAO_0s.js → bell-GrTZcnD2.js} +1 -1
  28. package/dist/cdn/{browser-CbQIH4w2.js → browser-DG2Z8392.js} +1 -1
  29. package/dist/cdn/{brush-B_mKhyxG.js → brush-CelVvMGp.js} +1 -1
  30. package/dist/cdn/button-CB4uOoUV.js +2509 -0
  31. package/dist/cdn/{card-DqjqAq0o.js → card-BA-DQk-G.js} +2 -2
  32. package/dist/cdn/{checkbox-B4oUG6Rr.js → checkbox-kwVa4gRX.js} +4 -4
  33. package/dist/cdn/{clock-CmUbSx_B.js → clock-YMF8Gtw5.js} +1 -1
  34. package/dist/cdn/{code-V_0nf5rg.js → code-C8sN2OGR.js} +1 -1
  35. package/dist/cdn/{jsx-runtime-CIxvMpEo.js → createLucideIcon-BONxC1L5.js} +57 -24
  36. package/dist/cdn/{dialog-Dnl-pZsY.js → dialog-CJGnC5Ag.js} +165 -165
  37. package/dist/cdn/{dist-DjXr_YO3.js → dist-CTJnCYmk.js} +1 -1
  38. package/dist/cdn/{dist-mRDqCgKU.js → dist-dw0FdK5Y.js} +116 -114
  39. package/dist/cdn/{external-link-CjmfT6rW.js → external-link-Bo4lQxr1.js} +1 -1
  40. package/dist/cdn/{eye-B7H96av8.js → eye-pSGG7nvf.js} +1 -1
  41. package/dist/cdn/{folder-open-B3lu2rG_.js → folder-open-aM8CPtBO.js} +1 -1
  42. package/dist/cdn/{hash-BVQnWi7q.js → hash-DDs2vE1k.js} +1 -1
  43. package/dist/cdn/{history-Csw4rb44.js → history-BfUFpL1d.js} +1 -1
  44. package/dist/cdn/{index-browser-CVUwR-Bu.js → index-browser-B1xWyLr0.js} +113 -201
  45. package/dist/cdn/{info-CNiOwqkf.js → info-BMkB68mB.js} +1 -1
  46. package/dist/cdn/{input-BLxOA7V-.js → input-BCpgLXU1.js} +3039 -3600
  47. package/dist/cdn/inspector.css +1 -1
  48. package/dist/cdn/inspector.js +7797 -7857
  49. package/dist/cdn/{label-CBvG613A.js → label-A0UGV8FE.js} +8 -8
  50. package/dist/cdn/{loader-circle-BLy9A_pp.js → loader-circle-BKRHJEB7.js} +1 -1
  51. package/dist/cdn/{manufact-auth-0TVxpeTA.js → manufact-auth-BQMHhbLV.js} +142 -106
  52. package/dist/cdn/{maximize-2-CH5Lq90B.js → maximize-2-DdrB_spi.js} +1 -1
  53. package/dist/cdn/{maximize-BALCV_ep.js → maximize-hSOCz133.js} +1 -1
  54. package/dist/cdn/{message-square-BnxdpJxZ.js → message-square-D3tKB3uJ.js} +1 -1
  55. package/dist/cdn/{not-found-BcNNsTjS.js → not-found-BajFyZpp.js} +4 -6
  56. package/dist/cdn/{play-vuZ5PLnI.js → play-B1leulYf.js} +1 -1
  57. package/dist/cdn/providerMeta-CjGU4rID.js +436 -0
  58. package/dist/cdn/{react-BxO-uEDZ.js → react-BoOQpLwo.js} +838 -849
  59. package/dist/cdn/{refresh-cw-BXY-Pa0U.js → refresh-cw-CyvXrS91.js} +1 -1
  60. package/dist/cdn/{save-Tgil_AJZ.js → save-CmdEPUAm.js} +1 -1
  61. package/dist/cdn/{select-BZ_IoKxg.js → select-CCFHjOGk.js} +843 -842
  62. package/dist/cdn/{servers-Dm72iTpY.js → servers-Dd0Vcp81.js} +5 -1
  63. package/dist/cdn/{shared-uMiV6Fx1.js → shared-CJVHJhag.js} +35 -35
  64. package/dist/cdn/sheet-oyq1mIyg.js +2078 -0
  65. package/dist/cdn/{sparkles-BntO2rDR.js → sparkles-CxeZpVtX.js} +1 -1
  66. package/dist/cdn/{spinner-CWcJhIY_.js → spinner-Be1GlSGX.js} +3 -3
  67. package/dist/cdn/{square-check-big-BvwQ17Bl.js → square-check-big-C_4wbfwF.js} +1 -1
  68. package/dist/cdn/{switch-DtQOLb9R.js → switch-DHXEA_N5.js} +211 -210
  69. package/dist/cdn/{tabs-subtle-C5cy35sY.js → tabs-subtle-Dubd6Kj8.js} +259 -258
  70. package/dist/cdn/{telemetry-Ct6pVkM1.js → telemetry-C7bt_ifQ.js} +38 -70
  71. package/dist/cdn/{textarea-Bj-CT7hC.js → textarea-CwmI8_uI.js} +2 -2
  72. package/dist/cdn/{trash-2-RwpJY5SL.js → trash-2-BhumJAFE.js} +1 -1
  73. package/dist/cdn/{useAriaLabelledBy-Bm9qHGK6.js → useAriaLabelledBy-Cra6w3YY.js} +2 -1
  74. package/dist/cdn/{useCompositeItem-CNJ6MXdi.js → useCompositeItem-Dhnm-7el.js} +3 -3
  75. package/dist/cdn/{useConfig-CwxZ6Quj.js → useConfig-DiOY6evp.js} +73 -46
  76. package/dist/cdn/{useSavedRequests-Ci2I919u.js → useSavedRequests-mSIsDd4c.js} +1 -1
  77. package/dist/cdn/{useViewHostProps-Dr6W2ooF.js → useViewHostProps-D1emxC9m.js} +124 -108
  78. package/dist/cdn/{wrench-DzGmCfnb.js → wrench-DvK20LUT.js} +1 -1
  79. package/dist/cdn/{x-C3vRQIYu.js → x-EilKPiCX.js} +1 -1
  80. package/dist/cdn/{zap-Mb-pbw2X.js → zap-0Wr9QO7N.js} +1 -1
  81. package/dist/cli.js +87 -14
  82. package/dist/client/auth/manufact-auth.d.ts +3 -1
  83. package/dist/client/auth/manufact-auth.d.ts.map +1 -1
  84. package/dist/client/components/ChatTab.d.ts +1 -8
  85. package/dist/client/components/ChatTab.d.ts.map +1 -1
  86. package/dist/client/components/MCPAppsDebugControls.d.ts.map +1 -1
  87. package/dist/client/components/ResourcesTab.d.ts.map +1 -1
  88. package/dist/client/components/ToolsTab.d.ts.map +1 -1
  89. package/dist/client/components/chat/ChatHeader.d.ts +7 -2
  90. package/dist/client/components/chat/ChatHeader.d.ts.map +1 -1
  91. package/dist/client/components/chat/ChatLandingForm.d.ts +4 -2
  92. package/dist/client/components/chat/ChatLandingForm.d.ts.map +1 -1
  93. package/dist/client/components/chat/ChatManagedNotice.d.ts +10 -0
  94. package/dist/client/components/chat/ChatManagedNotice.d.ts.map +1 -0
  95. package/dist/client/components/chat/ChatScrollTopFade.d.ts +7 -0
  96. package/dist/client/components/chat/ChatScrollTopFade.d.ts.map +1 -0
  97. package/dist/client/components/chat/ConfigurationDialog.d.ts +11 -9
  98. package/dist/client/components/chat/ConfigurationDialog.d.ts.map +1 -1
  99. package/dist/client/components/chat/ConfigureEmptyState.d.ts +1 -6
  100. package/dist/client/components/chat/ConfigureEmptyState.d.ts.map +1 -1
  101. package/dist/client/components/chat/MessageList.d.ts +1 -0
  102. package/dist/client/components/chat/MessageList.d.ts.map +1 -1
  103. package/dist/client/components/chat/StreamingAssistantContent.d.ts.map +1 -1
  104. package/dist/client/components/chat/ToolResultRenderer.d.ts.map +1 -1
  105. package/dist/client/components/chat/chatModeStorage.d.ts +11 -0
  106. package/dist/client/components/chat/chatModeStorage.d.ts.map +1 -0
  107. package/dist/client/components/chat/managedChatNotice.d.ts +16 -0
  108. package/dist/client/components/chat/managedChatNotice.d.ts.map +1 -0
  109. package/dist/client/components/chat/partialToolArgs.d.ts +10 -0
  110. package/dist/client/components/chat/partialToolArgs.d.ts.map +1 -0
  111. package/dist/client/components/chat/providerMeta.d.ts +11 -0
  112. package/dist/client/components/chat/providerMeta.d.ts.map +1 -1
  113. package/dist/client/components/chat/types.d.ts +1 -0
  114. package/dist/client/components/chat/types.d.ts.map +1 -1
  115. package/dist/client/components/chat/useChatMessages.d.ts +7 -5
  116. package/dist/client/components/chat/useChatMessages.d.ts.map +1 -1
  117. package/dist/client/components/chat/useChatMessagesClientSide.d.ts +4 -6
  118. package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +1 -1
  119. package/dist/client/components/chat/useChatScrollToBottom.d.ts +1 -0
  120. package/dist/client/components/chat/useChatScrollToBottom.d.ts.map +1 -1
  121. package/dist/client/components/chat/useConfig.d.ts +1 -1
  122. package/dist/client/components/chat/useConfig.d.ts.map +1 -1
  123. package/dist/client/components/chat/useHostedChatMode.d.ts +1 -1
  124. package/dist/client/components/chat/useHostedChatMode.d.ts.map +1 -1
  125. package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts +29 -0
  126. package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts.map +1 -0
  127. package/dist/client/components/shared/MarkdownRenderer.d.ts +2 -1
  128. package/dist/client/components/shared/MarkdownRenderer.d.ts.map +1 -1
  129. package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +1 -1
  130. package/dist/client/components/tools/ToolResultDisplay.d.ts +2 -1
  131. package/dist/client/components/tools/ToolResultDisplay.d.ts.map +1 -1
  132. package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +1 -1
  133. package/dist/client/components/ui/MeshGradientCanvas.d.ts +13 -0
  134. package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +1 -0
  135. package/dist/client/components/ui/chat-message.d.ts +1 -1
  136. package/dist/client/components/ui/chat-message.d.ts.map +1 -1
  137. package/dist/client/components/ui/file-thumbnail.d.ts.map +1 -1
  138. package/dist/client/components/ui/mesh-animation-pause.d.ts +14 -0
  139. package/dist/client/components/ui/mesh-animation-pause.d.ts.map +1 -0
  140. package/dist/client/components/ui/mesh-gradient-colors.d.ts +6 -0
  141. package/dist/client/components/ui/mesh-gradient-colors.d.ts.map +1 -0
  142. package/dist/client/components/ui/mesh-tab-background.d.ts +3 -1
  143. package/dist/client/components/ui/mesh-tab-background.d.ts.map +1 -1
  144. package/dist/client/components/ui/not-found.d.ts.map +1 -1
  145. package/dist/client/context/InspectorContext.d.ts.map +1 -1
  146. package/dist/client/context/WidgetDebugContext.d.ts +1 -11
  147. package/dist/client/context/WidgetDebugContext.d.ts.map +1 -1
  148. package/dist/client/hooks/useDeviceViewport.d.ts +1 -5
  149. package/dist/client/hooks/useDeviceViewport.d.ts.map +1 -1
  150. package/dist/client/hooks/useViewHostProps.d.ts +1 -1
  151. package/dist/client/hooks/useViewHostProps.d.ts.map +1 -1
  152. package/dist/client/index.js +4202 -3491
  153. package/dist/client/telemetry/init.d.ts.map +1 -1
  154. package/dist/client/telemetry/utils.d.ts.map +1 -1
  155. package/dist/client/utils/servers.d.ts +5 -0
  156. package/dist/client/utils/servers.d.ts.map +1 -1
  157. package/dist/server/asset-urls.d.ts +4 -0
  158. package/dist/server/asset-urls.d.ts.map +1 -1
  159. package/dist/server/asset-urls.js +7 -3
  160. package/dist/server/cdn-shell.d.ts.map +1 -1
  161. package/dist/server/cdn-shell.js +3 -3
  162. package/dist/server/{chunk-IXYK6ZOY.js → chunk-5XMQ5UJR.js} +2 -2
  163. package/dist/server/{chunk-KBVKS4J5.js → chunk-H6ZCIKBS.js} +10 -0
  164. package/dist/server/{chunk-VDUV6LR6.js → chunk-KTPQKADO.js} +75 -5
  165. package/dist/server/{chunk-Y2GBQOQW.js → chunk-LMLZJR2K.js} +2 -9
  166. package/dist/server/{chunk-K2V2SDQD.js → chunk-OWR2BIBW.js} +1 -1
  167. package/dist/server/{chunk-5B3SXGZP.js → chunk-UJLXHNQP.js} +1 -1
  168. package/dist/server/{chunk-6XWDZEFF.js → chunk-XCNS5CIW.js} +8 -3
  169. package/dist/server/cli.js +5 -5
  170. package/dist/server/create-dev-api-app.js +3 -3
  171. package/dist/server/dev-callback-redirect.d.ts +3 -0
  172. package/dist/server/dev-callback-redirect.d.ts.map +1 -0
  173. package/dist/server/dev-callback-redirect.js +18 -0
  174. package/dist/server/index.js +6 -6
  175. package/dist/server/middleware.js +6 -6
  176. package/dist/server/proxy/index.js +1 -1
  177. package/dist/server/proxy/mcp-proxy.d.ts +2 -0
  178. package/dist/server/proxy/mcp-proxy.d.ts.map +1 -1
  179. package/dist/server/proxy/mcp-proxy.js +3 -1
  180. package/dist/server/proxy-routes.js +2 -2
  181. package/dist/server/server.js +3 -3
  182. package/dist/server/version.js +1 -1
  183. package/dist/server/vite-dev-api-plugin.js +3 -3
  184. package/dist/web/assets/AnimatePresence-FfDQQNFJ.js +9 -0
  185. package/dist/web/assets/ChatTab-x6dg7xyx.js +18 -0
  186. package/dist/web/assets/ConnectionSettingsTab-DUwCNYXJ.js +1 -0
  187. package/dist/web/assets/ElicitationTab-Dk04sjRw.js +1 -0
  188. package/dist/web/assets/FormContext-sV-yByKz.js +1 -0
  189. package/dist/web/assets/ListTabHeader-CrGae306.js +1 -0
  190. package/dist/web/assets/MCPAppsDebugControls-Kh10bYHm.js +34 -0
  191. package/dist/web/assets/{ManufactOAuthCallback-DCLbW-mz.js → ManufactOAuthCallback-Bq00h5wq.js} +1 -1
  192. package/dist/web/assets/MarkdownRenderer--ZbJc80m.js +47 -0
  193. package/dist/web/assets/McpAppsViewPanel-BM7S0O6E.js +1 -0
  194. package/dist/web/assets/{NotificationsTab-JevzvJTg.js → NotificationsTab-DTcas5xQ.js} +1 -1
  195. package/dist/web/assets/{OAuthCallback-BjcRxLh5.js → OAuthCallback-CZ5PbMLP.js} +1 -1
  196. package/dist/web/assets/PromptsTab-Ce9hFDPL.js +15 -0
  197. package/dist/web/assets/ResourcesTab-CfV_CTOT.js +2 -0
  198. package/dist/web/assets/SamplingTab-7FoVfzSl.js +1 -0
  199. package/dist/web/assets/ServerMetadataTab-DfOYnm2P.js +1 -0
  200. package/dist/web/assets/ToolsTab-CeDM6lbc.js +8 -0
  201. package/dist/web/assets/ViewPreview-DMpWAByN.js +1 -0
  202. package/dist/web/assets/WidgetWrapper-cv_BM1bY.js +1 -0
  203. package/dist/web/assets/{brush--0LobUi4.js → brush-DX0UZ_pI.js} +1 -1
  204. package/dist/web/assets/button-C8Xa2k4x.js +1 -0
  205. package/dist/web/assets/checkbox-ocTkuPLe.js +1 -0
  206. package/dist/web/assets/code-B14rVdNt.js +1 -0
  207. package/dist/web/assets/createLucideIcon-BEHeJH0M.js +1 -0
  208. package/dist/web/assets/dist-D6mojCV5.js +21 -0
  209. package/dist/web/assets/index-BfmL5fRO.js +499 -0
  210. package/dist/web/assets/index-bCIH1Sdx.css +1 -0
  211. package/dist/web/assets/input-C0OQCUZy.js +1 -0
  212. package/dist/web/assets/{label-B5Q_Zr8M.js → label-CI7JWQOo.js} +1 -1
  213. package/dist/web/assets/{maximize-2-BTT9QQU9.js → maximize-2-Br1WQzT2.js} +1 -1
  214. package/dist/web/assets/{maximize-_O55kFcr.js → maximize-CJNgRe6S.js} +1 -1
  215. package/dist/web/assets/{refresh-cw-C9wQl8_d.js → refresh-cw-B5iaAZKn.js} +1 -1
  216. package/dist/web/assets/{save-B-MsgxX9.js → save-TM6fvNrt.js} +1 -1
  217. package/dist/web/assets/select-D6jzbLJn.js +1 -0
  218. package/dist/web/assets/shared-BaJnSpaR.js +1 -0
  219. package/dist/web/assets/{sparkles-2OAsc1aP.js → sparkles-BGYTDThM.js} +1 -1
  220. package/dist/web/assets/tabs-subtle-C3U3Xswq.js +1 -0
  221. package/dist/web/assets/textarea-CRTXuRmE.js +1 -0
  222. package/dist/web/assets/useConfig-tIq2w5rV.js +1 -0
  223. package/dist/web/assets/useViewHostProps--1CXsG5i.js +1 -0
  224. package/dist/web/assets/{zap-Du2Uc5pa.js → zap-BDWHCVHU.js} +1 -1
  225. package/dist/web/index.html +10 -11
  226. package/package.json +5 -12
  227. package/dist/cdn/ChatTab-D8uwCHAf.js +0 -13218
  228. package/dist/cdn/ConnectionSettingsForm-BNS6bOMD.js +0 -873
  229. package/dist/cdn/ConnectionSettingsTab-B97gPPJW.js +0 -145
  230. package/dist/cdn/PromptsTab-Cspfnl6n.js +0 -4400
  231. package/dist/cdn/bundle-mjs-B0nmHDtp.js +0 -1953
  232. package/dist/cdn/chunk-BO2N2NFS-Cy167e0X.js +0 -17500
  233. package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
  234. package/dist/cdn/highlighted-body-OFNGDK62-CoReNbTX.js +0 -36
  235. package/dist/cdn/mermaid-GHXKKRXX-DgVIbk-D.js +0 -2
  236. package/dist/cdn/pdf-CxFT9FER.js +0 -16291
  237. package/dist/cdn/popover-C_SSrXT0.js +0 -2005
  238. package/dist/cdn/sheet-CerCdhxz.js +0 -78
  239. package/dist/cdn/useHostedSession-BA39Aegc.js +0 -153
  240. package/dist/cdn/useMCPPrompts-D3_Hla_z.js +0 -104
  241. package/dist/client/components/chat/streamdown-code-slim.d.ts +0 -4
  242. package/dist/client/components/chat/streamdown-code-slim.d.ts.map +0 -1
  243. package/dist/web/assets/AnimatePresence-CthXziG2.js +0 -9
  244. package/dist/web/assets/ChatTab-Cy8eyFYI.js +0 -460
  245. package/dist/web/assets/ConnectionSettingsTab-sDZGaUJn.js +0 -1
  246. package/dist/web/assets/ElicitationTab-wDKgU1qL.js +0 -1
  247. package/dist/web/assets/FormContext-Cqc_A12u.js +0 -1
  248. package/dist/web/assets/ListTabHeader-G-nQX18m.js +0 -1
  249. package/dist/web/assets/PromptsTab-DsQVOjKH.js +0 -61
  250. package/dist/web/assets/ResourcesTab-Bw8_p6M1.js +0 -2
  251. package/dist/web/assets/SamplingTab-BrcF1zJF.js +0 -1
  252. package/dist/web/assets/ServerMetadataTab-Bydeh1Po.js +0 -1
  253. package/dist/web/assets/ToolsTab-DJWF7Q_x.js +0 -8
  254. package/dist/web/assets/ViewPreview-jgeU7bY9.js +0 -1
  255. package/dist/web/assets/WidgetWrapper-B_vJU9uF.js +0 -34
  256. package/dist/web/assets/bundle-mjs-8puS6ou7.js +0 -1
  257. package/dist/web/assets/checkbox-BA-XURSj.js +0 -1
  258. package/dist/web/assets/chunk-BO2N2NFS-CGbd3eLY.js +0 -131
  259. package/dist/web/assets/code-tME-5H6D.js +0 -1
  260. package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
  261. package/dist/web/assets/dist-BcAQZluc.js +0 -21
  262. package/dist/web/assets/highlighted-body-OFNGDK62-BBJFbIMp.js +0 -1
  263. package/dist/web/assets/index-BjH-Qp85.css +0 -1
  264. package/dist/web/assets/index-D2UxaT9v.js +0 -475
  265. package/dist/web/assets/input-CjmxOFr6.js +0 -1
  266. package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
  267. package/dist/web/assets/mermaid-GHXKKRXX-B4MKVODA.js +0 -1
  268. package/dist/web/assets/pdf-CuwKm9zO.js +0 -54
  269. package/dist/web/assets/select-C0xlfLAa.js +0 -1
  270. package/dist/web/assets/shared-DQE60Op-.js +0 -1
  271. package/dist/web/assets/sheet-7TIkLdpr.js +0 -1
  272. package/dist/web/assets/tabs-subtle-AkJZvdxS.js +0 -1
  273. package/dist/web/assets/textarea-Ci09-en6.js +0 -1
  274. package/dist/web/assets/useConfig-Qglo4xs1.js +0 -1
  275. package/dist/web/assets/useMCPPrompts-USLYc1I4.js +0 -1
  276. package/dist/web/assets/useViewHostProps-DXAD1g7g.js +0 -1
@@ -1,144 +1,144 @@
1
1
  import { a as e, s as t, t as n } from "./react-BIs9pQ3H.js";
2
- import { A as r, C as i, D as a, E as o, I as s, M as c, N as l, O as u, P as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as ee, g as te, h as y, i as b, j as x, k as S, l as C, m as ne, n as w, o as re, p as T, r as E, s as D, t as O, v as k, w as A, x as j, y as ie } from "./cfWorker-Bxcs9rNe.js";
2
+ import { A as r, C as i, D as a, E as o, I as s, M as c, N as l, O as u, P as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as ee, g as te, h as y, i as b, j as x, k as S, l as C, m as ne, n as w, o as re, p as T, r as E, s as D, t as ie, v as O, w as k, x as ae, y as A } from "./cfWorker-Bxcs9rNe.js";
3
3
  //#region ../../node_modules/.pnpm/@modelcontextprotocol+core@2.0.0-beta.4/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs
4
- var M = /* @__PURE__ */ t(n(), 1), N = "io.modelcontextprotocol/related-task", ae = "io.modelcontextprotocol/subscriptionId", P = j(() => x([
4
+ var j = /* @__PURE__ */ t(n(), 1), oe = "io.modelcontextprotocol/related-task", se = "io.modelcontextprotocol/subscriptionId", M = ae(() => x([
5
5
  r(),
6
6
  p(),
7
- k(),
7
+ O(),
8
8
  ne(),
9
- S(r(), P),
10
- m(P)
11
- ])), F = S(r(), P);
12
- m(P);
13
- var I = x([r(), p().int()]), oe = r(), se = o({ ttl: p().optional() }), ce = o({ taskId: r() }), le = i({
14
- progressToken: I.optional(),
15
- [N]: ce.optional()
16
- }), L = o({ _meta: le.optional() }), ue = L.extend({ task: se.optional() }), R = o({
9
+ S(r(), M),
10
+ m(M)
11
+ ])), N = S(r(), M);
12
+ m(M);
13
+ var ce = x([r(), p().int()]), P = r(), le = o({ ttl: p().optional() }), ue = o({ taskId: r() }), de = i({
14
+ progressToken: ce.optional(),
15
+ [oe]: ue.optional()
16
+ }), F = o({ _meta: de.optional() }), fe = F.extend({ task: le.optional() }), I = o({
17
17
  method: r(),
18
- params: L.loose().optional()
19
- }), z = o({ _meta: le.optional() }), B = o({
18
+ params: F.loose().optional()
19
+ }), L = o({ _meta: de.optional() }), R = o({
20
20
  method: r(),
21
- params: z.loose().optional()
22
- }), V = i({ _meta: le.optional() }), de = x([r(), p().int()]), fe = o({
21
+ params: L.loose().optional()
22
+ }), z = i({ _meta: de.optional() }), pe = x([r(), p().int()]), me = o({
23
23
  jsonrpc: f("2.0"),
24
- id: de,
25
- ...R.shape
26
- }).strict(), pe = o({
24
+ id: pe,
25
+ ...I.shape
26
+ }).strict(), he = o({
27
27
  jsonrpc: f("2.0"),
28
- ...B.shape
29
- }).strict(), me = o({
28
+ ...R.shape
29
+ }).strict(), ge = o({
30
30
  jsonrpc: f("2.0"),
31
- id: de,
32
- result: V
33
- }).strict(), he = o({
31
+ id: pe,
32
+ result: z
33
+ }).strict(), _e = o({
34
34
  jsonrpc: f("2.0"),
35
- id: de.optional(),
35
+ id: pe.optional(),
36
36
  error: o({
37
37
  code: p().int(),
38
38
  message: r(),
39
39
  data: c().optional()
40
40
  })
41
- }).strict(), ge = x([
42
- fe,
43
- pe,
41
+ }).strict(), ve = x([
44
42
  me,
45
- he
43
+ he,
44
+ ge,
45
+ _e
46
46
  ]);
47
- x([me, he]);
48
- var _e = V.strict(), ve = z.extend({
49
- requestId: de.optional(),
47
+ x([ge, _e]);
48
+ var ye = z.strict(), be = L.extend({
49
+ requestId: pe.optional(),
50
50
  reason: r().optional()
51
- }), ye = B.extend({
51
+ }), xe = R.extend({
52
52
  method: f("notifications/cancelled"),
53
- params: ve
54
- }), H = o({ icons: m(o({
53
+ params: be
54
+ }), B = o({ icons: m(o({
55
55
  src: r(),
56
56
  mimeType: r().optional(),
57
57
  sizes: m(r()).optional(),
58
58
  theme: T(["light", "dark"]).optional()
59
- })).optional() }), be = o({
59
+ })).optional() }), Se = o({
60
60
  name: r(),
61
61
  title: r().optional()
62
- }), xe = be.extend({
63
- ...be.shape,
64
- ...H.shape,
62
+ }), Ce = Se.extend({
63
+ ...Se.shape,
64
+ ...B.shape,
65
65
  version: r(),
66
66
  websiteUrl: r().optional(),
67
67
  description: r().optional()
68
- }), Se = u((e) => e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0 ? { form: {} } : e, g(o({
69
- form: g(o({ applyDefaults: k().optional() }), F).optional(),
70
- url: F.optional()
71
- }), F.optional())), Ce = i({
72
- list: F.optional(),
73
- cancel: F.optional(),
68
+ }), we = u((e) => e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0 ? { form: {} } : e, g(o({
69
+ form: g(o({ applyDefaults: O().optional() }), N).optional(),
70
+ url: N.optional()
71
+ }), N.optional())), Te = i({
72
+ list: N.optional(),
73
+ cancel: N.optional(),
74
74
  requests: i({
75
- sampling: i({ createMessage: F.optional() }).optional(),
76
- elicitation: i({ create: F.optional() }).optional()
75
+ sampling: i({ createMessage: N.optional() }).optional(),
76
+ elicitation: i({ create: N.optional() }).optional()
77
77
  }).optional()
78
- }), we = i({
79
- list: F.optional(),
80
- cancel: F.optional(),
81
- requests: i({ tools: i({ call: F.optional() }).optional() }).optional()
82
- }), Te = o({
83
- experimental: S(r(), F).optional(),
78
+ }), Ee = i({
79
+ list: N.optional(),
80
+ cancel: N.optional(),
81
+ requests: i({ tools: i({ call: N.optional() }).optional() }).optional()
82
+ }), De = o({
83
+ experimental: S(r(), N).optional(),
84
84
  sampling: o({
85
- context: F.optional(),
86
- tools: F.optional()
85
+ context: N.optional(),
86
+ tools: N.optional()
87
87
  }).optional(),
88
- elicitation: Se.optional(),
89
- roots: o({ listChanged: k().optional() }).optional(),
90
- tasks: Ce.optional(),
91
- extensions: S(r(), F).optional()
92
- }), Ee = L.extend({
88
+ elicitation: we.optional(),
89
+ roots: o({ listChanged: O().optional() }).optional(),
90
+ tasks: Te.optional(),
91
+ extensions: S(r(), N).optional()
92
+ }), V = F.extend({
93
93
  protocolVersion: r(),
94
- capabilities: Te,
95
- clientInfo: xe
96
- }), De = R.extend({
94
+ capabilities: De,
95
+ clientInfo: Ce
96
+ }), Oe = I.extend({
97
97
  method: f("initialize"),
98
- params: Ee
99
- }), Oe = o({
100
- experimental: S(r(), F).optional(),
101
- logging: F.optional(),
102
- completions: F.optional(),
103
- prompts: o({ listChanged: k().optional() }).optional(),
98
+ params: V
99
+ }), ke = o({
100
+ experimental: S(r(), N).optional(),
101
+ logging: N.optional(),
102
+ completions: N.optional(),
103
+ prompts: o({ listChanged: O().optional() }).optional(),
104
104
  resources: o({
105
- subscribe: k().optional(),
106
- listChanged: k().optional()
105
+ subscribe: O().optional(),
106
+ listChanged: O().optional()
107
107
  }).optional(),
108
- tools: o({ listChanged: k().optional() }).optional(),
109
- tasks: we.optional(),
110
- extensions: S(r(), F).optional()
111
- }), ke = V.extend({
108
+ tools: o({ listChanged: O().optional() }).optional(),
109
+ tasks: Ee.optional(),
110
+ extensions: S(r(), N).optional()
111
+ }), Ae = z.extend({
112
112
  protocolVersion: r(),
113
- capabilities: Oe,
114
- serverInfo: xe,
113
+ capabilities: ke,
114
+ serverInfo: Ce,
115
115
  instructions: r().optional()
116
- }), Ae = B.extend({
117
- method: f("notifications/initialized"),
118
- params: z.optional()
119
116
  }), je = R.extend({
120
- method: f("server/discover"),
117
+ method: f("notifications/initialized"),
121
118
  params: L.optional()
122
- }), Me = V.extend({
119
+ }), Me = I.extend({
120
+ method: f("server/discover"),
121
+ params: F.optional()
122
+ }), Ne = z.extend({
123
123
  supportedVersions: m(r()),
124
- capabilities: Oe,
125
- serverInfo: xe,
124
+ capabilities: ke,
125
+ serverInfo: Ce,
126
126
  instructions: r().optional()
127
- }), Ne = R.extend({
127
+ }), Pe = I.extend({
128
128
  method: f("ping"),
129
- params: L.optional()
130
- }), Pe = o({
129
+ params: F.optional()
130
+ }), Fe = o({
131
131
  progress: p(),
132
132
  total: a(p()),
133
133
  message: a(r())
134
- }), Fe = o({
135
- ...z.shape,
136
- ...Pe.shape,
137
- progressToken: I
138
- }), Ie = B.extend({
134
+ }), H = o({
135
+ ...L.shape,
136
+ ...Fe.shape,
137
+ progressToken: ce
138
+ }), Ie = R.extend({
139
139
  method: f("notifications/progress"),
140
- params: Fe
141
- }), Le = L.extend({ cursor: oe.optional() }), U = R.extend({ params: Le.optional() }), Re = V.extend({ nextCursor: oe.optional() }), W = o({
140
+ params: H
141
+ }), Le = F.extend({ cursor: P.optional() }), U = I.extend({ params: Le.optional() }), Re = z.extend({ nextCursor: P.optional() }), W = o({
142
142
  uri: r(),
143
143
  mimeType: a(r()),
144
144
  _meta: S(r(), c()).optional()
@@ -153,8 +153,8 @@ var _e = V.strict(), ve = z.extend({
153
153
  priority: p().min(0).max(1).optional(),
154
154
  lastModified: d({ offset: !0 }).optional()
155
155
  }), He = o({
156
- ...be.shape,
157
- ...H.shape,
156
+ ...Se.shape,
157
+ ...B.shape,
158
158
  uri: r(),
159
159
  description: a(r()),
160
160
  mimeType: a(r()),
@@ -162,53 +162,53 @@ var _e = V.strict(), ve = z.extend({
162
162
  annotations: Ve.optional(),
163
163
  _meta: a(i({}))
164
164
  }), Ue = o({
165
- ...be.shape,
166
- ...H.shape,
165
+ ...Se.shape,
166
+ ...B.shape,
167
167
  uriTemplate: r(),
168
168
  description: a(r()),
169
169
  mimeType: a(r()),
170
170
  annotations: Ve.optional(),
171
171
  _meta: a(i({}))
172
- }), We = U.extend({ method: f("resources/list") }), q = Re.extend({ resources: m(He) }), Ge = U.extend({ method: f("resources/templates/list") }), Ke = Re.extend({ resourceTemplates: m(Ue) }), qe = L.extend({ uri: r() }), Je = qe, Ye = R.extend({
172
+ }), We = U.extend({ method: f("resources/list") }), q = Re.extend({ resources: m(He) }), Ge = U.extend({ method: f("resources/templates/list") }), Ke = Re.extend({ resourceTemplates: m(Ue) }), qe = F.extend({ uri: r() }), Je = qe, Ye = I.extend({
173
173
  method: f("resources/read"),
174
174
  params: Je
175
- }), Xe = V.extend({ contents: m(x([ze, K])) }), Ze = B.extend({
175
+ }), Xe = z.extend({ contents: m(x([ze, K])) }), Ze = R.extend({
176
176
  method: f("notifications/resources/list_changed"),
177
- params: z.optional()
178
- }), Qe = qe, $e = R.extend({
177
+ params: L.optional()
178
+ }), Qe = qe, $e = I.extend({
179
179
  method: f("resources/subscribe"),
180
180
  params: Qe
181
- }), et = qe, tt = R.extend({
181
+ }), et = qe, tt = I.extend({
182
182
  method: f("resources/unsubscribe"),
183
183
  params: et
184
184
  }), nt = o({
185
- toolsListChanged: k().optional(),
186
- promptsListChanged: k().optional(),
187
- resourcesListChanged: k().optional(),
185
+ toolsListChanged: O().optional(),
186
+ promptsListChanged: O().optional(),
187
+ resourcesListChanged: O().optional(),
188
188
  resourceSubscriptions: m(r()).optional()
189
- }), J = L.extend({ notifications: nt }), rt = R.extend({
189
+ }), J = F.extend({ notifications: nt }), rt = I.extend({
190
190
  method: f("subscriptions/listen"),
191
191
  params: J
192
- }), it = z.extend({ notifications: nt }), Y = B.extend({
192
+ }), it = L.extend({ notifications: nt }), Y = R.extend({
193
193
  method: f("notifications/subscriptions/acknowledged"),
194
194
  params: it
195
- }), at = i({ [ae]: de }), ot = V.extend({ _meta: at }), st = z.extend({ uri: r() }), ct = B.extend({
195
+ }), at = i({ [se]: pe }), ot = z.extend({ _meta: at }), st = L.extend({ uri: r() }), ct = R.extend({
196
196
  method: f("notifications/resources/updated"),
197
197
  params: st
198
198
  }), lt = o({
199
199
  name: r(),
200
200
  description: a(r()),
201
- required: a(k())
201
+ required: a(O())
202
202
  }), ut = o({
203
- ...be.shape,
204
- ...H.shape,
203
+ ...Se.shape,
204
+ ...B.shape,
205
205
  description: a(r()),
206
206
  arguments: a(m(lt)),
207
207
  _meta: a(i({}))
208
- }), dt = U.extend({ method: f("prompts/list") }), ft = Re.extend({ prompts: m(ut) }), pt = L.extend({
208
+ }), dt = U.extend({ method: f("prompts/list") }), ft = Re.extend({ prompts: m(ut) }), pt = F.extend({
209
209
  name: r(),
210
210
  arguments: S(r(), r()).optional()
211
- }), mt = R.extend({
211
+ }), mt = I.extend({
212
212
  method: f("prompts/get"),
213
213
  params: pt
214
214
  }), ht = o({
@@ -248,53 +248,53 @@ var _e = V.strict(), ve = z.extend({
248
248
  ]), St = o({
249
249
  role: Be,
250
250
  content: xt
251
- }), Ct = V.extend({
251
+ }), Ct = z.extend({
252
252
  description: r().optional(),
253
253
  messages: m(St)
254
- }), wt = B.extend({
254
+ }), wt = R.extend({
255
255
  method: f("notifications/prompts/list_changed"),
256
- params: z.optional()
256
+ params: L.optional()
257
257
  }), Tt = o({
258
258
  title: r().optional(),
259
- readOnlyHint: k().optional(),
260
- destructiveHint: k().optional(),
261
- idempotentHint: k().optional(),
262
- openWorldHint: k().optional()
259
+ readOnlyHint: O().optional(),
260
+ destructiveHint: O().optional(),
261
+ idempotentHint: O().optional(),
262
+ openWorldHint: O().optional()
263
263
  }), Et = o({ taskSupport: T([
264
264
  "required",
265
265
  "optional",
266
266
  "forbidden"
267
267
  ]).optional() }), Dt = o({
268
- ...be.shape,
269
- ...H.shape,
268
+ ...Se.shape,
269
+ ...B.shape,
270
270
  description: r().optional(),
271
271
  inputSchema: o({
272
272
  type: f("object"),
273
- properties: S(r(), P).optional(),
273
+ properties: S(r(), M).optional(),
274
274
  required: m(r()).optional()
275
275
  }).catchall(c()),
276
276
  outputSchema: i({ $schema: r().optional() }).optional(),
277
277
  annotations: Tt.optional(),
278
278
  execution: Et.optional(),
279
279
  _meta: S(r(), c()).optional()
280
- }), Ot = U.extend({ method: f("tools/list") }), kt = Re.extend({ tools: m(Dt) }), At = V.extend({
280
+ }), Ot = U.extend({ method: f("tools/list") }), kt = Re.extend({ tools: m(Dt) }), At = z.extend({
281
281
  content: m(xt).default([]),
282
282
  structuredContent: c().optional(),
283
- isError: k().optional()
283
+ isError: O().optional()
284
284
  });
285
- At.or(V.extend({ toolResult: c() }));
286
- var jt = ue.extend({
285
+ At.or(z.extend({ toolResult: c() }));
286
+ var jt = fe.extend({
287
287
  name: r(),
288
288
  arguments: S(r(), c()).optional()
289
- }), Mt = R.extend({
289
+ }), Mt = I.extend({
290
290
  method: f("tools/call"),
291
291
  params: jt
292
- }), Nt = B.extend({
292
+ }), Nt = R.extend({
293
293
  method: f("notifications/tools/list_changed"),
294
- params: z.optional()
294
+ params: L.optional()
295
295
  });
296
296
  o({
297
- autoRefresh: k().default(!0),
297
+ autoRefresh: O().default(!0),
298
298
  debounceMs: p().int().nonnegative().default(300)
299
299
  });
300
300
  var Pt = T([
@@ -306,14 +306,14 @@ var Pt = T([
306
306
  "critical",
307
307
  "alert",
308
308
  "emergency"
309
- ]), Ft = L.extend({ level: Pt }), It = R.extend({
309
+ ]), Ft = F.extend({ level: Pt }), It = I.extend({
310
310
  method: f("logging/setLevel"),
311
311
  params: Ft
312
- }), Lt = z.extend({
312
+ }), Lt = L.extend({
313
313
  level: Pt,
314
314
  logger: r().optional(),
315
315
  data: c()
316
- }), Rt = B.extend({
316
+ }), Rt = R.extend({
317
317
  method: f("notifications/message"),
318
318
  params: Lt
319
319
  }), zt = o({
@@ -330,13 +330,13 @@ var Pt = T([
330
330
  toolUseId: r().describe("The unique identifier for the corresponding tool call."),
331
331
  content: m(xt),
332
332
  structuredContent: c().optional(),
333
- isError: k().optional(),
333
+ isError: O().optional(),
334
334
  _meta: S(r(), c()).optional()
335
- }), Ht = ie("type", [
335
+ }), Ht = A("type", [
336
336
  ht,
337
337
  gt,
338
338
  _t
339
- ]), Ut = ie("type", [
339
+ ]), Ut = A("type", [
340
340
  ht,
341
341
  gt,
342
342
  _t,
@@ -346,7 +346,7 @@ var Pt = T([
346
346
  role: Be,
347
347
  content: x([Ut, m(Ut)]),
348
348
  _meta: S(r(), c()).optional()
349
- }), Gt = ue.extend({
349
+ }), Gt = fe.extend({
350
350
  messages: m(Wt),
351
351
  modelPreferences: zt.optional(),
352
352
  systemPrompt: r().optional(),
@@ -358,13 +358,13 @@ var Pt = T([
358
358
  temperature: p().optional(),
359
359
  maxTokens: p().int(),
360
360
  stopSequences: m(r()).optional(),
361
- metadata: F.optional(),
361
+ metadata: N.optional(),
362
362
  tools: m(Dt).optional(),
363
363
  toolChoice: Bt.optional()
364
- }), Kt = R.extend({
364
+ }), Kt = I.extend({
365
365
  method: f("sampling/createMessage"),
366
366
  params: Gt
367
- }), qt = V.extend({
367
+ }), qt = z.extend({
368
368
  model: r(),
369
369
  stopReason: a(T([
370
370
  "endTurn",
@@ -373,7 +373,7 @@ var Pt = T([
373
373
  ]).or(r())),
374
374
  role: Be,
375
375
  content: Ht
376
- }), Jt = V.extend({
376
+ }), Jt = z.extend({
377
377
  model: r(),
378
378
  stopReason: a(T([
379
379
  "endTurn",
@@ -387,7 +387,7 @@ var Pt = T([
387
387
  type: f("boolean"),
388
388
  title: r().optional(),
389
389
  description: r().optional(),
390
- default: k().optional()
390
+ default: O().optional()
391
391
  }), Xt = o({
392
392
  type: f("string"),
393
393
  title: r().optional(),
@@ -461,7 +461,7 @@ var Pt = T([
461
461
  Yt,
462
462
  Xt,
463
463
  Zt
464
- ]), tn = x([ue.extend({
464
+ ]), tn = x([fe.extend({
465
465
  mode: f("form").optional(),
466
466
  message: r(),
467
467
  requestedSchema: o({
@@ -469,18 +469,18 @@ var Pt = T([
469
469
  properties: S(r(), en),
470
470
  required: m(r()).optional()
471
471
  }).catchall(c())
472
- }), ue.extend({
472
+ }), fe.extend({
473
473
  mode: f("url"),
474
474
  message: r(),
475
475
  elicitationId: r(),
476
476
  url: r().url()
477
- })]), nn = R.extend({
477
+ })]), nn = I.extend({
478
478
  method: f("elicitation/create"),
479
479
  params: tn
480
- }), rn = z.extend({ elicitationId: r() }), an = B.extend({
480
+ }), rn = L.extend({ elicitationId: r() }), an = R.extend({
481
481
  method: f("notifications/elicitation/complete"),
482
482
  params: rn
483
- }), on = V.extend({
483
+ }), on = z.extend({
484
484
  action: T([
485
485
  "accept",
486
486
  "decline",
@@ -489,7 +489,7 @@ var Pt = T([
489
489
  content: u((e) => e === null ? void 0 : e, S(r(), x([
490
490
  r(),
491
491
  p(),
492
- k(),
492
+ O(),
493
493
  m(r())
494
494
  ])).optional())
495
495
  }), sn = o({
@@ -498,30 +498,30 @@ var Pt = T([
498
498
  }), cn = o({
499
499
  type: f("ref/prompt"),
500
500
  name: r()
501
- }), ln = L.extend({
501
+ }), ln = F.extend({
502
502
  ref: x([cn, sn]),
503
503
  argument: o({
504
504
  name: r(),
505
505
  value: r()
506
506
  }),
507
507
  context: o({ arguments: S(r(), r()).optional() }).optional()
508
- }), un = R.extend({
508
+ }), un = I.extend({
509
509
  method: f("completion/complete"),
510
510
  params: ln
511
- }), dn = V.extend({ completion: i({
511
+ }), dn = z.extend({ completion: i({
512
512
  values: m(r()).max(100),
513
513
  total: a(p().int()),
514
- hasMore: a(k())
514
+ hasMore: a(O())
515
515
  }) }), fn = o({
516
516
  uri: r().startsWith("file://"),
517
517
  name: r().optional(),
518
518
  _meta: S(r(), c()).optional()
519
- }), pn = R.extend({
519
+ }), pn = I.extend({
520
520
  method: f("roots/list"),
521
- params: L.optional()
522
- }), mn = V.extend({ roots: m(fn) }), hn = B.extend({
521
+ params: F.optional()
522
+ }), mn = z.extend({ roots: m(fn) }), hn = R.extend({
523
523
  method: f("notifications/roots/list_changed"),
524
- params: z.optional()
524
+ params: L.optional()
525
525
  });
526
526
  i({
527
527
  ttl: p().optional(),
@@ -542,24 +542,24 @@ var gn = T([
542
542
  pollInterval: a(p()),
543
543
  statusMessage: a(r())
544
544
  });
545
- V.extend({ task: _n });
546
- var vn = z.merge(_n);
547
- B.extend({
545
+ z.extend({ task: _n });
546
+ var vn = L.merge(_n);
547
+ R.extend({
548
548
  method: f("notifications/tasks/status"),
549
549
  params: vn
550
- }), R.extend({
550
+ }), I.extend({
551
551
  method: f("tasks/get"),
552
- params: L.extend({ taskId: r() })
553
- }), V.merge(_n), R.extend({
552
+ params: F.extend({ taskId: r() })
553
+ }), z.merge(_n), I.extend({
554
554
  method: f("tasks/result"),
555
- params: L.extend({ taskId: r() })
556
- }), V.loose(), U.extend({ method: f("tasks/list") }), Re.extend({ tasks: m(_n) }), R.extend({
555
+ params: F.extend({ taskId: r() })
556
+ }), z.loose(), U.extend({ method: f("tasks/list") }), Re.extend({ tasks: m(_n) }), I.extend({
557
557
  method: f("tasks/cancel"),
558
- params: L.extend({ taskId: r() })
559
- }), V.merge(_n), x([
560
- Ne,
561
- De,
562
- je,
558
+ params: F.extend({ taskId: r() })
559
+ }), z.merge(_n), x([
560
+ Pe,
561
+ Oe,
562
+ Me,
563
563
  un,
564
564
  It,
565
565
  mt,
@@ -573,23 +573,23 @@ B.extend({
573
573
  Mt,
574
574
  Ot
575
575
  ]), x([
576
- ye,
576
+ xe,
577
577
  Ie,
578
- Ae,
578
+ je,
579
579
  hn
580
580
  ]), x([
581
- _e,
581
+ ye,
582
582
  qt,
583
583
  Jt,
584
584
  on,
585
585
  mn
586
586
  ]), x([
587
- Ne,
587
+ Pe,
588
588
  Kt,
589
589
  nn,
590
590
  pn
591
591
  ]), x([
592
- ye,
592
+ xe,
593
593
  Ie,
594
594
  Rt,
595
595
  ct,
@@ -599,9 +599,9 @@ B.extend({
599
599
  Y,
600
600
  an
601
601
  ]), x([
602
- _e,
603
- ke,
604
- Me,
602
+ ye,
603
+ Ae,
604
+ Ne,
605
605
  dn,
606
606
  Ct,
607
607
  ft,
@@ -633,10 +633,10 @@ i({
633
633
  resource_documentation: r().optional(),
634
634
  resource_policy_uri: r().url().optional(),
635
635
  resource_tos_uri: r().url().optional(),
636
- tls_client_certificate_bound_access_tokens: k().optional(),
636
+ tls_client_certificate_bound_access_tokens: O().optional(),
637
637
  authorization_details_types_supported: m(r()).optional(),
638
638
  dpop_signing_alg_values_supported: m(r()).optional(),
639
- dpop_bound_access_tokens_required: k().optional()
639
+ dpop_bound_access_tokens_required: O().optional()
640
640
  });
641
641
  var yn = i({
642
642
  issuer: r(),
@@ -657,8 +657,8 @@ var yn = i({
657
657
  introspection_endpoint_auth_methods_supported: m(r()).optional(),
658
658
  introspection_endpoint_auth_signing_alg_values_supported: m(r()).optional(),
659
659
  code_challenge_methods_supported: m(r()).optional(),
660
- client_id_metadata_document_supported: k().optional(),
661
- authorization_response_iss_parameter_supported: k().optional().catch(void 0)
660
+ client_id_metadata_document_supported: O().optional(),
661
+ authorization_response_iss_parameter_supported: O().optional().catch(void 0)
662
662
  });
663
663
  o({
664
664
  ...i({
@@ -691,14 +691,14 @@ o({
691
691
  service_documentation: r().optional(),
692
692
  claims_locales_supported: m(r()).optional(),
693
693
  ui_locales_supported: m(r()).optional(),
694
- claims_parameter_supported: k().optional(),
695
- request_parameter_supported: k().optional(),
696
- request_uri_parameter_supported: k().optional(),
697
- require_request_uri_registration: k().optional(),
694
+ claims_parameter_supported: O().optional(),
695
+ request_parameter_supported: O().optional(),
696
+ request_uri_parameter_supported: O().optional(),
697
+ require_request_uri_registration: O().optional(),
698
698
  op_policy_uri: X.optional(),
699
699
  op_tos_uri: X.optional(),
700
- client_id_metadata_document_supported: k().optional(),
701
- authorization_response_iss_parameter_supported: k().optional().catch(void 0)
700
+ client_id_metadata_document_supported: O().optional(),
701
+ authorization_response_iss_parameter_supported: O().optional().catch(void 0)
702
702
  }).shape,
703
703
  ...yn.pick({ code_challenge_methods_supported: !0 }).shape
704
704
  }), o({
@@ -868,7 +868,7 @@ var Cn = class {
868
868
  ]).describe("CSS variable keys available to MCP apps for theming.").describe("Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation."), x([r(), y()]).describe("Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.")).describe("Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation."), On = o({
869
869
  method: f("ui/open-link"),
870
870
  params: o({ url: r().describe("URL to open in the host's browser") })
871
- }), kn = o({ isError: k().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), An = o({ isError: k().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), jn = o({ isError: k().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), Mn = o({
871
+ }), kn = o({ isError: O().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), An = o({ isError: O().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), jn = o({ isError: O().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), Mn = o({
872
872
  method: f("ui/notifications/sandbox-proxy-ready"),
873
873
  params: o({})
874
874
  }), Nn = o({
@@ -920,8 +920,8 @@ var Rn = S(r(), c()), zn = o({
920
920
  experimental: o({}).optional().describe("Experimental features (structure TBD)."),
921
921
  openLinks: o({}).optional().describe("Host supports opening external URLs."),
922
922
  downloadFile: o({}).optional().describe("Host supports file downloads via ui/download-file."),
923
- serverTools: o({ listChanged: k().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."),
924
- serverResources: o({ listChanged: k().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
923
+ serverTools: o({ listChanged: O().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."),
924
+ serverResources: o({ listChanged: O().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
925
925
  logging: o({}).optional().describe("Host accepts log messages."),
926
926
  sandbox: o({
927
927
  permissions: Pn.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
@@ -932,7 +932,7 @@ var Rn = S(r(), c()), zn = o({
932
932
  sampling: o({ tools: o({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.") }).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")
933
933
  }), Hn = o({
934
934
  experimental: o({}).optional().describe("Experimental features (structure TBD)."),
935
- tools: o({ listChanged: k().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
935
+ tools: o({ listChanged: O().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
936
936
  availableDisplayModes: m(En).optional().describe("Display modes the app supports.")
937
937
  }), Un = o({
938
938
  method: f("ui/notifications/initialized"),
@@ -942,7 +942,7 @@ o({
942
942
  csp: Nn.optional().describe("Content Security Policy configuration for UI resources."),
943
943
  permissions: Pn.optional().describe("Sandbox permissions requested by the UI resource."),
944
944
  domain: r().optional().describe("Dedicated origin for view sandbox.\n\nUseful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.\n\n**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:\n- Hash-based subdomains (e.g., `{hash}.claudemcpcontent.com`)\n- URL-derived subdomains (e.g., `www-example-com.oaiusercontent.com`)\n\nIf omitted, host uses default sandbox origin (typically per-conversation)."),
945
- prefersBorder: k().optional().describe("Visual boundary preference - true if view prefers a visible border.\n\nBoolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.\n\n- `true`: request visible border + background\n- `false`: request no visible border + background\n- omitted: host decides border")
945
+ prefersBorder: O().optional().describe("Visual boundary preference - true if view prefers a visible border.\n\nBoolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.\n\n- `true`: request visible border + background\n- `false`: request no visible border + background\n- omitted: host decides border")
946
946
  });
947
947
  var Wn = o({
948
948
  method: f("ui/request-display-mode"),
@@ -951,8 +951,8 @@ var Wn = o({
951
951
  o({
952
952
  resourceUri: r().optional(),
953
953
  visibility: m(Kn).optional().describe("Who can access this tool. Default: [\"model\", \"app\"]\n- \"model\": Tool visible to and callable by the agent\n- \"app\": Tool callable by the app from this server only"),
954
- csp: A().optional(),
955
- permissions: A().optional()
954
+ csp: k().optional(),
955
+ permissions: k().optional()
956
956
  }), o({ mimeTypes: m(r()).optional().describe("Array of supported MIME types for UI resources.\nMust include `\"text/html;profile=mcp-app\"` for MCP Apps support.") });
957
957
  var qn = o({
958
958
  method: f("ui/download-file"),
@@ -978,7 +978,7 @@ o({
978
978
  });
979
979
  var Yn = o({
980
980
  toolInfo: o({
981
- id: de.optional().describe("JSON-RPC id of the tools/call request."),
981
+ id: pe.optional().describe("JSON-RPC id of the tools/call request."),
982
982
  tool: Dt.describe("Tool definition including name, inputSchema, etc.")
983
983
  }).optional().describe("Metadata of the tool call that instantiated this App."),
984
984
  theme: Tn.optional().describe("Current color theme preference."),
@@ -995,8 +995,8 @@ var Yn = o({
995
995
  f("mobile")
996
996
  ]).optional().describe("Platform type for responsive design decisions."),
997
997
  deviceCapabilities: o({
998
- touch: k().optional().describe("Whether the device supports touch input."),
999
- hover: k().optional().describe("Whether the device supports hover interactions.")
998
+ touch: O().optional().describe("Whether the device supports touch input."),
999
+ hover: O().optional().describe("Whether the device supports hover interactions.")
1000
1000
  }).optional().describe("Device input capabilities."),
1001
1001
  safeAreaInsets: o({
1002
1002
  top: p().describe("Top safe area inset in pixels."),
@@ -1018,13 +1018,13 @@ var Xn = o({
1018
1018
  }), Zn = o({
1019
1019
  method: f("ui/initialize"),
1020
1020
  params: o({
1021
- appInfo: xe.describe("App identification (name and version)."),
1021
+ appInfo: Ce.describe("App identification (name and version)."),
1022
1022
  appCapabilities: Hn.describe("Features and capabilities this app provides."),
1023
1023
  protocolVersion: r().describe("Protocol version this app supports.")
1024
1024
  })
1025
1025
  }), Qn = o({
1026
1026
  protocolVersion: r().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
1027
- hostInfo: xe.describe("Host application identification and version."),
1027
+ hostInfo: Ce.describe("Host application identification and version."),
1028
1028
  hostCapabilities: Vn.describe("Features and capabilities provided by the host."),
1029
1029
  hostContext: Yn.describe("Rich context about the host environment.")
1030
1030
  }).passthrough(), $n = class {
@@ -1037,7 +1037,7 @@ var Xn = o({
1037
1037
  console.debug("Ignoring message from unknown source", e);
1038
1038
  return;
1039
1039
  }
1040
- let n = ge.safeParse(e.data);
1040
+ let n = ve.safeParse(e.data);
1041
1041
  n.success ? (console.debug("Parsed message", n.data), this.onmessage?.(n.data)) : e.data?.jsonrpc === "2.0" ? (console.error("Failed to parse message", n.error.message, e), this.onerror?.(Error("Invalid JSON-RPC message received: " + n.error.message))) : console.debug("Ignoring non-JSON-RPC message", n.error.message, e);
1042
1042
  };
1043
1043
  }
@@ -1219,7 +1219,7 @@ var nr = [wn], rr = class extends D {
1219
1219
  set onupdatemodelcontext(e) {
1220
1220
  this.warnIfRequestHandlerReplaced("onupdatemodelcontext", this._onupdatemodelcontext, e), this._onupdatemodelcontext = e, this.setRequestHandler("ui/update-model-context", {
1221
1221
  params: Xn.shape.params,
1222
- result: _e
1222
+ result: ye
1223
1223
  }, async (e, t) => {
1224
1224
  if (!this._onupdatemodelcontext) throw Error("No onupdatemodelcontext handler set");
1225
1225
  return this._onupdatemodelcontext(e, t);
@@ -2135,7 +2135,7 @@ var Vr = class extends Rr {
2135
2135
  a = this.opts.wrapTransport(a, e);
2136
2136
  }
2137
2137
  let o = this.buildClientOptions();
2138
- Z.debug("Creating Client with capabilities:", JSON.stringify(o.capabilities, null, 2)), this.client = new O(this.clientInfo, o), this.setupRootsHandler(), this.setupSamplingHandler(), this.setupElicitationHandler(), Z.debug("Roots/sampling/elicitation handlers registered before connect");
2138
+ Z.debug("Creating Client with capabilities:", JSON.stringify(o.capabilities, null, 2)), this.client = new ie(this.clientInfo, o), this.setupRootsHandler(), this.setupSamplingHandler(), this.setupElicitationHandler(), Z.debug("Roots/sampling/elicitation handlers registered before connect");
2139
2139
  try {
2140
2140
  let e;
2141
2141
  if (await Promise.race([this.client.connect(a), new Promise((t, n) => {
@@ -2198,7 +2198,7 @@ var Vr = class extends Rr {
2198
2198
  }
2199
2199
  await super.cleanupResources();
2200
2200
  }
2201
- }, Hr = "2.0.0-beta.0";
2201
+ }, Hr = "2.0.0-beta.5";
2202
2202
  function Ur() {
2203
2203
  return Hr;
2204
2204
  }
@@ -2786,52 +2786,8 @@ async function ci(e, t) {
2786
2786
  await fetch(e, t);
2787
2787
  } catch {}
2788
2788
  }
2789
- var li = "https://eu.i.posthog.com", ui = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", di = "https://mcpuse.gateway.scarf.sh/events-ts", fi = "https://mcpuse.gateway.scarf.sh/simple/", pi = 1800, mi = /* @__PURE__ */ new Set([
2790
- "query",
2791
- "response",
2792
- "messages"
2793
- ]);
2794
- function hi(e) {
2795
- if (e == null) return "";
2796
- if (typeof e == "string") return e;
2797
- if (typeof e == "number" || typeof e == "boolean") return String(e);
2798
- try {
2799
- return JSON.stringify(e);
2800
- } catch {
2801
- return String(e);
2802
- }
2803
- }
2804
- function gi(e, t = fi) {
2805
- let n = new URLSearchParams();
2806
- for (let [t, r] of Object.entries(e)) {
2807
- let e = hi(r);
2808
- mi.has(t) && e.length > 120 && (e = `${e.slice(0, 117)}...`), e !== "" && n.set(t, e);
2809
- }
2810
- let r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`;
2811
- if (r.length <= pi) return r;
2812
- let i = [...n.keys()].sort((e, t) => (n.get(t)?.length ?? 0) - (n.get(e)?.length ?? 0));
2813
- for (let e of i) {
2814
- if (r.length <= pi) break;
2815
- e === "event" || e === "user_id" || (n.delete(e), r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`);
2816
- }
2817
- return r.slice(0, pi);
2818
- }
2819
- function _i(e, t) {
2820
- return ci(t, {
2821
- method: "POST",
2822
- headers: { "Content-Type": "application/json" },
2823
- keepalive: !0,
2824
- body: JSON.stringify(e)
2825
- });
2826
- }
2827
- function vi(e, t) {
2828
- try {
2829
- let n = gi(e, t), r = new Image();
2830
- r.referrerPolicy = "no-referrer-when-downgrade", r.src = n;
2831
- } catch {}
2832
- return Promise.resolve();
2833
- }
2834
- function yi(e) {
2789
+ var li = "https://eu.i.posthog.com", ui = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
2790
+ function di(e) {
2835
2791
  let t = e.host ?? li, n = e.apiKey ?? ui;
2836
2792
  return ci(`${t}/i/v0/e/`, {
2837
2793
  method: "POST",
@@ -2846,30 +2802,19 @@ function yi(e) {
2846
2802
  })
2847
2803
  });
2848
2804
  }
2849
- function bi(e, t = di) {
2850
- return typeof window < "u" ? vi(e, t === di ? fi : t) : _i(e, t);
2851
- }
2852
- function xi() {
2805
+ function fi() {
2853
2806
  return globalThis.crypto.randomUUID();
2854
2807
  }
2855
- function Si() {
2808
+ function pi() {
2856
2809
  let e = new Uint8Array(8);
2857
2810
  return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
2858
2811
  }
2859
- function Ci(e, t) {
2860
- let n = (e) => e.split("-")[0].split(".").map((e) => parseInt(e, 10) || 0), r = n(e), i = n(t), a = Math.max(r.length, i.length);
2861
- for (let e = 0; e < a; e++) {
2862
- let t = r[e] ?? 0, n = i[e] ?? 0;
2863
- if (t !== n) return t > n;
2864
- }
2865
- return !1;
2866
- }
2867
- var wi = "mcp_use_user_id", Ti = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", Ei = "https://eu.i.posthog.com", Di = null;
2868
- function Oi() {
2812
+ var mi = "mcp_use_user_id", hi = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", gi = "https://eu.i.posthog.com", _i = null;
2813
+ function vi() {
2869
2814
  return typeof localStorage < "u" && typeof localStorage.getItem == "function" && typeof localStorage.setItem == "function" && typeof localStorage.removeItem == "function";
2870
2815
  }
2871
- function ki() {
2872
- if (!Oi()) return null;
2816
+ function yi() {
2817
+ if (!vi()) return null;
2873
2818
  try {
2874
2819
  localStorage.setItem("__mcp_use_test__", "1"), localStorage.removeItem("__mcp_use_test__");
2875
2820
  } catch {
@@ -2878,66 +2823,60 @@ function ki() {
2878
2823
  return {
2879
2824
  getUserId() {
2880
2825
  try {
2881
- return localStorage.getItem(wi);
2826
+ return localStorage.getItem(mi);
2882
2827
  } catch {
2883
2828
  return null;
2884
2829
  }
2885
2830
  },
2886
2831
  setUserId(e) {
2887
2832
  try {
2888
- localStorage.setItem(wi, e);
2833
+ localStorage.setItem(mi, e);
2889
2834
  } catch {}
2890
- },
2891
- getDownloadedVersion: () => null,
2892
- setDownloadedVersion: () => void 0
2835
+ }
2893
2836
  };
2894
2837
  }
2895
- function Ai() {
2838
+ function bi() {
2896
2839
  try {
2897
2840
  return globalThis.Bun === void 0 ? globalThis.Deno === void 0 ? typeof navigator < "u" && navigator.userAgent?.includes("Cloudflare-Workers") ? "cloudflare-workers" : globalThis.EdgeRuntime === void 0 ? typeof window < "u" && typeof document < "u" ? "browser" : typeof process < "u" && process.versions?.node !== void 0 ? "node" : "unknown" : "edge" : "deno" : "bun";
2898
2841
  } catch {
2899
2842
  return "unknown";
2900
2843
  }
2901
2844
  }
2902
- function ji() {
2845
+ function xi() {
2903
2846
  if (typeof process < "u" && {}.MCP_USE_TELEMETRY_SOURCE) return {}.MCP_USE_TELEMETRY_SOURCE;
2904
2847
  try {
2905
- if (Oi()) return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE") ?? void 0;
2848
+ if (vi()) return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE") ?? void 0;
2906
2849
  } catch {}
2907
2850
  }
2908
- function Mi() {
2851
+ function Si() {
2909
2852
  if (typeof window < "u" && window.__MCP_USE_ANONYMIZED_TELEMETRY__ === !1 || typeof process < "u" && {}.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false") return !0;
2910
2853
  try {
2911
- if (Oi() && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") return !0;
2854
+ if (vi() && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") return !0;
2912
2855
  } catch {}
2913
2856
  return !1;
2914
2857
  }
2915
- function Ni() {
2858
+ function Ci() {
2916
2859
  try {
2917
- return `session-${xi()}`;
2860
+ return `session-${fi()}`;
2918
2861
  } catch {
2919
- return `session-${Date.now()}-${Si()}`;
2862
+ return `session-${Date.now()}-${pi()}`;
2920
2863
  }
2921
2864
  }
2922
- var Pi = class e {
2865
+ var wi = class e {
2923
2866
  static instance = null;
2924
2867
  UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
2925
2868
  _currUserId = null;
2926
2869
  _telemetryEnabled = !1;
2927
2870
  _pending = /* @__PURE__ */ new Set();
2928
- _scarfEnabled = !1;
2929
2871
  _runtimeEnvironment;
2930
2872
  _storageCapability;
2931
2873
  _storage;
2932
- _fsBacked;
2933
2874
  _source;
2934
2875
  _productVersion;
2935
2876
  constructor() {
2936
- this._runtimeEnvironment = Ai(), this._fsBacked = Di !== null, this._storage = Di ?? ki() ?? null, this._storageCapability = this._storage ? "persistent" : "session-only", this._source = ji() || this._runtimeEnvironment;
2937
- let e = Mi(), t = this._runtimeEnvironment !== "unknown";
2938
- e ? (this._telemetryEnabled = !1, Z.debug("Telemetry disabled via opt-out")) : t ? (Z.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0, this._scarfEnabled = !0, this._fsBacked && setTimeout(() => {
2939
- this.trackPackageDownload({ triggered_by: "initialization" }).catch((e) => Z.debug(`Failed to track package download: ${e}`));
2940
- }, 0)) : (this._telemetryEnabled = !1, Z.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
2877
+ this._runtimeEnvironment = bi(), this._storage = _i ?? yi() ?? null, this._storageCapability = this._storage ? "persistent" : "session-only", this._source = xi() || this._runtimeEnvironment;
2878
+ let e = Si(), t = this._runtimeEnvironment !== "unknown";
2879
+ e ? (this._telemetryEnabled = !1, Z.debug("Telemetry disabled via opt-out")) : t ? (Z.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0) : (this._telemetryEnabled = !1, Z.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
2941
2880
  }
2942
2881
  get runtimeEnvironment() {
2943
2882
  return this._runtimeEnvironment;
@@ -2951,7 +2890,7 @@ var Pi = class e {
2951
2890
  setSource(e) {
2952
2891
  this._source = e;
2953
2892
  try {
2954
- Oi() && localStorage.setItem("MCP_USE_TELEMETRY_SOURCE", e);
2893
+ vi() && localStorage.setItem("MCP_USE_TELEMETRY_SOURCE", e);
2955
2894
  } catch {}
2956
2895
  Z.debug(`Telemetry source set to: ${e}`);
2957
2896
  }
@@ -2962,7 +2901,7 @@ var Pi = class e {
2962
2901
  this._productVersion = e;
2963
2902
  }
2964
2903
  get isEnabled() {
2965
- return this._telemetryEnabled || this._scarfEnabled;
2904
+ return this._telemetryEnabled;
2966
2905
  }
2967
2906
  get userId() {
2968
2907
  if (this._currUserId) return this._currUserId;
@@ -2970,56 +2909,31 @@ var Pi = class e {
2970
2909
  if (this._storage) {
2971
2910
  let e = this._storage.getUserId();
2972
2911
  if (e) return this._currUserId = e, e;
2973
- let t = xi();
2912
+ let t = fi();
2974
2913
  return this._storage.setUserId(t), this._currUserId = t, t;
2975
2914
  }
2976
- this._currUserId = Ni();
2915
+ this._currUserId = Ci();
2977
2916
  } catch {
2978
2917
  this._currUserId = this.UNKNOWN_USER_ID;
2979
2918
  }
2980
2919
  return this._currUserId;
2981
2920
  }
2982
2921
  async capture(e) {
2983
- if (!this._telemetryEnabled && !this._scarfEnabled) return;
2922
+ if (!this._telemetryEnabled) return;
2984
2923
  let t = this.userId, n = {
2985
2924
  ...e.properties,
2986
2925
  mcp_use_version: this._productVersion ?? Ur(),
2987
2926
  language: "typescript",
2988
2927
  source: this._source,
2989
2928
  runtime: this._runtimeEnvironment
2990
- };
2991
- if (this._telemetryEnabled) {
2992
- let r = yi({
2993
- host: Ei,
2994
- apiKey: Ti,
2995
- event: e.name,
2996
- distinctId: t,
2997
- properties: n
2998
- });
2999
- this._pending.add(r), r.finally(() => this._pending.delete(r));
3000
- }
3001
- if (this._scarfEnabled) {
3002
- let r = bi({
3003
- ...n,
3004
- user_id: t,
3005
- event: e.name
3006
- });
3007
- this._pending.add(r), r.finally(() => this._pending.delete(r));
3008
- }
3009
- }
3010
- async trackPackageDownload(e) {
3011
- if (!this._scarfEnabled || !this._fsBacked || !this._storage) return;
3012
- let t = Ur(), n = this._storage.getDownloadedVersion(), r = !1, i = !1;
3013
- n ? Ci(t, n) && (i = !0, this._storage.setDownloadedVersion(t)) : (i = !0, r = !0, this._storage.setDownloadedVersion(t)), i && await bi({
3014
- ...e || {},
3015
- mcp_use_version: t,
3016
- user_id: this.userId,
3017
- event: "package_download",
3018
- first_download: r,
3019
- language: "typescript",
3020
- source: this._source,
3021
- runtime: this._runtimeEnvironment
2929
+ }, r = di({
2930
+ host: gi,
2931
+ apiKey: hi,
2932
+ event: e.name,
2933
+ distinctId: t,
2934
+ properties: n
3022
2935
  });
2936
+ this._pending.add(r), r.finally(() => this._pending.delete(r));
3023
2937
  }
3024
2938
  async trackAgentExecution(e) {
3025
2939
  this.isEnabled && await this.capture(new ri(e));
@@ -3076,9 +2990,9 @@ var Pi = class e {
3076
2990
  });
3077
2991
  }
3078
2992
  identify(e, t) {
3079
- this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled && yi({
3080
- host: Ei,
3081
- apiKey: Ti,
2993
+ this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled && di({
2994
+ host: gi,
2995
+ apiKey: hi,
3082
2996
  event: "$identify",
3083
2997
  distinctId: e,
3084
2998
  properties: { $set: t ?? {} }
@@ -3097,21 +3011,21 @@ var Pi = class e {
3097
3011
  Z.debug(`Error flushing telemetry captures: ${e}`);
3098
3012
  }
3099
3013
  }
3100
- }, Fi = 5 * 6e4;
3101
- function Ii(e, t = 0) {
3014
+ }, Ti = 5 * 6e4;
3015
+ function Ei(e, t = 0) {
3102
3016
  if (!e || t > 5) return !1;
3103
3017
  if (e instanceof E) return !0;
3104
3018
  if (e instanceof Error) {
3105
3019
  if (e.code === 401 || e.name === "UnauthorizedError") return !0;
3106
3020
  let n = e.message ?? "";
3107
- if (n.includes("401") || n.includes("Unauthorized") || e.cause && Ii(e.cause, t + 1)) return !0;
3021
+ if (n.includes("401") || n.includes("Unauthorized") || e.cause && Ei(e.cause, t + 1)) return !0;
3108
3022
  let r = e.data;
3109
- if (r?.cause && Ii(r.cause, t + 1)) return !0;
3023
+ if (r?.cause && Ei(r.cause, t + 1)) return !0;
3110
3024
  }
3111
3025
  return !1;
3112
3026
  }
3113
- async function Li(e, t, n = {}) {
3114
- let r = e, i = n.timeoutMs ?? Fi, a = n.fetchFn ?? r.getProxyFetch?.() ?? void 0;
3027
+ async function Di(e, t, n = {}) {
3028
+ let r = e, i = n.timeoutMs ?? Ti, a = n.fetchFn ?? r.getProxyFetch?.() ?? void 0;
3115
3029
  if (!r.hasPendingFlow) {
3116
3030
  let n = await b(e, {
3117
3031
  serverUrl: t,
@@ -3128,9 +3042,9 @@ async function Li(e, t, n = {}) {
3128
3042
  });
3129
3043
  return;
3130
3044
  }
3131
- await Ri(r, i);
3045
+ await Oi(r, i);
3132
3046
  }
3133
- async function Ri(e, t) {
3047
+ async function Oi(e, t) {
3134
3048
  if (typeof window > "u") throw Error("OAuth redirect requires a browser environment or a provider with getAuthorizationCode()");
3135
3049
  if (e.useRedirectFlow) return;
3136
3050
  let n = e.getKey?.("tokens");
@@ -3154,7 +3068,7 @@ async function Ri(e, t) {
3154
3068
  }
3155
3069
  }
3156
3070
  mr();
3157
- var zi = class {
3071
+ var ki = class {
3158
3072
  connector;
3159
3073
  autoConnect;
3160
3074
  constructor(e, t = !0) {
@@ -3248,17 +3162,17 @@ var zi = class {
3248
3162
  async request(e, t = null, n) {
3249
3163
  return this.connector.request(e, t, n);
3250
3164
  }
3251
- }, Bi;
3252
- function Vi(e, t) {
3253
- Bi?.addServer(e, t);
3165
+ }, Ai;
3166
+ function ji(e, t) {
3167
+ Ai?.addServer(e, t);
3254
3168
  }
3255
- function Hi(e) {
3256
- Bi?.removeServer(e);
3169
+ function Mi(e) {
3170
+ Ai?.removeServer(e);
3257
3171
  }
3258
- function Ui(e) {
3172
+ function Ni(e) {
3259
3173
  return !!e && typeof e == "object" && "redirectUrl" in e && "clientMetadata" in e;
3260
3174
  }
3261
- var Wi = class {
3175
+ var Pi = class {
3262
3176
  config = {};
3263
3177
  sessions = {};
3264
3178
  activeSessions = [];
@@ -3269,10 +3183,10 @@ var Wi = class {
3269
3183
  throw Error("fromDict must be implemented by concrete class");
3270
3184
  }
3271
3185
  addServer(e, t) {
3272
- this.config.mcpServers = this.config.mcpServers || {}, this.config.mcpServers[e] = t, Vi(e, t);
3186
+ this.config.mcpServers = this.config.mcpServers || {}, this.config.mcpServers[e] = t, ji(e, t);
3273
3187
  }
3274
3188
  async removeServer(e) {
3275
- this.config.mcpServers?.[e] && (await this.closeSession(e), delete this.config.mcpServers[e], Hi(e));
3189
+ this.config.mcpServers?.[e] && (await this.closeSession(e), delete this.config.mcpServers[e], Mi(e));
3276
3190
  }
3277
3191
  getServerNames() {
3278
3192
  return Object.keys(this.config.mcpServers ?? {});
@@ -3293,17 +3207,17 @@ var Wi = class {
3293
3207
  ...r,
3294
3208
  authProvider: i
3295
3209
  };
3296
- } else "authProvider" in r && r.authProvider && Ui(r.authProvider) && (i = r.authProvider);
3210
+ } else "authProvider" in r && r.authProvider && Ni(r.authProvider) && (i = r.authProvider);
3297
3211
  let a = async () => {
3298
- let e = new zi(await Promise.resolve(this.createConnectorFromConfig(r)));
3212
+ let e = new ki(await Promise.resolve(this.createConnectorFromConfig(r)));
3299
3213
  return t && await e.initialize(), e;
3300
3214
  }, o;
3301
3215
  try {
3302
3216
  o = await a();
3303
3217
  } catch (n) {
3304
3218
  let s = r;
3305
- if (!t || !i || !("url" in s) || !Ii(n) || i.preventAutoAuth) throw n;
3306
- Z.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await Li(i, s.url), o = await a();
3219
+ if (!t || !i || !("url" in s) || !Ei(n) || i.preventAutoAuth) throw n;
3220
+ Z.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await Di(i, s.url), o = await a();
3307
3221
  }
3308
3222
  return this.sessions[e] = o, this.activeSessions.includes(e) || this.activeSessions.push(e), o;
3309
3223
  }
@@ -3358,9 +3272,9 @@ var Wi = class {
3358
3272
  await this.closeAllSessions();
3359
3273
  }
3360
3274
  };
3361
- function Gi(e) {
3275
+ function Fi(e) {
3362
3276
  let t = Object.keys(e.mcpServers ?? {});
3363
- Pi.getInstance().trackMCPClientInit({
3277
+ wi.getInstance().trackMCPClientInit({
3364
3278
  codeMode: !1,
3365
3279
  sandbox: !1,
3366
3280
  allCallbacks: !1,
@@ -3370,12 +3284,12 @@ function Gi(e) {
3370
3284
  isBrowser: !0
3371
3285
  }).catch((e) => Z.debug(`Failed to track BrowserMCPClient init: ${e}`));
3372
3286
  }
3373
- var Ki = class e extends Wi {
3287
+ var Ii = class e extends Pi {
3374
3288
  static getPackageVersion() {
3375
3289
  return Ur();
3376
3290
  }
3377
3291
  constructor(e) {
3378
- super(e), Gi(this.config);
3292
+ super(e), Fi(this.config);
3379
3293
  }
3380
3294
  static fromDict(t) {
3381
3295
  return new e(t);
@@ -3407,8 +3321,8 @@ var Ki = class e extends Wi {
3407
3321
  }
3408
3322
  };
3409
3323
  mr();
3410
- var qi = "https://favicon.tools.mcp-use.com", Ji = /^\d{1,3}(\.\d{1,3}){3}$/;
3411
- function Yi(e) {
3324
+ var Li = "https://favicon.tools.mcp-use.com", Ri = /^\d{1,3}(\.\d{1,3}){3}$/;
3325
+ function zi(e) {
3412
3326
  try {
3413
3327
  let t = e.includes("://") ? e : `https://${e}`;
3414
3328
  return new URL(t).hostname;
@@ -3416,10 +3330,10 @@ function Yi(e) {
3416
3330
  return null;
3417
3331
  }
3418
3332
  }
3419
- function Xi(e) {
3333
+ function Bi(e) {
3420
3334
  let t = e.toLowerCase();
3421
3335
  if (t === "localhost" || t.endsWith(".localhost") || t === "host.docker.internal" || t === "0.0.0.0") return !0;
3422
- if (!Ji.test(t)) return !1;
3336
+ if (!Ri.test(t)) return !1;
3423
3337
  if (t === "127.0.0.1" || t.startsWith("127.") || t.startsWith("10.") || t.startsWith("192.168.")) return !0;
3424
3338
  let n = /^172\.(\d+)\./.exec(t);
3425
3339
  if (n) {
@@ -3428,28 +3342,28 @@ function Xi(e) {
3428
3342
  }
3429
3343
  return !1;
3430
3344
  }
3431
- function Zi(e) {
3345
+ function Vi(e) {
3432
3346
  let t = e.split(".");
3433
3347
  return Array.from({ length: t.length - 1 }, (e, n) => t.slice(n).join("."));
3434
3348
  }
3435
- function Qi(e) {
3349
+ function Hi(e) {
3436
3350
  return new Promise((t, n) => {
3437
3351
  let r = new FileReader();
3438
3352
  r.onloadend = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
3439
3353
  });
3440
3354
  }
3441
- async function $i(e) {
3355
+ async function Ui(e) {
3442
3356
  try {
3443
- let t = Yi(e);
3444
- if (!t || Xi(t)) return null;
3445
- for (let e of Zi(t)) try {
3446
- let t = await fetch(`${qi}/${e}?response=json`, { signal: AbortSignal.timeout(2e3) });
3357
+ let t = zi(e);
3358
+ if (!t || Bi(t)) return null;
3359
+ for (let e of Vi(t)) try {
3360
+ let t = await fetch(`${Li}/${e}?response=json`, { signal: AbortSignal.timeout(2e3) });
3447
3361
  if (!t.ok) continue;
3448
3362
  let n = await t.json();
3449
3363
  if (n.source === "default") continue;
3450
3364
  let r = n.url.replace(/^http:\/\//, "https://"), i = await fetch(r, { signal: AbortSignal.timeout(2e3) });
3451
3365
  if (!i.ok) continue;
3452
- return await Qi(await i.blob());
3366
+ return await Hi(await i.blob());
3453
3367
  } catch {
3454
3368
  continue;
3455
3369
  }
@@ -3458,11 +3372,11 @@ async function $i(e) {
3458
3372
  return console.warn("[favicon] Error detecting favicon:", e), null;
3459
3373
  }
3460
3374
  }
3461
- var ea = "inspector-server";
3462
- function ta(e, t) {
3375
+ var Wi = "inspector-server";
3376
+ function Gi(e, t) {
3463
3377
  if (!e) throw Error(t);
3464
3378
  }
3465
- async function na(e) {
3379
+ async function Ki(e) {
3466
3380
  try {
3467
3381
  let t = e.serverInfo.icons?.[0]?.src;
3468
3382
  if (t) {
@@ -3477,7 +3391,7 @@ async function na(e) {
3477
3391
  } : void 0), e.addLog("debug", "Server icon converted to base64")), r;
3478
3392
  }
3479
3393
  if (e.url) {
3480
- let t = await $i(e.url);
3394
+ let t = await Ui(e.url);
3481
3395
  if (!e.isMounted()) return e.addLog("debug", "Connection aborted after favicon detection - component unmounted"), null;
3482
3396
  if (t) return e.setServerInfo((e) => e ? {
3483
3397
  ...e,
@@ -3489,10 +3403,10 @@ async function na(e) {
3489
3403
  return e.addLog("debug", "Icon loading failed (non-critical):", t), null;
3490
3404
  }
3491
3405
  }
3492
- function ra(e, t) {
3406
+ function qi(e, t) {
3493
3407
  return t ? `state=${e}` : `client disconnected (state=${e})`;
3494
3408
  }
3495
- function ia(e) {
3409
+ function Ji(e) {
3496
3410
  return {
3497
3411
  name: e.name,
3498
3412
  version: e.version,
@@ -3500,11 +3414,11 @@ function ia(e) {
3500
3414
  logo_uri: e.icons?.[0]?.src
3501
3415
  };
3502
3416
  }
3503
- function aa(e) {
3417
+ function Yi(e) {
3504
3418
  let t = (e instanceof Error ? e.message : String(e)).toLowerCase();
3505
3419
  return t.includes("oauth discovery failed") || t.includes("oauth-authorization-server") || t.includes("not valid json") || t.includes("404") && (t.includes("openid-configuration") || t.includes("oauth-protected-resources") || t.includes("oauth-authorization-url") || t.includes("register")) || t.includes("invalid oauth error response") && t.includes("not found");
3506
3420
  }
3507
- function oa(e, t) {
3421
+ function Xi(e, t) {
3508
3422
  if (t) return t;
3509
3423
  if (e) try {
3510
3424
  let t = new URL(e);
@@ -3513,8 +3427,8 @@ function oa(e, t) {
3513
3427
  return;
3514
3428
  }
3515
3429
  }
3516
- function sa(e) {
3517
- let t = oa(e.gatewayUrl, e.oauthProxyUrl);
3430
+ function Zi(e) {
3431
+ let t = Xi(e.gatewayUrl, e.oauthProxyUrl);
3518
3432
  return {
3519
3433
  provider: new ei(e.effectiveOAuthUrl, {
3520
3434
  storageKeyPrefix: e.storageKeyPrefix,
@@ -3535,7 +3449,7 @@ function sa(e) {
3535
3449
  oauthProxyUrl: t
3536
3450
  };
3537
3451
  }
3538
- function ca(e) {
3452
+ function Qi(e) {
3539
3453
  let t = null, n = Date.now(), r = !1, i = e.healthCheckIntervalMs ?? 1e4, a = e.healthCheckTimeoutMs ?? 3e4;
3540
3454
  return t = setInterval(async () => {
3541
3455
  if (!r) {
@@ -3571,79 +3485,79 @@ function ca(e) {
3571
3485
  t &&= (clearInterval(t), null);
3572
3486
  };
3573
3487
  }
3574
- function la(e, t) {
3488
+ function $i(e, t) {
3575
3489
  let n = e.connectionRef.current;
3576
- if (e.stateRef.current !== "ready" || !e.hasClient() || !n) throw Error(`MCP client is not ready (${ra(e.stateRef.current, e.hasClient())}). Cannot ${t}.`);
3490
+ if (e.stateRef.current !== "ready" || !e.hasClient() || !n) throw Error(`MCP client is not ready (${qi(e.stateRef.current, e.hasClient())}). Cannot ${t}.`);
3577
3491
  return n;
3578
3492
  }
3579
- function ua(e) {
3580
- let t = (0, M.useCallback)(async (t, n, r) => {
3581
- let i = la(e, `call tool "${t}"`);
3493
+ function ea(e) {
3494
+ let t = (0, j.useCallback)(async (t, n, r) => {
3495
+ let i = $i(e, `call tool "${t}"`);
3582
3496
  e.addLog("info", `Calling tool: ${t}`, n);
3583
3497
  let a = Date.now();
3584
3498
  try {
3585
3499
  let o = await i.callTool(t, n || {}, r);
3586
- return e.addLog("info", `Tool "${t}" call successful:`, o), Pi.getInstance().trackUseMcpToolCall({
3500
+ return e.addLog("info", `Tool "${t}" call successful:`, o), wi.getInstance().trackUseMcpToolCall({
3587
3501
  toolName: t,
3588
3502
  success: !0,
3589
3503
  executionTimeMs: Date.now() - a
3590
3504
  }).catch(() => {}), o;
3591
3505
  } catch (n) {
3592
- throw e.addLog("error", `Tool "${t}" call failed:`, n), Pi.getInstance().trackUseMcpToolCall({
3506
+ throw e.addLog("error", `Tool "${t}" call failed:`, n), wi.getInstance().trackUseMcpToolCall({
3593
3507
  toolName: t,
3594
3508
  success: !1,
3595
3509
  errorType: n instanceof Error ? n.name : "UnknownError",
3596
3510
  executionTimeMs: Date.now() - a
3597
3511
  }).catch(() => {}), n;
3598
3512
  }
3599
- }, [e.addLog]), n = (0, M.useCallback)(async () => {
3600
- let t = la(e, "list resources");
3513
+ }, [e.addLog]), n = (0, j.useCallback)(async () => {
3514
+ let t = $i(e, "list resources");
3601
3515
  e.addLog("info", "Listing resources");
3602
3516
  let n = await t.listAllResources();
3603
3517
  e.setResources(n.resources || []);
3604
- }, [e.addLog]), r = (0, M.useCallback)(async (t) => {
3605
- let n = la(e, "read resource");
3518
+ }, [e.addLog]), r = (0, j.useCallback)(async (t) => {
3519
+ let n = $i(e, "read resource");
3606
3520
  e.addLog("info", `Reading resource: ${t}`);
3607
3521
  try {
3608
3522
  let e = await n.readResource(t);
3609
- return Pi.getInstance().trackUseMcpResourceRead({
3523
+ return wi.getInstance().trackUseMcpResourceRead({
3610
3524
  resourceUri: t,
3611
3525
  success: !0
3612
3526
  }).catch(() => {}), e;
3613
3527
  } catch (e) {
3614
- throw Pi.getInstance().trackUseMcpResourceRead({
3528
+ throw wi.getInstance().trackUseMcpResourceRead({
3615
3529
  resourceUri: t,
3616
3530
  success: !1,
3617
3531
  errorType: e instanceof Error ? e.name : "UnknownError"
3618
3532
  }).catch(() => {}), e;
3619
3533
  }
3620
- }, [e.addLog]), i = (0, M.useCallback)(async () => {
3621
- let t = la(e, "list prompts");
3534
+ }, [e.addLog]), i = (0, j.useCallback)(async () => {
3535
+ let t = $i(e, "list prompts");
3622
3536
  e.addLog("info", "Listing prompts");
3623
3537
  let n = await t.listPrompts();
3624
3538
  e.setPrompts(n.prompts || []);
3625
- }, [e.addLog]), a = (0, M.useCallback)(async () => {
3539
+ }, [e.addLog]), a = (0, j.useCallback)(async () => {
3626
3540
  if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
3627
3541
  e.setTools(await e.connectionRef.current.listTools() || []);
3628
3542
  } catch (t) {
3629
3543
  e.addLog("error", "Failed to refresh tools:", t);
3630
3544
  }
3631
- }, [e.addLog]), o = (0, M.useCallback)(async () => {
3545
+ }, [e.addLog]), o = (0, j.useCallback)(async () => {
3632
3546
  if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
3633
3547
  let t = await e.connectionRef.current.listAllResources();
3634
3548
  e.setResources(t.resources || []);
3635
3549
  } catch (t) {
3636
3550
  e.addLog("warn", "Failed to refresh resources:", t);
3637
3551
  }
3638
- }, [e.addLog]), s = (0, M.useCallback)(async () => {
3552
+ }, [e.addLog]), s = (0, j.useCallback)(async () => {
3639
3553
  if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
3640
3554
  let t = await e.connectionRef.current.listPrompts();
3641
3555
  e.setPrompts(t.prompts || []);
3642
3556
  } catch (t) {
3643
3557
  e.addLog("warn", "Failed to refresh prompts:", t);
3644
3558
  }
3645
- }, [e.addLog]), c = (0, M.useCallback)(async () => {
3646
- let t = await la(e, "refresh resource templates").listResourceTemplates();
3559
+ }, [e.addLog]), c = (0, j.useCallback)(async () => {
3560
+ let t = await $i(e, "refresh resource templates").listResourceTemplates();
3647
3561
  e.isMounted() && e.setResourceTemplates(t.resourceTemplates || []);
3648
3562
  }, [e.addLog]);
3649
3563
  return {
@@ -3655,7 +3569,7 @@ function ua(e) {
3655
3569
  refreshResources: o,
3656
3570
  refreshPrompts: s,
3657
3571
  refreshResourceTemplates: c,
3658
- refreshAll: (0, M.useCallback)(() => Promise.all([
3572
+ refreshAll: (0, j.useCallback)(() => Promise.all([
3659
3573
  a(),
3660
3574
  o(),
3661
3575
  c(),
@@ -3666,26 +3580,26 @@ function ua(e) {
3666
3580
  c,
3667
3581
  s
3668
3582
  ]),
3669
- getPrompt: (0, M.useCallback)(async (t, n) => la(e, "get prompt").getPrompt(t, n || {}), [e.addLog]),
3670
- complete: (0, M.useCallback)(async (t) => la(e, "request completion").complete(t), [e.addLog])
3583
+ getPrompt: (0, j.useCallback)(async (t, n) => $i(e, "get prompt").getPrompt(t, n || {}), [e.addLog]),
3584
+ complete: (0, j.useCallback)(async (t) => $i(e, "request completion").complete(t), [e.addLog])
3671
3585
  };
3672
3586
  }
3673
- var da = 3e3, fa = 5e3;
3674
- function pa(e) {
3675
- let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? Yr(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c, autoProxyFallback: l = !1, logLevel: u = "silent", autoRetry: d = !1, autoReconnect: f = !0, reconnectionOptions: p, preventAutoAuth: m = !0, useRedirectFlow: h = !1, onPopupWindow: g, timeout: _ = 3e4, wrapTransport: v, serverId: ee, fetch: te, clientOptions: y, protocolNegotiation: x, onNotification: S, onSampling: C, onElicitation: ne, oauth: w } = e, re = "http", T = w?.clientId?.trim() || void 0, E = w?.clientMetadataUrl?.trim() || void 0, D = w?.scope?.trim() || void 0, O = (0, M.useMemo)(() => T ? { client_id: T } : void 0, [T]), k = (0, M.useMemo)(() => {
3587
+ var ta = 3e3, na = 5e3;
3588
+ function ra(e) {
3589
+ let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? Yr(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c, autoProxyFallback: l = !1, logLevel: u = "silent", autoRetry: d = !1, autoReconnect: f = !0, reconnectionOptions: p, preventAutoAuth: m = !0, useRedirectFlow: h = !1, onPopupWindow: g, timeout: _ = 3e4, wrapTransport: v, serverId: ee, fetch: te, clientOptions: y, protocolNegotiation: x, onNotification: S, onSampling: C, onElicitation: ne, oauth: w } = e, re = "http", T = w?.clientId?.trim() || void 0, E = w?.clientMetadataUrl?.trim() || void 0, D = w?.scope?.trim() || void 0, ie = (0, j.useMemo)(() => T ? { client_id: T } : void 0, [T]), O = (0, j.useMemo)(() => {
3676
3590
  let e = `useMcp:${t || "no-url"}`, n = pr.get(e);
3677
3591
  return u && (n.level = u), n;
3678
- }, [t, u]), A = o ?? {}, j = (0, M.useMemo)(() => Jr(y), [y]), ie = C, N = ne, ae = (0, M.useMemo)(() => ({
3592
+ }, [t, u]), k = o ?? {}, ae = (0, j.useMemo)(() => Jr(y), [y]), A = C, oe = ne, se = (0, j.useMemo)(() => ({
3679
3593
  name: "mcp-use",
3680
3594
  title: "mcp-use",
3681
3595
  version: Ur(),
3682
3596
  description: "mcp-use is a complete TypeScript framework for building and using MCP",
3683
3597
  icons: [{ src: "https://mcp-use.com/logo.png" }],
3684
3598
  websiteUrl: "https://mcp-use.com"
3685
- }), []), P = (0, M.useMemo)(() => e.clientInfo ? {
3686
- ...ae,
3599
+ }), []), M = (0, j.useMemo)(() => e.clientInfo ? {
3600
+ ...se,
3687
3601
  ...e.clientInfo
3688
- } : ae, [e.clientInfo, ae]), F = (0, M.useMemo)(() => ia(P), [P]), I = (0, M.useMemo)(() => {
3602
+ } : se, [e.clientInfo, se]), N = (0, j.useMemo)(() => Ji(M), [M]), ce = (0, j.useMemo)(() => {
3689
3603
  if (!l) return {
3690
3604
  enabled: !1,
3691
3605
  proxyAddress: void 0
@@ -3702,14 +3616,14 @@ function pa(e) {
3702
3616
  enabled: l.enabled !== !1 && !!e,
3703
3617
  proxyAddress: e
3704
3618
  };
3705
- }, [l, s]), oe = (0, M.useMemo)(() => f === !1 ? {
3619
+ }, [l, s]), P = (0, j.useMemo)(() => f === !1 ? {
3706
3620
  enabled: !1,
3707
3621
  initialDelay: 0,
3708
3622
  healthCheckInterval: !1,
3709
3623
  healthCheckTimeout: 3e4
3710
3624
  } : f === !0 ? {
3711
3625
  enabled: !0,
3712
- initialDelay: da,
3626
+ initialDelay: ta,
3713
3627
  healthCheckInterval: 1e4,
3714
3628
  healthCheckTimeout: 3e4
3715
3629
  } : typeof f == "number" ? {
@@ -3719,91 +3633,91 @@ function pa(e) {
3719
3633
  healthCheckTimeout: 3e4
3720
3634
  } : {
3721
3635
  enabled: f.enabled !== !1,
3722
- initialDelay: f.initialDelay ?? da,
3636
+ initialDelay: f.initialDelay ?? ta,
3723
3637
  healthCheckInterval: f.healthCheckInterval ?? 1e4,
3724
3638
  healthCheckTimeout: f.healthCheckTimeout ?? 3e4
3725
- }, [f]), [se, ce] = (0, M.useState)(void 0);
3726
- (0, M.useEffect)(() => {
3727
- ce(void 0);
3639
+ }, [f]), [le, ue] = (0, j.useState)(void 0);
3640
+ (0, j.useEffect)(() => {
3641
+ ue(void 0);
3728
3642
  }, [t, s]);
3729
- let le = (0, M.useMemo)(() => {
3730
- if (!se?.proxyAddress) return s;
3643
+ let de = (0, j.useMemo)(() => {
3644
+ if (!le?.proxyAddress) return s;
3731
3645
  let e = s?.headers ?? {};
3732
3646
  return {
3733
- ...se,
3647
+ ...le,
3734
3648
  headers: {
3735
3649
  ...e,
3736
- ...se.headers ?? {}
3650
+ ...le.headers ?? {}
3737
3651
  }
3738
3652
  };
3739
- }, [se, s]), L = le?.proxyAddress, ue = le?.headers ?? {}, R = (0, M.useMemo)(() => t || "", [t]), z = (0, M.useMemo)(() => ({
3740
- ...ue,
3741
- ...A
3742
- }), [ue, A]), [B, V] = (0, M.useState)("discovering"), [de, fe] = (0, M.useState)([]), [pe, me] = (0, M.useState)([]), [he, ge] = (0, M.useState)([]), [_e, ve] = (0, M.useState)([]), [ye, H] = (0, M.useState)(e._initialServerInfo?.name ? e._initialServerInfo : void 0), [be, xe] = (0, M.useState)(), [Se, Ce] = (0, M.useState)(void 0), [we, Te] = (0, M.useState)(void 0), [Ee, De] = (0, M.useState)(), [Oe, ke] = (0, M.useState)({}), [Ae, je] = (0, M.useState)(void 0), [Me, Ne] = (0, M.useState)([]), [Pe, Fe] = (0, M.useState)(void 0), [Ie, Le] = (0, M.useState)(void 0), U = (0, M.useRef)(null), Re = (0, M.useRef)(null), W = (0, M.useRef)(a ?? null), ze = (0, M.useRef)(null), G = (0, M.useRef)(!1), K = (0, M.useRef)(!0), Be = (0, M.useRef)(0), Ve = (0, M.useRef)(0), He = (0, M.useRef)(null), Ue = (0, M.useRef)(!1), We = (0, M.useRef)(!1), q = (0, M.useRef)(B), Ge = (0, M.useRef)(f), Ke = (0, M.useRef)(null), qe = (0, M.useRef)(null), Je = (0, M.useRef)(null), Ye = (0, M.useRef)(ie), Xe = (0, M.useRef)(N), Ze = (0, M.useRef)(ie !== void 0), Qe = (0, M.useRef)(N !== void 0), $e = (0, M.useRef)(S);
3743
- ie !== void 0 && (Ye.current = ie), N !== void 0 && (Xe.current = N), Ze.current = ie !== void 0, Qe.current = N !== void 0, $e.current = S;
3744
- let et = (0, M.useCallback)(async (e) => Ye.current(e), []), tt = (0, M.useCallback)(async (e) => Xe.current(e), []), nt = (0, M.useCallback)((e) => {
3653
+ }, [le, s]), F = de?.proxyAddress, fe = de?.headers ?? {}, I = (0, j.useMemo)(() => t || "", [t]), L = (0, j.useMemo)(() => ({
3654
+ ...fe,
3655
+ ...k
3656
+ }), [fe, k]), [R, z] = (0, j.useState)("discovering"), [pe, me] = (0, j.useState)([]), [he, ge] = (0, j.useState)([]), [_e, ve] = (0, j.useState)([]), [ye, be] = (0, j.useState)([]), [xe, B] = (0, j.useState)(e._initialServerInfo?.name ? e._initialServerInfo : void 0), [Se, Ce] = (0, j.useState)(), [we, Te] = (0, j.useState)(void 0), [Ee, De] = (0, j.useState)(void 0), [V, Oe] = (0, j.useState)(), [ke, Ae] = (0, j.useState)({}), [je, Me] = (0, j.useState)(void 0), [Ne, Pe] = (0, j.useState)([]), [Fe, H] = (0, j.useState)(void 0), [Ie, Le] = (0, j.useState)(void 0), U = (0, j.useRef)(null), Re = (0, j.useRef)(null), W = (0, j.useRef)(a ?? null), ze = (0, j.useRef)(null), G = (0, j.useRef)(!1), K = (0, j.useRef)(!0), Be = (0, j.useRef)(0), Ve = (0, j.useRef)(0), He = (0, j.useRef)(null), Ue = (0, j.useRef)(!1), We = (0, j.useRef)(!1), q = (0, j.useRef)(R), Ge = (0, j.useRef)(f), Ke = (0, j.useRef)(null), qe = (0, j.useRef)(null), Je = (0, j.useRef)(null), Ye = (0, j.useRef)(A), Xe = (0, j.useRef)(oe), Ze = (0, j.useRef)(A !== void 0), Qe = (0, j.useRef)(oe !== void 0), $e = (0, j.useRef)(S);
3657
+ A !== void 0 && (Ye.current = A), oe !== void 0 && (Xe.current = oe), Ze.current = A !== void 0, Qe.current = oe !== void 0, $e.current = S;
3658
+ let et = (0, j.useCallback)(async (e) => Ye.current(e), []), tt = (0, j.useCallback)(async (e) => Xe.current(e), []), nt = (0, j.useCallback)((e) => {
3745
3659
  $e.current?.(e);
3746
3660
  }, []);
3747
- (0, M.useEffect)(() => {
3748
- q.current = B, Ge.current = f;
3749
- }, [B, f]), (0, M.useEffect)(() => {
3661
+ (0, j.useEffect)(() => {
3662
+ q.current = R, Ge.current = f;
3663
+ }, [R, f]), (0, j.useEffect)(() => {
3750
3664
  W.current = a ?? null;
3751
3665
  }, [a]);
3752
- let J = (0, M.useCallback)((e, t, ...n) => {
3666
+ let J = (0, j.useCallback)((e, t, ...n) => {
3753
3667
  let r = n.length > 0 ? `${t} ${n.map((e) => JSON.stringify(e)).join(" ")}` : t, i = `[useMcp] ${r}`;
3754
3668
  switch (e) {
3755
3669
  case "error":
3756
- k.error(i);
3670
+ O.error(i);
3757
3671
  break;
3758
3672
  case "warn":
3759
- k.warn(i);
3673
+ O.warn(i);
3760
3674
  break;
3761
3675
  case "info":
3762
- k.info(i);
3676
+ O.info(i);
3763
3677
  break;
3764
3678
  case "debug":
3765
- k.debug(i);
3679
+ O.debug(i);
3766
3680
  break;
3767
- default: k.info(i);
3681
+ default: O.info(i);
3768
3682
  }
3769
- K.current && Ne((t) => [...t.slice(-100), {
3683
+ K.current && Pe((t) => [...t.slice(-100), {
3770
3684
  level: e,
3771
3685
  message: r,
3772
3686
  timestamp: Date.now()
3773
3687
  }]);
3774
- }, [k]), rt = ua({
3688
+ }, [O]), rt = ea({
3775
3689
  stateRef: q,
3776
3690
  connectionRef: Re,
3777
3691
  hasClient: () => U.current !== null,
3778
3692
  isMounted: () => K.current,
3779
- setTools: fe,
3780
- setResources: me,
3781
- setResourceTemplates: ge,
3782
- setPrompts: ve,
3693
+ setTools: me,
3694
+ setResources: ge,
3695
+ setResourceTemplates: ve,
3696
+ setPrompts: be,
3783
3697
  addLog: J
3784
- }), it = (0, M.useCallback)(async (e = !1) => {
3698
+ }), it = (0, j.useCallback)(async (e = !1) => {
3785
3699
  e || J("info", "Disconnecting..."), G.current = !1, He.current && clearTimeout(He.current), He.current = null;
3786
3700
  let t = Ve.current, n = U.current;
3787
3701
  if (n) try {
3788
- let e = ea, t = n === U.current ? Re.current : null;
3702
+ let e = Wi, t = n === U.current ? Re.current : null;
3789
3703
  t && t._healthCheckCleanup && (t._healthCheckCleanup(), t._healthCheckCleanup = null), t && await n.closeSession(e);
3790
3704
  } catch (t) {
3791
3705
  e || J("warn", "Error closing connection:", t);
3792
3706
  }
3793
3707
  let r = Ve.current !== t;
3794
- U.current === n && !r && (U.current = null, Re.current = null), K.current && !e && !r && (V("discovering"), fe([]), me([]), ge([]), ve([]), je(void 0), Fe(void 0), Le(void 0), H(void 0), xe(void 0), Ce(void 0), Te(void 0), De(void 0), ke({}));
3795
- }, [J]), Y = (0, M.useCallback)((e, n) => {
3708
+ U.current === n && !r && (U.current = null, Re.current = null), K.current && !e && !r && (z("discovering"), me([]), ge([]), ve([]), be([]), Me(void 0), H(void 0), Le(void 0), B(void 0), Ce(void 0), Te(void 0), De(void 0), Oe(void 0), Ae({}));
3709
+ }, [J]), Y = (0, j.useCallback)((e, n) => {
3796
3710
  J("error", e, n ?? "");
3797
- let r = n && "code" in n ? n.code : void 0, i = I.enabled && !le?.proxyAddress, o = e.includes("CORS") || e.includes("blocked by CORS policy") || e.includes("Failed to fetch"), s = r === 400;
3798
- if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return J("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), U.current = null, a || (W.current = null), J("debug", "Cleared client and auth provider for proxy fallback"), ce({ proxyAddress: I.proxyAddress }), K.current && V("discovering"), setTimeout(() => {
3711
+ let r = n && "code" in n ? n.code : void 0, i = ce.enabled && !de?.proxyAddress, o = e.includes("CORS") || e.includes("blocked by CORS policy") || e.includes("Failed to fetch"), s = r === 400;
3712
+ if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return J("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), U.current = null, a || (W.current = null), J("debug", "Cleared client and auth provider for proxy fallback"), ue({ proxyAddress: ce.proxyAddress }), K.current && z("discovering"), setTimeout(() => {
3799
3713
  K.current && qe.current?.();
3800
3714
  }, 1e3), !0;
3801
3715
  if (K.current) {
3802
- J("info", "Setting state to FAILED:", e), V("failed"), je(e);
3716
+ J("info", "Setting state to FAILED:", e), z("failed"), Me(e);
3803
3717
  let t = W.current?.getLastAttemptedAuthUrl?.();
3804
- t && (Fe(t), J("info", "Manual authentication URL may be available.", t));
3718
+ t && (H(t), J("info", "Manual authentication URL may be available.", t));
3805
3719
  }
3806
- return G.current = !1, t && Pi.getInstance().trackUseMcpConnection({
3720
+ return G.current = !1, t && wi.getInstance().trackUseMcpConnection({
3807
3721
  url: t,
3808
3722
  transportType: re,
3809
3723
  success: !1,
@@ -3816,10 +3730,10 @@ function pa(e) {
3816
3730
  J,
3817
3731
  t,
3818
3732
  re,
3819
- I,
3820
- le,
3733
+ ce,
3734
+ de,
3821
3735
  a
3822
- ]), at = (0, M.useCallback)(async () => {
3736
+ ]), at = (0, j.useCallback)(async () => {
3823
3737
  if (!n || !t) {
3824
3738
  J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag.");
3825
3739
  return;
@@ -3832,42 +3746,42 @@ function pa(e) {
3832
3746
  J("debug", "Connect called after unmount, aborting.");
3833
3747
  return;
3834
3748
  }
3835
- if (G.current = !0, Ve.current += 1, Be.current += 1, je(void 0), Fe(void 0), Ke.current = null, V("discovering"), fe([]), me([]), ge([]), ve([]), H(void 0), xe(void 0), Ce(void 0), Te(void 0), De(void 0), ke({}), J("info", `Connecting attempt #${Be.current} to ${t}...`), !W.current) {
3836
- let { provider: e, oauthProxyUrl: t } = sa({
3837
- effectiveOAuthUrl: R,
3749
+ if (G.current = !0, Ve.current += 1, Be.current += 1, Me(void 0), H(void 0), Ke.current = null, z("discovering"), me([]), ge([]), ve([]), be([]), B(void 0), Ce(void 0), Te(void 0), De(void 0), Oe(void 0), Ae({}), J("info", `Connecting attempt #${Be.current} to ${t}...`), !W.current) {
3750
+ let { provider: e, oauthProxyUrl: t } = Zi({
3751
+ effectiveOAuthUrl: I,
3838
3752
  storageKeyPrefix: i,
3839
- oauthClientConfig: F,
3753
+ oauthClientConfig: N,
3840
3754
  callbackUrl: r,
3841
3755
  preventAutoAuth: m,
3842
3756
  useRedirectFlow: h,
3843
- gatewayUrl: L,
3757
+ gatewayUrl: F,
3844
3758
  oauthProxyUrl: c,
3845
3759
  onPopupWindow: g,
3846
3760
  proxyOAuthRequests: !0,
3847
- staticClientInfo: O,
3761
+ staticClientInfo: ie,
3848
3762
  clientMetadataUrl: E,
3849
3763
  scope: D
3850
3764
  });
3851
- W.current = e, t && J("debug", `OAuth BFF enabled: ${t}`), J("debug", `BrowserOAuthClientProvider initialized with URL: ${R}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${L ? "enabled" : "disabled"}`);
3765
+ W.current = e, t && J("debug", `OAuth BFF enabled: ${t}`), J("debug", `BrowserOAuthClientProvider initialized with URL: ${I}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${F ? "enabled" : "disabled"}`);
3852
3766
  }
3853
- U.current ? J("debug", "BrowserMCPClient already exists, reusing.") : (U.current = new Ki(), J("debug", "BrowserMCPClient initialized in connect."));
3767
+ U.current ? J("debug", "BrowserMCPClient already exists, reusing.") : (U.current = new Ii(), J("debug", "BrowserMCPClient initialized in connect."));
3854
3768
  let e = async (n) => {
3855
3769
  if (!K.current) return J("debug", "Connection attempt aborted - component unmounted"), "failed";
3856
3770
  J("info", `Attempting connection with transport: ${n}`), J("debug", `Client ref status at start of tryConnectWithTransport: ${U.current ? "initialized" : "NULL"}`);
3857
3771
  try {
3858
- let e = ea, r = {
3772
+ let e = Wi, r = {
3859
3773
  url: t,
3860
3774
  timeout: _,
3861
- clientInfo: P,
3775
+ clientInfo: M,
3862
3776
  ...(() => {
3863
3777
  let e = W.current?.getProxyFetch?.(te) ?? te;
3864
3778
  return e ? { fetch: e } : {};
3865
3779
  })(),
3866
- ...j && { clientOptions: j },
3780
+ ...ae && { clientOptions: ae },
3867
3781
  ...x !== void 0 && { protocolNegotiation: x },
3868
3782
  ...p ? { reconnectionOptions: p } : f === !1 ? { reconnectionOptions: { maxRetries: 0 } } : {}
3869
3783
  };
3870
- if (L && (r.gatewayUrl = L, J("debug", `Using proxy gateway: ${L} for target: ${t}`)), z && Object.keys(z).length > 0 && (r.headers = z), !U.current) {
3784
+ if (F && (r.gatewayUrl = F, J("debug", `Using proxy gateway: ${F} for target: ${t}`)), L && Object.keys(L).length > 0 && (r.headers = L), !U.current) {
3871
3785
  if (!K.current) return J("debug", "Connection aborted - component unmounted, client cleaned up"), "failed";
3872
3786
  let e = /* @__PURE__ */ Error("Client not initialized - this is a bug in the connection flow");
3873
3787
  throw J("error", "Client ref is null in tryConnectWithTransport but component is still mounted"), e;
@@ -3884,10 +3798,10 @@ function pa(e) {
3884
3798
  });
3885
3799
  let i = await U.current.connect(e);
3886
3800
  if (Re.current = i, !K.current) return J("debug", "Connection aborted after connection creation - component unmounted"), "failed";
3887
- J("info", "✅ Successfully connected to MCP server"), J("info", "Server info:", i.info.server), J("info", "Server capabilities:", i.info.capabilities), oe.enabled && oe.healthCheckInterval !== !1 && (i._healthCheckCleanup = ca({
3888
- gatewayUrl: L,
3801
+ J("info", "✅ Successfully connected to MCP server"), J("info", "Server info:", i.info.server), J("info", "Server capabilities:", i.info.capabilities), P.enabled && P.healthCheckInterval !== !1 && (i._healthCheckCleanup = Qi({
3802
+ gatewayUrl: F,
3889
3803
  url: t,
3890
- allHeaders: z,
3804
+ allHeaders: L,
3891
3805
  getAuthHeaders: async () => {
3892
3806
  try {
3893
3807
  let e = await W.current?.tokens?.();
@@ -3901,41 +3815,41 @@ function pa(e) {
3901
3815
  isMountedRef: K,
3902
3816
  stateRef: q,
3903
3817
  autoReconnectRef: Ge,
3904
- setState: V,
3818
+ setState: z,
3905
3819
  addLog: J,
3906
3820
  connect: at,
3907
- defaultReconnectDelay: oe.initialDelay,
3908
- healthCheckIntervalMs: oe.healthCheckInterval,
3909
- healthCheckTimeoutMs: oe.healthCheckTimeout
3910
- })), Pi.getInstance().trackUseMcpConnection({
3821
+ defaultReconnectDelay: P.initialDelay,
3822
+ healthCheckIntervalMs: P.healthCheckInterval,
3823
+ healthCheckTimeoutMs: P.healthCheckTimeout
3824
+ })), wi.getInstance().trackUseMcpConnection({
3911
3825
  url: t,
3912
3826
  transportType: n,
3913
3827
  success: !0,
3914
3828
  hasOAuth: !!W.current,
3915
3829
  hasSampling: Ze.current,
3916
3830
  hasElicitation: Qe.current
3917
- }).catch(() => {}), fe(i.tools || []);
3831
+ }).catch(() => {}), me(i.tools || []);
3918
3832
  let [a, o, s] = await Promise.all([
3919
3833
  i.listAllResources(),
3920
3834
  i.listPrompts(),
3921
3835
  i.supports("resources") ? i.listResourceTemplates() : Promise.resolve({ resourceTemplates: [] })
3922
3836
  ]);
3923
3837
  if (!K.current) return J("debug", "Connection aborted after discovery - component unmounted"), "failed";
3924
- me(a.resources || []), ve(o.prompts || []), ge(s.resourceTemplates || []);
3838
+ ge(a.resources || []), be(o.prompts || []), ve(s.resourceTemplates || []);
3925
3839
  let { server: c, capabilities: l, protocolEra: u, protocolVersion: d, instructions: m, extensions: h } = i.info;
3926
- if (K.current && (Ce(u), Te(d), De(m), ke(h)), c) {
3840
+ if (K.current && (Te(u), De(d), Oe(m), Ae(h)), c) {
3927
3841
  if (J("debug", "Server info:", c), !K.current) return J("debug", "Skipping state update - component unmounted"), "failed";
3928
- H(c), ze.current = na({
3842
+ B(c), ze.current = Ki({
3929
3843
  serverInfo: c,
3930
3844
  url: t,
3931
3845
  isMounted: () => K.current,
3932
- setServerInfo: H,
3846
+ setServerInfo: B,
3933
3847
  addLog: J
3934
3848
  });
3935
3849
  }
3936
3850
  if (l) {
3937
3851
  if (J("debug", "Server capabilities:", l), !K.current) return J("debug", "Skipping state update - component unmounted"), "failed";
3938
- xe(l);
3852
+ Ce(l);
3939
3853
  }
3940
3854
  if (W.current) {
3941
3855
  let e = await W.current.tokens?.();
@@ -3965,20 +3879,20 @@ function pa(e) {
3965
3879
  });
3966
3880
  }
3967
3881
  }
3968
- return Ke.current = n, V("ready"), "success";
3882
+ return Ke.current = n, z("ready"), "success";
3969
3883
  } catch (r) {
3970
3884
  let i = r, a = i?.message || String(r), o = W.current?.getLastAttemptedAuthUrl?.();
3971
- if (o && W.current && m) return J("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), K.current && (V("pending_auth"), Fe(o)), G.current = !1, "auth_redirect";
3972
- let s = aa(r), c = Ii(r);
3973
- if (s && A && Object.keys(A).length > 0) return Y("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."), "failed";
3974
- if (s && (!A || Object.keys(A).length === 0)) return Y("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
3885
+ if (o && W.current && m) return J("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), K.current && (z("pending_auth"), H(o)), G.current = !1, "auth_redirect";
3886
+ let s = Yi(r), c = Ei(r);
3887
+ if (s && k && Object.keys(k).length > 0) return Y("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."), "failed";
3888
+ if (s && (!k || Object.keys(k).length === 0)) return Y("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
3975
3889
  if (c) {
3976
3890
  if (s) return Y("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
3977
3891
  if (W.current) if (J("info", "Authentication required. OAuth provider available."), m) {
3978
3892
  if (J("info", "Waiting for user to initiate authentication flow..."), K.current) {
3979
- V("pending_auth");
3893
+ z("pending_auth");
3980
3894
  let e = W.current?.getLastAttemptedAuthUrl?.();
3981
- e && (Fe(e), J("info", "Retrieved stored auth URL for manual authentication"));
3895
+ e && (H(e), J("info", "Retrieved stored auth URL for manual authentication"));
3982
3896
  }
3983
3897
  return G.current = !1, "auth_redirect";
3984
3898
  } else {
@@ -4001,7 +3915,7 @@ function pa(e) {
4001
3915
  return Y(`Automatic OAuth authentication failed: ${e instanceof Error ? e.message : String(e)}`, e instanceof Error ? e : Error(String(e))), "failed";
4002
3916
  }
4003
3917
  }
4004
- return A && Object.keys(A).length > 0 ? (Y("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."), "failed") : (Y("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed");
3918
+ return k && Object.keys(k).length > 0 ? (Y("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."), "failed") : (Y("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed");
4005
3919
  }
4006
3920
  return Y(a, i instanceof Error ? i : Error(String(i))) ? "auth_redirect" : "failed";
4007
3921
  }
@@ -4014,44 +3928,44 @@ function pa(e) {
4014
3928
  t,
4015
3929
  i,
4016
3930
  r,
4017
- F.name,
4018
- F.version,
4019
- F.uri,
4020
- F.logo_uri,
4021
- O,
3931
+ N.name,
3932
+ N.version,
3933
+ N.uri,
3934
+ N.logo_uri,
3935
+ ie,
4022
3936
  E,
4023
3937
  D,
4024
- A,
3938
+ k,
4025
3939
  re,
4026
3940
  m,
4027
3941
  h,
4028
3942
  g,
4029
3943
  n,
4030
3944
  _,
4031
- P,
4032
- j,
3945
+ M,
3946
+ ae,
4033
3947
  x,
4034
- L,
3948
+ F,
4035
3949
  c,
4036
- z,
4037
- R,
3950
+ L,
3951
+ I,
4038
3952
  et,
4039
3953
  tt,
4040
3954
  nt
4041
3955
  ]);
4042
- (0, M.useEffect)(() => {
3956
+ (0, j.useEffect)(() => {
4043
3957
  qe.current = at, Je.current = Y;
4044
3958
  }, [at, Y]);
4045
- let ot = (0, M.useCallback)(() => {
3959
+ let ot = (0, j.useCallback)(() => {
4046
3960
  q.current === "failed" ? (J("info", "Retry requested..."), qe.current?.()) : J("warn", `Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`);
4047
- }, [J]), st = (0, M.useCallback)(async () => {
3961
+ }, [J]), st = (0, j.useCallback)(async () => {
4048
3962
  J("info", "Manual authentication requested...");
4049
3963
  let e = q.current;
4050
3964
  if (e === "failed") J("info", "Attempting to reconnect and authenticate via retry..."), ot();
4051
3965
  else if (e === "pending_auth") {
4052
3966
  J("info", "Proceeding with authentication from pending state...");
4053
3967
  try {
4054
- if (ta(W.current, "Auth Provider not available for manual auth"), ta(t, "Server URL is required for authentication"), a) {
3968
+ if (Gi(W.current, "Auth Provider not available for manual auth"), Gi(t, "Server URL is required for authentication"), a) {
4055
3969
  J("info", "Using provided authProvider for manual authentication");
4056
3970
  let e = new URL(t), n = e.origin + e.pathname.replace(/\/+$/, "");
4057
3971
  await b(W.current, {
@@ -4060,15 +3974,15 @@ function pa(e) {
4060
3974
  }), qe.current?.();
4061
3975
  return;
4062
3976
  }
4063
- J("info", `Cleared ${W.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`), V("authenticating");
4064
- let e = null, n = null, { provider: o, oauthProxyUrl: s } = sa({
4065
- effectiveOAuthUrl: R,
3977
+ J("info", `Cleared ${W.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`), z("authenticating");
3978
+ let e = null, n = null, { provider: o, oauthProxyUrl: s } = Zi({
3979
+ effectiveOAuthUrl: I,
4066
3980
  storageKeyPrefix: i,
4067
- oauthClientConfig: F,
3981
+ oauthClientConfig: N,
4068
3982
  callbackUrl: r,
4069
3983
  preventAutoAuth: !1,
4070
3984
  useRedirectFlow: h,
4071
- gatewayUrl: L,
3985
+ gatewayUrl: F,
4072
3986
  oauthProxyUrl: c,
4073
3987
  onPopupWindow: (t, r, i) => {
4074
3988
  e = i;
@@ -4078,7 +3992,7 @@ function pa(e) {
4078
3992
  g?.(t, r, i);
4079
3993
  },
4080
3994
  proxyOAuthRequests: !0,
4081
- staticClientInfo: O,
3995
+ staticClientInfo: ie,
4082
3996
  clientMetadataUrl: E,
4083
3997
  scope: D
4084
3998
  });
@@ -4093,7 +4007,7 @@ function pa(e) {
4093
4007
  J("info", "OAuth flow initiated (popup/redirect):", e instanceof Error ? e.message : "Redirecting...");
4094
4008
  }
4095
4009
  let d = o.getLastAttemptedAuthUrl?.();
4096
- if (d && (Fe(d), J("info", "Updated auth URL for fallback:", d), !n)) try {
4010
+ if (d && (H(d), J("info", "Updated auth URL for fallback:", d), !n)) try {
4097
4011
  n = new URL(d).searchParams.get("state");
4098
4012
  } catch {}
4099
4013
  if (h) return;
@@ -4119,10 +4033,10 @@ function pa(e) {
4119
4033
  J("info", "Authentication succeeded; reconnecting to MCP server..."), G.current = !1, qe.current?.();
4120
4034
  break;
4121
4035
  case "cancelled":
4122
- J("warn", "Authentication popup was closed before completing. Returning to pending_auth."), V("pending_auth");
4036
+ J("warn", "Authentication popup was closed before completing. Returning to pending_auth."), z("pending_auth");
4123
4037
  break;
4124
4038
  case "timeout":
4125
- J("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."), V("pending_auth");
4039
+ J("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."), z("pending_auth");
4126
4040
  break;
4127
4041
  case "error":
4128
4042
  Y(`Authentication failed: ${p.error}`);
@@ -4131,39 +4045,39 @@ function pa(e) {
4131
4045
  }
4132
4046
  } catch (e) {
4133
4047
  if (!K.current) return;
4134
- V("pending_auth"), J("error", `Manual authentication failed: ${e instanceof Error ? e.message : String(e)}`);
4048
+ z("pending_auth"), J("error", `Manual authentication failed: ${e instanceof Error ? e.message : String(e)}`);
4135
4049
  }
4136
4050
  } else if (e === "authenticating") {
4137
4051
  J("warn", "Already attempting authentication. Check for blocked popups or wait for timeout.");
4138
4052
  let e = W.current?.getLastAttemptedAuthUrl?.();
4139
- e && !Pe && (Fe(e), J("info", "Manual authentication URL retrieved:", e));
4053
+ e && !Fe && (H(e), J("info", "Manual authentication URL retrieved:", e));
4140
4054
  } else J("info", `Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`);
4141
4055
  }, [
4142
4056
  J,
4143
4057
  ot,
4144
4058
  Y,
4145
- Pe,
4059
+ Fe,
4146
4060
  t,
4147
4061
  h,
4148
4062
  g,
4149
4063
  i,
4150
- F.name,
4151
- F.uri,
4152
- F.logo_uri,
4153
- O,
4064
+ N.name,
4065
+ N.uri,
4066
+ N.logo_uri,
4067
+ ie,
4154
4068
  E,
4155
4069
  D,
4156
4070
  r,
4157
- P,
4071
+ M,
4158
4072
  a
4159
- ]), ct = (0, M.useCallback)(() => {
4160
- W.current?.clearStorage ? (J("info", `Cleared ${W.current.clearStorage()} item(s) from localStorage for ${t}.`), Fe(void 0), it()) : J("warn", "Auth provider not initialized, cannot clear storage.");
4073
+ ]), ct = (0, j.useCallback)(() => {
4074
+ W.current?.clearStorage ? (J("info", `Cleared ${W.current.clearStorage()} item(s) from localStorage for ${t}.`), H(void 0), it()) : J("warn", "Auth provider not initialized, cannot clear storage.");
4161
4075
  }, [
4162
4076
  t,
4163
4077
  J,
4164
4078
  it
4165
4079
  ]);
4166
- (0, M.useEffect)(() => {
4080
+ (0, j.useEffect)(() => {
4167
4081
  if (typeof window > "u") return;
4168
4082
  let e = (e, t) => {
4169
4083
  if (We.current) {
@@ -4206,28 +4120,28 @@ function pa(e) {
4206
4120
  }
4207
4121
  He.current && clearTimeout(He.current);
4208
4122
  };
4209
- }, [J]), (0, M.useEffect)(() => {
4210
- if (K.current = !0, !n || !t) return J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."), V("discovering"), () => {
4123
+ }, [J]), (0, j.useEffect)(() => {
4124
+ if (K.current = !0, !n || !t) return J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."), z("discovering"), () => {
4211
4125
  K.current = !1;
4212
4126
  };
4213
4127
  if (J("debug", "useMcp mounted, initiating connection."), Be.current = 0, a) W.current = a, J("debug", "Using externally provided authProvider");
4214
- else if (!W.current || W.current.serverUrl !== R) {
4215
- let { provider: e, oauthProxyUrl: t } = sa({
4216
- effectiveOAuthUrl: R,
4128
+ else if (!W.current || W.current.serverUrl !== I) {
4129
+ let { provider: e, oauthProxyUrl: t } = Zi({
4130
+ effectiveOAuthUrl: I,
4217
4131
  storageKeyPrefix: i,
4218
- oauthClientConfig: F,
4132
+ oauthClientConfig: N,
4219
4133
  callbackUrl: r,
4220
4134
  preventAutoAuth: m,
4221
4135
  useRedirectFlow: h,
4222
- gatewayUrl: L,
4136
+ gatewayUrl: F,
4223
4137
  oauthProxyUrl: c,
4224
4138
  onPopupWindow: g,
4225
4139
  proxyOAuthRequests: !0,
4226
- staticClientInfo: O,
4140
+ staticClientInfo: ie,
4227
4141
  clientMetadataUrl: E,
4228
4142
  scope: D
4229
4143
  });
4230
- W.current = e, t && J("debug", `OAuth proxy URL in effect: ${t}`), J("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${R}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${L ? "enabled" : "disabled"}`);
4144
+ W.current = e, t && J("debug", `OAuth proxy URL in effect: ${t}`), J("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${I}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${F ? "enabled" : "disabled"}`);
4231
4145
  }
4232
4146
  return at(), () => {
4233
4147
  K.current = !1, J("debug", "useMcp unmounting, disconnecting."), it(!0);
@@ -4237,54 +4151,54 @@ function pa(e) {
4237
4151
  n,
4238
4152
  i,
4239
4153
  r,
4240
- F.name,
4241
- F.version,
4242
- F.uri,
4243
- F.logo_uri,
4244
- O,
4154
+ N.name,
4155
+ N.version,
4156
+ N.uri,
4157
+ N.logo_uri,
4158
+ ie,
4245
4159
  E,
4246
4160
  D,
4247
4161
  h,
4248
- P,
4249
- R,
4162
+ M,
4163
+ I,
4250
4164
  s,
4251
4165
  a
4252
4166
  ]);
4253
- let lt = (0, M.useRef)(ot), ut = (0, M.useRef)(J);
4254
- (0, M.useEffect)(() => {
4167
+ let lt = (0, j.useRef)(ot), ut = (0, j.useRef)(J);
4168
+ (0, j.useEffect)(() => {
4255
4169
  lt.current = ot, ut.current = J;
4256
- }, [ot, J]), (0, M.useEffect)(() => {
4170
+ }, [ot, J]), (0, j.useEffect)(() => {
4257
4171
  let e = null;
4258
- if (B === "failed" && d && Be.current > 0) {
4172
+ if (R === "failed" && d && Be.current > 0) {
4259
4173
  if (!Ue.current) {
4260
4174
  Ue.current = !0;
4261
- let t = typeof d == "number" ? d : fa;
4175
+ let t = typeof d == "number" ? d : na;
4262
4176
  ut.current("info", `Connection failed, auto-retrying in ${t}ms...`), e = setTimeout(() => {
4263
4177
  Ue.current = !1, K.current && q.current === "failed" && lt.current();
4264
4178
  }, t);
4265
4179
  }
4266
- } else B !== "failed" && (Ue.current = !1);
4180
+ } else R !== "failed" && (Ue.current = !1);
4267
4181
  return () => {
4268
4182
  e && (clearTimeout(e), Ue.current = !1);
4269
4183
  };
4270
- }, [B, d]);
4271
- let dt = (0, M.useCallback)(async () => q.current === "ready" ? ye?.icon ? ye.icon : ze.current ? (J("debug", "Waiting for icon to finish loading..."), await ze.current) : (J("debug", "No icon available and no loading in progress"), null) : (J("warn", "Cannot ensure icon loaded - not connected"), null), [ye, J]);
4184
+ }, [R, d]);
4185
+ let dt = (0, j.useCallback)(async () => q.current === "ready" ? xe?.icon ? xe.icon : ze.current ? (J("debug", "Waiting for icon to finish loading..."), await ze.current) : (J("debug", "No icon available and no loading in progress"), null) : (J("warn", "Cannot ensure icon loaded - not connected"), null), [xe, J]);
4272
4186
  return {
4273
- state: B,
4274
- name: ye?.name || t || "",
4275
- tools: de,
4276
- resources: pe,
4277
- resourceTemplates: he,
4278
- prompts: _e,
4279
- serverInfo: ye,
4280
- capabilities: be,
4281
- protocolEra: Se,
4282
- protocolVersion: we,
4283
- instructions: Ee,
4284
- extensions: Oe,
4285
- error: Ae,
4286
- log: Me,
4287
- authUrl: Pe,
4187
+ state: R,
4188
+ name: xe?.name || t || "",
4189
+ tools: pe,
4190
+ resources: he,
4191
+ resourceTemplates: _e,
4192
+ prompts: ye,
4193
+ serverInfo: xe,
4194
+ capabilities: Se,
4195
+ protocolEra: we,
4196
+ protocolVersion: Ee,
4197
+ instructions: V,
4198
+ extensions: ke,
4199
+ error: je,
4200
+ log: Ne,
4201
+ authUrl: Fe,
4288
4202
  authTokens: Ie,
4289
4203
  client: U.current,
4290
4204
  ...rt,
@@ -4295,11 +4209,11 @@ function pa(e) {
4295
4209
  ensureIconLoaded: dt
4296
4210
  };
4297
4211
  }
4298
- var ma = null;
4299
- function ha() {
4212
+ var ia = null;
4213
+ function aa() {
4300
4214
  return typeof window < "u" && window.name.startsWith("mcp_auth_");
4301
4215
  }
4302
- function ga(e, t, n) {
4216
+ function oa(e, t, n) {
4303
4217
  return {
4304
4218
  type: Er,
4305
4219
  success: e,
@@ -4308,7 +4222,7 @@ function ga(e, t, n) {
4308
4222
  ...n.serverUrlHash ? { serverUrlHash: n.serverUrlHash } : {}
4309
4223
  };
4310
4224
  }
4311
- function _a(e) {
4225
+ function sa(e) {
4312
4226
  if (typeof BroadcastChannel > "u") return;
4313
4227
  let t;
4314
4228
  try {
@@ -4323,7 +4237,7 @@ function _a(e) {
4323
4237
  }, 0);
4324
4238
  }
4325
4239
  }
4326
- function va(e, t, n, r) {
4240
+ function ca(e, t, n, r) {
4327
4241
  if (typeof document > "u") return;
4328
4242
  document.body.innerHTML = "";
4329
4243
  let i = document.createElement("div");
@@ -4339,7 +4253,7 @@ function va(e, t, n, r) {
4339
4253
  }
4340
4254
  document.body.appendChild(i);
4341
4255
  }
4342
- function ya(e) {
4256
+ function la(e) {
4343
4257
  let t = `mcp:auth:state_${e}`, n = localStorage.getItem(t) ? t : null;
4344
4258
  if (!n) {
4345
4259
  let t = `:state_${e}`;
@@ -4364,14 +4278,14 @@ function ya(e) {
4364
4278
  value: i
4365
4279
  };
4366
4280
  }
4367
- function ba(e, t) {
4281
+ function ua(e, t) {
4368
4282
  let n = new URL(e);
4369
4283
  n.searchParams.set("auth_error", "oauth_callback_failed"), n.searchParams.set("auth_error_description", t), window.location.href = n.toString();
4370
4284
  }
4371
- function xa(e, t, n, r) {
4372
- let i = ga(e, t, r), a = n?.returnUrl, o = n?.flowType === "popup" || ha();
4285
+ function da(e, t, n, r) {
4286
+ let i = oa(e, t, r), a = n?.returnUrl, o = n?.flowType === "popup" || aa();
4373
4287
  if (n?.flowType === "redirect" && a) {
4374
- e ? window.location.href = a : ba(a, t ?? "Authentication failed.");
4288
+ e ? window.location.href = a : ua(a, t ?? "Authentication failed.");
4375
4289
  return;
4376
4290
  }
4377
4291
  if (window.opener && !window.opener.closed) {
@@ -4379,50 +4293,50 @@ function xa(e, t, n, r) {
4379
4293
  return;
4380
4294
  }
4381
4295
  if (o) {
4382
- _a(i), va(e ? "Authentication Successful!" : "Authentication Error", e ? "You're authenticated. You can close this window and return to the app." : t ?? "Authentication failed.", !e, a);
4296
+ sa(i), ca(e ? "Authentication Successful!" : "Authentication Error", e ? "You're authenticated. You can close this window and return to the app." : t ?? "Authentication failed.", !e, a);
4383
4297
  try {
4384
4298
  window.close();
4385
4299
  } catch {}
4386
4300
  return;
4387
4301
  }
4388
4302
  if (a) {
4389
- e ? window.location.href = a : ba(a, t ?? "Authentication failed.");
4303
+ e ? window.location.href = a : ua(a, t ?? "Authentication failed.");
4390
4304
  return;
4391
4305
  }
4392
4306
  if (!e) {
4393
- va("Authentication Error", t ?? "Authentication failed.", !0);
4307
+ ca("Authentication Error", t ?? "Authentication failed.", !0);
4394
4308
  return;
4395
4309
  }
4396
4310
  window.location.href = "/";
4397
4311
  }
4398
- function Sa() {
4399
- return ma ||= Ca(), ma;
4312
+ function fa() {
4313
+ return ia ||= pa(), ia;
4400
4314
  }
4401
- async function Ca() {
4315
+ async function pa() {
4402
4316
  let e = new URLSearchParams(window.location.search), t = e.get("state"), n = null, r = null, i = null;
4403
4317
  try {
4404
4318
  if (!t) throw Error("OAuth callback is missing the state parameter.");
4405
- let a = ya(t);
4319
+ let a = la(t);
4406
4320
  if (n = a.key, r = a.value, !r.expiry || r.expiry < Date.now()) throw localStorage.removeItem(n), Error("OAuth state has expired. Please start authentication again.");
4407
4321
  if (!r.providerOptions) throw Error("Stored OAuth state is missing provider options.");
4408
4322
  let { serverUrl: o, ...s } = r.providerOptions;
4409
4323
  i = new ei(o, s), await new w(new URL(o), {
4410
4324
  authProvider: i,
4411
4325
  fetch: i.getProxyFetch()
4412
- }).finishAuth(e), localStorage.removeItem(n), xa(!0, void 0, r, {
4326
+ }).finishAuth(e), localStorage.removeItem(n), da(!0, void 0, r, {
4413
4327
  state: t,
4414
4328
  serverUrlHash: r.serverUrlHash
4415
4329
  });
4416
4330
  } catch (e) {
4417
4331
  let a = e instanceof Error ? e.message : String(e);
4418
- console.error("[mcp-callback] OAuth callback failed:", e), n && localStorage.removeItem(n), i && localStorage.removeItem(i.getKey("last_auth_url")), xa(!1, a, r, {
4332
+ console.error("[mcp-callback] OAuth callback failed:", e), n && localStorage.removeItem(n), i && localStorage.removeItem(i.getKey("last_auth_url")), da(!1, a, r, {
4419
4333
  state: t,
4420
4334
  serverUrlHash: r?.serverUrlHash
4421
4335
  });
4422
4336
  }
4423
4337
  }
4424
4338
  mr();
4425
- var wa = [
4339
+ var ma = [
4426
4340
  "url",
4427
4341
  "displayName",
4428
4342
  "enabled",
@@ -4446,27 +4360,27 @@ var wa = [
4446
4360
  "clientInfo",
4447
4361
  "oauth"
4448
4362
  ];
4449
- function Ta(e) {
4363
+ function ha(e) {
4450
4364
  let t = {};
4451
- for (let n of wa) {
4365
+ for (let n of ma) {
4452
4366
  let r = e[n];
4453
4367
  r !== void 0 && (t[n] = r);
4454
4368
  }
4455
4369
  return t;
4456
4370
  }
4457
- function Ea(e) {
4458
- return Ta(e);
4371
+ function ga(e) {
4372
+ return ha(e);
4459
4373
  }
4460
- var Da = 500, Oa = 5 * 6e4;
4461
- function ka(e) {
4462
- let [t, n] = (0, M.useState)([]), [r, i] = (0, M.useState)([]), [a, o] = (0, M.useState)([]), s = (0, M.useRef)(0), c = (0, M.useRef)(0), l = (0, M.useRef)(/* @__PURE__ */ new Map()), u = (0, M.useRef)(/* @__PURE__ */ new Map()), d = (0, M.useCallback)((e) => {
4374
+ var _a = 500, va = 5 * 6e4;
4375
+ function ya(e) {
4376
+ let [t, n] = (0, j.useState)([]), [r, i] = (0, j.useState)([]), [a, o] = (0, j.useState)([]), s = (0, j.useRef)(0), c = (0, j.useRef)(0), l = (0, j.useRef)(/* @__PURE__ */ new Map()), u = (0, j.useRef)(/* @__PURE__ */ new Map()), d = (0, j.useCallback)((e) => {
4463
4377
  for (let t of l.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
4464
4378
  l.current.clear();
4465
4379
  for (let t of u.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
4466
4380
  u.current.clear(), i([]), o([]);
4467
4381
  }, []);
4468
- (0, M.useEffect)(() => () => d("MCP server connection was removed"), [d]);
4469
- let f = (0, M.useCallback)((t) => {
4382
+ (0, j.useEffect)(() => () => d("MCP server connection was removed"), [d]);
4383
+ let f = (0, j.useCallback)((t) => {
4470
4384
  let r = {
4471
4385
  id: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`,
4472
4386
  method: t.method,
@@ -4474,14 +4388,14 @@ function ka(e) {
4474
4388
  timestamp: Date.now(),
4475
4389
  read: !1
4476
4390
  };
4477
- n((e) => [r, ...e].slice(0, Da)), e.onNotificationReceived?.(r);
4478
- }, [e.onNotificationReceived]), p = (0, M.useCallback)((e, t) => {
4391
+ n((e) => [r, ...e].slice(0, _a)), e.onNotificationReceived?.(r);
4392
+ }, [e.onNotificationReceived]), p = (0, j.useCallback)((e, t) => {
4479
4393
  let n = l.current.get(e);
4480
4394
  n && (clearTimeout(n.timeout), l.current.delete(e), i((t) => t.filter((t) => t.id !== e)), n.resolve(t));
4481
- }, []), m = (0, M.useCallback)((e, t) => {
4395
+ }, []), m = (0, j.useCallback)((e, t) => {
4482
4396
  let n = l.current.get(e);
4483
4397
  n && (clearTimeout(n.timeout), l.current.delete(e), i((t) => t.filter((t) => t.id !== e)), n.reject(Error(t ?? "User rejected sampling request")));
4484
- }, []), h = (0, M.useCallback)((t) => new Promise((n, r) => {
4398
+ }, []), h = (0, j.useCallback)((t) => new Promise((n, r) => {
4485
4399
  let a = `sampling-${s.current++}`, o = {
4486
4400
  id: a,
4487
4401
  request: {
@@ -4490,7 +4404,7 @@ function ka(e) {
4490
4404
  },
4491
4405
  timestamp: Date.now(),
4492
4406
  serverName: e.serverName
4493
- }, c = setTimeout(() => m(a, "Sampling request timed out"), Oa);
4407
+ }, c = setTimeout(() => m(a, "Sampling request timed out"), va);
4494
4408
  l.current.set(a, {
4495
4409
  resolve: n,
4496
4410
  reject: r,
@@ -4500,19 +4414,19 @@ function ka(e) {
4500
4414
  p,
4501
4415
  e,
4502
4416
  m
4503
- ]), g = (0, M.useCallback)((e, t) => {
4417
+ ]), g = (0, j.useCallback)((e, t) => {
4504
4418
  let n = u.current.get(e);
4505
4419
  n && (clearTimeout(n.timeout), u.current.delete(e), o((t) => t.filter((t) => t.id !== e)), n.resolve(t));
4506
- }, []), _ = (0, M.useCallback)((e, t) => {
4420
+ }, []), _ = (0, j.useCallback)((e, t) => {
4507
4421
  let n = u.current.get(e);
4508
4422
  n && (clearTimeout(n.timeout), u.current.delete(e), o((t) => t.filter((t) => t.id !== e)), n.reject(Error(t ?? "User rejected elicitation request")));
4509
- }, []), v = (0, M.useCallback)((t) => new Promise((n, r) => {
4423
+ }, []), v = (0, j.useCallback)((t) => new Promise((n, r) => {
4510
4424
  let i = `elicitation-${c.current++}`, a = {
4511
4425
  id: i,
4512
4426
  request: t,
4513
4427
  timestamp: Date.now(),
4514
4428
  serverName: e.serverName
4515
- }, s = setTimeout(() => _(i, "Elicitation request timed out"), Oa);
4429
+ }, s = setTimeout(() => _(i, "Elicitation request timed out"), va);
4516
4430
  u.current.set(i, {
4517
4431
  resolve: n,
4518
4432
  reject: r,
@@ -4522,15 +4436,15 @@ function ka(e) {
4522
4436
  g,
4523
4437
  e,
4524
4438
  _
4525
- ]), ee = (0, M.useCallback)((e) => {
4439
+ ]), ee = (0, j.useCallback)((e) => {
4526
4440
  n((t) => t.map((t) => t.id === e ? {
4527
4441
  ...t,
4528
4442
  read: !0
4529
4443
  } : t));
4530
- }, []), te = (0, M.useCallback)(() => n((e) => e.map((e) => ({
4444
+ }, []), te = (0, j.useCallback)(() => n((e) => e.map((e) => ({
4531
4445
  ...e,
4532
4446
  read: !0
4533
- }))), []), y = (0, M.useCallback)(() => n([]), []);
4447
+ }))), []), y = (0, j.useCallback)(() => n([]), []);
4534
4448
  return {
4535
4449
  notifications: t,
4536
4450
  pendingSamplingRequests: r,
@@ -4549,15 +4463,15 @@ function ka(e) {
4549
4463
  rejectAll: d
4550
4464
  };
4551
4465
  }
4552
- var Q = pr.get("McpClientProvider"), Aa = (0, M.createContext)(null);
4466
+ var Q = pr.get("McpClientProvider"), ba = (0, j.createContext)(null);
4553
4467
  function $(e, t) {
4554
4468
  return JSON.stringify(e) === JSON.stringify(t);
4555
4469
  }
4556
- function ja(e, t) {
4557
- return e.id === t.id && $(Ta(e), Ta(t)) && e.name === t.name && e.state === t.state && e.error === t.error && e.authUrl === t.authUrl && $(e.authTokens, t.authTokens) && e.protocolEra === t.protocolEra && e.protocolVersion === t.protocolVersion && $(e.serverInfo, t.serverInfo) && $(e.capabilities, t.capabilities) && e.instructions === t.instructions && $(e.extensions, t.extensions) && $(e.tools, t.tools) && $(e.resources, t.resources) && $(e.resourceTemplates, t.resourceTemplates) && $(e.prompts, t.prompts) && $(e.notifications, t.notifications) && e.unreadNotificationCount === t.unreadNotificationCount && $(e.pendingSamplingRequests, t.pendingSamplingRequests) && $(e.pendingElicitationRequests, t.pendingElicitationRequests) && e.client === t.client;
4470
+ function xa(e, t) {
4471
+ return e.id === t.id && $(ha(e), ha(t)) && e.name === t.name && e.state === t.state && e.error === t.error && e.authUrl === t.authUrl && $(e.authTokens, t.authTokens) && e.protocolEra === t.protocolEra && e.protocolVersion === t.protocolVersion && $(e.serverInfo, t.serverInfo) && $(e.capabilities, t.capabilities) && e.instructions === t.instructions && $(e.extensions, t.extensions) && $(e.tools, t.tools) && $(e.resources, t.resources) && $(e.resourceTemplates, t.resourceTemplates) && $(e.prompts, t.prompts) && $(e.notifications, t.notifications) && e.unreadNotificationCount === t.unreadNotificationCount && $(e.pendingSamplingRequests, t.pendingSamplingRequests) && $(e.pendingElicitationRequests, t.pendingElicitationRequests) && e.client === t.client;
4558
4472
  }
4559
- function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a, clientInfo: o, cachedMetadata: s, onUpdate: c, onUpdateConfig: l, onUpdateDisplayName: u, onReconnect: d, rpcWrapTransport: f, onGlobalSamplingRequest: p, onGlobalElicitationRequest: m }) {
4560
- let { displayName: h, onSamplingRequest: g, onElicitationRequest: _, onNotificationReceived: v, wrapTransport: ee } = t, te = (0, M.useMemo)(() => {
4473
+ function Sa({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a, clientInfo: o, cachedMetadata: s, onUpdate: c, onUpdateConfig: l, onUpdateDisplayName: u, onReconnect: d, rpcWrapTransport: f, onGlobalSamplingRequest: p, onGlobalElicitationRequest: m }) {
4474
+ let { displayName: h, onSamplingRequest: g, onElicitationRequest: _, onNotificationReceived: v, wrapTransport: ee } = t, te = (0, j.useMemo)(() => {
4561
4475
  let { displayName: c, onSamplingRequest: l, onElicitationRequest: u, onNotificationReceived: d, wrapTransport: f, ...p } = t;
4562
4476
  return {
4563
4477
  ...p,
@@ -4580,7 +4494,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4580
4494
  a,
4581
4495
  o,
4582
4496
  s
4583
- ]), y = (0, M.useMemo)(() => {
4497
+ ]), y = (0, j.useMemo)(() => {
4584
4498
  if (!(!f && !ee)) return (t) => {
4585
4499
  let n = t;
4586
4500
  return f && (n = f(n, e)), ee && (n = ee(n, e)), n;
@@ -4589,7 +4503,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4589
4503
  f,
4590
4504
  ee,
4591
4505
  e
4592
- ]), b = ka({
4506
+ ]), b = ya({
4593
4507
  serverId: e,
4594
4508
  serverName: h || e,
4595
4509
  onNotificationReceived: v,
@@ -4597,17 +4511,17 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4597
4511
  onElicitationRequest: _,
4598
4512
  onGlobalSamplingRequest: p,
4599
4513
  onGlobalElicitationRequest: m
4600
- }), x = pa({
4514
+ }), x = ra({
4601
4515
  ...te,
4602
4516
  onNotification: b.onNotification,
4603
4517
  onSampling: b.onSampling,
4604
4518
  onElicitation: b.onElicitation,
4605
4519
  wrapTransport: y
4606
4520
  });
4607
- (0, M.useEffect)(() => {
4521
+ (0, j.useEffect)(() => {
4608
4522
  x.state !== "ready" && b.rejectAll("MCP server connection is no longer active");
4609
4523
  }, [x.state, b.rejectAll]);
4610
- let S = (0, M.useCallback)((t) => l(e, t), [e, l]), C = (0, M.useCallback)((n) => {
4524
+ let S = (0, j.useCallback)((t) => l(e, t), [e, l]), C = (0, j.useCallback)((n) => {
4611
4525
  let r = t.proxyConfig?.proxyAddress?.trim();
4612
4526
  return t.connectionMode === "proxy" && r ? l(e, {
4613
4527
  proxyConfig: {
@@ -4622,12 +4536,12 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4622
4536
  t.connectionMode,
4623
4537
  t.proxyConfig,
4624
4538
  l
4625
- ]), ne = (0, M.useCallback)((t) => u(e, t), [e, u]), w = (0, M.useCallback)(() => d(e), [e, d]), re = (0, M.useRef)(c), T = (0, M.useRef)(null);
4626
- return (0, M.useEffect)(() => {
4539
+ ]), ne = (0, j.useCallback)((t) => u(e, t), [e, u]), w = (0, j.useCallback)(() => d(e), [e, d]), re = (0, j.useRef)(c), T = (0, j.useRef)(null);
4540
+ return (0, j.useEffect)(() => {
4627
4541
  re.current = c;
4628
- }, [c]), (0, M.useEffect)(() => {
4542
+ }, [c]), (0, j.useEffect)(() => {
4629
4543
  let n = {
4630
- ...Ea(t),
4544
+ ...ga(t),
4631
4545
  ...x,
4632
4546
  id: e,
4633
4547
  displayName: h || t.displayName || e,
@@ -4647,7 +4561,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4647
4561
  setDisplayName: ne,
4648
4562
  reconnect: w
4649
4563
  }, r = T.current;
4650
- !r || !ja(r, n) ? (T.current = n, re.current(n)) : Q.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`);
4564
+ !r || !xa(r, n) ? (T.current = n, re.current(n)) : Q.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`);
4651
4565
  }, [
4652
4566
  e,
4653
4567
  h,
@@ -4674,13 +4588,13 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4674
4588
  w
4675
4589
  ]), null;
4676
4590
  }
4677
- function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a = !1, defaultServerConfig: o, clientInfo: s, storageProvider: c, enableRpcLogging: l = !1, onServerAdded: u, onServerRemoved: d, onServerStateChange: f, onSamplingRequest: p, onElicitationRequest: m }) {
4678
- let [h, g] = (0, M.useState)([]), [_, v] = (0, M.useState)([]), [ee, te] = (0, M.useState)({}), [y, b] = (0, M.useState)(!1), x = (0, M.useRef)(!1), S = (0, M.useRef)([]);
4679
- (0, M.useEffect)(() => {
4591
+ function Ca({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a = !1, defaultServerConfig: o, clientInfo: s, storageProvider: c, enableRpcLogging: l = !1, onServerAdded: u, onServerRemoved: d, onServerStateChange: f, onSamplingRequest: p, onElicitationRequest: m }) {
4592
+ let [h, g] = (0, j.useState)([]), [_, v] = (0, j.useState)([]), [ee, te] = (0, j.useState)({}), [y, b] = (0, j.useState)(!1), x = (0, j.useRef)(!1), S = (0, j.useRef)([]);
4593
+ (0, j.useEffect)(() => {
4680
4594
  S.current = _;
4681
4595
  }, [_]);
4682
- let C = (0, M.useRef)({}), [ne, w] = (0, M.useState)(void 0), [re, T] = (0, M.useState)(!1);
4683
- (0, M.useEffect)(() => {
4596
+ let C = (0, j.useRef)({}), [ne, w] = (0, j.useState)(void 0), [re, T] = (0, j.useState)(!1);
4597
+ (0, j.useEffect)(() => {
4684
4598
  if (!l || typeof window > "u") {
4685
4599
  w(void 0), T(!0);
4686
4600
  return;
@@ -4690,7 +4604,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4690
4604
  }).catch((e) => {
4691
4605
  Q.error("[McpClientProvider] Failed to load RPC logger:", e), w(void 0), T(!0);
4692
4606
  });
4693
- }, [l]), (0, M.useEffect)(() => {
4607
+ }, [l]), (0, j.useEffect)(() => {
4694
4608
  if (!re) {
4695
4609
  Q.debug("[McpClientProvider] Waiting for RPC logging to be ready before loading servers");
4696
4610
  return;
@@ -4734,10 +4648,10 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4734
4648
  c,
4735
4649
  t,
4736
4650
  re
4737
- ]), (0, M.useEffect)(() => {
4651
+ ]), (0, j.useEffect)(() => {
4738
4652
  !c || !y || (async () => {
4739
4653
  try {
4740
- let e = h.reduce((e, t) => (e[t.id] = Ea(t.options), e), {});
4654
+ let e = h.reduce((e, t) => (e[t.id] = ga(t.options), e), {});
4741
4655
  await Promise.resolve(c.setServers(e));
4742
4656
  } catch (e) {
4743
4657
  Q.error("[McpClientProvider] Failed to save to storage:", e);
@@ -4748,7 +4662,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4748
4662
  c,
4749
4663
  y
4750
4664
  ]);
4751
- let E = (0, M.useCallback)((e) => {
4665
+ let E = (0, j.useCallback)((e) => {
4752
4666
  Q.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`, {
4753
4667
  toolCount: e.tools.length,
4754
4668
  state: e.state
@@ -4763,7 +4677,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4763
4677
  currentToolCount: i.tools.length,
4764
4678
  updatedToolCount: e.tools.length,
4765
4679
  stateChanged: a
4766
- }), ja(i, e)) return Q.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`), n;
4680
+ }), xa(i, e)) return Q.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`), n;
4767
4681
  if (Q.debug(`[McpClientProvider] Updating server ${e.id} in state`), a && t.push(() => f?.(e.id, e.state)), o && e.serverInfo && c?.setServerMetadata) {
4768
4682
  let t = {
4769
4683
  name: e.serverInfo.name,
@@ -4786,12 +4700,12 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4786
4700
  u,
4787
4701
  f,
4788
4702
  c
4789
- ]), D = (0, M.useCallback)((e, t) => {
4703
+ ]), D = (0, j.useCallback)((e, t) => {
4790
4704
  g((n) => n.find((t) => t.id === e) ? n : (Q.debug("[McpClientProvider] Adding new server to configs:", e), [...n, {
4791
4705
  id: e,
4792
4706
  options: t
4793
4707
  }]));
4794
- }, []), O = (0, M.useCallback)(async (e, t) => {
4708
+ }, []), ie = (0, j.useCallback)(async (e, t) => {
4795
4709
  let n = S.current.find((t) => t.id === e);
4796
4710
  if (v((t) => t.filter((t) => t.id !== e)), g((t) => t.filter((t) => t.id !== e)), te((t) => {
4797
4711
  let { [e]: n, ...r } = t;
@@ -4801,7 +4715,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4801
4715
  t(e);
4802
4716
  }
4803
4717
  d?.(e);
4804
- }, [l, d]), k = (0, M.useCallback)(async (e, t) => {
4718
+ }, [l, d]), O = (0, j.useCallback)(async (e, t) => {
4805
4719
  let n = h.find((t) => t.id === e);
4806
4720
  if (!n) {
4807
4721
  Q.warn(`[McpClientProvider] Cannot update server "${e}" - not found`);
@@ -4811,14 +4725,14 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4811
4725
  ...n.options,
4812
4726
  ...t
4813
4727
  };
4814
- $(Ta(n.options), Ta(r)) || (await S.current.find((t) => t.id === e)?.disconnect(), v((t) => t.filter((t) => t.id !== e)), g((t) => t.map((t) => t.id === e ? {
4728
+ $(ha(n.options), ha(r)) || (await S.current.find((t) => t.id === e)?.disconnect(), v((t) => t.filter((t) => t.id !== e)), g((t) => t.map((t) => t.id === e ? {
4815
4729
  id: e,
4816
4730
  options: r
4817
4731
  } : t)), te((t) => ({
4818
4732
  ...t,
4819
4733
  [e]: (t[e] ?? 0) + 1
4820
4734
  })));
4821
- }, [h]), A = (0, M.useCallback)(async (e) => {
4735
+ }, [h]), k = (0, j.useCallback)(async (e) => {
4822
4736
  if (!h.find((t) => t.id === e)) {
4823
4737
  Q.warn(`[McpClientProvider] Cannot reconnect server "${e}" - not found`);
4824
4738
  return;
@@ -4827,7 +4741,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4827
4741
  ...t,
4828
4742
  [e]: (t[e] ?? 0) + 1
4829
4743
  }));
4830
- }, [h]), j = (0, M.useCallback)(async (e, t) => new Promise((n) => {
4744
+ }, [h]), ae = (0, j.useCallback)(async (e, t) => new Promise((n) => {
4831
4745
  let r = h.find((t) => t.id === e);
4832
4746
  if (!r) {
4833
4747
  Q.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`), n();
@@ -4847,33 +4761,33 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4847
4761
  } : t);
4848
4762
  return setTimeout(() => n(), 0), r;
4849
4763
  });
4850
- }), [h]), ie = (0, M.useCallback)((e) => _.find((t) => t.id === e), [_]), N = (0, M.useMemo)(() => ({
4764
+ }), [h]), A = (0, j.useCallback)((e) => _.find((t) => t.id === e), [_]), oe = (0, j.useMemo)(() => ({
4851
4765
  servers: _,
4852
4766
  addServer: D,
4853
- removeServer: O,
4854
- updateServerMetadata: j,
4855
- updateServer: k,
4856
- getServer: ie,
4767
+ removeServer: ie,
4768
+ updateServerMetadata: ae,
4769
+ updateServer: O,
4770
+ getServer: A,
4857
4771
  storageLoaded: y
4858
4772
  }), [
4859
4773
  _,
4860
4774
  D,
4861
- O,
4862
- j,
4863
- k,
4864
4775
  ie,
4776
+ ae,
4777
+ O,
4778
+ A,
4865
4779
  y
4866
- ]), { capabilities: ae, ...P } = s || {}, F = (0, M.useMemo)(() => Object.keys(P).length ? P : void 0, [s]), I = (0, M.useMemo)(() => h.map((e) => {
4780
+ ]), { capabilities: se, ...M } = s || {}, N = (0, j.useMemo)(() => Object.keys(M).length ? M : void 0, [s]), ce = (0, j.useMemo)(() => h.map((e) => {
4867
4781
  let t = o ? {
4868
4782
  ...o,
4869
4783
  ...e.options
4870
4784
  } : e.options;
4871
- return ae && (t = {
4785
+ return se && (t = {
4872
4786
  ...t,
4873
4787
  clientOptions: {
4874
4788
  ...t.clientOptions,
4875
4789
  capabilities: {
4876
- ...ae,
4790
+ ...se,
4877
4791
  ...t.clientOptions?.capabilities
4878
4792
  }
4879
4793
  }
@@ -4883,10 +4797,10 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4883
4797
  };
4884
4798
  }), [
4885
4799
  h,
4886
- ae,
4800
+ se,
4887
4801
  o
4888
- ]), oe = typeof window < "u" && /\/oauth\/callback\/?$/.test(window.location.pathname);
4889
- return /* @__PURE__ */ M.createElement(Aa.Provider, { value: N }, e, !oe && I.map((e) => /* @__PURE__ */ M.createElement(Ma, {
4802
+ ]), P = typeof window < "u" && /\/oauth\/callback\/?$/.test(window.location.pathname);
4803
+ return /* @__PURE__ */ j.createElement(ba.Provider, { value: oe }, e, !P && ce.map((e) => /* @__PURE__ */ j.createElement(Sa, {
4890
4804
  key: `${e.id}-v${ee[e.id] ?? 0}`,
4891
4805
  id: e.id,
4892
4806
  options: e.options,
@@ -4894,23 +4808,23 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4894
4808
  defaultOAuthProxyUrl: r,
4895
4809
  defaultProxyConfig: i,
4896
4810
  defaultAutoProxyFallback: a,
4897
- clientInfo: F,
4811
+ clientInfo: N,
4898
4812
  cachedMetadata: C.current[e.id],
4899
4813
  onUpdate: E,
4900
- onUpdateConfig: k,
4901
- onUpdateDisplayName: (e, t) => j(e, { name: t }),
4902
- onReconnect: A,
4814
+ onUpdateConfig: O,
4815
+ onUpdateDisplayName: (e, t) => ae(e, { name: t }),
4816
+ onReconnect: k,
4903
4817
  rpcWrapTransport: ne,
4904
4818
  onGlobalSamplingRequest: p,
4905
4819
  onGlobalElicitationRequest: m
4906
4820
  })));
4907
4821
  }
4908
- function Pa() {
4909
- let e = (0, M.useContext)(Aa);
4822
+ function wa() {
4823
+ let e = (0, j.useContext)(ba);
4910
4824
  if (!e) throw Error("useMcpClient must be used within a McpClientProvider");
4911
4825
  return e;
4912
4826
  }
4913
- var Fa = class {
4827
+ var Ta = class {
4914
4828
  constructor(e = "mcp-client-servers") {
4915
4829
  this.storageKey = e, this.metadataKey = `${e}-metadata`;
4916
4830
  }
@@ -4976,7 +4890,7 @@ var Fa = class {
4976
4890
  }
4977
4891
  };
4978
4892
  wr();
4979
- function Ia(e) {
4893
+ function Ea(e) {
4980
4894
  let t = {};
4981
4895
  if (!e) return t;
4982
4896
  for (let [n, r] of Object.entries(e)) if (typeof r == "string" && (r.trim().startsWith("[") || r.trim().startsWith("{"))) try {
@@ -4987,7 +4901,11 @@ function Ia(e) {
4987
4901
  else t[n] = r;
4988
4902
  return t;
4989
4903
  }
4990
- function La(e) {
4904
+ var Da = "<script>\n(function () {\n var files = new Map();\n window.openai = window.openai || {};\n window.openai.uploadFile = async function (file) {\n var fileId = crypto.randomUUID();\n files.set(fileId, file);\n return { fileId: fileId };\n };\n window.openai.getFileDownloadUrl = async function (ref) {\n var file = files.get(ref.fileId);\n if (!file) {\n throw new Error(\"File not found: \" + ref.fileId);\n }\n return { downloadUrl: URL.createObjectURL(file) };\n };\n})();\n<\/script>";
4905
+ function Oa(e) {
4906
+ return e.includes("<head>") ? e.replace("<head>", "<head>" + Da) : e.includes("<HEAD>") ? e.replace("<HEAD>", "<HEAD>" + Da) : e.includes("<html>") ? e.replace("<html>", "<html><head>" + Da + "</head>") : e.includes("<HTML>") ? e.replace("<HTML>", "<HTML><head>" + Da + "</head>") : e.includes("<!DOCTYPE") || e.includes("<!doctype") ? e.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, "$1<head>" + Da + "</head>") : Da + e;
4907
+ }
4908
+ function ka(e) {
4991
4909
  let { resourceResult: t, listingResource: n, cspMode: r, resourceUri: i } = e, a = (Array.isArray(t?.contents) ? t.contents : [])[0], o = "", s;
4992
4910
  if (a && (s = a.mimeType, typeof a.text == "string" ? o = a.text : typeof a.blob == "string" && (o = atob(a.blob))), !o) throw Error("No HTML content in resource");
4993
4911
  let c = n?._meta?.ui, l = a?._meta?.ui, u = c || l ? {
@@ -5005,7 +4923,7 @@ function La(e) {
5005
4923
  mimeTypeWarning: h
5006
4924
  };
5007
4925
  }
5008
- function Ra(e, t) {
4926
+ function Aa(e, t) {
5009
4927
  let { cspMode: n, permissions: r, widgetCsp: i } = t;
5010
4928
  e.searchParams.set("v", JSON.stringify({
5011
4929
  cspMode: n,
@@ -5013,77 +4931,92 @@ function Ra(e, t) {
5013
4931
  widgetCsp: i
5014
4932
  })), e.searchParams.set("csp_mode", n), r && Object.keys(r).length > 0 && e.searchParams.set("permissions", JSON.stringify(r)), i && Object.keys(i).length > 0 && e.searchParams.set("widget_csp", JSON.stringify(i));
5015
4933
  }
5016
- function za(e) {
4934
+ function ja(e) {
5017
4935
  let t = new URL("https://sandbox.invalid/");
5018
- Ra(t, e);
5019
- let n = Va(t.search);
4936
+ Aa(t, e);
4937
+ let n = Na(t.search);
5020
4938
  return new URL(URL.createObjectURL(new Blob([n], { type: "text/html" })));
5021
4939
  }
5022
- var Ba = "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta\n http-equiv=\"Content-Security-Policy\"\n content=\"default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src * 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data:; style-src * blob: data: 'unsafe-inline'; connect-src * data: blob: about:; frame-src * blob: data: http://localhost:* https://localhost:* http://127.0.0.1:* https://127.0.0.1:*;\"\n />\n <title>MCP Apps Sandbox Proxy</title>\n <style>\n html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }\n * { box-sizing: border-box; }\n iframe { display: block; background-color: transparent; border: 0px none transparent; padding: 0px; width: 100%; height: 100%; }\n </style>\n </head>\n <body>\n <script>\n function sanitizeDomain(domain) {\n if (typeof domain !== \"string\") return \"\";\n return domain.replace(/['\"<>;]/g, \"\").trim();\n }\n\n function buildAllowAttribute(permissions) {\n if (!permissions) return \"\";\n const allowList = [];\n if (permissions.camera) allowList.push(\"camera *\");\n if (permissions.microphone) allowList.push(\"microphone *\");\n if (permissions.geolocation) allowList.push(\"geolocation *\");\n if (permissions.clipboardWrite) allowList.push(\"clipboard-write *\");\n return allowList.join(\"; \");\n }\n\n function buildCSP(csp) {\n if (!csp) {\n return [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline'\",\n \"style-src 'unsafe-inline'\",\n \"img-src data:\",\n \"font-src data:\",\n \"media-src data:\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n ].join(\"; \");\n }\n\n const connectDomains = (csp.connectDomains || []).map(sanitizeDomain).filter(Boolean);\n const resourceDomains = (csp.resourceDomains || []).map(sanitizeDomain).filter(Boolean);\n const frameDomains = (csp.frameDomains || []).map(sanitizeDomain).filter(Boolean);\n const baseUriDomains = (csp.baseUriDomains || []).map(sanitizeDomain).filter(Boolean);\n const scriptDirectives = (csp.scriptDirectives || []).filter(function(d) { return typeof d === \"string\" && d.length > 0; });\n\n const connectSrc = connectDomains.length > 0 ? connectDomains.join(\" \") : \"'none'\";\n const resourceSrc = resourceDomains.length > 0 ? [\"data:\", \"blob:\", ...resourceDomains].join(\" \") : \"data: blob:\";\n const frameSrc = frameDomains.length > 0 ? frameDomains.join(\" \") : \"'none'\";\n const baseUri = baseUriDomains.length > 0 ? baseUriDomains.join(\" \") : \"'none'\";\n const scriptSrcParts = [\"'unsafe-inline'\", resourceSrc];\n if (scriptDirectives.length > 0) scriptSrcParts.push(scriptDirectives.join(\" \"));\n\n return [\n \"default-src 'none'\",\n \"script-src \" + scriptSrcParts.join(\" \"),\n \"style-src 'unsafe-inline' \" + resourceSrc,\n \"img-src \" + resourceSrc,\n \"font-src \" + resourceSrc,\n \"media-src \" + resourceSrc,\n \"connect-src \" + connectSrc,\n \"frame-src \" + frameSrc,\n \"object-src 'none'\",\n \"base-uri \" + baseUri,\n ].join(\"; \");\n }\n\n function buildViolationListenerScript() {\n return `<script>\ndocument.addEventListener('securitypolicyviolation', function(e) {\n var violation = {\n type: 'mcp-apps:csp-violation',\n directive: e.violatedDirective,\n blockedUri: e.blockedURI,\n sourceFile: e.sourceFile || null,\n lineNumber: e.lineNumber || null,\n columnNumber: e.columnNumber || null,\n effectiveDirective: e.effectiveDirective,\n originalPolicy: e.originalPolicy,\n disposition: e.disposition,\n timestamp: Date.now()\n };\n console.warn('[MCP Apps CSP Violation]', violation.directive, ':', violation.blockedUri);\n window.parent.postMessage(violation, '*');\n});\n\nfunction serializeConsoleArgs(args) {\n try {\n return Array.from(args || []).map(function(arg) {\n if (arg instanceof Error) {\n return {\n type: 'Error',\n message: arg.message,\n stack: arg.stack,\n name: arg.name,\n };\n }\n if (typeof arg === 'object' && arg !== null) {\n try {\n return JSON.parse(JSON.stringify(arg));\n } catch (e) {\n return String(arg);\n }\n }\n return arg;\n });\n } catch (e) {\n return [String(args)];\n }\n}\n\nfunction sendConsoleToParent(level, args) {\n try {\n window.parent.postMessage({\n type: 'iframe-console-log',\n level: level,\n args: serializeConsoleArgs(args),\n timestamp: new Date().toISOString(),\n url: window.location.href,\n }, '*');\n } catch (e) {}\n}\n\nvar originalConsoleError = console.error.bind(console);\nconsole.error = function() {\n var args = Array.from(arguments);\n originalConsoleError.apply(console, args);\n sendConsoleToParent('error', args);\n};\n\nwindow.addEventListener('error', function(event) {\n sendConsoleToParent('error', [{\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error ? {\n message: event.error.message,\n stack: event.error.stack,\n name: event.error.name,\n } : null,\n }]);\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n sendConsoleToParent('error', [{\n message: 'Unhandled Promise Rejection',\n reason: event.reason ? String(event.reason) : 'Unknown',\n error: event.reason instanceof Error ? {\n message: event.reason.message,\n stack: event.reason.stack,\n name: event.reason.name,\n } : null,\n }]);\n});\n</` + `script>`;\n }\n\n function injectCSP(html, cspValue) {\n const cspMeta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + cspValue + '\">';\n const violationListener = buildViolationListenerScript();\n const injection = cspMeta + violationListener;\n\n if (html.includes(\"<head>\")) {\n return html.replace(\"<head>\", \"<head>\" + injection);\n } else if (html.includes(\"<HEAD>\")) {\n return html.replace(\"<HEAD>\", \"<HEAD>\" + injection);\n } else if (html.includes(\"<html>\")) {\n return html.replace(\"<html>\", \"<html><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<HTML>\")) {\n return html.replace(\"<HTML>\", \"<HTML><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<!DOCTYPE\") || html.includes(\"<!doctype\")) {\n return html.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, \"$1<head>\" + injection + \"</head>\");\n } else {\n return injection + html;\n }\n }\n\n // Query params from host (csp_mode, permissions, widget_csp). AppFrame only\n // sends { html, csp } in sandbox-resource-ready; we carry the rest on the URL.\n // Blob URLs cannot reliably carry search params, so the CDN shell injects\n // window.__SANDBOX_SEARCH__ via buildSandboxProxyBlobHtml.\n const query = new URLSearchParams(\n typeof window.__SANDBOX_SEARCH__ === \"string\"\n ? window.__SANDBOX_SEARCH__\n : location.search\n );\n const queryCspMode = query.get(\"csp_mode\") || \"permissive\";\n let queryPermissions = null;\n let queryWidgetCsp = null;\n try {\n const rawPerm = query.get(\"permissions\");\n if (rawPerm) queryPermissions = JSON.parse(rawPerm);\n } catch (e) {}\n try {\n const rawCsp = query.get(\"widget_csp\");\n if (rawCsp) queryWidgetCsp = JSON.parse(rawCsp);\n } catch (e) {}\n\n const inner = document.createElement(\"iframe\");\n inner.style = \"width:100%; height:100%; border:none;\";\n inner.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\n document.body.appendChild(inner);\n\n window.addEventListener(\"message\", async (event) => {\n if (event.source === window.parent) {\n if (event.data && event.data.method === \"ui/notifications/sandbox-resource-ready\") {\n const params = event.data.params || {};\n const html = params.html;\n const sandbox = params.sandbox;\n // Prefer message csp when present; fall back to URL widget_csp\n const csp = params.csp != null ? params.csp : queryWidgetCsp;\n const permissions = params.permissions != null ? params.permissions : queryPermissions;\n const permissive =\n typeof params.permissive === \"boolean\"\n ? params.permissive\n : queryCspMode === \"permissive\";\n if (typeof sandbox === \"string\") {\n inner.setAttribute(\"sandbox\", sandbox);\n }\n const allowAttribute = buildAllowAttribute(permissions);\n if (allowAttribute) {\n inner.setAttribute(\"allow\", allowAttribute);\n }\n if (typeof html === \"string\") {\n if (permissive) {\n const permissiveCsp = [\n \"default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:\",\n \"script-src * 'unsafe-inline' 'unsafe-eval' data: blob:\",\n \"style-src * 'unsafe-inline' data: blob:\",\n \"img-src * data: blob: https: http:\",\n \"media-src * data: blob: https: http:\",\n \"font-src * data: blob: https: http:\",\n \"connect-src * data: blob: https: http: ws: wss: about:\",\n \"frame-src * data: blob: https: http: about:\",\n \"object-src * data: blob:\",\n \"base-uri *\",\n \"form-action *\",\n ].join(\"; \");\n const processedHtml = injectCSP(html, permissiveCsp);\n inner.srcdoc = processedHtml;\n } else {\n const cspValue = buildCSP(csp);\n const processedHtml = injectCSP(html, cspValue);\n inner.srcdoc = processedHtml;\n }\n }\n } else {\n if (inner && inner.contentWindow) {\n inner.contentWindow.postMessage(event.data, \"*\");\n }\n }\n } else if (event.source === inner.contentWindow) {\n window.parent.postMessage(event.data, \"*\");\n }\n });\n\n window.parent.postMessage({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/sandbox-proxy-ready\",\n params: {},\n }, \"*\");\n <\/script>\n </body>\n</html>";
5023
- function Va(e) {
4940
+ var Ma = "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta\n http-equiv=\"Content-Security-Policy\"\n content=\"default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src * 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data:; style-src * blob: data: 'unsafe-inline'; connect-src * data: blob: about:; frame-src * blob: data: http://localhost:* https://localhost:* http://127.0.0.1:* https://127.0.0.1:*;\"\n />\n <title>MCP Apps Sandbox Proxy</title>\n <style>\n html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }\n * { box-sizing: border-box; }\n iframe { display: block; background-color: transparent; border: 0px none transparent; padding: 0px; width: 100%; height: 100%; }\n </style>\n </head>\n <body>\n <script>\n function sanitizeDomain(domain) {\n if (typeof domain !== \"string\") return \"\";\n return domain.replace(/['\"<>;]/g, \"\").trim();\n }\n\n function buildAllowAttribute(permissions) {\n if (!permissions) return \"\";\n const allowList = [];\n if (permissions.camera) allowList.push(\"camera *\");\n if (permissions.microphone) allowList.push(\"microphone *\");\n if (permissions.geolocation) allowList.push(\"geolocation *\");\n if (permissions.clipboardWrite) allowList.push(\"clipboard-write *\");\n return allowList.join(\"; \");\n }\n\n function buildCSP(csp) {\n if (!csp) {\n return [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline'\",\n \"style-src 'unsafe-inline'\",\n \"img-src data:\",\n \"font-src data:\",\n \"media-src data:\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n ].join(\"; \");\n }\n\n const connectDomains = (csp.connectDomains || []).map(sanitizeDomain).filter(Boolean);\n const resourceDomains = (csp.resourceDomains || []).map(sanitizeDomain).filter(Boolean);\n const frameDomains = (csp.frameDomains || []).map(sanitizeDomain).filter(Boolean);\n const baseUriDomains = (csp.baseUriDomains || []).map(sanitizeDomain).filter(Boolean);\n const scriptDirectives = (csp.scriptDirectives || []).filter(function(d) { return typeof d === \"string\" && d.length > 0; });\n\n const connectSrc = connectDomains.length > 0 ? connectDomains.join(\" \") : \"'none'\";\n const resourceSrc = resourceDomains.length > 0 ? [\"data:\", \"blob:\", ...resourceDomains].join(\" \") : \"data: blob:\";\n const frameSrc = frameDomains.length > 0 ? frameDomains.join(\" \") : \"'none'\";\n const baseUri = baseUriDomains.length > 0 ? baseUriDomains.join(\" \") : \"'none'\";\n const scriptSrcParts = [\"'unsafe-inline'\", resourceSrc];\n if (scriptDirectives.length > 0) scriptSrcParts.push(scriptDirectives.join(\" \"));\n\n return [\n \"default-src 'none'\",\n \"script-src \" + scriptSrcParts.join(\" \"),\n \"style-src 'unsafe-inline' \" + resourceSrc,\n \"img-src \" + resourceSrc,\n \"font-src \" + resourceSrc,\n \"media-src \" + resourceSrc,\n \"connect-src \" + connectSrc,\n \"frame-src \" + frameSrc,\n \"object-src 'none'\",\n \"base-uri \" + baseUri,\n ].join(\"; \");\n }\n\n function buildViolationListenerScript() {\n return `<script>\ndocument.addEventListener('securitypolicyviolation', function(e) {\n var violation = {\n type: 'mcp-apps:csp-violation',\n directive: e.violatedDirective,\n blockedUri: e.blockedURI,\n sourceFile: e.sourceFile || null,\n lineNumber: e.lineNumber || null,\n columnNumber: e.columnNumber || null,\n effectiveDirective: e.effectiveDirective,\n originalPolicy: e.originalPolicy,\n disposition: e.disposition,\n timestamp: Date.now()\n };\n console.warn('[MCP Apps CSP Violation]', violation.directive, ':', violation.blockedUri);\n window.parent.postMessage(violation, '*');\n});\n\nfunction serializeConsoleArgs(args) {\n try {\n return Array.from(args || []).map(function(arg) {\n if (arg instanceof Error) {\n return {\n type: 'Error',\n message: arg.message,\n stack: arg.stack,\n name: arg.name,\n };\n }\n if (typeof arg === 'object' && arg !== null) {\n try {\n return JSON.parse(JSON.stringify(arg));\n } catch (e) {\n return String(arg);\n }\n }\n return arg;\n });\n } catch (e) {\n return [String(args)];\n }\n}\n\nfunction sendConsoleToParent(level, args) {\n try {\n window.parent.postMessage({\n type: 'iframe-console-log',\n level: level,\n args: serializeConsoleArgs(args),\n timestamp: new Date().toISOString(),\n url: window.location.href,\n }, '*');\n } catch (e) {}\n}\n\nvar originalConsoleError = console.error.bind(console);\nconsole.error = function() {\n var args = Array.from(arguments);\n originalConsoleError.apply(console, args);\n sendConsoleToParent('error', args);\n};\n\nwindow.addEventListener('error', function(event) {\n sendConsoleToParent('error', [{\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error ? {\n message: event.error.message,\n stack: event.error.stack,\n name: event.error.name,\n } : null,\n }]);\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n sendConsoleToParent('error', [{\n message: 'Unhandled Promise Rejection',\n reason: event.reason ? String(event.reason) : 'Unknown',\n error: event.reason instanceof Error ? {\n message: event.reason.message,\n stack: event.reason.stack,\n name: event.reason.name,\n } : null,\n }]);\n});\n</` + `script>`;\n }\n\n function injectCSP(html, cspValue) {\n const cspMeta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + cspValue + '\">';\n const violationListener = buildViolationListenerScript();\n const injection = cspMeta + violationListener;\n\n if (html.includes(\"<head>\")) {\n return html.replace(\"<head>\", \"<head>\" + injection);\n } else if (html.includes(\"<HEAD>\")) {\n return html.replace(\"<HEAD>\", \"<HEAD>\" + injection);\n } else if (html.includes(\"<html>\")) {\n return html.replace(\"<html>\", \"<html><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<HTML>\")) {\n return html.replace(\"<HTML>\", \"<HTML><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<!DOCTYPE\") || html.includes(\"<!doctype\")) {\n return html.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, \"$1<head>\" + injection + \"</head>\");\n } else {\n return injection + html;\n }\n }\n\n // Query params from host (csp_mode, permissions, widget_csp). AppFrame only\n // sends { html, csp } in sandbox-resource-ready; we carry the rest on the URL.\n // Blob URLs cannot reliably carry search params, so the CDN shell injects\n // window.__SANDBOX_SEARCH__ via buildSandboxProxyBlobHtml.\n const query = new URLSearchParams(\n typeof window.__SANDBOX_SEARCH__ === \"string\"\n ? window.__SANDBOX_SEARCH__\n : location.search\n );\n const queryCspMode = query.get(\"csp_mode\") || \"permissive\";\n let queryPermissions = null;\n let queryWidgetCsp = null;\n try {\n const rawPerm = query.get(\"permissions\");\n if (rawPerm) queryPermissions = JSON.parse(rawPerm);\n } catch (e) {}\n try {\n const rawCsp = query.get(\"widget_csp\");\n if (rawCsp) queryWidgetCsp = JSON.parse(rawCsp);\n } catch (e) {}\n\n const inner = document.createElement(\"iframe\");\n inner.style = \"width:100%; height:100%; border:none;\";\n inner.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\n document.body.appendChild(inner);\n\n window.addEventListener(\"message\", async (event) => {\n if (event.source === window.parent) {\n if (event.data && event.data.method === \"ui/notifications/sandbox-resource-ready\") {\n const params = event.data.params || {};\n const html = params.html;\n const sandbox = params.sandbox;\n // Prefer message csp when present; fall back to URL widget_csp\n const csp = params.csp != null ? params.csp : queryWidgetCsp;\n const permissions = params.permissions != null ? params.permissions : queryPermissions;\n const permissive =\n typeof params.permissive === \"boolean\"\n ? params.permissive\n : queryCspMode === \"permissive\";\n if (typeof sandbox === \"string\") {\n inner.setAttribute(\"sandbox\", sandbox);\n }\n const allowAttribute = buildAllowAttribute(permissions);\n if (allowAttribute) {\n inner.setAttribute(\"allow\", allowAttribute);\n }\n if (typeof html === \"string\") {\n if (permissive) {\n const permissiveCsp = [\n \"default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:\",\n \"script-src * 'unsafe-inline' 'unsafe-eval' data: blob:\",\n \"style-src * 'unsafe-inline' data: blob:\",\n \"img-src * data: blob: https: http:\",\n \"media-src * data: blob: https: http:\",\n \"font-src * data: blob: https: http:\",\n \"connect-src * data: blob: https: http: ws: wss: about:\",\n \"frame-src * data: blob: https: http: about:\",\n \"object-src * data: blob:\",\n \"base-uri *\",\n \"form-action *\",\n ].join(\"; \");\n const processedHtml = injectCSP(html, permissiveCsp);\n inner.srcdoc = processedHtml;\n } else {\n const cspValue = buildCSP(csp);\n const processedHtml = injectCSP(html, cspValue);\n inner.srcdoc = processedHtml;\n }\n }\n } else {\n if (inner && inner.contentWindow) {\n inner.contentWindow.postMessage(event.data, \"*\");\n }\n }\n } else if (event.source === inner.contentWindow) {\n window.parent.postMessage(event.data, \"*\");\n }\n });\n\n window.parent.postMessage({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/sandbox-proxy-ready\",\n params: {},\n }, \"*\");\n <\/script>\n </body>\n</html>";
4941
+ function Na(e) {
5024
4942
  let t = "<script>window.__SANDBOX_SEARCH__ = " + JSON.stringify(e).replace(/</g, "\\u003c") + ";<\/script>";
5025
- return Ba.replace("<body>", "<body>" + t);
4943
+ return Ma.replace("<body>", "<body>" + t);
5026
4944
  }
5027
- var Ha = "fixed inset-0 z-[100] w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background", Ua = [
5028
- "fixed top-4 left-1/2 -translate-x-1/2 z-[100]",
4945
+ var Pa = "fixed inset-0 z-[200] w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background", Fa = [
4946
+ "fixed top-4 left-1/2 -translate-x-1/2 z-[200]",
5029
4947
  "rounded-3xl w-full min-w-[300px] h-[400px]",
5030
4948
  "shadow-2xl border overflow-hidden",
5031
4949
  "bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",
5032
4950
  "flex flex-col"
5033
- ].join(" "), Wa = "data-mcp-widget-fullscreen", Ga = "data-mcp-widget-display-mode";
5034
- function Ka(e) {
5035
- (0, M.useEffect)(() => {
4951
+ ].join(" "), Ia = "data-mcp-widget-fullscreen", La = "data-mcp-widget-display-mode";
4952
+ function Ra(e) {
4953
+ (0, j.useEffect)(() => {
5036
4954
  if (!(typeof document > "u")) {
5037
- if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(Ga, e), e === "fullscreen" ? document.documentElement.setAttribute(Wa, "") : document.documentElement.removeAttribute(Wa), () => {
5038
- document.documentElement.removeAttribute(Ga), document.documentElement.removeAttribute(Wa);
4955
+ if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(La, e), e === "fullscreen" ? document.documentElement.setAttribute(Ia, "") : document.documentElement.removeAttribute(Ia), () => {
4956
+ document.documentElement.removeAttribute(La), document.documentElement.removeAttribute(Ia);
5039
4957
  };
5040
- document.documentElement.removeAttribute(Ga), document.documentElement.removeAttribute(Wa);
4958
+ document.documentElement.removeAttribute(La), document.documentElement.removeAttribute(Ia);
5041
4959
  }
5042
4960
  }, [e]);
5043
4961
  }
5044
- function qa({ displayMode: e, setDisplayMode: t }) {
4962
+ function za({ displayMode: e, setDisplayMode: t }) {
5045
4963
  let n = e === "fullscreen", r = e === "pip";
5046
- return Ka(e), {
5047
- handleDisplayModeChange: (0, M.useCallback)((e) => t(e), [t]),
5048
- fullscreenShellClassName: n ? Ha : void 0,
5049
- pipShellClassName: r ? Ua : void 0,
4964
+ return Ra(e), {
4965
+ handleDisplayModeChange: (0, j.useCallback)((e) => t(e), [t]),
4966
+ fullscreenShellClassName: n ? Pa : void 0,
4967
+ pipShellClassName: r ? Fa : void 0,
5050
4968
  isFullscreen: n,
5051
4969
  isPip: r
5052
4970
  };
5053
4971
  }
5054
- var Ja = {
4972
+ var Ba = {
5055
4973
  PIP_MAX_WIDTH: 700,
5056
- DEFAULT_HEIGHT: 400
4974
+ DEFAULT_HEIGHT: 400,
4975
+ FULLSCREEN_HEADER_HEIGHT: 50
5057
4976
  };
5058
- function Ya(e) {
4977
+ function Va(e) {
5059
4978
  let t = e?.ui;
5060
4979
  return t && typeof t == "object" && "resourceUri" in t && typeof t.resourceUri == "string" ? t.resourceUri : null;
5061
4980
  }
5062
- function Xa(e) {
5063
- return Ya(e) !== null;
4981
+ function Ha(e) {
4982
+ return Va(e) !== null;
5064
4983
  }
5065
- function Za(e) {
4984
+ function Ua(e) {
5066
4985
  return e === er;
5067
4986
  }
5068
- var Qa = {
4987
+ var Wa = {
5069
4988
  name: "mcp-use-client",
5070
4989
  version: "2.0.0"
5071
- }, $a = 6e5, eo = "ui/notifications/sandbox-proxy-ready", to = {
4990
+ }, Ga = 6e5, Ka = "ui/notifications/sandbox-proxy-ready", qa = {
5072
4991
  openLinks: {},
5073
4992
  serverTools: {},
5074
4993
  serverResources: {},
5075
4994
  logging: {},
5076
- updateModelContext: { text: {} }
4995
+ updateModelContext: { text: {} },
4996
+ message: { text: {} }
5077
4997
  };
5078
- function no(e) {
4998
+ function Ja() {
4999
+ return /* @__PURE__ */ j.createElement("svg", {
5000
+ width: "14",
5001
+ height: "14",
5002
+ viewBox: "0 0 24 24",
5003
+ fill: "none",
5004
+ stroke: "currentColor",
5005
+ strokeWidth: "2",
5006
+ strokeLinecap: "round",
5007
+ strokeLinejoin: "round",
5008
+ "aria-hidden": !0
5009
+ }, /* @__PURE__ */ j.createElement("path", { d: "M18 6 6 18" }), /* @__PURE__ */ j.createElement("path", { d: "m6 6 12 12" }));
5010
+ }
5011
+ function Ya(e) {
5079
5012
  return new Promise((t) => {
5080
5013
  let n = (r) => {
5081
- r.source === e.contentWindow && r.data?.method === eo && (window.removeEventListener("message", n), t());
5014
+ r.source === e.contentWindow && r.data?.method === Ka && (window.removeEventListener("message", n), t());
5082
5015
  };
5083
5016
  window.addEventListener("message", n);
5084
5017
  });
5085
5018
  }
5086
- function ro(e) {
5019
+ function Xa(e) {
5087
5020
  let t = e.oninitialized;
5088
5021
  return new Promise((n) => {
5089
5022
  e.oninitialized = (...r) => {
@@ -5091,67 +5024,76 @@ function ro(e) {
5091
5024
  };
5092
5025
  });
5093
5026
  }
5094
- function io(e, t) {
5095
- let n = Ia(t);
5027
+ function Za(e, t) {
5028
+ let n = Ea(t);
5096
5029
  return Object.keys(n).length > 0 ? {
5097
5030
  ...typeof e == "object" && e ? e : {},
5098
5031
  structuredContent: n
5099
5032
  } : e ?? null;
5100
5033
  }
5101
- function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInput: i, toolOutput: a, partialToolInput: o, customProps: s, cancelled: c, hostInfo: l = Qa, hostContext: u, hostCapabilities: d, cspMode: f = "widget-declared", displayMode: p, onDisplayModeChange: m, inlineMaxWidth: h = 768, chromeless: g, onMessage: _, onModelContextUpdate: v, onLog: ee, onReady: te, onLifecycleChange: y, onError: b, onCspViolation: x, onResourceResolved: S, wrapTransport: C, toolCallTimeout: ne = $a, className: w, testId: re = "mcp-app-frame", invoking: T, invoked: E }) {
5102
- let D = (0, M.useRef)(null), O = (0, M.useRef)(null), k = (0, M.useRef)(null), A = (0, M.useRef)(t.kind === "live" ? t.connection : null), [j, ie] = (0, M.useState)(null), [N, ae] = (0, M.useState)(null), [P, F] = (0, M.useState)(null), [I, oe] = (0, M.useState)(0), [se, ce] = (0, M.useState)(!0), [le, L] = (0, M.useState)(Ja.DEFAULT_HEIGHT), [ue, R] = (0, M.useState)("inline"), z = p ?? ue, B = (0, M.useRef)(u);
5103
- B.current = u;
5104
- let V = (0, M.useRef)(_);
5105
- V.current = _;
5106
- let de = (0, M.useRef)(i);
5107
- de.current = i;
5108
- let fe = (0, M.useRef)(a);
5109
- fe.current = a;
5110
- let pe = (0, M.useRef)(s);
5111
- pe.current = s;
5112
- let me = (0, M.useRef)(S);
5113
- me.current = S;
5114
- let he = (0, M.useRef)(v);
5115
- he.current = v;
5116
- let ge = (0, M.useRef)(ee);
5117
- ge.current = ee;
5118
- let _e = (0, M.useRef)(b);
5119
- _e.current = b;
5120
- let ve = (0, M.useRef)(x);
5121
- ve.current = x;
5122
- let ye = (0, M.useRef)(te);
5123
- ye.current = te;
5124
- let H = (0, M.useRef)(y);
5125
- H.current = y;
5126
- let be = (0, M.useRef)(n);
5127
- be.current = n;
5128
- let xe = (0, M.useRef)(f);
5129
- xe.current = f;
5130
- let Se = (0, M.useCallback)((e) => {
5131
- let t = be.current;
5132
- return t ? typeof t == "function" ? t(e) : t : za({
5133
- cspMode: xe.current,
5034
+ function Qa({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInput: i, toolOutput: a, partialToolInput: o, customProps: s, cancelled: c, hostInfo: l = Wa, hostContext: u, hostCapabilities: d, cspMode: f = "widget-declared", displayMode: p, onDisplayModeChange: m, inlineMaxWidth: h = 768, chromeless: g, onMessage: _, onModelContextUpdate: v, onLog: ee, onReady: te, onLifecycleChange: y, onError: b, onCspViolation: x, onResourceResolved: S, wrapTransport: C, toolCallTimeout: ne = Ga, mockOpenAiFileApis: w = !1, onInlineHeightChange: re, fullscreenHeader: T, renderFullscreenClose: E, className: D, testId: ie = "mcp-app-frame", invoking: O, invoked: k }) {
5035
+ let ae = (0, j.useRef)(null), A = (0, j.useRef)(null), oe = (0, j.useRef)(null), se = (0, j.useRef)(/* @__PURE__ */ new Map()), M = (0, j.useRef)(t.kind === "live" ? t.connection : null), [N, ce] = (0, j.useState)(null), [P, le] = (0, j.useState)(null), [ue, de] = (0, j.useState)(null), [F, fe] = (0, j.useState)(0), [I, L] = (0, j.useState)(!0), [R, z] = (0, j.useState)(Ba.DEFAULT_HEIGHT), [pe, me] = (0, j.useState)("inline"), he = p ?? pe, ge = (0, j.useMemo)(() => !u || u.displayMode === he ? u : {
5036
+ ...u,
5037
+ displayMode: he
5038
+ }, [u, he]), _e = (0, j.useRef)(ge);
5039
+ _e.current = ge;
5040
+ let ve = (0, j.useRef)(_);
5041
+ ve.current = _;
5042
+ let ye = (0, j.useRef)(i);
5043
+ ye.current = i;
5044
+ let be = (0, j.useRef)(o);
5045
+ be.current = o;
5046
+ let xe = (0, j.useRef)(a);
5047
+ xe.current = a;
5048
+ let B = (0, j.useRef)(s);
5049
+ B.current = s;
5050
+ let Se = (0, j.useRef)(S);
5051
+ Se.current = S;
5052
+ let Ce = (0, j.useRef)(v);
5053
+ Ce.current = v;
5054
+ let we = (0, j.useRef)(ee);
5055
+ we.current = ee;
5056
+ let Te = (0, j.useRef)(b);
5057
+ Te.current = b;
5058
+ let Ee = (0, j.useRef)(x);
5059
+ Ee.current = x;
5060
+ let De = (0, j.useRef)(te);
5061
+ De.current = te;
5062
+ let V = (0, j.useRef)(y);
5063
+ V.current = y;
5064
+ let Oe = (0, j.useRef)(re);
5065
+ Oe.current = re;
5066
+ let ke = (0, j.useRef)(n);
5067
+ ke.current = n;
5068
+ let Ae = (0, j.useRef)(f);
5069
+ Ae.current = f;
5070
+ let je = (0, j.useRef)(w);
5071
+ je.current = w;
5072
+ let Me = (0, j.useCallback)((e) => {
5073
+ let t = ke.current;
5074
+ return t ? typeof t == "function" ? t(e) : t : ja({
5075
+ cspMode: Ae.current,
5134
5076
  permissions: e.permissions,
5135
5077
  widgetCsp: e.declaredCsp
5136
5078
  });
5137
- }, []), { handleDisplayModeChange: Ce, fullscreenShellClassName: we, pipShellClassName: Te, isFullscreen: Ee, isPip: De } = qa({
5138
- containerRef: k,
5139
- displayMode: z,
5140
- setDisplayMode: (0, M.useCallback)((e) => {
5141
- m ? m(e) : R(e);
5079
+ }, []), { handleDisplayModeChange: Ne, fullscreenShellClassName: Pe, pipShellClassName: Fe, isFullscreen: H, isPip: Ie } = za({
5080
+ containerRef: oe,
5081
+ displayMode: he,
5082
+ setDisplayMode: (0, j.useCallback)((e) => {
5083
+ m ? m(e) : me(e);
5142
5084
  }, [m])
5143
- }), Oe = (0, M.useRef)(Ce);
5144
- Oe.current = Ce;
5145
- let ke = (0, M.useRef)(z);
5146
- ke.current = z;
5147
- let Ae = t.kind === "live" ? t.resourceUri : void 0, je = t.kind === "preloaded" ? t.html : void 0;
5148
- t.kind === "live" && (A.current = t.connection), (0, M.useEffect)(() => {
5085
+ }), Le = (0, j.useRef)(Ne);
5086
+ Le.current = Ne;
5087
+ let U = (0, j.useRef)(he);
5088
+ U.current = he;
5089
+ let Re = t.kind === "live" ? t.resourceUri : void 0, W = t.kind === "preloaded" ? t.html : void 0;
5090
+ t.kind === "live" && (M.current = t.connection), (0, j.useEffect)(() => {
5149
5091
  let e = !1;
5150
- H.current?.({ status: "resolving" });
5092
+ V.current?.({ status: "resolving" });
5151
5093
  let n = (e) => {
5152
- ie(e), H.current?.({ status: "sandbox-loading" });
5153
- let t = Se(e);
5154
- ae((e) => e?.href === t.href ? e : t), me.current?.(e);
5094
+ ce(e), V.current?.({ status: "sandbox-loading" });
5095
+ let t = Me(e);
5096
+ le((e) => e?.href === t.href ? e : t), Se.current?.(e);
5155
5097
  };
5156
5098
  if (t.kind === "preloaded") {
5157
5099
  n({
@@ -5167,11 +5109,11 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5167
5109
  return;
5168
5110
  }
5169
5111
  let { connection: r, resourceUri: i } = t;
5170
- return A.current = r, (async () => {
5112
+ return M.current = r, (async () => {
5171
5113
  try {
5172
5114
  let t = await r.readResource(i);
5173
5115
  if (e) return;
5174
- let a = r.resources?.find((e) => e.uri === i), o = La({
5116
+ let a = r.resources?.find((e) => e.uri === i), o = ka({
5175
5117
  resourceResult: t,
5176
5118
  listingResource: a,
5177
5119
  cspMode: f,
@@ -5179,7 +5121,7 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5179
5121
  });
5180
5122
  if (!o.mimeTypeValid) {
5181
5123
  let e = o.mimeTypeWarning || "Invalid MIME type - SEP-1865 requires \"text/html;profile=mcp-app\"";
5182
- F(e), H.current?.({
5124
+ de(e), V.current?.({
5183
5125
  status: "error",
5184
5126
  error: e
5185
5127
  });
@@ -5188,7 +5130,7 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5188
5130
  n(o);
5189
5131
  } catch (t) {
5190
5132
  if (e) return;
5191
- F(t instanceof Error ? t.message : "Failed to prepare view"), H.current?.({
5133
+ de(t instanceof Error ? t.message : "Failed to prepare view"), V.current?.({
5192
5134
  status: "error",
5193
5135
  error: t instanceof Error ? t.message : "Failed to prepare view"
5194
5136
  });
@@ -5198,30 +5140,35 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5198
5140
  };
5199
5141
  }, [
5200
5142
  t.kind,
5201
- Ae,
5202
- je,
5143
+ Re,
5144
+ W,
5203
5145
  f,
5204
- Se
5205
- ]), (0, M.useEffect)(() => {
5206
- let e = N;
5207
- return () => {
5208
- e?.protocol === "blob:" && URL.revokeObjectURL(e.href);
5146
+ Me
5147
+ ]), (0, j.useEffect)(() => {
5148
+ let e = P;
5149
+ if (!e || e.protocol !== "blob:") return;
5150
+ let t = se.current.get(e.href);
5151
+ return t && (clearTimeout(t), se.current.delete(e.href)), () => {
5152
+ let t = setTimeout(() => {
5153
+ URL.revokeObjectURL(e.href), se.current.delete(e.href);
5154
+ }, 1e3);
5155
+ se.current.set(e.href, t);
5209
5156
  };
5210
- }, [N]);
5211
- let Me = N?.protocol === "blob:", Ne = !N || Me ? null : (() => {
5157
+ }, [P]);
5158
+ let ze = P?.protocol === "blob:", G = !P || ze ? null : (() => {
5212
5159
  try {
5213
- return N.origin;
5160
+ return P.origin;
5214
5161
  } catch {
5215
5162
  return null;
5216
5163
  }
5217
5164
  })();
5218
- (0, M.useEffect)(() => {
5219
- if (!Ne && !Me) return;
5165
+ (0, j.useEffect)(() => {
5166
+ if (!G && !ze) return;
5220
5167
  let e = (e) => {
5221
- let t = D.current;
5222
- if (t?.contentWindow && e.source === t.contentWindow && !(!Me && e.origin !== Ne && Ne !== "*")) {
5168
+ let t = ae.current;
5169
+ if (t?.contentWindow && e.source === t.contentWindow && !(!ze && e.origin !== G && G !== "*")) {
5223
5170
  if (e.data?.type === "mcp-apps:csp-violation") {
5224
- ve.current?.({
5171
+ Ee.current?.({
5225
5172
  directive: e.data.directive,
5226
5173
  effectiveDirective: e.data.effectiveDirective,
5227
5174
  blockedUri: e.data.blockedUri,
@@ -5233,33 +5180,38 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5233
5180
  });
5234
5181
  return;
5235
5182
  }
5236
- e.data?.type === "iframe-console-log" && ge.current && ge.current({
5183
+ e.data?.type === "iframe-console-log" && we.current && we.current({
5237
5184
  level: e.data.level ?? "log",
5238
5185
  data: e.data.args
5239
5186
  });
5240
5187
  }
5241
5188
  };
5242
5189
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
5243
- }, [Ne, Me]), (0, M.useEffect)(() => {
5244
- if (!j || !N) return;
5245
- let t = D.current;
5190
+ }, [G, ze]), (0, j.useEffect)(() => {
5191
+ if (!N || !P) return;
5192
+ let t = ae.current;
5246
5193
  if (!t) return;
5247
5194
  let n = !1, r = null;
5248
5195
  return (async () => {
5249
5196
  try {
5250
- H.current?.({ status: "connecting" }), t.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
5251
- let i = tr(j.permissions);
5197
+ V.current?.({ status: "connecting" }), t.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
5198
+ let i = tr(N.permissions);
5252
5199
  i && t.setAttribute("allow", i);
5253
- let a = no(t);
5254
- if (t.src = N.href, await a, n) return;
5200
+ let a = Ya(t);
5201
+ if (P.protocol === "blob:") {
5202
+ let e = await (await fetch(P.href)).text();
5203
+ if (n) return;
5204
+ t.srcdoc = e;
5205
+ } else t.src = P.href;
5206
+ if (await a, n) return;
5255
5207
  r = new rr(null, l, {
5256
- ...d ?? to,
5208
+ ...d ?? qa,
5257
5209
  sandbox: {
5258
- csp: f === "permissive" ? void 0 : j.csp,
5259
- permissions: j.permissions
5210
+ csp: f === "permissive" ? void 0 : N.csp,
5211
+ permissions: N.permissions
5260
5212
  }
5261
- }, { hostContext: B.current }), r.onmessage = async ({ content: e }) => (e.length > 0 && V.current && V.current(e), {}), r.onopenlink = async ({ url: e }) => (e && window.open(e, "_blank", "noopener,noreferrer"), {}), r.oncalltool = (async ({ name: e, arguments: t }) => {
5262
- let n = A.current;
5213
+ }, { hostContext: _e.current }), r.onmessage = async ({ content: e }) => (e.length > 0 && ve.current && ve.current(e), {}), r.onopenlink = async ({ url: e }) => (e && window.open(e, "_blank", "noopener,noreferrer"), {}), r.oncalltool = (async ({ name: e, arguments: t }) => {
5214
+ let n = M.current;
5263
5215
  if (!n) throw Error("Server connection not available");
5264
5216
  try {
5265
5217
  return await n.callTool(e, t || {}, {
@@ -5270,47 +5222,51 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5270
5222
  throw r?.sendToolCancelled({ reason: e instanceof Error ? e.message : String(e) }), e;
5271
5223
  }
5272
5224
  }), r.onreadresource = (async ({ uri: e }) => {
5273
- let t = A.current;
5225
+ let t = M.current;
5274
5226
  if (!t) throw Error("Server connection not available");
5275
5227
  return await t.readResource(e);
5276
5228
  }), r.onlistresources = (async () => {
5277
- let e = A.current;
5229
+ let e = M.current;
5278
5230
  if (!e) throw Error("Server connection not available");
5279
5231
  return { resources: [...e.resources ?? []] };
5280
5232
  }), r.onrequestdisplaymode = async ({ mode: e }) => {
5281
- let t = e ?? "inline", n = (B.current?.availableDisplayModes ?? [
5233
+ let t = e ?? "inline", n = (_e.current?.availableDisplayModes ?? [
5282
5234
  "inline",
5283
5235
  "pip",
5284
5236
  "fullscreen"
5285
- ]).includes(t) ? t : ke.current;
5286
- return await Oe.current(n), { mode: n };
5287
- }, r.onupdatemodelcontext = async ({ content: e, structuredContent: t }) => (he.current?.({
5237
+ ]).includes(t) ? t : U.current;
5238
+ return await Le.current(n), { mode: n };
5239
+ }, r.onupdatemodelcontext = async ({ content: e, structuredContent: t }) => (Ce.current?.({
5288
5240
  content: e,
5289
5241
  structuredContent: t
5290
- }), {}), r.onloggingmessage = async ({ level: e, data: t }) => (ge.current?.({
5242
+ }), {}), r.onloggingmessage = async ({ level: e, data: t }) => (we.current?.({
5291
5243
  level: e,
5292
5244
  data: t
5293
5245
  }), {}), r.onsizechange = async ({ height: e }) => {
5294
- ke.current === "inline" && e !== void 0 && L(e);
5246
+ U.current === "inline" && e !== void 0 && (z(e), Oe.current?.(e));
5295
5247
  };
5296
- let o = ro(r), s = new $n(t.contentWindow, t.contentWindow);
5248
+ let o = Xa(r), s = new $n(t.contentWindow, t.contentWindow);
5297
5249
  if (C && (s = C(s, e)), await r.connect(s), n || (await r.sendSandboxResourceReady({
5298
- html: j.html,
5299
- csp: j.csp,
5300
- permissions: j.permissions
5250
+ html: je.current ? Oa(N.html) : N.html,
5251
+ csp: N.csp,
5252
+ permissions: N.permissions
5301
5253
  }), await o, n)) return;
5302
- O.current = r, oe((e) => e + 1), H.current?.({ status: "initialized" });
5303
- let c = {
5304
- ...de.current,
5305
- ...Ia(pe.current)
5306
- };
5307
- r.sendToolInput({ arguments: c });
5308
- let u = io(fe.current, pe.current);
5309
- u && r.sendToolResult(u), H.current?.({ status: "ready" });
5254
+ A.current = r, fe((e) => e + 1), V.current?.({ status: "initialized" });
5255
+ let c = be.current;
5256
+ if (c) r.sendToolInputPartial({ arguments: c });
5257
+ else {
5258
+ let e = {
5259
+ ...ye.current,
5260
+ ...Ea(B.current)
5261
+ };
5262
+ r.sendToolInput({ arguments: e });
5263
+ }
5264
+ let u = Za(xe.current, B.current);
5265
+ u && r.sendToolResult(u), V.current?.({ status: "ready" });
5310
5266
  } catch (e) {
5311
5267
  if (!n) {
5312
5268
  let t = e instanceof Error ? e.message : "Failed to connect view";
5313
- F(t), _e.current?.(t), H.current?.({
5269
+ de(t), Te.current?.(t), V.current?.({
5314
5270
  status: "error",
5315
5271
  error: t
5316
5272
  });
@@ -5319,99 +5275,132 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5319
5275
  })(), () => {
5320
5276
  n = !0;
5321
5277
  let e = r;
5322
- O.current = null, e && (H.current?.({ status: "tearing-down" }), (async () => {
5278
+ A.current = null, e && (V.current?.({ status: "tearing-down" }), (async () => {
5323
5279
  try {
5324
5280
  await Promise.race([e.teardownResource({}), new Promise((e, t) => setTimeout(() => t(/* @__PURE__ */ Error("teardown timeout")), 2e3))]);
5325
5281
  } catch {} finally {
5326
- e.close().catch(() => {}), H.current?.({ status: "closed" });
5282
+ e.close().catch(() => {}), V.current?.({ status: "closed" });
5327
5283
  }
5328
5284
  })());
5329
5285
  };
5330
5286
  }, [
5331
- j,
5332
5287
  N,
5288
+ P,
5333
5289
  l,
5334
5290
  d,
5335
5291
  f,
5336
5292
  e,
5337
5293
  C,
5338
- ne
5339
- ]), (0, M.useEffect)(() => {
5340
- let e = O.current;
5341
- !e || I === 0 || !u || e.setHostContext(u);
5342
- }, [u, I]), (0, M.useEffect)(() => {
5343
- let e = O.current;
5344
- !e || I === 0 || !o || e.sendToolInputPartial({ arguments: o });
5345
- }, [I, o]), (0, M.useEffect)(() => {
5346
- let e = O.current;
5347
- if (!e || I === 0) return;
5294
+ ne,
5295
+ w
5296
+ ]), (0, j.useEffect)(() => {
5297
+ let e = A.current;
5298
+ !e || F === 0 || !ge || e.setHostContext(ge);
5299
+ }, [ge, F]), (0, j.useEffect)(() => {
5300
+ let e = A.current;
5301
+ !e || F === 0 || !o || e.sendToolInputPartial({ arguments: o });
5302
+ }, [F, o]), (0, j.useEffect)(() => {
5303
+ let e = A.current;
5304
+ if (!e || F === 0 || o) return;
5348
5305
  let t = {
5349
5306
  ...i,
5350
- ...Ia(s)
5307
+ ...Ea(s)
5351
5308
  };
5352
5309
  e.sendToolInput({ arguments: t });
5353
5310
  }, [
5354
- I,
5311
+ F,
5355
5312
  i,
5313
+ o,
5356
5314
  s
5357
- ]), (0, M.useEffect)(() => {
5358
- let e = O.current;
5359
- if (!e || I === 0) return;
5360
- let t = io(a, s);
5315
+ ]), (0, j.useEffect)(() => {
5316
+ let e = A.current;
5317
+ if (!e || F === 0) return;
5318
+ let t = Za(a, s);
5361
5319
  t && e.sendToolResult(t);
5362
5320
  }, [
5363
- I,
5321
+ F,
5364
5322
  a,
5365
5323
  s
5366
- ]), (0, M.useEffect)(() => {
5367
- let e = O.current;
5368
- !e || I === 0 || !c || e.sendToolCancelled({ reason: "Cancelled by user" });
5369
- }, [c, I]);
5370
- let Pe = (0, M.useRef)(!1);
5371
- if ((0, M.useEffect)(() => {
5372
- Pe.current || I === 0 || (Pe.current = !0, ye.current?.());
5373
- }, [I]), (0, M.useEffect)(() => {
5374
- if (I === 0 || !se) return;
5375
- let e = setTimeout(() => ce(!1), 300);
5324
+ ]), (0, j.useEffect)(() => {
5325
+ let e = A.current;
5326
+ !e || F === 0 || !c || e.sendToolCancelled({ reason: "Cancelled by user" });
5327
+ }, [c, F]);
5328
+ let K = (0, j.useRef)(!1);
5329
+ (0, j.useEffect)(() => {
5330
+ K.current || F === 0 || (K.current = !0, De.current?.());
5331
+ }, [F]), (0, j.useEffect)(() => {
5332
+ if (F === 0 || !I) return;
5333
+ let e = setTimeout(() => L(!1), 300);
5376
5334
  return () => clearTimeout(e);
5377
- }, [I, se]), P) return /* @__PURE__ */ M.createElement("div", { className: w }, /* @__PURE__ */ M.createElement("div", { className: "border border-red-200/50 dark:border-red-800/50 bg-red-50/30 dark:bg-red-950/20 rounded-lg p-4" }, /* @__PURE__ */ M.createElement("p", { className: "text-sm text-red-600 dark:text-red-400" }, "Failed to load view: ", P)));
5378
- if (!j) return /* @__PURE__ */ M.createElement("div", { className: w }, /* @__PURE__ */ M.createElement("div", { className: "flex items-center justify-center w-full h-[200px]" }, /* @__PURE__ */ M.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading view…")));
5379
- let Fe = we ?? Te ?? "flex group flex-1 items-center justify-center", Ie = {
5380
- height: Ee || De ? "100%" : `${le}px`,
5335
+ }, [F, I]);
5336
+ let Be = N !== null && N.prefersBorder && he !== "fullscreen";
5337
+ if (ue) return /* @__PURE__ */ j.createElement("div", { className: D }, /* @__PURE__ */ j.createElement("div", { className: "border border-red-200/50 dark:border-red-800/50 bg-red-50/30 dark:bg-red-950/20 rounded-lg p-4" }, /* @__PURE__ */ j.createElement("p", { className: "text-sm text-red-600 dark:text-red-400" }, "Failed to load view: ", ue)));
5338
+ if (!N) return /* @__PURE__ */ j.createElement("div", { className: D }, /* @__PURE__ */ j.createElement("div", { className: "flex items-center justify-center w-full h-[200px]" }, /* @__PURE__ */ j.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading view…")));
5339
+ let Ve = Pe ?? Fe ?? "flex group flex-1 items-center justify-center", He = {
5340
+ height: H || Ie ? "100%" : `${R}px`,
5381
5341
  width: "100%",
5382
- maxWidth: z === "inline" ? `${h}px` : "100%",
5383
- transition: Ee || De ? void 0 : "height 300ms ease-out"
5384
- }, Le = /* @__PURE__ */ M.createElement("div", {
5385
- ref: k,
5386
- className: Fe,
5387
- style: De ? {
5388
- height: Ja.DEFAULT_HEIGHT,
5389
- maxWidth: Ja.PIP_MAX_WIDTH,
5342
+ maxWidth: he === "inline" ? `${h}px` : "100%",
5343
+ transition: H || Ie ? void 0 : "height 300ms ease-out"
5344
+ }, Ue = /* @__PURE__ */ j.createElement("div", {
5345
+ ref: oe,
5346
+ className: H ? `${Ve} flex flex-col` : Ve,
5347
+ style: Ie ? {
5348
+ height: Ba.DEFAULT_HEIGHT,
5349
+ maxWidth: Ba.PIP_MAX_WIDTH,
5390
5350
  zIndex: 100
5391
- } : Ee ? { zIndex: 100 } : void 0
5392
- }, (Ee || De) && /* @__PURE__ */ M.createElement("button", {
5351
+ } : H ? { zIndex: 100 } : void 0
5352
+ }, H && /* @__PURE__ */ j.createElement("header", {
5353
+ className: "grid shrink-0 items-center border-b border-zinc-200 bg-background px-3 dark:border-zinc-700",
5354
+ style: {
5355
+ height: Ba.FULLSCREEN_HEADER_HEIGHT,
5356
+ gridTemplateColumns: "auto 1fr auto"
5357
+ }
5358
+ }, E ? E({
5359
+ onClick: () => void Ne("inline"),
5360
+ "data-testid": "debugger-exit-fullscreen-button",
5361
+ "aria-label": "Exit fullscreen"
5362
+ }) : /* @__PURE__ */ j.createElement("button", {
5363
+ type: "button",
5364
+ "data-testid": "debugger-exit-fullscreen-button",
5365
+ "aria-label": "Exit fullscreen",
5366
+ className: "flex size-8 cursor-pointer items-center justify-center rounded-full border border-zinc-200 bg-background text-foreground shadow-sm hover:bg-muted dark:border-zinc-700",
5367
+ onClick: () => void Ne("inline")
5368
+ }, /* @__PURE__ */ j.createElement(Ja, null)), /* @__PURE__ */ j.createElement("div", { className: "flex min-w-0 items-center justify-center gap-2 px-2" }, T?.iconUrl ? /* @__PURE__ */ j.createElement("img", {
5369
+ src: T.iconUrl,
5370
+ alt: "",
5371
+ className: "size-6 shrink-0 rounded-md object-contain"
5372
+ }) : null, /* @__PURE__ */ j.createElement("span", { className: "truncate text-sm font-medium text-foreground" }, T?.title ?? r)), /* @__PURE__ */ j.createElement("div", {
5373
+ className: "size-8 shrink-0",
5374
+ "aria-hidden": !0
5375
+ })), Ie && (E ? /* @__PURE__ */ j.createElement("div", {
5376
+ className: "absolute right-3 top-3",
5377
+ style: { zIndex: 110 }
5378
+ }, E({
5379
+ onClick: () => void Ne("inline"),
5380
+ "data-testid": "debugger-exit-pip-button",
5381
+ "aria-label": "Exit picture-in-picture"
5382
+ })) : /* @__PURE__ */ j.createElement("button", {
5393
5383
  type: "button",
5394
- "data-testid": Ee ? "debugger-exit-fullscreen-button" : "debugger-exit-pip-button",
5395
- "aria-label": Ee ? "Exit fullscreen" : "Exit picture-in-picture",
5396
- className: "absolute right-3 top-3 z-[110] flex size-8 items-center justify-center rounded-full border border-border bg-background/90 text-lg leading-none text-foreground shadow-sm backdrop-blur-sm hover:bg-background",
5384
+ "data-testid": "debugger-exit-pip-button",
5385
+ "aria-label": "Exit picture-in-picture",
5386
+ className: "absolute right-3 top-3 z-[110] flex size-8 cursor-pointer items-center justify-center rounded-full border border-border bg-background/90 text-foreground shadow-sm backdrop-blur-sm hover:bg-background",
5397
5387
  style: { zIndex: 110 },
5398
- onClick: () => void Ce("inline")
5399
- }, "×"), /* @__PURE__ */ M.createElement("div", { className: Ee || De ? "relative w-full h-full min-h-0 flex flex-1 flex-col" : "relative w-full flex flex-1 justify-center items-center" }, se && /* @__PURE__ */ M.createElement("div", { className: "flex absolute inset-0 items-center justify-center z-10" }, /* @__PURE__ */ M.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading…")), !De && !Ee && (T || E) && /* @__PURE__ */ M.createElement("div", { className: "absolute -top-8 left-2 z-10 whitespace-nowrap pointer-events-none text-xs text-muted-foreground" }, T && !a ? T : E), /* @__PURE__ */ M.createElement("div", {
5400
- "data-testid": re,
5388
+ onClick: () => void Ne("inline")
5389
+ }, /* @__PURE__ */ j.createElement(Ja, null))), /* @__PURE__ */ j.createElement("div", { className: H ? "relative flex min-h-0 w-full flex-1 flex-col" : Ie ? "relative w-full h-full min-h-0 flex flex-1 flex-col" : "relative w-full flex flex-1 justify-center items-center" }, I && /* @__PURE__ */ j.createElement("div", { className: "flex absolute inset-0 items-center justify-center z-10" }, /* @__PURE__ */ j.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading…")), !Ie && !H && (O || k) && /* @__PURE__ */ j.createElement("div", { className: "absolute -top-8 left-2 z-10 whitespace-nowrap pointer-events-none text-xs text-muted-foreground" }, O && !a ? O : k), /* @__PURE__ */ j.createElement("div", {
5390
+ "data-testid": ie,
5401
5391
  "data-mcp-app-tool": r,
5402
- className: z === "fullscreen" ? "w-full h-full overflow-hidden" : "w-full overflow-hidden",
5403
- style: Ie
5404
- }, /* @__PURE__ */ M.createElement("iframe", {
5405
- ref: D,
5392
+ className: he === "fullscreen" ? "w-full h-full overflow-hidden" : "w-full overflow-hidden",
5393
+ style: He
5394
+ }, /* @__PURE__ */ j.createElement("iframe", {
5395
+ ref: ae,
5406
5396
  title: `MCP App: ${r}`,
5407
- className: "w-full h-full border-0 bg-transparent",
5408
- style: { border: j.prefersBorder && z !== "fullscreen" ? void 0 : "none" }
5397
+ className: Be ? "w-full h-full bg-transparent border border-border rounded-xl" : "w-full h-full bg-transparent border-0"
5409
5398
  }))));
5410
- return /* @__PURE__ */ M.createElement("div", { className: w }, Le);
5399
+ return /* @__PURE__ */ j.createElement("div", { className: D }, Ue);
5411
5400
  }
5412
- function oo(e, t) {
5413
- return !(e.viewId !== t.viewId || e.source !== t.source || e.sandboxUrl !== t.sandboxUrl || e.displayMode !== t.displayMode || e.cancelled !== t.cancelled || e.toolInput !== t.toolInput || e.toolOutput !== t.toolOutput || e.partialToolInput !== t.partialToolInput || e.customProps !== t.customProps || e.hostContext !== t.hostContext || e.hostCapabilities !== t.hostCapabilities || e.cspMode !== t.cspMode || e.className !== t.className || e.onReady !== t.onReady || e.onLifecycleChange !== t.onLifecycleChange);
5401
+ function $a(e, t) {
5402
+ return !(e.viewId !== t.viewId || e.source !== t.source || e.sandboxUrl !== t.sandboxUrl || e.displayMode !== t.displayMode || e.cancelled !== t.cancelled || e.toolInput !== t.toolInput || e.toolOutput !== t.toolOutput || e.partialToolInput !== t.partialToolInput || e.customProps !== t.customProps || e.hostContext !== t.hostContext || e.hostCapabilities !== t.hostCapabilities || e.cspMode !== t.cspMode || e.mockOpenAiFileApis !== t.mockOpenAiFileApis || e.onInlineHeightChange !== t.onInlineHeightChange || e.fullscreenHeader !== t.fullscreenHeader || e.renderFullscreenClose !== t.renderFullscreenClose || e.className !== t.className || e.onReady !== t.onReady || e.onLifecycleChange !== t.onLifecycleChange);
5414
5403
  }
5415
- var so = (0, M.memo)(ao, oo);
5404
+ var eo = (0, j.memo)(Qa, $a);
5416
5405
  //#endregion
5417
- export { _r as a, Xa as c, Pa as d, yr as i, Sa as l, Na as n, Ya as o, so as r, Za as s, Fa as t, vr as u };
5406
+ export { _r as a, Ha as c, wa as d, yr as i, fa as l, Ca as n, Va as o, eo as r, Ua as s, Ta as t, vr as u };