@mcp-use/inspector 20.0.0-beta.0 → 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 (284) 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-BJJtLqMb.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-BxuOVgdb.js → OAuthCallback-Hdtybeu0.js} +3 -3
  18. package/dist/cdn/PromptsTab-b4UpzPPY.js +902 -0
  19. package/dist/cdn/{ResourcesTab-BczUMFil.js → ResourcesTab-BCA0_b8c.js} +106 -124
  20. package/dist/cdn/{SamplingTab-6u5s845G.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-CUhwP4rZ.js → ToolsTab-4lvUZRQq.js} +671 -693
  24. package/dist/cdn/{ViewPreview-CxJc1Kht.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 +7800 -7853
  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-yUi9mVK4.js → react-BoOQpLwo.js} +868 -873
  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-C7vjco2m.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 +202 -27
  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 +18 -0
  158. package/dist/server/asset-urls.d.ts.map +1 -0
  159. package/dist/server/asset-urls.js +17 -0
  160. package/dist/server/cdn-shell.d.ts +3 -3
  161. package/dist/server/cdn-shell.d.ts.map +1 -1
  162. package/dist/server/cdn-shell.js +5 -3
  163. package/dist/server/{chunk-J67FVPHF.js → chunk-5XMQ5UJR.js} +2 -2
  164. package/dist/server/chunk-H6ZCIKBS.js +63 -0
  165. package/dist/server/{chunk-ESODOPDD.js → chunk-J4FNYLBF.js} +4 -0
  166. package/dist/server/{chunk-TPHRVELX.js → chunk-KTPQKADO.js} +87 -10
  167. package/dist/server/{chunk-THQ67TSE.js → chunk-LMLZJR2K.js} +3 -10
  168. package/dist/server/chunk-M5TZA42I.js +54 -0
  169. package/dist/server/{chunk-K2V2SDQD.js → chunk-OWR2BIBW.js} +1 -1
  170. package/dist/server/{chunk-5B3SXGZP.js → chunk-UJLXHNQP.js} +1 -1
  171. package/dist/server/{chunk-6XWDZEFF.js → chunk-XCNS5CIW.js} +8 -3
  172. package/dist/server/cli.js +8 -6
  173. package/dist/server/create-dev-api-app.js +3 -3
  174. package/dist/server/dev-callback-redirect.d.ts +3 -0
  175. package/dist/server/dev-callback-redirect.d.ts.map +1 -0
  176. package/dist/server/dev-callback-redirect.js +18 -0
  177. package/dist/server/favicon-static.d.ts.map +1 -1
  178. package/dist/server/favicon-static.js +1 -1
  179. package/dist/server/index.js +9 -7
  180. package/dist/server/middleware.js +9 -7
  181. package/dist/server/proxy/index.js +1 -1
  182. package/dist/server/proxy/mcp-proxy.d.ts +2 -0
  183. package/dist/server/proxy/mcp-proxy.d.ts.map +1 -1
  184. package/dist/server/proxy/mcp-proxy.js +3 -1
  185. package/dist/server/proxy-routes.js +2 -2
  186. package/dist/server/server.js +3 -3
  187. package/dist/server/static-assets.d.ts +5 -0
  188. package/dist/server/static-assets.d.ts.map +1 -0
  189. package/dist/server/static-assets.js +9 -0
  190. package/dist/server/version.js +1 -1
  191. package/dist/server/vite-dev-api-plugin.js +3 -3
  192. package/dist/web/assets/AnimatePresence-FfDQQNFJ.js +9 -0
  193. package/dist/web/assets/ChatTab-x6dg7xyx.js +18 -0
  194. package/dist/web/assets/ConnectionSettingsTab-DUwCNYXJ.js +1 -0
  195. package/dist/web/assets/ElicitationTab-Dk04sjRw.js +1 -0
  196. package/dist/web/assets/FormContext-sV-yByKz.js +1 -0
  197. package/dist/web/assets/ListTabHeader-CrGae306.js +1 -0
  198. package/dist/web/assets/MCPAppsDebugControls-Kh10bYHm.js +34 -0
  199. package/dist/web/assets/{ManufactOAuthCallback-B-tdkUA2.js → ManufactOAuthCallback-Bq00h5wq.js} +1 -1
  200. package/dist/web/assets/MarkdownRenderer--ZbJc80m.js +47 -0
  201. package/dist/web/assets/McpAppsViewPanel-BM7S0O6E.js +1 -0
  202. package/dist/web/assets/{NotificationsTab-BgLjxuos.js → NotificationsTab-DTcas5xQ.js} +1 -1
  203. package/dist/web/assets/{OAuthCallback-Bp-jLoQs.js → OAuthCallback-CZ5PbMLP.js} +1 -1
  204. package/dist/web/assets/PromptsTab-Ce9hFDPL.js +15 -0
  205. package/dist/web/assets/ResourcesTab-CfV_CTOT.js +2 -0
  206. package/dist/web/assets/SamplingTab-7FoVfzSl.js +1 -0
  207. package/dist/web/assets/ServerMetadataTab-DfOYnm2P.js +1 -0
  208. package/dist/web/assets/ToolsTab-CeDM6lbc.js +8 -0
  209. package/dist/web/assets/ViewPreview-DMpWAByN.js +1 -0
  210. package/dist/web/assets/WidgetWrapper-cv_BM1bY.js +1 -0
  211. package/dist/web/assets/{brush--0LobUi4.js → brush-DX0UZ_pI.js} +1 -1
  212. package/dist/web/assets/button-C8Xa2k4x.js +1 -0
  213. package/dist/web/assets/checkbox-ocTkuPLe.js +1 -0
  214. package/dist/web/assets/code-B14rVdNt.js +1 -0
  215. package/dist/web/assets/createLucideIcon-BEHeJH0M.js +1 -0
  216. package/dist/web/assets/dist-D6mojCV5.js +21 -0
  217. package/dist/web/assets/index-BfmL5fRO.js +499 -0
  218. package/dist/web/assets/index-bCIH1Sdx.css +1 -0
  219. package/dist/web/assets/input-C0OQCUZy.js +1 -0
  220. package/dist/web/assets/{label-B5Q_Zr8M.js → label-CI7JWQOo.js} +1 -1
  221. package/dist/web/assets/{maximize-2-BTT9QQU9.js → maximize-2-Br1WQzT2.js} +1 -1
  222. package/dist/web/assets/{maximize-_O55kFcr.js → maximize-CJNgRe6S.js} +1 -1
  223. package/dist/web/assets/{refresh-cw-C9wQl8_d.js → refresh-cw-B5iaAZKn.js} +1 -1
  224. package/dist/web/assets/{save-B-MsgxX9.js → save-TM6fvNrt.js} +1 -1
  225. package/dist/web/assets/select-D6jzbLJn.js +1 -0
  226. package/dist/web/assets/shared-BaJnSpaR.js +1 -0
  227. package/dist/web/assets/{sparkles-2OAsc1aP.js → sparkles-BGYTDThM.js} +1 -1
  228. package/dist/web/assets/tabs-subtle-C3U3Xswq.js +1 -0
  229. package/dist/web/assets/textarea-CRTXuRmE.js +1 -0
  230. package/dist/web/assets/useConfig-tIq2w5rV.js +1 -0
  231. package/dist/web/assets/useViewHostProps--1CXsG5i.js +1 -0
  232. package/dist/web/assets/{zap-Du2Uc5pa.js → zap-BDWHCVHU.js} +1 -1
  233. package/dist/web/index.html +10 -11
  234. package/package.json +6 -13
  235. package/dist/cdn/ChatTab-5ya_YTFV.js +0 -13218
  236. package/dist/cdn/ConnectionSettingsForm-iwNW86ZU.js +0 -873
  237. package/dist/cdn/ConnectionSettingsTab-CeK83dxn.js +0 -145
  238. package/dist/cdn/PromptsTab-Cspfnl6n.js +0 -4400
  239. package/dist/cdn/bundle-mjs-B0nmHDtp.js +0 -1953
  240. package/dist/cdn/chunk-BO2N2NFS-Cy167e0X.js +0 -17500
  241. package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
  242. package/dist/cdn/highlighted-body-OFNGDK62-CoReNbTX.js +0 -36
  243. package/dist/cdn/mermaid-GHXKKRXX-DgVIbk-D.js +0 -2
  244. package/dist/cdn/pdf-CxFT9FER.js +0 -16291
  245. package/dist/cdn/popover-C_SSrXT0.js +0 -2005
  246. package/dist/cdn/sheet-CerCdhxz.js +0 -78
  247. package/dist/cdn/useHostedSession-BA39Aegc.js +0 -153
  248. package/dist/cdn/useMCPPrompts-D3_Hla_z.js +0 -104
  249. package/dist/client/components/chat/streamdown-code-slim.d.ts +0 -4
  250. package/dist/client/components/chat/streamdown-code-slim.d.ts.map +0 -1
  251. package/dist/web/assets/AnimatePresence-CthXziG2.js +0 -9
  252. package/dist/web/assets/ChatTab-CiAqtqhj.js +0 -460
  253. package/dist/web/assets/ConnectionSettingsTab-CTh6MFKE.js +0 -1
  254. package/dist/web/assets/ElicitationTab-B3Eg0_Jm.js +0 -1
  255. package/dist/web/assets/FormContext-Cqc_A12u.js +0 -1
  256. package/dist/web/assets/ListTabHeader-G-nQX18m.js +0 -1
  257. package/dist/web/assets/PromptsTab-CA-SZs43.js +0 -61
  258. package/dist/web/assets/ResourcesTab-DdMIW_af.js +0 -2
  259. package/dist/web/assets/SamplingTab-DjyDG01W.js +0 -1
  260. package/dist/web/assets/ServerMetadataTab-Q4PlqP_B.js +0 -1
  261. package/dist/web/assets/ToolsTab-BHk8GCmd.js +0 -8
  262. package/dist/web/assets/ViewPreview-DWtmwzCb.js +0 -1
  263. package/dist/web/assets/WidgetWrapper-B43lqbld.js +0 -34
  264. package/dist/web/assets/bundle-mjs-8puS6ou7.js +0 -1
  265. package/dist/web/assets/checkbox-_GzEPQic.js +0 -1
  266. package/dist/web/assets/chunk-BO2N2NFS-BdIeB5Lr.js +0 -131
  267. package/dist/web/assets/code-tME-5H6D.js +0 -1
  268. package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
  269. package/dist/web/assets/dist-DQjEDTKs.js +0 -21
  270. package/dist/web/assets/highlighted-body-OFNGDK62-Dp3e1QHL.js +0 -1
  271. package/dist/web/assets/index-Bbn-6QR2.js +0 -475
  272. package/dist/web/assets/index-BjH-Qp85.css +0 -1
  273. package/dist/web/assets/input-CjmxOFr6.js +0 -1
  274. package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
  275. package/dist/web/assets/mermaid-GHXKKRXX-yq1lkD3x.js +0 -1
  276. package/dist/web/assets/pdf-C3cfS_Ha.js +0 -54
  277. package/dist/web/assets/select-C0xlfLAa.js +0 -1
  278. package/dist/web/assets/shared-Dfwy7nyg.js +0 -1
  279. package/dist/web/assets/sheet-CRPrEqAa.js +0 -1
  280. package/dist/web/assets/tabs-subtle-Dxgism9f.js +0 -1
  281. package/dist/web/assets/textarea-Ci09-en6.js +0 -1
  282. package/dist/web/assets/useConfig-b1f_iVFH.js +0 -1
  283. package/dist/web/assets/useMCPPrompts-CPskz9af.js +0 -1
  284. package/dist/web/assets/useViewHostProps-BgsQ2yYl.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
+ jsonrpc: f("2.0"),
24
+ id: pe,
25
+ ...I.shape
26
+ }).strict(), he = o({
23
27
  jsonrpc: f("2.0"),
24
- id: de,
25
28
  ...R.shape
26
- }).strict(), pe = o({
29
+ }).strict(), ge = o({
27
30
  jsonrpc: f("2.0"),
28
- ...B.shape
29
- }).strict(), me = o({
31
+ id: pe,
32
+ result: z
33
+ }).strict(), _e = o({
30
34
  jsonrpc: f("2.0"),
31
- id: de,
32
- result: V
33
- }).strict(), he = o({
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,109 +3449,115 @@ function sa(e) {
3535
3449
  oauthProxyUrl: t
3536
3450
  };
3537
3451
  }
3538
- function ca(e) {
3539
- let t = null, n = Date.now(), r = e.healthCheckIntervalMs ?? 1e4, i = e.healthCheckTimeoutMs ?? 3e4;
3452
+ function Qi(e) {
3453
+ let t = null, n = Date.now(), r = !1, i = e.healthCheckIntervalMs ?? 1e4, a = e.healthCheckTimeoutMs ?? 3e4;
3540
3454
  return t = setInterval(async () => {
3541
- if (!e.isMountedRef.current || e.stateRef.current !== "ready") {
3542
- t &&= (clearInterval(t), null);
3543
- return;
3544
- }
3545
- try {
3546
- let t = e.gatewayUrl || e.url;
3547
- if (!t) return;
3548
- let r = e.getAuthHeaders ? await e.getAuthHeaders() : {}, i = await fetch(t, {
3549
- method: "HEAD",
3550
- headers: {
3551
- ...e.allHeaders,
3552
- ...r
3553
- },
3554
- signal: AbortSignal.timeout(5e3)
3555
- });
3556
- if (i.ok || i.status < 500) n = Date.now();
3557
- else throw Error(`Server returned ${i.status}`);
3558
- } catch {
3559
- let r = Date.now() - n;
3560
- r > i && (e.addLog("warn", `Connection appears to be broken (no response for ${Math.round(r / 1e3)}s), attempting to reconnect...`), t &&= (clearInterval(t), null), e.autoReconnectRef.current && e.isMountedRef.current && (e.setState("discovering"), e.addLog("info", "Auto-reconnecting to MCP server..."), setTimeout(() => {
3561
- e.isMountedRef.current && e.stateRef.current === "discovering" && e.connect();
3562
- }, typeof e.autoReconnectRef.current == "number" ? e.autoReconnectRef.current : e.defaultReconnectDelay)));
3455
+ if (!r) {
3456
+ if (!e.isMountedRef.current || e.stateRef.current !== "ready") {
3457
+ t &&= (clearInterval(t), null);
3458
+ return;
3459
+ }
3460
+ try {
3461
+ let i = e.gatewayUrl || e.url;
3462
+ if (!i) return;
3463
+ let a = e.getAuthHeaders ? await e.getAuthHeaders() : {}, o = await fetch(i, {
3464
+ method: "HEAD",
3465
+ headers: {
3466
+ ...e.allHeaders,
3467
+ ...a
3468
+ },
3469
+ signal: AbortSignal.timeout(5e3)
3470
+ });
3471
+ if (o.status === 405 || o.status === 404) {
3472
+ r = !0, n = Date.now(), t &&= (clearInterval(t), null);
3473
+ return;
3474
+ }
3475
+ if (o.ok || o.status < 500) n = Date.now();
3476
+ else throw Error(`Server returned ${o.status}`);
3477
+ } catch {
3478
+ let r = Date.now() - n;
3479
+ r > a && (e.addLog("warn", `Connection appears to be broken (no response for ${Math.round(r / 1e3)}s), attempting to reconnect...`), t &&= (clearInterval(t), null), e.autoReconnectRef.current && e.isMountedRef.current && (e.setState("discovering"), e.addLog("info", "Auto-reconnecting to MCP server..."), setTimeout(() => {
3480
+ e.isMountedRef.current && e.stateRef.current === "discovering" && e.connect();
3481
+ }, typeof e.autoReconnectRef.current == "number" ? e.autoReconnectRef.current : e.defaultReconnectDelay)));
3482
+ }
3563
3483
  }
3564
- }, r), () => {
3484
+ }, i), () => {
3565
3485
  t &&= (clearInterval(t), null);
3566
3486
  };
3567
3487
  }
3568
- function la(e, t) {
3488
+ function $i(e, t) {
3569
3489
  let n = e.connectionRef.current;
3570
- 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}.`);
3571
3491
  return n;
3572
3492
  }
3573
- function ua(e) {
3574
- let t = (0, M.useCallback)(async (t, n, r) => {
3575
- 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}"`);
3576
3496
  e.addLog("info", `Calling tool: ${t}`, n);
3577
3497
  let a = Date.now();
3578
3498
  try {
3579
3499
  let o = await i.callTool(t, n || {}, r);
3580
- 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({
3581
3501
  toolName: t,
3582
3502
  success: !0,
3583
3503
  executionTimeMs: Date.now() - a
3584
3504
  }).catch(() => {}), o;
3585
3505
  } catch (n) {
3586
- 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({
3587
3507
  toolName: t,
3588
3508
  success: !1,
3589
3509
  errorType: n instanceof Error ? n.name : "UnknownError",
3590
3510
  executionTimeMs: Date.now() - a
3591
3511
  }).catch(() => {}), n;
3592
3512
  }
3593
- }, [e.addLog]), n = (0, M.useCallback)(async () => {
3594
- let t = la(e, "list resources");
3513
+ }, [e.addLog]), n = (0, j.useCallback)(async () => {
3514
+ let t = $i(e, "list resources");
3595
3515
  e.addLog("info", "Listing resources");
3596
3516
  let n = await t.listAllResources();
3597
3517
  e.setResources(n.resources || []);
3598
- }, [e.addLog]), r = (0, M.useCallback)(async (t) => {
3599
- let n = la(e, "read resource");
3518
+ }, [e.addLog]), r = (0, j.useCallback)(async (t) => {
3519
+ let n = $i(e, "read resource");
3600
3520
  e.addLog("info", `Reading resource: ${t}`);
3601
3521
  try {
3602
3522
  let e = await n.readResource(t);
3603
- return Pi.getInstance().trackUseMcpResourceRead({
3523
+ return wi.getInstance().trackUseMcpResourceRead({
3604
3524
  resourceUri: t,
3605
3525
  success: !0
3606
3526
  }).catch(() => {}), e;
3607
3527
  } catch (e) {
3608
- throw Pi.getInstance().trackUseMcpResourceRead({
3528
+ throw wi.getInstance().trackUseMcpResourceRead({
3609
3529
  resourceUri: t,
3610
3530
  success: !1,
3611
3531
  errorType: e instanceof Error ? e.name : "UnknownError"
3612
3532
  }).catch(() => {}), e;
3613
3533
  }
3614
- }, [e.addLog]), i = (0, M.useCallback)(async () => {
3615
- let t = la(e, "list prompts");
3534
+ }, [e.addLog]), i = (0, j.useCallback)(async () => {
3535
+ let t = $i(e, "list prompts");
3616
3536
  e.addLog("info", "Listing prompts");
3617
3537
  let n = await t.listPrompts();
3618
3538
  e.setPrompts(n.prompts || []);
3619
- }, [e.addLog]), a = (0, M.useCallback)(async () => {
3539
+ }, [e.addLog]), a = (0, j.useCallback)(async () => {
3620
3540
  if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
3621
3541
  e.setTools(await e.connectionRef.current.listTools() || []);
3622
3542
  } catch (t) {
3623
3543
  e.addLog("error", "Failed to refresh tools:", t);
3624
3544
  }
3625
- }, [e.addLog]), o = (0, M.useCallback)(async () => {
3545
+ }, [e.addLog]), o = (0, j.useCallback)(async () => {
3626
3546
  if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
3627
3547
  let t = await e.connectionRef.current.listAllResources();
3628
3548
  e.setResources(t.resources || []);
3629
3549
  } catch (t) {
3630
3550
  e.addLog("warn", "Failed to refresh resources:", t);
3631
3551
  }
3632
- }, [e.addLog]), s = (0, M.useCallback)(async () => {
3552
+ }, [e.addLog]), s = (0, j.useCallback)(async () => {
3633
3553
  if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
3634
3554
  let t = await e.connectionRef.current.listPrompts();
3635
3555
  e.setPrompts(t.prompts || []);
3636
3556
  } catch (t) {
3637
3557
  e.addLog("warn", "Failed to refresh prompts:", t);
3638
3558
  }
3639
- }, [e.addLog]), c = (0, M.useCallback)(async () => {
3640
- 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();
3641
3561
  e.isMounted() && e.setResourceTemplates(t.resourceTemplates || []);
3642
3562
  }, [e.addLog]);
3643
3563
  return {
@@ -3649,7 +3569,7 @@ function ua(e) {
3649
3569
  refreshResources: o,
3650
3570
  refreshPrompts: s,
3651
3571
  refreshResourceTemplates: c,
3652
- refreshAll: (0, M.useCallback)(() => Promise.all([
3572
+ refreshAll: (0, j.useCallback)(() => Promise.all([
3653
3573
  a(),
3654
3574
  o(),
3655
3575
  c(),
@@ -3660,26 +3580,26 @@ function ua(e) {
3660
3580
  c,
3661
3581
  s
3662
3582
  ]),
3663
- getPrompt: (0, M.useCallback)(async (t, n) => la(e, "get prompt").getPrompt(t, n || {}), [e.addLog]),
3664
- 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])
3665
3585
  };
3666
3586
  }
3667
- var da = 3e3, fa = 5e3;
3668
- function pa(e) {
3669
- 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)(() => {
3670
3590
  let e = `useMcp:${t || "no-url"}`, n = pr.get(e);
3671
3591
  return u && (n.level = u), n;
3672
- }, [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)(() => ({
3673
3593
  name: "mcp-use",
3674
3594
  title: "mcp-use",
3675
3595
  version: Ur(),
3676
3596
  description: "mcp-use is a complete TypeScript framework for building and using MCP",
3677
3597
  icons: [{ src: "https://mcp-use.com/logo.png" }],
3678
3598
  websiteUrl: "https://mcp-use.com"
3679
- }), []), P = (0, M.useMemo)(() => e.clientInfo ? {
3680
- ...ae,
3599
+ }), []), M = (0, j.useMemo)(() => e.clientInfo ? {
3600
+ ...se,
3681
3601
  ...e.clientInfo
3682
- } : 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)(() => {
3683
3603
  if (!l) return {
3684
3604
  enabled: !1,
3685
3605
  proxyAddress: void 0
@@ -3696,14 +3616,14 @@ function pa(e) {
3696
3616
  enabled: l.enabled !== !1 && !!e,
3697
3617
  proxyAddress: e
3698
3618
  };
3699
- }, [l, s]), oe = (0, M.useMemo)(() => f === !1 ? {
3619
+ }, [l, s]), P = (0, j.useMemo)(() => f === !1 ? {
3700
3620
  enabled: !1,
3701
3621
  initialDelay: 0,
3702
3622
  healthCheckInterval: !1,
3703
3623
  healthCheckTimeout: 3e4
3704
3624
  } : f === !0 ? {
3705
3625
  enabled: !0,
3706
- initialDelay: da,
3626
+ initialDelay: ta,
3707
3627
  healthCheckInterval: 1e4,
3708
3628
  healthCheckTimeout: 3e4
3709
3629
  } : typeof f == "number" ? {
@@ -3713,91 +3633,91 @@ function pa(e) {
3713
3633
  healthCheckTimeout: 3e4
3714
3634
  } : {
3715
3635
  enabled: f.enabled !== !1,
3716
- initialDelay: f.initialDelay ?? da,
3636
+ initialDelay: f.initialDelay ?? ta,
3717
3637
  healthCheckInterval: f.healthCheckInterval ?? 1e4,
3718
3638
  healthCheckTimeout: f.healthCheckTimeout ?? 3e4
3719
- }, [f]), [se, ce] = (0, M.useState)(void 0);
3720
- (0, M.useEffect)(() => {
3721
- ce(void 0);
3639
+ }, [f]), [le, ue] = (0, j.useState)(void 0);
3640
+ (0, j.useEffect)(() => {
3641
+ ue(void 0);
3722
3642
  }, [t, s]);
3723
- let le = (0, M.useMemo)(() => {
3724
- if (!se?.proxyAddress) return s;
3643
+ let de = (0, j.useMemo)(() => {
3644
+ if (!le?.proxyAddress) return s;
3725
3645
  let e = s?.headers ?? {};
3726
3646
  return {
3727
- ...se,
3647
+ ...le,
3728
3648
  headers: {
3729
3649
  ...e,
3730
- ...se.headers ?? {}
3650
+ ...le.headers ?? {}
3731
3651
  }
3732
3652
  };
3733
- }, [se, s]), L = le?.proxyAddress, ue = le?.headers ?? {}, R = (0, M.useMemo)(() => t || "", [t]), z = (0, M.useMemo)(() => ({
3734
- ...ue,
3735
- ...A
3736
- }), [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);
3737
- 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;
3738
- 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) => {
3739
3659
  $e.current?.(e);
3740
3660
  }, []);
3741
- (0, M.useEffect)(() => {
3742
- q.current = B, Ge.current = f;
3743
- }, [B, f]), (0, M.useEffect)(() => {
3661
+ (0, j.useEffect)(() => {
3662
+ q.current = R, Ge.current = f;
3663
+ }, [R, f]), (0, j.useEffect)(() => {
3744
3664
  W.current = a ?? null;
3745
3665
  }, [a]);
3746
- let J = (0, M.useCallback)((e, t, ...n) => {
3666
+ let J = (0, j.useCallback)((e, t, ...n) => {
3747
3667
  let r = n.length > 0 ? `${t} ${n.map((e) => JSON.stringify(e)).join(" ")}` : t, i = `[useMcp] ${r}`;
3748
3668
  switch (e) {
3749
3669
  case "error":
3750
- k.error(i);
3670
+ O.error(i);
3751
3671
  break;
3752
3672
  case "warn":
3753
- k.warn(i);
3673
+ O.warn(i);
3754
3674
  break;
3755
3675
  case "info":
3756
- k.info(i);
3676
+ O.info(i);
3757
3677
  break;
3758
3678
  case "debug":
3759
- k.debug(i);
3679
+ O.debug(i);
3760
3680
  break;
3761
- default: k.info(i);
3681
+ default: O.info(i);
3762
3682
  }
3763
- K.current && Ne((t) => [...t.slice(-100), {
3683
+ K.current && Pe((t) => [...t.slice(-100), {
3764
3684
  level: e,
3765
3685
  message: r,
3766
3686
  timestamp: Date.now()
3767
3687
  }]);
3768
- }, [k]), rt = ua({
3688
+ }, [O]), rt = ea({
3769
3689
  stateRef: q,
3770
3690
  connectionRef: Re,
3771
3691
  hasClient: () => U.current !== null,
3772
3692
  isMounted: () => K.current,
3773
- setTools: fe,
3774
- setResources: me,
3775
- setResourceTemplates: ge,
3776
- setPrompts: ve,
3693
+ setTools: me,
3694
+ setResources: ge,
3695
+ setResourceTemplates: ve,
3696
+ setPrompts: be,
3777
3697
  addLog: J
3778
- }), it = (0, M.useCallback)(async (e = !1) => {
3698
+ }), it = (0, j.useCallback)(async (e = !1) => {
3779
3699
  e || J("info", "Disconnecting..."), G.current = !1, He.current && clearTimeout(He.current), He.current = null;
3780
3700
  let t = Ve.current, n = U.current;
3781
3701
  if (n) try {
3782
- let e = ea, t = n === U.current ? Re.current : null;
3702
+ let e = Wi, t = n === U.current ? Re.current : null;
3783
3703
  t && t._healthCheckCleanup && (t._healthCheckCleanup(), t._healthCheckCleanup = null), t && await n.closeSession(e);
3784
3704
  } catch (t) {
3785
3705
  e || J("warn", "Error closing connection:", t);
3786
3706
  }
3787
3707
  let r = Ve.current !== t;
3788
- 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({}));
3789
- }, [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) => {
3790
3710
  J("error", e, n ?? "");
3791
- 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;
3792
- 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(() => {
3793
3713
  K.current && qe.current?.();
3794
3714
  }, 1e3), !0;
3795
3715
  if (K.current) {
3796
- J("info", "Setting state to FAILED:", e), V("failed"), je(e);
3716
+ J("info", "Setting state to FAILED:", e), z("failed"), Me(e);
3797
3717
  let t = W.current?.getLastAttemptedAuthUrl?.();
3798
- 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));
3799
3719
  }
3800
- return G.current = !1, t && Pi.getInstance().trackUseMcpConnection({
3720
+ return G.current = !1, t && wi.getInstance().trackUseMcpConnection({
3801
3721
  url: t,
3802
3722
  transportType: re,
3803
3723
  success: !1,
@@ -3810,10 +3730,10 @@ function pa(e) {
3810
3730
  J,
3811
3731
  t,
3812
3732
  re,
3813
- I,
3814
- le,
3733
+ ce,
3734
+ de,
3815
3735
  a
3816
- ]), at = (0, M.useCallback)(async () => {
3736
+ ]), at = (0, j.useCallback)(async () => {
3817
3737
  if (!n || !t) {
3818
3738
  J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag.");
3819
3739
  return;
@@ -3826,42 +3746,42 @@ function pa(e) {
3826
3746
  J("debug", "Connect called after unmount, aborting.");
3827
3747
  return;
3828
3748
  }
3829
- 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) {
3830
- let { provider: e, oauthProxyUrl: t } = sa({
3831
- 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,
3832
3752
  storageKeyPrefix: i,
3833
- oauthClientConfig: F,
3753
+ oauthClientConfig: N,
3834
3754
  callbackUrl: r,
3835
3755
  preventAutoAuth: m,
3836
3756
  useRedirectFlow: h,
3837
- gatewayUrl: L,
3757
+ gatewayUrl: F,
3838
3758
  oauthProxyUrl: c,
3839
3759
  onPopupWindow: g,
3840
3760
  proxyOAuthRequests: !0,
3841
- staticClientInfo: O,
3761
+ staticClientInfo: ie,
3842
3762
  clientMetadataUrl: E,
3843
3763
  scope: D
3844
3764
  });
3845
- 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"}`);
3846
3766
  }
3847
- 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."));
3848
3768
  let e = async (n) => {
3849
3769
  if (!K.current) return J("debug", "Connection attempt aborted - component unmounted"), "failed";
3850
3770
  J("info", `Attempting connection with transport: ${n}`), J("debug", `Client ref status at start of tryConnectWithTransport: ${U.current ? "initialized" : "NULL"}`);
3851
3771
  try {
3852
- let e = ea, r = {
3772
+ let e = Wi, r = {
3853
3773
  url: t,
3854
3774
  timeout: _,
3855
- clientInfo: P,
3775
+ clientInfo: M,
3856
3776
  ...(() => {
3857
3777
  let e = W.current?.getProxyFetch?.(te) ?? te;
3858
3778
  return e ? { fetch: e } : {};
3859
3779
  })(),
3860
- ...j && { clientOptions: j },
3780
+ ...ae && { clientOptions: ae },
3861
3781
  ...x !== void 0 && { protocolNegotiation: x },
3862
3782
  ...p ? { reconnectionOptions: p } : f === !1 ? { reconnectionOptions: { maxRetries: 0 } } : {}
3863
3783
  };
3864
- 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) {
3865
3785
  if (!K.current) return J("debug", "Connection aborted - component unmounted, client cleaned up"), "failed";
3866
3786
  let e = /* @__PURE__ */ Error("Client not initialized - this is a bug in the connection flow");
3867
3787
  throw J("error", "Client ref is null in tryConnectWithTransport but component is still mounted"), e;
@@ -3878,10 +3798,10 @@ function pa(e) {
3878
3798
  });
3879
3799
  let i = await U.current.connect(e);
3880
3800
  if (Re.current = i, !K.current) return J("debug", "Connection aborted after connection creation - component unmounted"), "failed";
3881
- 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({
3882
- 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,
3883
3803
  url: t,
3884
- allHeaders: z,
3804
+ allHeaders: L,
3885
3805
  getAuthHeaders: async () => {
3886
3806
  try {
3887
3807
  let e = await W.current?.tokens?.();
@@ -3895,41 +3815,41 @@ function pa(e) {
3895
3815
  isMountedRef: K,
3896
3816
  stateRef: q,
3897
3817
  autoReconnectRef: Ge,
3898
- setState: V,
3818
+ setState: z,
3899
3819
  addLog: J,
3900
3820
  connect: at,
3901
- defaultReconnectDelay: oe.initialDelay,
3902
- healthCheckIntervalMs: oe.healthCheckInterval,
3903
- healthCheckTimeoutMs: oe.healthCheckTimeout
3904
- })), Pi.getInstance().trackUseMcpConnection({
3821
+ defaultReconnectDelay: P.initialDelay,
3822
+ healthCheckIntervalMs: P.healthCheckInterval,
3823
+ healthCheckTimeoutMs: P.healthCheckTimeout
3824
+ })), wi.getInstance().trackUseMcpConnection({
3905
3825
  url: t,
3906
3826
  transportType: n,
3907
3827
  success: !0,
3908
3828
  hasOAuth: !!W.current,
3909
3829
  hasSampling: Ze.current,
3910
3830
  hasElicitation: Qe.current
3911
- }).catch(() => {}), fe(i.tools || []);
3831
+ }).catch(() => {}), me(i.tools || []);
3912
3832
  let [a, o, s] = await Promise.all([
3913
3833
  i.listAllResources(),
3914
3834
  i.listPrompts(),
3915
3835
  i.supports("resources") ? i.listResourceTemplates() : Promise.resolve({ resourceTemplates: [] })
3916
3836
  ]);
3917
3837
  if (!K.current) return J("debug", "Connection aborted after discovery - component unmounted"), "failed";
3918
- me(a.resources || []), ve(o.prompts || []), ge(s.resourceTemplates || []);
3838
+ ge(a.resources || []), be(o.prompts || []), ve(s.resourceTemplates || []);
3919
3839
  let { server: c, capabilities: l, protocolEra: u, protocolVersion: d, instructions: m, extensions: h } = i.info;
3920
- 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) {
3921
3841
  if (J("debug", "Server info:", c), !K.current) return J("debug", "Skipping state update - component unmounted"), "failed";
3922
- H(c), ze.current = na({
3842
+ B(c), ze.current = Ki({
3923
3843
  serverInfo: c,
3924
3844
  url: t,
3925
3845
  isMounted: () => K.current,
3926
- setServerInfo: H,
3846
+ setServerInfo: B,
3927
3847
  addLog: J
3928
3848
  });
3929
3849
  }
3930
3850
  if (l) {
3931
3851
  if (J("debug", "Server capabilities:", l), !K.current) return J("debug", "Skipping state update - component unmounted"), "failed";
3932
- xe(l);
3852
+ Ce(l);
3933
3853
  }
3934
3854
  if (W.current) {
3935
3855
  let e = await W.current.tokens?.();
@@ -3959,20 +3879,20 @@ function pa(e) {
3959
3879
  });
3960
3880
  }
3961
3881
  }
3962
- return Ke.current = n, V("ready"), "success";
3882
+ return Ke.current = n, z("ready"), "success";
3963
3883
  } catch (r) {
3964
3884
  let i = r, a = i?.message || String(r), o = W.current?.getLastAttemptedAuthUrl?.();
3965
- 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";
3966
- let s = aa(r), c = Ii(r);
3967
- 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";
3968
- 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";
3969
3889
  if (c) {
3970
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";
3971
3891
  if (W.current) if (J("info", "Authentication required. OAuth provider available."), m) {
3972
3892
  if (J("info", "Waiting for user to initiate authentication flow..."), K.current) {
3973
- V("pending_auth");
3893
+ z("pending_auth");
3974
3894
  let e = W.current?.getLastAttemptedAuthUrl?.();
3975
- 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"));
3976
3896
  }
3977
3897
  return G.current = !1, "auth_redirect";
3978
3898
  } else {
@@ -3995,7 +3915,7 @@ function pa(e) {
3995
3915
  return Y(`Automatic OAuth authentication failed: ${e instanceof Error ? e.message : String(e)}`, e instanceof Error ? e : Error(String(e))), "failed";
3996
3916
  }
3997
3917
  }
3998
- 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");
3999
3919
  }
4000
3920
  return Y(a, i instanceof Error ? i : Error(String(i))) ? "auth_redirect" : "failed";
4001
3921
  }
@@ -4008,44 +3928,44 @@ function pa(e) {
4008
3928
  t,
4009
3929
  i,
4010
3930
  r,
4011
- F.name,
4012
- F.version,
4013
- F.uri,
4014
- F.logo_uri,
4015
- O,
3931
+ N.name,
3932
+ N.version,
3933
+ N.uri,
3934
+ N.logo_uri,
3935
+ ie,
4016
3936
  E,
4017
3937
  D,
4018
- A,
3938
+ k,
4019
3939
  re,
4020
3940
  m,
4021
3941
  h,
4022
3942
  g,
4023
3943
  n,
4024
3944
  _,
4025
- P,
4026
- j,
3945
+ M,
3946
+ ae,
4027
3947
  x,
4028
- L,
3948
+ F,
4029
3949
  c,
4030
- z,
4031
- R,
3950
+ L,
3951
+ I,
4032
3952
  et,
4033
3953
  tt,
4034
3954
  nt
4035
3955
  ]);
4036
- (0, M.useEffect)(() => {
3956
+ (0, j.useEffect)(() => {
4037
3957
  qe.current = at, Je.current = Y;
4038
3958
  }, [at, Y]);
4039
- let ot = (0, M.useCallback)(() => {
3959
+ let ot = (0, j.useCallback)(() => {
4040
3960
  q.current === "failed" ? (J("info", "Retry requested..."), qe.current?.()) : J("warn", `Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`);
4041
- }, [J]), st = (0, M.useCallback)(async () => {
3961
+ }, [J]), st = (0, j.useCallback)(async () => {
4042
3962
  J("info", "Manual authentication requested...");
4043
3963
  let e = q.current;
4044
3964
  if (e === "failed") J("info", "Attempting to reconnect and authenticate via retry..."), ot();
4045
3965
  else if (e === "pending_auth") {
4046
3966
  J("info", "Proceeding with authentication from pending state...");
4047
3967
  try {
4048
- 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) {
4049
3969
  J("info", "Using provided authProvider for manual authentication");
4050
3970
  let e = new URL(t), n = e.origin + e.pathname.replace(/\/+$/, "");
4051
3971
  await b(W.current, {
@@ -4054,15 +3974,15 @@ function pa(e) {
4054
3974
  }), qe.current?.();
4055
3975
  return;
4056
3976
  }
4057
- J("info", `Cleared ${W.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`), V("authenticating");
4058
- let e = null, n = null, { provider: o, oauthProxyUrl: s } = sa({
4059
- 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,
4060
3980
  storageKeyPrefix: i,
4061
- oauthClientConfig: F,
3981
+ oauthClientConfig: N,
4062
3982
  callbackUrl: r,
4063
3983
  preventAutoAuth: !1,
4064
3984
  useRedirectFlow: h,
4065
- gatewayUrl: L,
3985
+ gatewayUrl: F,
4066
3986
  oauthProxyUrl: c,
4067
3987
  onPopupWindow: (t, r, i) => {
4068
3988
  e = i;
@@ -4072,7 +3992,7 @@ function pa(e) {
4072
3992
  g?.(t, r, i);
4073
3993
  },
4074
3994
  proxyOAuthRequests: !0,
4075
- staticClientInfo: O,
3995
+ staticClientInfo: ie,
4076
3996
  clientMetadataUrl: E,
4077
3997
  scope: D
4078
3998
  });
@@ -4087,7 +4007,7 @@ function pa(e) {
4087
4007
  J("info", "OAuth flow initiated (popup/redirect):", e instanceof Error ? e.message : "Redirecting...");
4088
4008
  }
4089
4009
  let d = o.getLastAttemptedAuthUrl?.();
4090
- 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 {
4091
4011
  n = new URL(d).searchParams.get("state");
4092
4012
  } catch {}
4093
4013
  if (h) return;
@@ -4113,10 +4033,10 @@ function pa(e) {
4113
4033
  J("info", "Authentication succeeded; reconnecting to MCP server..."), G.current = !1, qe.current?.();
4114
4034
  break;
4115
4035
  case "cancelled":
4116
- 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");
4117
4037
  break;
4118
4038
  case "timeout":
4119
- 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");
4120
4040
  break;
4121
4041
  case "error":
4122
4042
  Y(`Authentication failed: ${p.error}`);
@@ -4125,39 +4045,39 @@ function pa(e) {
4125
4045
  }
4126
4046
  } catch (e) {
4127
4047
  if (!K.current) return;
4128
- 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)}`);
4129
4049
  }
4130
4050
  } else if (e === "authenticating") {
4131
4051
  J("warn", "Already attempting authentication. Check for blocked popups or wait for timeout.");
4132
4052
  let e = W.current?.getLastAttemptedAuthUrl?.();
4133
- e && !Pe && (Fe(e), J("info", "Manual authentication URL retrieved:", e));
4053
+ e && !Fe && (H(e), J("info", "Manual authentication URL retrieved:", e));
4134
4054
  } else J("info", `Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`);
4135
4055
  }, [
4136
4056
  J,
4137
4057
  ot,
4138
4058
  Y,
4139
- Pe,
4059
+ Fe,
4140
4060
  t,
4141
4061
  h,
4142
4062
  g,
4143
4063
  i,
4144
- F.name,
4145
- F.uri,
4146
- F.logo_uri,
4147
- O,
4064
+ N.name,
4065
+ N.uri,
4066
+ N.logo_uri,
4067
+ ie,
4148
4068
  E,
4149
4069
  D,
4150
4070
  r,
4151
- P,
4071
+ M,
4152
4072
  a
4153
- ]), ct = (0, M.useCallback)(() => {
4154
- 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.");
4155
4075
  }, [
4156
4076
  t,
4157
4077
  J,
4158
4078
  it
4159
4079
  ]);
4160
- (0, M.useEffect)(() => {
4080
+ (0, j.useEffect)(() => {
4161
4081
  if (typeof window > "u") return;
4162
4082
  let e = (e, t) => {
4163
4083
  if (We.current) {
@@ -4200,28 +4120,28 @@ function pa(e) {
4200
4120
  }
4201
4121
  He.current && clearTimeout(He.current);
4202
4122
  };
4203
- }, [J]), (0, M.useEffect)(() => {
4204
- 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"), () => {
4205
4125
  K.current = !1;
4206
4126
  };
4207
4127
  if (J("debug", "useMcp mounted, initiating connection."), Be.current = 0, a) W.current = a, J("debug", "Using externally provided authProvider");
4208
- else if (!W.current || W.current.serverUrl !== R) {
4209
- let { provider: e, oauthProxyUrl: t } = sa({
4210
- effectiveOAuthUrl: R,
4128
+ else if (!W.current || W.current.serverUrl !== I) {
4129
+ let { provider: e, oauthProxyUrl: t } = Zi({
4130
+ effectiveOAuthUrl: I,
4211
4131
  storageKeyPrefix: i,
4212
- oauthClientConfig: F,
4132
+ oauthClientConfig: N,
4213
4133
  callbackUrl: r,
4214
4134
  preventAutoAuth: m,
4215
4135
  useRedirectFlow: h,
4216
- gatewayUrl: L,
4136
+ gatewayUrl: F,
4217
4137
  oauthProxyUrl: c,
4218
4138
  onPopupWindow: g,
4219
4139
  proxyOAuthRequests: !0,
4220
- staticClientInfo: O,
4140
+ staticClientInfo: ie,
4221
4141
  clientMetadataUrl: E,
4222
4142
  scope: D
4223
4143
  });
4224
- 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"}`);
4225
4145
  }
4226
4146
  return at(), () => {
4227
4147
  K.current = !1, J("debug", "useMcp unmounting, disconnecting."), it(!0);
@@ -4231,54 +4151,54 @@ function pa(e) {
4231
4151
  n,
4232
4152
  i,
4233
4153
  r,
4234
- F.name,
4235
- F.version,
4236
- F.uri,
4237
- F.logo_uri,
4238
- O,
4154
+ N.name,
4155
+ N.version,
4156
+ N.uri,
4157
+ N.logo_uri,
4158
+ ie,
4239
4159
  E,
4240
4160
  D,
4241
4161
  h,
4242
- P,
4243
- R,
4162
+ M,
4163
+ I,
4244
4164
  s,
4245
4165
  a
4246
4166
  ]);
4247
- let lt = (0, M.useRef)(ot), ut = (0, M.useRef)(J);
4248
- (0, M.useEffect)(() => {
4167
+ let lt = (0, j.useRef)(ot), ut = (0, j.useRef)(J);
4168
+ (0, j.useEffect)(() => {
4249
4169
  lt.current = ot, ut.current = J;
4250
- }, [ot, J]), (0, M.useEffect)(() => {
4170
+ }, [ot, J]), (0, j.useEffect)(() => {
4251
4171
  let e = null;
4252
- if (B === "failed" && d && Be.current > 0) {
4172
+ if (R === "failed" && d && Be.current > 0) {
4253
4173
  if (!Ue.current) {
4254
4174
  Ue.current = !0;
4255
- let t = typeof d == "number" ? d : fa;
4175
+ let t = typeof d == "number" ? d : na;
4256
4176
  ut.current("info", `Connection failed, auto-retrying in ${t}ms...`), e = setTimeout(() => {
4257
4177
  Ue.current = !1, K.current && q.current === "failed" && lt.current();
4258
4178
  }, t);
4259
4179
  }
4260
- } else B !== "failed" && (Ue.current = !1);
4180
+ } else R !== "failed" && (Ue.current = !1);
4261
4181
  return () => {
4262
4182
  e && (clearTimeout(e), Ue.current = !1);
4263
4183
  };
4264
- }, [B, d]);
4265
- 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]);
4266
4186
  return {
4267
- state: B,
4268
- name: ye?.name || t || "",
4269
- tools: de,
4270
- resources: pe,
4271
- resourceTemplates: he,
4272
- prompts: _e,
4273
- serverInfo: ye,
4274
- capabilities: be,
4275
- protocolEra: Se,
4276
- protocolVersion: we,
4277
- instructions: Ee,
4278
- extensions: Oe,
4279
- error: Ae,
4280
- log: Me,
4281
- 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,
4282
4202
  authTokens: Ie,
4283
4203
  client: U.current,
4284
4204
  ...rt,
@@ -4289,11 +4209,11 @@ function pa(e) {
4289
4209
  ensureIconLoaded: dt
4290
4210
  };
4291
4211
  }
4292
- var ma = null;
4293
- function ha() {
4212
+ var ia = null;
4213
+ function aa() {
4294
4214
  return typeof window < "u" && window.name.startsWith("mcp_auth_");
4295
4215
  }
4296
- function ga(e, t, n) {
4216
+ function oa(e, t, n) {
4297
4217
  return {
4298
4218
  type: Er,
4299
4219
  success: e,
@@ -4302,7 +4222,7 @@ function ga(e, t, n) {
4302
4222
  ...n.serverUrlHash ? { serverUrlHash: n.serverUrlHash } : {}
4303
4223
  };
4304
4224
  }
4305
- function _a(e) {
4225
+ function sa(e) {
4306
4226
  if (typeof BroadcastChannel > "u") return;
4307
4227
  let t;
4308
4228
  try {
@@ -4317,7 +4237,7 @@ function _a(e) {
4317
4237
  }, 0);
4318
4238
  }
4319
4239
  }
4320
- function va(e, t, n, r) {
4240
+ function ca(e, t, n, r) {
4321
4241
  if (typeof document > "u") return;
4322
4242
  document.body.innerHTML = "";
4323
4243
  let i = document.createElement("div");
@@ -4333,7 +4253,7 @@ function va(e, t, n, r) {
4333
4253
  }
4334
4254
  document.body.appendChild(i);
4335
4255
  }
4336
- function ya(e) {
4256
+ function la(e) {
4337
4257
  let t = `mcp:auth:state_${e}`, n = localStorage.getItem(t) ? t : null;
4338
4258
  if (!n) {
4339
4259
  let t = `:state_${e}`;
@@ -4358,14 +4278,14 @@ function ya(e) {
4358
4278
  value: i
4359
4279
  };
4360
4280
  }
4361
- function ba(e, t) {
4281
+ function ua(e, t) {
4362
4282
  let n = new URL(e);
4363
4283
  n.searchParams.set("auth_error", "oauth_callback_failed"), n.searchParams.set("auth_error_description", t), window.location.href = n.toString();
4364
4284
  }
4365
- function xa(e, t, n, r) {
4366
- 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();
4367
4287
  if (n?.flowType === "redirect" && a) {
4368
- e ? window.location.href = a : ba(a, t ?? "Authentication failed.");
4288
+ e ? window.location.href = a : ua(a, t ?? "Authentication failed.");
4369
4289
  return;
4370
4290
  }
4371
4291
  if (window.opener && !window.opener.closed) {
@@ -4373,50 +4293,50 @@ function xa(e, t, n, r) {
4373
4293
  return;
4374
4294
  }
4375
4295
  if (o) {
4376
- _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);
4377
4297
  try {
4378
4298
  window.close();
4379
4299
  } catch {}
4380
4300
  return;
4381
4301
  }
4382
4302
  if (a) {
4383
- e ? window.location.href = a : ba(a, t ?? "Authentication failed.");
4303
+ e ? window.location.href = a : ua(a, t ?? "Authentication failed.");
4384
4304
  return;
4385
4305
  }
4386
4306
  if (!e) {
4387
- va("Authentication Error", t ?? "Authentication failed.", !0);
4307
+ ca("Authentication Error", t ?? "Authentication failed.", !0);
4388
4308
  return;
4389
4309
  }
4390
4310
  window.location.href = "/";
4391
4311
  }
4392
- function Sa() {
4393
- return ma ||= Ca(), ma;
4312
+ function fa() {
4313
+ return ia ||= pa(), ia;
4394
4314
  }
4395
- async function Ca() {
4315
+ async function pa() {
4396
4316
  let e = new URLSearchParams(window.location.search), t = e.get("state"), n = null, r = null, i = null;
4397
4317
  try {
4398
4318
  if (!t) throw Error("OAuth callback is missing the state parameter.");
4399
- let a = ya(t);
4319
+ let a = la(t);
4400
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.");
4401
4321
  if (!r.providerOptions) throw Error("Stored OAuth state is missing provider options.");
4402
4322
  let { serverUrl: o, ...s } = r.providerOptions;
4403
4323
  i = new ei(o, s), await new w(new URL(o), {
4404
4324
  authProvider: i,
4405
4325
  fetch: i.getProxyFetch()
4406
- }).finishAuth(e), localStorage.removeItem(n), xa(!0, void 0, r, {
4326
+ }).finishAuth(e), localStorage.removeItem(n), da(!0, void 0, r, {
4407
4327
  state: t,
4408
4328
  serverUrlHash: r.serverUrlHash
4409
4329
  });
4410
4330
  } catch (e) {
4411
4331
  let a = e instanceof Error ? e.message : String(e);
4412
- 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, {
4413
4333
  state: t,
4414
4334
  serverUrlHash: r?.serverUrlHash
4415
4335
  });
4416
4336
  }
4417
4337
  }
4418
4338
  mr();
4419
- var wa = [
4339
+ var ma = [
4420
4340
  "url",
4421
4341
  "displayName",
4422
4342
  "enabled",
@@ -4440,27 +4360,27 @@ var wa = [
4440
4360
  "clientInfo",
4441
4361
  "oauth"
4442
4362
  ];
4443
- function Ta(e) {
4363
+ function ha(e) {
4444
4364
  let t = {};
4445
- for (let n of wa) {
4365
+ for (let n of ma) {
4446
4366
  let r = e[n];
4447
4367
  r !== void 0 && (t[n] = r);
4448
4368
  }
4449
4369
  return t;
4450
4370
  }
4451
- function Ea(e) {
4452
- return Ta(e);
4371
+ function ga(e) {
4372
+ return ha(e);
4453
4373
  }
4454
- var Da = 500, Oa = 5 * 6e4;
4455
- function ka(e) {
4456
- 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) => {
4457
4377
  for (let t of l.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
4458
4378
  l.current.clear();
4459
4379
  for (let t of u.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
4460
4380
  u.current.clear(), i([]), o([]);
4461
4381
  }, []);
4462
- (0, M.useEffect)(() => () => d("MCP server connection was removed"), [d]);
4463
- let f = (0, M.useCallback)((t) => {
4382
+ (0, j.useEffect)(() => () => d("MCP server connection was removed"), [d]);
4383
+ let f = (0, j.useCallback)((t) => {
4464
4384
  let r = {
4465
4385
  id: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`,
4466
4386
  method: t.method,
@@ -4468,14 +4388,14 @@ function ka(e) {
4468
4388
  timestamp: Date.now(),
4469
4389
  read: !1
4470
4390
  };
4471
- n((e) => [r, ...e].slice(0, Da)), e.onNotificationReceived?.(r);
4472
- }, [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) => {
4473
4393
  let n = l.current.get(e);
4474
4394
  n && (clearTimeout(n.timeout), l.current.delete(e), i((t) => t.filter((t) => t.id !== e)), n.resolve(t));
4475
- }, []), m = (0, M.useCallback)((e, t) => {
4395
+ }, []), m = (0, j.useCallback)((e, t) => {
4476
4396
  let n = l.current.get(e);
4477
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")));
4478
- }, []), h = (0, M.useCallback)((t) => new Promise((n, r) => {
4398
+ }, []), h = (0, j.useCallback)((t) => new Promise((n, r) => {
4479
4399
  let a = `sampling-${s.current++}`, o = {
4480
4400
  id: a,
4481
4401
  request: {
@@ -4484,7 +4404,7 @@ function ka(e) {
4484
4404
  },
4485
4405
  timestamp: Date.now(),
4486
4406
  serverName: e.serverName
4487
- }, c = setTimeout(() => m(a, "Sampling request timed out"), Oa);
4407
+ }, c = setTimeout(() => m(a, "Sampling request timed out"), va);
4488
4408
  l.current.set(a, {
4489
4409
  resolve: n,
4490
4410
  reject: r,
@@ -4494,19 +4414,19 @@ function ka(e) {
4494
4414
  p,
4495
4415
  e,
4496
4416
  m
4497
- ]), g = (0, M.useCallback)((e, t) => {
4417
+ ]), g = (0, j.useCallback)((e, t) => {
4498
4418
  let n = u.current.get(e);
4499
4419
  n && (clearTimeout(n.timeout), u.current.delete(e), o((t) => t.filter((t) => t.id !== e)), n.resolve(t));
4500
- }, []), _ = (0, M.useCallback)((e, t) => {
4420
+ }, []), _ = (0, j.useCallback)((e, t) => {
4501
4421
  let n = u.current.get(e);
4502
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")));
4503
- }, []), v = (0, M.useCallback)((t) => new Promise((n, r) => {
4423
+ }, []), v = (0, j.useCallback)((t) => new Promise((n, r) => {
4504
4424
  let i = `elicitation-${c.current++}`, a = {
4505
4425
  id: i,
4506
4426
  request: t,
4507
4427
  timestamp: Date.now(),
4508
4428
  serverName: e.serverName
4509
- }, s = setTimeout(() => _(i, "Elicitation request timed out"), Oa);
4429
+ }, s = setTimeout(() => _(i, "Elicitation request timed out"), va);
4510
4430
  u.current.set(i, {
4511
4431
  resolve: n,
4512
4432
  reject: r,
@@ -4516,15 +4436,15 @@ function ka(e) {
4516
4436
  g,
4517
4437
  e,
4518
4438
  _
4519
- ]), ee = (0, M.useCallback)((e) => {
4439
+ ]), ee = (0, j.useCallback)((e) => {
4520
4440
  n((t) => t.map((t) => t.id === e ? {
4521
4441
  ...t,
4522
4442
  read: !0
4523
4443
  } : t));
4524
- }, []), te = (0, M.useCallback)(() => n((e) => e.map((e) => ({
4444
+ }, []), te = (0, j.useCallback)(() => n((e) => e.map((e) => ({
4525
4445
  ...e,
4526
4446
  read: !0
4527
- }))), []), y = (0, M.useCallback)(() => n([]), []);
4447
+ }))), []), y = (0, j.useCallback)(() => n([]), []);
4528
4448
  return {
4529
4449
  notifications: t,
4530
4450
  pendingSamplingRequests: r,
@@ -4543,15 +4463,15 @@ function ka(e) {
4543
4463
  rejectAll: d
4544
4464
  };
4545
4465
  }
4546
- var Q = pr.get("McpClientProvider"), Aa = (0, M.createContext)(null);
4466
+ var Q = pr.get("McpClientProvider"), ba = (0, j.createContext)(null);
4547
4467
  function $(e, t) {
4548
4468
  return JSON.stringify(e) === JSON.stringify(t);
4549
4469
  }
4550
- function ja(e, t) {
4551
- 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;
4552
4472
  }
4553
- 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 }) {
4554
- 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)(() => {
4555
4475
  let { displayName: c, onSamplingRequest: l, onElicitationRequest: u, onNotificationReceived: d, wrapTransport: f, ...p } = t;
4556
4476
  return {
4557
4477
  ...p,
@@ -4574,7 +4494,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4574
4494
  a,
4575
4495
  o,
4576
4496
  s
4577
- ]), y = (0, M.useMemo)(() => {
4497
+ ]), y = (0, j.useMemo)(() => {
4578
4498
  if (!(!f && !ee)) return (t) => {
4579
4499
  let n = t;
4580
4500
  return f && (n = f(n, e)), ee && (n = ee(n, e)), n;
@@ -4583,7 +4503,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4583
4503
  f,
4584
4504
  ee,
4585
4505
  e
4586
- ]), b = ka({
4506
+ ]), b = ya({
4587
4507
  serverId: e,
4588
4508
  serverName: h || e,
4589
4509
  onNotificationReceived: v,
@@ -4591,17 +4511,17 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4591
4511
  onElicitationRequest: _,
4592
4512
  onGlobalSamplingRequest: p,
4593
4513
  onGlobalElicitationRequest: m
4594
- }), x = pa({
4514
+ }), x = ra({
4595
4515
  ...te,
4596
4516
  onNotification: b.onNotification,
4597
4517
  onSampling: b.onSampling,
4598
4518
  onElicitation: b.onElicitation,
4599
4519
  wrapTransport: y
4600
4520
  });
4601
- (0, M.useEffect)(() => {
4521
+ (0, j.useEffect)(() => {
4602
4522
  x.state !== "ready" && b.rejectAll("MCP server connection is no longer active");
4603
4523
  }, [x.state, b.rejectAll]);
4604
- 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) => {
4605
4525
  let r = t.proxyConfig?.proxyAddress?.trim();
4606
4526
  return t.connectionMode === "proxy" && r ? l(e, {
4607
4527
  proxyConfig: {
@@ -4616,12 +4536,12 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4616
4536
  t.connectionMode,
4617
4537
  t.proxyConfig,
4618
4538
  l
4619
- ]), 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);
4620
- 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)(() => {
4621
4541
  re.current = c;
4622
- }, [c]), (0, M.useEffect)(() => {
4542
+ }, [c]), (0, j.useEffect)(() => {
4623
4543
  let n = {
4624
- ...Ea(t),
4544
+ ...ga(t),
4625
4545
  ...x,
4626
4546
  id: e,
4627
4547
  displayName: h || t.displayName || e,
@@ -4641,7 +4561,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4641
4561
  setDisplayName: ne,
4642
4562
  reconnect: w
4643
4563
  }, r = T.current;
4644
- !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`);
4645
4565
  }, [
4646
4566
  e,
4647
4567
  h,
@@ -4668,13 +4588,13 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
4668
4588
  w
4669
4589
  ]), null;
4670
4590
  }
4671
- 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 }) {
4672
- 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)([]);
4673
- (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)(() => {
4674
4594
  S.current = _;
4675
4595
  }, [_]);
4676
- let C = (0, M.useRef)({}), [ne, w] = (0, M.useState)(void 0), [re, T] = (0, M.useState)(!1);
4677
- (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)(() => {
4678
4598
  if (!l || typeof window > "u") {
4679
4599
  w(void 0), T(!0);
4680
4600
  return;
@@ -4684,7 +4604,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4684
4604
  }).catch((e) => {
4685
4605
  Q.error("[McpClientProvider] Failed to load RPC logger:", e), w(void 0), T(!0);
4686
4606
  });
4687
- }, [l]), (0, M.useEffect)(() => {
4607
+ }, [l]), (0, j.useEffect)(() => {
4688
4608
  if (!re) {
4689
4609
  Q.debug("[McpClientProvider] Waiting for RPC logging to be ready before loading servers");
4690
4610
  return;
@@ -4728,10 +4648,10 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4728
4648
  c,
4729
4649
  t,
4730
4650
  re
4731
- ]), (0, M.useEffect)(() => {
4651
+ ]), (0, j.useEffect)(() => {
4732
4652
  !c || !y || (async () => {
4733
4653
  try {
4734
- 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), {});
4735
4655
  await Promise.resolve(c.setServers(e));
4736
4656
  } catch (e) {
4737
4657
  Q.error("[McpClientProvider] Failed to save to storage:", e);
@@ -4742,7 +4662,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4742
4662
  c,
4743
4663
  y
4744
4664
  ]);
4745
- let E = (0, M.useCallback)((e) => {
4665
+ let E = (0, j.useCallback)((e) => {
4746
4666
  Q.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`, {
4747
4667
  toolCount: e.tools.length,
4748
4668
  state: e.state
@@ -4757,7 +4677,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4757
4677
  currentToolCount: i.tools.length,
4758
4678
  updatedToolCount: e.tools.length,
4759
4679
  stateChanged: a
4760
- }), 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;
4761
4681
  if (Q.debug(`[McpClientProvider] Updating server ${e.id} in state`), a && t.push(() => f?.(e.id, e.state)), o && e.serverInfo && c?.setServerMetadata) {
4762
4682
  let t = {
4763
4683
  name: e.serverInfo.name,
@@ -4780,12 +4700,12 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4780
4700
  u,
4781
4701
  f,
4782
4702
  c
4783
- ]), D = (0, M.useCallback)((e, t) => {
4703
+ ]), D = (0, j.useCallback)((e, t) => {
4784
4704
  g((n) => n.find((t) => t.id === e) ? n : (Q.debug("[McpClientProvider] Adding new server to configs:", e), [...n, {
4785
4705
  id: e,
4786
4706
  options: t
4787
4707
  }]));
4788
- }, []), O = (0, M.useCallback)(async (e, t) => {
4708
+ }, []), ie = (0, j.useCallback)(async (e, t) => {
4789
4709
  let n = S.current.find((t) => t.id === e);
4790
4710
  if (v((t) => t.filter((t) => t.id !== e)), g((t) => t.filter((t) => t.id !== e)), te((t) => {
4791
4711
  let { [e]: n, ...r } = t;
@@ -4795,7 +4715,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4795
4715
  t(e);
4796
4716
  }
4797
4717
  d?.(e);
4798
- }, [l, d]), k = (0, M.useCallback)(async (e, t) => {
4718
+ }, [l, d]), O = (0, j.useCallback)(async (e, t) => {
4799
4719
  let n = h.find((t) => t.id === e);
4800
4720
  if (!n) {
4801
4721
  Q.warn(`[McpClientProvider] Cannot update server "${e}" - not found`);
@@ -4805,14 +4725,14 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4805
4725
  ...n.options,
4806
4726
  ...t
4807
4727
  };
4808
- $(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 ? {
4809
4729
  id: e,
4810
4730
  options: r
4811
4731
  } : t)), te((t) => ({
4812
4732
  ...t,
4813
4733
  [e]: (t[e] ?? 0) + 1
4814
4734
  })));
4815
- }, [h]), A = (0, M.useCallback)(async (e) => {
4735
+ }, [h]), k = (0, j.useCallback)(async (e) => {
4816
4736
  if (!h.find((t) => t.id === e)) {
4817
4737
  Q.warn(`[McpClientProvider] Cannot reconnect server "${e}" - not found`);
4818
4738
  return;
@@ -4821,7 +4741,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4821
4741
  ...t,
4822
4742
  [e]: (t[e] ?? 0) + 1
4823
4743
  }));
4824
- }, [h]), j = (0, M.useCallback)(async (e, t) => new Promise((n) => {
4744
+ }, [h]), ae = (0, j.useCallback)(async (e, t) => new Promise((n) => {
4825
4745
  let r = h.find((t) => t.id === e);
4826
4746
  if (!r) {
4827
4747
  Q.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`), n();
@@ -4841,33 +4761,33 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4841
4761
  } : t);
4842
4762
  return setTimeout(() => n(), 0), r;
4843
4763
  });
4844
- }), [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)(() => ({
4845
4765
  servers: _,
4846
4766
  addServer: D,
4847
- removeServer: O,
4848
- updateServerMetadata: j,
4849
- updateServer: k,
4850
- getServer: ie,
4767
+ removeServer: ie,
4768
+ updateServerMetadata: ae,
4769
+ updateServer: O,
4770
+ getServer: A,
4851
4771
  storageLoaded: y
4852
4772
  }), [
4853
4773
  _,
4854
4774
  D,
4855
- O,
4856
- j,
4857
- k,
4858
4775
  ie,
4776
+ ae,
4777
+ O,
4778
+ A,
4859
4779
  y
4860
- ]), { 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) => {
4861
4781
  let t = o ? {
4862
4782
  ...o,
4863
4783
  ...e.options
4864
4784
  } : e.options;
4865
- return ae && (t = {
4785
+ return se && (t = {
4866
4786
  ...t,
4867
4787
  clientOptions: {
4868
4788
  ...t.clientOptions,
4869
4789
  capabilities: {
4870
- ...ae,
4790
+ ...se,
4871
4791
  ...t.clientOptions?.capabilities
4872
4792
  }
4873
4793
  }
@@ -4877,10 +4797,10 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4877
4797
  };
4878
4798
  }), [
4879
4799
  h,
4880
- ae,
4800
+ se,
4881
4801
  o
4882
- ]);
4883
- return /* @__PURE__ */ M.createElement(Aa.Provider, { value: N }, e, 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, {
4884
4804
  key: `${e.id}-v${ee[e.id] ?? 0}`,
4885
4805
  id: e.id,
4886
4806
  options: e.options,
@@ -4888,23 +4808,23 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
4888
4808
  defaultOAuthProxyUrl: r,
4889
4809
  defaultProxyConfig: i,
4890
4810
  defaultAutoProxyFallback: a,
4891
- clientInfo: F,
4811
+ clientInfo: N,
4892
4812
  cachedMetadata: C.current[e.id],
4893
4813
  onUpdate: E,
4894
- onUpdateConfig: k,
4895
- onUpdateDisplayName: (e, t) => j(e, { name: t }),
4896
- onReconnect: A,
4814
+ onUpdateConfig: O,
4815
+ onUpdateDisplayName: (e, t) => ae(e, { name: t }),
4816
+ onReconnect: k,
4897
4817
  rpcWrapTransport: ne,
4898
4818
  onGlobalSamplingRequest: p,
4899
4819
  onGlobalElicitationRequest: m
4900
4820
  })));
4901
4821
  }
4902
- function Pa() {
4903
- let e = (0, M.useContext)(Aa);
4822
+ function wa() {
4823
+ let e = (0, j.useContext)(ba);
4904
4824
  if (!e) throw Error("useMcpClient must be used within a McpClientProvider");
4905
4825
  return e;
4906
4826
  }
4907
- var Fa = class {
4827
+ var Ta = class {
4908
4828
  constructor(e = "mcp-client-servers") {
4909
4829
  this.storageKey = e, this.metadataKey = `${e}-metadata`;
4910
4830
  }
@@ -4970,7 +4890,7 @@ var Fa = class {
4970
4890
  }
4971
4891
  };
4972
4892
  wr();
4973
- function Ia(e) {
4893
+ function Ea(e) {
4974
4894
  let t = {};
4975
4895
  if (!e) return t;
4976
4896
  for (let [n, r] of Object.entries(e)) if (typeof r == "string" && (r.trim().startsWith("[") || r.trim().startsWith("{"))) try {
@@ -4981,7 +4901,11 @@ function Ia(e) {
4981
4901
  else t[n] = r;
4982
4902
  return t;
4983
4903
  }
4984
- 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) {
4985
4909
  let { resourceResult: t, listingResource: n, cspMode: r, resourceUri: i } = e, a = (Array.isArray(t?.contents) ? t.contents : [])[0], o = "", s;
4986
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");
4987
4911
  let c = n?._meta?.ui, l = a?._meta?.ui, u = c || l ? {
@@ -4999,7 +4923,7 @@ function La(e) {
4999
4923
  mimeTypeWarning: h
5000
4924
  };
5001
4925
  }
5002
- function Ra(e, t) {
4926
+ function Aa(e, t) {
5003
4927
  let { cspMode: n, permissions: r, widgetCsp: i } = t;
5004
4928
  e.searchParams.set("v", JSON.stringify({
5005
4929
  cspMode: n,
@@ -5007,77 +4931,92 @@ function Ra(e, t) {
5007
4931
  widgetCsp: i
5008
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));
5009
4933
  }
5010
- function za(e) {
4934
+ function ja(e) {
5011
4935
  let t = new URL("https://sandbox.invalid/");
5012
- Ra(t, e);
5013
- let n = Va(t.search);
4936
+ Aa(t, e);
4937
+ let n = Na(t.search);
5014
4938
  return new URL(URL.createObjectURL(new Blob([n], { type: "text/html" })));
5015
4939
  }
5016
- 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>";
5017
- 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) {
5018
4942
  let t = "<script>window.__SANDBOX_SEARCH__ = " + JSON.stringify(e).replace(/</g, "\\u003c") + ";<\/script>";
5019
- return Ba.replace("<body>", "<body>" + t);
4943
+ return Ma.replace("<body>", "<body>" + t);
5020
4944
  }
5021
- 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 = [
5022
- "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]",
5023
4947
  "rounded-3xl w-full min-w-[300px] h-[400px]",
5024
4948
  "shadow-2xl border overflow-hidden",
5025
4949
  "bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",
5026
4950
  "flex flex-col"
5027
- ].join(" "), Wa = "data-mcp-widget-fullscreen", Ga = "data-mcp-widget-display-mode";
5028
- function Ka(e) {
5029
- (0, M.useEffect)(() => {
4951
+ ].join(" "), Ia = "data-mcp-widget-fullscreen", La = "data-mcp-widget-display-mode";
4952
+ function Ra(e) {
4953
+ (0, j.useEffect)(() => {
5030
4954
  if (!(typeof document > "u")) {
5031
- if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(Ga, e), e === "fullscreen" ? document.documentElement.setAttribute(Wa, "") : document.documentElement.removeAttribute(Wa), () => {
5032
- 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);
5033
4957
  };
5034
- document.documentElement.removeAttribute(Ga), document.documentElement.removeAttribute(Wa);
4958
+ document.documentElement.removeAttribute(La), document.documentElement.removeAttribute(Ia);
5035
4959
  }
5036
4960
  }, [e]);
5037
4961
  }
5038
- function qa({ displayMode: e, setDisplayMode: t }) {
4962
+ function za({ displayMode: e, setDisplayMode: t }) {
5039
4963
  let n = e === "fullscreen", r = e === "pip";
5040
- return Ka(e), {
5041
- handleDisplayModeChange: (0, M.useCallback)((e) => t(e), [t]),
5042
- fullscreenShellClassName: n ? Ha : void 0,
5043
- 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,
5044
4968
  isFullscreen: n,
5045
4969
  isPip: r
5046
4970
  };
5047
4971
  }
5048
- var Ja = {
4972
+ var Ba = {
5049
4973
  PIP_MAX_WIDTH: 700,
5050
- DEFAULT_HEIGHT: 400
4974
+ DEFAULT_HEIGHT: 400,
4975
+ FULLSCREEN_HEADER_HEIGHT: 50
5051
4976
  };
5052
- function Ya(e) {
4977
+ function Va(e) {
5053
4978
  let t = e?.ui;
5054
4979
  return t && typeof t == "object" && "resourceUri" in t && typeof t.resourceUri == "string" ? t.resourceUri : null;
5055
4980
  }
5056
- function Xa(e) {
5057
- return Ya(e) !== null;
4981
+ function Ha(e) {
4982
+ return Va(e) !== null;
5058
4983
  }
5059
- function Za(e) {
4984
+ function Ua(e) {
5060
4985
  return e === er;
5061
4986
  }
5062
- var Qa = {
4987
+ var Wa = {
5063
4988
  name: "mcp-use-client",
5064
4989
  version: "2.0.0"
5065
- }, $a = 6e5, eo = "ui/notifications/sandbox-proxy-ready", to = {
4990
+ }, Ga = 6e5, Ka = "ui/notifications/sandbox-proxy-ready", qa = {
5066
4991
  openLinks: {},
5067
4992
  serverTools: {},
5068
4993
  serverResources: {},
5069
4994
  logging: {},
5070
- updateModelContext: { text: {} }
4995
+ updateModelContext: { text: {} },
4996
+ message: { text: {} }
5071
4997
  };
5072
- 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) {
5073
5012
  return new Promise((t) => {
5074
5013
  let n = (r) => {
5075
- 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());
5076
5015
  };
5077
5016
  window.addEventListener("message", n);
5078
5017
  });
5079
5018
  }
5080
- function ro(e) {
5019
+ function Xa(e) {
5081
5020
  let t = e.oninitialized;
5082
5021
  return new Promise((n) => {
5083
5022
  e.oninitialized = (...r) => {
@@ -5085,67 +5024,76 @@ function ro(e) {
5085
5024
  };
5086
5025
  });
5087
5026
  }
5088
- function io(e, t) {
5089
- let n = Ia(t);
5027
+ function Za(e, t) {
5028
+ let n = Ea(t);
5090
5029
  return Object.keys(n).length > 0 ? {
5091
5030
  ...typeof e == "object" && e ? e : {},
5092
5031
  structuredContent: n
5093
5032
  } : e ?? null;
5094
5033
  }
5095
- 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 }) {
5096
- 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);
5097
- B.current = u;
5098
- let V = (0, M.useRef)(_);
5099
- V.current = _;
5100
- let de = (0, M.useRef)(i);
5101
- de.current = i;
5102
- let fe = (0, M.useRef)(a);
5103
- fe.current = a;
5104
- let pe = (0, M.useRef)(s);
5105
- pe.current = s;
5106
- let me = (0, M.useRef)(S);
5107
- me.current = S;
5108
- let he = (0, M.useRef)(v);
5109
- he.current = v;
5110
- let ge = (0, M.useRef)(ee);
5111
- ge.current = ee;
5112
- let _e = (0, M.useRef)(b);
5113
- _e.current = b;
5114
- let ve = (0, M.useRef)(x);
5115
- ve.current = x;
5116
- let ye = (0, M.useRef)(te);
5117
- ye.current = te;
5118
- let H = (0, M.useRef)(y);
5119
- H.current = y;
5120
- let be = (0, M.useRef)(n);
5121
- be.current = n;
5122
- let xe = (0, M.useRef)(f);
5123
- xe.current = f;
5124
- let Se = (0, M.useCallback)((e) => {
5125
- let t = be.current;
5126
- return t ? typeof t == "function" ? t(e) : t : za({
5127
- 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,
5128
5076
  permissions: e.permissions,
5129
5077
  widgetCsp: e.declaredCsp
5130
5078
  });
5131
- }, []), { handleDisplayModeChange: Ce, fullscreenShellClassName: we, pipShellClassName: Te, isFullscreen: Ee, isPip: De } = qa({
5132
- containerRef: k,
5133
- displayMode: z,
5134
- setDisplayMode: (0, M.useCallback)((e) => {
5135
- 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);
5136
5084
  }, [m])
5137
- }), Oe = (0, M.useRef)(Ce);
5138
- Oe.current = Ce;
5139
- let ke = (0, M.useRef)(z);
5140
- ke.current = z;
5141
- let Ae = t.kind === "live" ? t.resourceUri : void 0, je = t.kind === "preloaded" ? t.html : void 0;
5142
- 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)(() => {
5143
5091
  let e = !1;
5144
- H.current?.({ status: "resolving" });
5092
+ V.current?.({ status: "resolving" });
5145
5093
  let n = (e) => {
5146
- ie(e), H.current?.({ status: "sandbox-loading" });
5147
- let t = Se(e);
5148
- 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);
5149
5097
  };
5150
5098
  if (t.kind === "preloaded") {
5151
5099
  n({
@@ -5161,11 +5109,11 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5161
5109
  return;
5162
5110
  }
5163
5111
  let { connection: r, resourceUri: i } = t;
5164
- return A.current = r, (async () => {
5112
+ return M.current = r, (async () => {
5165
5113
  try {
5166
5114
  let t = await r.readResource(i);
5167
5115
  if (e) return;
5168
- let a = r.resources?.find((e) => e.uri === i), o = La({
5116
+ let a = r.resources?.find((e) => e.uri === i), o = ka({
5169
5117
  resourceResult: t,
5170
5118
  listingResource: a,
5171
5119
  cspMode: f,
@@ -5173,7 +5121,7 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5173
5121
  });
5174
5122
  if (!o.mimeTypeValid) {
5175
5123
  let e = o.mimeTypeWarning || "Invalid MIME type - SEP-1865 requires \"text/html;profile=mcp-app\"";
5176
- F(e), H.current?.({
5124
+ de(e), V.current?.({
5177
5125
  status: "error",
5178
5126
  error: e
5179
5127
  });
@@ -5182,7 +5130,7 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5182
5130
  n(o);
5183
5131
  } catch (t) {
5184
5132
  if (e) return;
5185
- 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?.({
5186
5134
  status: "error",
5187
5135
  error: t instanceof Error ? t.message : "Failed to prepare view"
5188
5136
  });
@@ -5192,30 +5140,35 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5192
5140
  };
5193
5141
  }, [
5194
5142
  t.kind,
5195
- Ae,
5196
- je,
5143
+ Re,
5144
+ W,
5197
5145
  f,
5198
- Se
5199
- ]), (0, M.useEffect)(() => {
5200
- let e = N;
5201
- return () => {
5202
- 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);
5203
5156
  };
5204
- }, [N]);
5205
- let Me = N?.protocol === "blob:", Ne = !N || Me ? null : (() => {
5157
+ }, [P]);
5158
+ let ze = P?.protocol === "blob:", G = !P || ze ? null : (() => {
5206
5159
  try {
5207
- return N.origin;
5160
+ return P.origin;
5208
5161
  } catch {
5209
5162
  return null;
5210
5163
  }
5211
5164
  })();
5212
- (0, M.useEffect)(() => {
5213
- if (!Ne && !Me) return;
5165
+ (0, j.useEffect)(() => {
5166
+ if (!G && !ze) return;
5214
5167
  let e = (e) => {
5215
- let t = D.current;
5216
- 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 !== "*")) {
5217
5170
  if (e.data?.type === "mcp-apps:csp-violation") {
5218
- ve.current?.({
5171
+ Ee.current?.({
5219
5172
  directive: e.data.directive,
5220
5173
  effectiveDirective: e.data.effectiveDirective,
5221
5174
  blockedUri: e.data.blockedUri,
@@ -5227,33 +5180,38 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5227
5180
  });
5228
5181
  return;
5229
5182
  }
5230
- e.data?.type === "iframe-console-log" && ge.current && ge.current({
5183
+ e.data?.type === "iframe-console-log" && we.current && we.current({
5231
5184
  level: e.data.level ?? "log",
5232
5185
  data: e.data.args
5233
5186
  });
5234
5187
  }
5235
5188
  };
5236
5189
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
5237
- }, [Ne, Me]), (0, M.useEffect)(() => {
5238
- if (!j || !N) return;
5239
- let t = D.current;
5190
+ }, [G, ze]), (0, j.useEffect)(() => {
5191
+ if (!N || !P) return;
5192
+ let t = ae.current;
5240
5193
  if (!t) return;
5241
5194
  let n = !1, r = null;
5242
5195
  return (async () => {
5243
5196
  try {
5244
- H.current?.({ status: "connecting" }), t.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
5245
- 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);
5246
5199
  i && t.setAttribute("allow", i);
5247
- let a = no(t);
5248
- 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;
5249
5207
  r = new rr(null, l, {
5250
- ...d ?? to,
5208
+ ...d ?? qa,
5251
5209
  sandbox: {
5252
- csp: f === "permissive" ? void 0 : j.csp,
5253
- permissions: j.permissions
5210
+ csp: f === "permissive" ? void 0 : N.csp,
5211
+ permissions: N.permissions
5254
5212
  }
5255
- }, { 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 }) => {
5256
- 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;
5257
5215
  if (!n) throw Error("Server connection not available");
5258
5216
  try {
5259
5217
  return await n.callTool(e, t || {}, {
@@ -5264,47 +5222,51 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5264
5222
  throw r?.sendToolCancelled({ reason: e instanceof Error ? e.message : String(e) }), e;
5265
5223
  }
5266
5224
  }), r.onreadresource = (async ({ uri: e }) => {
5267
- let t = A.current;
5225
+ let t = M.current;
5268
5226
  if (!t) throw Error("Server connection not available");
5269
5227
  return await t.readResource(e);
5270
5228
  }), r.onlistresources = (async () => {
5271
- let e = A.current;
5229
+ let e = M.current;
5272
5230
  if (!e) throw Error("Server connection not available");
5273
5231
  return { resources: [...e.resources ?? []] };
5274
5232
  }), r.onrequestdisplaymode = async ({ mode: e }) => {
5275
- let t = e ?? "inline", n = (B.current?.availableDisplayModes ?? [
5233
+ let t = e ?? "inline", n = (_e.current?.availableDisplayModes ?? [
5276
5234
  "inline",
5277
5235
  "pip",
5278
5236
  "fullscreen"
5279
- ]).includes(t) ? t : ke.current;
5280
- return await Oe.current(n), { mode: n };
5281
- }, 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?.({
5282
5240
  content: e,
5283
5241
  structuredContent: t
5284
- }), {}), r.onloggingmessage = async ({ level: e, data: t }) => (ge.current?.({
5242
+ }), {}), r.onloggingmessage = async ({ level: e, data: t }) => (we.current?.({
5285
5243
  level: e,
5286
5244
  data: t
5287
5245
  }), {}), r.onsizechange = async ({ height: e }) => {
5288
- ke.current === "inline" && e !== void 0 && L(e);
5246
+ U.current === "inline" && e !== void 0 && (z(e), Oe.current?.(e));
5289
5247
  };
5290
- let o = ro(r), s = new $n(t.contentWindow, t.contentWindow);
5248
+ let o = Xa(r), s = new $n(t.contentWindow, t.contentWindow);
5291
5249
  if (C && (s = C(s, e)), await r.connect(s), n || (await r.sendSandboxResourceReady({
5292
- html: j.html,
5293
- csp: j.csp,
5294
- permissions: j.permissions
5250
+ html: je.current ? Oa(N.html) : N.html,
5251
+ csp: N.csp,
5252
+ permissions: N.permissions
5295
5253
  }), await o, n)) return;
5296
- O.current = r, oe((e) => e + 1), H.current?.({ status: "initialized" });
5297
- let c = {
5298
- ...de.current,
5299
- ...Ia(pe.current)
5300
- };
5301
- r.sendToolInput({ arguments: c });
5302
- let u = io(fe.current, pe.current);
5303
- 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" });
5304
5266
  } catch (e) {
5305
5267
  if (!n) {
5306
5268
  let t = e instanceof Error ? e.message : "Failed to connect view";
5307
- F(t), _e.current?.(t), H.current?.({
5269
+ de(t), Te.current?.(t), V.current?.({
5308
5270
  status: "error",
5309
5271
  error: t
5310
5272
  });
@@ -5313,99 +5275,132 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
5313
5275
  })(), () => {
5314
5276
  n = !0;
5315
5277
  let e = r;
5316
- O.current = null, e && (H.current?.({ status: "tearing-down" }), (async () => {
5278
+ A.current = null, e && (V.current?.({ status: "tearing-down" }), (async () => {
5317
5279
  try {
5318
5280
  await Promise.race([e.teardownResource({}), new Promise((e, t) => setTimeout(() => t(/* @__PURE__ */ Error("teardown timeout")), 2e3))]);
5319
5281
  } catch {} finally {
5320
- e.close().catch(() => {}), H.current?.({ status: "closed" });
5282
+ e.close().catch(() => {}), V.current?.({ status: "closed" });
5321
5283
  }
5322
5284
  })());
5323
5285
  };
5324
5286
  }, [
5325
- j,
5326
5287
  N,
5288
+ P,
5327
5289
  l,
5328
5290
  d,
5329
5291
  f,
5330
5292
  e,
5331
5293
  C,
5332
- ne
5333
- ]), (0, M.useEffect)(() => {
5334
- let e = O.current;
5335
- !e || I === 0 || !u || e.setHostContext(u);
5336
- }, [u, I]), (0, M.useEffect)(() => {
5337
- let e = O.current;
5338
- !e || I === 0 || !o || e.sendToolInputPartial({ arguments: o });
5339
- }, [I, o]), (0, M.useEffect)(() => {
5340
- let e = O.current;
5341
- 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;
5342
5305
  let t = {
5343
5306
  ...i,
5344
- ...Ia(s)
5307
+ ...Ea(s)
5345
5308
  };
5346
5309
  e.sendToolInput({ arguments: t });
5347
5310
  }, [
5348
- I,
5311
+ F,
5349
5312
  i,
5313
+ o,
5350
5314
  s
5351
- ]), (0, M.useEffect)(() => {
5352
- let e = O.current;
5353
- if (!e || I === 0) return;
5354
- 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);
5355
5319
  t && e.sendToolResult(t);
5356
5320
  }, [
5357
- I,
5321
+ F,
5358
5322
  a,
5359
5323
  s
5360
- ]), (0, M.useEffect)(() => {
5361
- let e = O.current;
5362
- !e || I === 0 || !c || e.sendToolCancelled({ reason: "Cancelled by user" });
5363
- }, [c, I]);
5364
- let Pe = (0, M.useRef)(!1);
5365
- if ((0, M.useEffect)(() => {
5366
- Pe.current || I === 0 || (Pe.current = !0, ye.current?.());
5367
- }, [I]), (0, M.useEffect)(() => {
5368
- if (I === 0 || !se) return;
5369
- 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);
5370
5334
  return () => clearTimeout(e);
5371
- }, [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)));
5372
- 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…")));
5373
- let Fe = we ?? Te ?? "flex group flex-1 items-center justify-center", Ie = {
5374
- 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`,
5375
5341
  width: "100%",
5376
- maxWidth: z === "inline" ? `${h}px` : "100%",
5377
- transition: Ee || De ? void 0 : "height 300ms ease-out"
5378
- }, Le = /* @__PURE__ */ M.createElement("div", {
5379
- ref: k,
5380
- className: Fe,
5381
- style: De ? {
5382
- height: Ja.DEFAULT_HEIGHT,
5383
- 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,
5384
5350
  zIndex: 100
5385
- } : Ee ? { zIndex: 100 } : void 0
5386
- }, (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", {
5387
5383
  type: "button",
5388
- "data-testid": Ee ? "debugger-exit-fullscreen-button" : "debugger-exit-pip-button",
5389
- "aria-label": Ee ? "Exit fullscreen" : "Exit picture-in-picture",
5390
- 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",
5391
5387
  style: { zIndex: 110 },
5392
- onClick: () => void Ce("inline")
5393
- }, "×"), /* @__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", {
5394
- "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,
5395
5391
  "data-mcp-app-tool": r,
5396
- className: z === "fullscreen" ? "w-full h-full overflow-hidden" : "w-full overflow-hidden",
5397
- style: Ie
5398
- }, /* @__PURE__ */ M.createElement("iframe", {
5399
- 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,
5400
5396
  title: `MCP App: ${r}`,
5401
- className: "w-full h-full border-0 bg-transparent",
5402
- 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"
5403
5398
  }))));
5404
- return /* @__PURE__ */ M.createElement("div", { className: w }, Le);
5399
+ return /* @__PURE__ */ j.createElement("div", { className: D }, Ue);
5405
5400
  }
5406
- function oo(e, t) {
5407
- 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);
5408
5403
  }
5409
- var so = (0, M.memo)(ao, oo);
5404
+ var eo = (0, j.memo)(Qa, $a);
5410
5405
  //#endregion
5411
- 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 };