@mcp-use/inspector 20.0.0-beta.4 → 20.0.0-beta.40

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 (580) hide show
  1. package/README.md +31 -78
  2. package/dist/app/inspector.css.gz +0 -0
  3. package/dist/app/inspector.js.gz +0 -0
  4. package/dist/app/providers/anthropic.png +0 -0
  5. package/dist/app/providers/google.png +0 -0
  6. package/dist/app/providers/openai.png +0 -0
  7. package/dist/cli.js +74 -1398
  8. package/dist/client/index.d.ts +1402 -50
  9. package/dist/client/index.js +165 -24019
  10. package/dist/server/index.d.ts +79 -7
  11. package/dist/server/index.js +99 -23
  12. package/package.json +77 -35
  13. package/dist/cdn/AnimatePresence-Dcw-FOy8.js +0 -393
  14. package/dist/cdn/ChatTab-UQAPDRQG.js +0 -6744
  15. package/dist/cdn/CheckboxIndicator-Bt4IICtv.js +0 -251
  16. package/dist/cdn/ConnectionSettingsForm-DrY1p-NO.js +0 -929
  17. package/dist/cdn/ConnectionSettingsTab-B1cRD7hz.js +0 -150
  18. package/dist/cdn/ElicitationTab-CL1KJ0bz.js +0 -654
  19. package/dist/cdn/FormContext-tmgN_Vdr.js +0 -135
  20. package/dist/cdn/InspectorContext-UjtEbNod.js +0 -123
  21. package/dist/cdn/JSONDisplay-BFxf5oEu.js +0 -324
  22. package/dist/cdn/ListTabHeader-Cv-GmtGF.js +0 -88
  23. package/dist/cdn/ManufactOAuthCallback-B98kSYCj.js +0 -31
  24. package/dist/cdn/MarkdownRenderer-BoDJE8tP.js +0 -3610
  25. package/dist/cdn/NotificationsTab-CeImSrhx.js +0 -290
  26. package/dist/cdn/OAuthCallback-C9AvCkOn.js +0 -58
  27. package/dist/cdn/PromptsTab-CkAWyWVb.js +0 -901
  28. package/dist/cdn/ResourcesTab-BtBKxd4c.js +0 -564
  29. package/dist/cdn/SamplingTab-Czp7Rmhz.js +0 -658
  30. package/dist/cdn/ServerMetadataTab-CvrKX8fz.js +0 -244
  31. package/dist/cdn/StatusIcon-D0-ARyOh.js +0 -66
  32. package/dist/cdn/ToolsTab-Dm4vCB8D.js +0 -2033
  33. package/dist/cdn/ViewPreview-CZvl_7x-.js +0 -238
  34. package/dist/cdn/WidgetDebugContext-D4usL_MA.js +0 -324
  35. package/dist/cdn/WidgetWrapper-DeiogRXV.js +0 -2210
  36. package/dist/cdn/basePath-B8HuhIMu.js +0 -25
  37. package/dist/cdn/bell-CGjAO_0s.js +0 -10
  38. package/dist/cdn/browser-CbQIH4w2.js +0 -42
  39. package/dist/cdn/brush-B_mKhyxG.js +0 -17
  40. package/dist/cdn/card-DgiYnSg-.js +0 -41
  41. package/dist/cdn/cfWorker-Bxcs9rNe.js +0 -10799
  42. package/dist/cdn/checkbox-By0FklhG.js +0 -20
  43. package/dist/cdn/chunk-QUQL4437-XnDcYQEx.js +0 -1508
  44. package/dist/cdn/clock-CmUbSx_B.js +0 -12
  45. package/dist/cdn/code-V_0nf5rg.js +0 -10
  46. package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
  47. package/dist/cdn/dialog-BsDpuJd3.js +0 -1028
  48. package/dist/cdn/dist-3QLh0dt8.js +0 -2306
  49. package/dist/cdn/dist-DaMB0Su9.js +0 -616
  50. package/dist/cdn/external-link-CjmfT6rW.js +0 -17
  51. package/dist/cdn/eye-B7H96av8.js +0 -29
  52. package/dist/cdn/folder-open-B3lu2rG_.js +0 -7
  53. package/dist/cdn/hash-BVQnWi7q.js +0 -33
  54. package/dist/cdn/history-Csw4rb44.js +0 -17
  55. package/dist/cdn/index-browser-CIoYSwCt.js +0 -1934
  56. package/dist/cdn/info-CNiOwqkf.js +0 -19
  57. package/dist/cdn/input-C2OBd4PJ.js +0 -12160
  58. package/dist/cdn/inspector-settings-layout-0VDsjeqb.js +0 -4
  59. package/dist/cdn/inspector.css +0 -2
  60. package/dist/cdn/inspector.js +0 -24523
  61. package/dist/cdn/jsx-runtime-CIxvMpEo.js +0 -180
  62. package/dist/cdn/label-B9Jmm9be.js +0 -60
  63. package/dist/cdn/loader-circle-BLy9A_pp.js +0 -7
  64. package/dist/cdn/manufact-auth-BQMHhbLV.js +0 -423
  65. package/dist/cdn/maximize-2-CH5Lq90B.js +0 -21
  66. package/dist/cdn/maximize-BALCV_ep.js +0 -21
  67. package/dist/cdn/message-square-BnxdpJxZ.js +0 -7
  68. package/dist/cdn/not-found-DEtSM_Wd.js +0 -34
  69. package/dist/cdn/play-vuZ5PLnI.js +0 -7
  70. package/dist/cdn/providerMeta-BQIfHuNL.js +0 -379
  71. package/dist/cdn/providers/anthropic.png +0 -0
  72. package/dist/cdn/providers/google.png +0 -0
  73. package/dist/cdn/providers/openai.png +0 -0
  74. package/dist/cdn/react-0oJnFpBS.js +0 -5425
  75. package/dist/cdn/react-BIs9pQ3H.js +0 -926
  76. package/dist/cdn/refresh-cw-BXY-Pa0U.js +0 -21
  77. package/dist/cdn/save-Tgil_AJZ.js +0 -34
  78. package/dist/cdn/schemaHelpers-DTV38jGq.js +0 -16
  79. package/dist/cdn/select-DDdiIPR2.js +0 -2594
  80. package/dist/cdn/servers-Dm72iTpY.js +0 -26
  81. package/dist/cdn/shared-DaILIQPP.js +0 -1700
  82. package/dist/cdn/sheet-Br_l2kry.js +0 -2077
  83. package/dist/cdn/sparkles-BntO2rDR.js +0 -23
  84. package/dist/cdn/spinner-jQtC7EBj.js +0 -15
  85. package/dist/cdn/square-check-big-BvwQ17Bl.js +0 -10
  86. package/dist/cdn/switch-C3IyQuid.js +0 -664
  87. package/dist/cdn/tabs-subtle-CkdI6Mac.js +0 -787
  88. package/dist/cdn/telemetry-BbhH1Z_E.js +0 -240
  89. package/dist/cdn/textarea-DSbwcFVt.js +0 -14
  90. package/dist/cdn/trash-2-RwpJY5SL.js +0 -25
  91. package/dist/cdn/useAriaLabelledBy-DqAdnppm.js +0 -29
  92. package/dist/cdn/useCompositeItem-BRqEzYh-.js +0 -26
  93. package/dist/cdn/useConfig-BNpU7Atw.js +0 -235
  94. package/dist/cdn/useSavedRequests-Ci2I919u.js +0 -51
  95. package/dist/cdn/useViewHostProps-ru80AnlT.js +0 -349
  96. package/dist/cdn/wrench-DzGmCfnb.js +0 -7
  97. package/dist/cdn/x-C3vRQIYu.js +0 -10
  98. package/dist/cdn/zap-Mb-pbw2X.js +0 -10
  99. package/dist/client/auth/manufact-auth.d.ts +0 -32
  100. package/dist/client/auth/manufact-auth.d.ts.map +0 -1
  101. package/dist/client/chat-history/ChatHistoryHeader.d.ts +0 -4
  102. package/dist/client/chat-history/ChatHistoryHeader.d.ts.map +0 -1
  103. package/dist/client/chat-history/ChatHistoryPanel.d.ts +0 -28
  104. package/dist/client/chat-history/ChatHistoryPanel.d.ts.map +0 -1
  105. package/dist/client/chat-history/ChatHistoryRail.d.ts +0 -5
  106. package/dist/client/chat-history/ChatHistoryRail.d.ts.map +0 -1
  107. package/dist/client/chat-history/ChatList.d.ts +0 -18
  108. package/dist/client/chat-history/ChatList.d.ts.map +0 -1
  109. package/dist/client/chat-history/ChatTitleReveal.d.ts +0 -10
  110. package/dist/client/chat-history/ChatTitleReveal.d.ts.map +0 -1
  111. package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts +0 -13
  112. package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts.map +0 -1
  113. package/dist/client/chat-history/chat-title.d.ts +0 -10
  114. package/dist/client/chat-history/chat-title.d.ts.map +0 -1
  115. package/dist/client/chat-history/providers/local-storage.d.ts +0 -21
  116. package/dist/client/chat-history/providers/local-storage.d.ts.map +0 -1
  117. package/dist/client/chat-history/types.d.ts +0 -39
  118. package/dist/client/chat-history/types.d.ts.map +0 -1
  119. package/dist/client/chat-history/useChatHistory.d.ts +0 -20
  120. package/dist/client/chat-history/useChatHistory.d.ts.map +0 -1
  121. package/dist/client/chat-history/useChatTitleGeneration.d.ts +0 -17
  122. package/dist/client/chat-history/useChatTitleGeneration.d.ts.map +0 -1
  123. package/dist/client/components/AddToClientDropdown.d.ts +0 -52
  124. package/dist/client/components/AddToClientDropdown.d.ts.map +0 -1
  125. package/dist/client/components/ChatTab.d.ts +0 -98
  126. package/dist/client/components/ChatTab.d.ts.map +0 -1
  127. package/dist/client/components/IframeConsole.d.ts +0 -7
  128. package/dist/client/components/IframeConsole.d.ts.map +0 -1
  129. package/dist/client/components/MCPAppsDebugControls.d.ts +0 -19
  130. package/dist/client/components/MCPAppsDebugControls.d.ts.map +0 -1
  131. package/dist/client/components/PromptsTab.d.ts +0 -34
  132. package/dist/client/components/PromptsTab.d.ts.map +0 -1
  133. package/dist/client/components/ResourcesTab.d.ts +0 -31
  134. package/dist/client/components/ResourcesTab.d.ts.map +0 -1
  135. package/dist/client/components/ToolsTab.d.ts +0 -39
  136. package/dist/client/components/ToolsTab.d.ts.map +0 -1
  137. package/dist/client/components/chat/AssistantMessage.d.ts +0 -10
  138. package/dist/client/components/chat/AssistantMessage.d.ts.map +0 -1
  139. package/dist/client/components/chat/ChatHeader.d.ts +0 -70
  140. package/dist/client/components/chat/ChatHeader.d.ts.map +0 -1
  141. package/dist/client/components/chat/ChatInput.d.ts +0 -29
  142. package/dist/client/components/chat/ChatInput.d.ts.map +0 -1
  143. package/dist/client/components/chat/ChatInputArea.d.ts +0 -65
  144. package/dist/client/components/chat/ChatInputArea.d.ts.map +0 -1
  145. package/dist/client/components/chat/ChatLandingForm.d.ts +0 -15
  146. package/dist/client/components/chat/ChatLandingForm.d.ts.map +0 -1
  147. package/dist/client/components/chat/ChatManagedNotice.d.ts +0 -10
  148. package/dist/client/components/chat/ChatManagedNotice.d.ts.map +0 -1
  149. package/dist/client/components/chat/ChatScrollToBottomButton.d.ts +0 -7
  150. package/dist/client/components/chat/ChatScrollToBottomButton.d.ts.map +0 -1
  151. package/dist/client/components/chat/ChatScrollTopFade.d.ts +0 -7
  152. package/dist/client/components/chat/ChatScrollTopFade.d.ts.map +0 -1
  153. package/dist/client/components/chat/ChatTraceView.d.ts +0 -7
  154. package/dist/client/components/chat/ChatTraceView.d.ts.map +0 -1
  155. package/dist/client/components/chat/ConfigurationDialog.d.ts +0 -42
  156. package/dist/client/components/chat/ConfigurationDialog.d.ts.map +0 -1
  157. package/dist/client/components/chat/ConfigureEmptyState.d.ts +0 -6
  158. package/dist/client/components/chat/ConfigureEmptyState.d.ts.map +0 -1
  159. package/dist/client/components/chat/CopyButton.d.ts +0 -10
  160. package/dist/client/components/chat/CopyButton.d.ts.map +0 -1
  161. package/dist/client/components/chat/FloatingChatElicitation.d.ts +0 -10
  162. package/dist/client/components/chat/FloatingChatElicitation.d.ts.map +0 -1
  163. package/dist/client/components/chat/McpReconnectBanner.d.ts +0 -10
  164. package/dist/client/components/chat/McpReconnectBanner.d.ts.map +0 -1
  165. package/dist/client/components/chat/MessageList.d.ts +0 -47
  166. package/dist/client/components/chat/MessageList.d.ts.map +0 -1
  167. package/dist/client/components/chat/MessageMetaActions.d.ts +0 -7
  168. package/dist/client/components/chat/MessageMetaActions.d.ts.map +0 -1
  169. package/dist/client/components/chat/PromptResultsList.d.ts +0 -8
  170. package/dist/client/components/chat/PromptResultsList.d.ts.map +0 -1
  171. package/dist/client/components/chat/PromptsDropdown.d.ts +0 -11
  172. package/dist/client/components/chat/PromptsDropdown.d.ts.map +0 -1
  173. package/dist/client/components/chat/StreamingAssistantContent.d.ts +0 -7
  174. package/dist/client/components/chat/StreamingAssistantContent.d.ts.map +0 -1
  175. package/dist/client/components/chat/SystemPromptButton.d.ts +0 -11
  176. package/dist/client/components/chat/SystemPromptButton.d.ts.map +0 -1
  177. package/dist/client/components/chat/ToolCallDisplay.d.ts +0 -10
  178. package/dist/client/components/chat/ToolCallDisplay.d.ts.map +0 -1
  179. package/dist/client/components/chat/ToolResultRenderer.d.ts +0 -15
  180. package/dist/client/components/chat/ToolResultRenderer.d.ts.map +0 -1
  181. package/dist/client/components/chat/ToolSelector.d.ts +0 -13
  182. package/dist/client/components/chat/ToolSelector.d.ts.map +0 -1
  183. package/dist/client/components/chat/UserMessage.d.ts +0 -10
  184. package/dist/client/components/chat/UserMessage.d.ts.map +0 -1
  185. package/dist/client/components/chat/chat-bar-styles.d.ts +0 -6
  186. package/dist/client/components/chat/chat-bar-styles.d.ts.map +0 -1
  187. package/dist/client/components/chat/chatModeStorage.d.ts +0 -11
  188. package/dist/client/components/chat/chatModeStorage.d.ts.map +0 -1
  189. package/dist/client/components/chat/conversion.d.ts +0 -19
  190. package/dist/client/components/chat/conversion.d.ts.map +0 -1
  191. package/dist/client/components/chat/freeTier.d.ts +0 -32
  192. package/dist/client/components/chat/freeTier.d.ts.map +0 -1
  193. package/dist/client/components/chat/managedChatNotice.d.ts +0 -16
  194. package/dist/client/components/chat/managedChatNotice.d.ts.map +0 -1
  195. package/dist/client/components/chat/providerMeta.d.ts +0 -27
  196. package/dist/client/components/chat/providerMeta.d.ts.map +0 -1
  197. package/dist/client/components/chat/system-prompt/local-storage.d.ts +0 -5
  198. package/dist/client/components/chat/system-prompt/local-storage.d.ts.map +0 -1
  199. package/dist/client/components/chat/system-prompt/types.d.ts +0 -8
  200. package/dist/client/components/chat/system-prompt/types.d.ts.map +0 -1
  201. package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts +0 -3
  202. package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts.map +0 -1
  203. package/dist/client/components/chat/system-prompt-default.d.ts +0 -2
  204. package/dist/client/components/chat/system-prompt-default.d.ts.map +0 -1
  205. package/dist/client/components/chat/trace.d.ts +0 -84
  206. package/dist/client/components/chat/trace.d.ts.map +0 -1
  207. package/dist/client/components/chat/types.d.ts +0 -75
  208. package/dist/client/components/chat/types.d.ts.map +0 -1
  209. package/dist/client/components/chat/useChatMessages.d.ts +0 -76
  210. package/dist/client/components/chat/useChatMessages.d.ts.map +0 -1
  211. package/dist/client/components/chat/useChatMessagesClientSide.d.ts +0 -43
  212. package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +0 -1
  213. package/dist/client/components/chat/useChatScrollToBottom.d.ts +0 -14
  214. package/dist/client/components/chat/useChatScrollToBottom.d.ts.map +0 -1
  215. package/dist/client/components/chat/useConfig.d.ts +0 -24
  216. package/dist/client/components/chat/useConfig.d.ts.map +0 -1
  217. package/dist/client/components/chat/useHostedChatMode.d.ts +0 -14
  218. package/dist/client/components/chat/useHostedChatMode.d.ts.map +0 -1
  219. package/dist/client/components/chat/useManagedCloudModel.d.ts +0 -14
  220. package/dist/client/components/chat/useManagedCloudModel.d.ts.map +0 -1
  221. package/dist/client/components/chat/utils.d.ts +0 -11
  222. package/dist/client/components/chat/utils.d.ts.map +0 -1
  223. package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts +0 -12
  224. package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts.map +0 -1
  225. package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts +0 -9
  226. package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts.map +0 -1
  227. package/dist/client/components/elicitation/shared/schemaHelpers.d.ts +0 -8
  228. package/dist/client/components/elicitation/shared/schemaHelpers.d.ts.map +0 -1
  229. package/dist/client/components/prompts/PromptExecutionPanel.d.ts +0 -13
  230. package/dist/client/components/prompts/PromptExecutionPanel.d.ts.map +0 -1
  231. package/dist/client/components/prompts/PromptInputForm.d.ts +0 -9
  232. package/dist/client/components/prompts/PromptInputForm.d.ts.map +0 -1
  233. package/dist/client/components/prompts/PromptMessageCard.d.ts +0 -29
  234. package/dist/client/components/prompts/PromptMessageCard.d.ts.map +0 -1
  235. package/dist/client/components/prompts/PromptResultDisplay.d.ts +0 -34
  236. package/dist/client/components/prompts/PromptResultDisplay.d.ts.map +0 -1
  237. package/dist/client/components/prompts/PromptsList.d.ts +0 -10
  238. package/dist/client/components/prompts/PromptsList.d.ts.map +0 -1
  239. package/dist/client/components/prompts/SavedPromptsList.d.ts +0 -19
  240. package/dist/client/components/prompts/SavedPromptsList.d.ts.map +0 -1
  241. package/dist/client/components/resources/PropsConfigDialog.d.ts +0 -16
  242. package/dist/client/components/resources/PropsConfigDialog.d.ts.map +0 -1
  243. package/dist/client/components/resources/ResourceResultDisplay.d.ts +0 -30
  244. package/dist/client/components/resources/ResourceResultDisplay.d.ts.map +0 -1
  245. package/dist/client/components/resources/ResourcesList.d.ts +0 -10
  246. package/dist/client/components/resources/ResourcesList.d.ts.map +0 -1
  247. package/dist/client/components/shared/CollapsibleJSON.d.ts +0 -6
  248. package/dist/client/components/shared/CollapsibleJSON.d.ts.map +0 -1
  249. package/dist/client/components/shared/InspectorScrollArea.d.ts +0 -9
  250. package/dist/client/components/shared/InspectorScrollArea.d.ts.map +0 -1
  251. package/dist/client/components/shared/JSONDisplay.d.ts +0 -12
  252. package/dist/client/components/shared/JSONDisplay.d.ts.map +0 -1
  253. package/dist/client/components/shared/ListItem.d.ts +0 -24
  254. package/dist/client/components/shared/ListItem.d.ts.map +0 -1
  255. package/dist/client/components/shared/ListTabHeader.d.ts +0 -47
  256. package/dist/client/components/shared/ListTabHeader.d.ts.map +0 -1
  257. package/dist/client/components/shared/MarkdownRenderer.d.ts +0 -15
  258. package/dist/client/components/shared/MarkdownRenderer.d.ts.map +0 -1
  259. package/dist/client/components/shared/SchemaFormField.d.ts +0 -12
  260. package/dist/client/components/shared/SchemaFormField.d.ts.map +0 -1
  261. package/dist/client/components/shared/SearchTabHeader.d.ts +0 -28
  262. package/dist/client/components/shared/SearchTabHeader.d.ts.map +0 -1
  263. package/dist/client/components/shared/StatusIcon.d.ts +0 -12
  264. package/dist/client/components/shared/StatusIcon.d.ts.map +0 -1
  265. package/dist/client/components/shared/index.d.ts +0 -7
  266. package/dist/client/components/shared/index.d.ts.map +0 -1
  267. package/dist/client/components/tools/SaveRequestDialog.d.ts +0 -11
  268. package/dist/client/components/tools/SaveRequestDialog.d.ts.map +0 -1
  269. package/dist/client/components/tools/SavedRequestsList.d.ts +0 -19
  270. package/dist/client/components/tools/SavedRequestsList.d.ts.map +0 -1
  271. package/dist/client/components/tools/ToolExecutionPanel.d.ts +0 -20
  272. package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +0 -1
  273. package/dist/client/components/tools/ToolInputForm.d.ts +0 -14
  274. package/dist/client/components/tools/ToolInputForm.d.ts.map +0 -1
  275. package/dist/client/components/tools/ToolResultDisplay.d.ts +0 -24
  276. package/dist/client/components/tools/ToolResultDisplay.d.ts.map +0 -1
  277. package/dist/client/components/tools/ToolsList.d.ts +0 -10
  278. package/dist/client/components/tools/ToolsList.d.ts.map +0 -1
  279. package/dist/client/components/tools/schema-utils.d.ts +0 -13
  280. package/dist/client/components/tools/schema-utils.d.ts.map +0 -1
  281. package/dist/client/components/tools/useToolExecution.d.ts +0 -26
  282. package/dist/client/components/tools/useToolExecution.d.ts.map +0 -1
  283. package/dist/client/components/tools/useToolsTabNavigation.d.ts +0 -35
  284. package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +0 -1
  285. package/dist/client/components/ui/MeshGradientCanvas.d.ts +0 -13
  286. package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +0 -1
  287. package/dist/client/components/ui/WidgetWrapper.d.ts +0 -12
  288. package/dist/client/components/ui/WidgetWrapper.d.ts.map +0 -1
  289. package/dist/client/components/ui/alert-dialog.d.ts +0 -15
  290. package/dist/client/components/ui/alert-dialog.d.ts.map +0 -1
  291. package/dist/client/components/ui/ask-user-questions.d.ts +0 -80
  292. package/dist/client/components/ui/ask-user-questions.d.ts.map +0 -1
  293. package/dist/client/components/ui/badge.d.ts +0 -34
  294. package/dist/client/components/ui/badge.d.ts.map +0 -1
  295. package/dist/client/components/ui/blur-fade.d.ts +0 -25
  296. package/dist/client/components/ui/blur-fade.d.ts.map +0 -1
  297. package/dist/client/components/ui/button.d.ts +0 -34
  298. package/dist/client/components/ui/button.d.ts.map +0 -1
  299. package/dist/client/components/ui/chat-message.d.ts +0 -23
  300. package/dist/client/components/ui/chat-message.d.ts.map +0 -1
  301. package/dist/client/components/ui/checkbox.d.ts +0 -4
  302. package/dist/client/components/ui/checkbox.d.ts.map +0 -1
  303. package/dist/client/components/ui/client-icons.d.ts +0 -20
  304. package/dist/client/components/ui/client-icons.d.ts.map +0 -1
  305. package/dist/client/components/ui/command.d.ts +0 -17
  306. package/dist/client/components/ui/command.d.ts.map +0 -1
  307. package/dist/client/components/ui/dialog.d.ts +0 -37
  308. package/dist/client/components/ui/dialog.d.ts.map +0 -1
  309. package/dist/client/components/ui/dropdown-menu.d.ts +0 -25
  310. package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
  311. package/dist/client/components/ui/dropdown.d.ts +0 -30
  312. package/dist/client/components/ui/dropdown.d.ts.map +0 -1
  313. package/dist/client/components/ui/file-thumbnail.d.ts +0 -9
  314. package/dist/client/components/ui/file-thumbnail.d.ts.map +0 -1
  315. package/dist/client/components/ui/input.d.ts +0 -4
  316. package/dist/client/components/ui/input.d.ts.map +0 -1
  317. package/dist/client/components/ui/kbd.d.ts +0 -3
  318. package/dist/client/components/ui/kbd.d.ts.map +0 -1
  319. package/dist/client/components/ui/label.d.ts +0 -4
  320. package/dist/client/components/ui/label.d.ts.map +0 -1
  321. package/dist/client/components/ui/menu-item.d.ts +0 -52
  322. package/dist/client/components/ui/menu-item.d.ts.map +0 -1
  323. package/dist/client/components/ui/mesh-tab-background.d.ts +0 -12
  324. package/dist/client/components/ui/mesh-tab-background.d.ts.map +0 -1
  325. package/dist/client/components/ui/not-found.d.ts +0 -9
  326. package/dist/client/components/ui/not-found.d.ts.map +0 -1
  327. package/dist/client/components/ui/popover.d.ts +0 -6
  328. package/dist/client/components/ui/popover.d.ts.map +0 -1
  329. package/dist/client/components/ui/resizable.d.ts +0 -10
  330. package/dist/client/components/ui/resizable.d.ts.map +0 -1
  331. package/dist/client/components/ui/scroll-area.d.ts +0 -4
  332. package/dist/client/components/ui/scroll-area.d.ts.map +0 -1
  333. package/dist/client/components/ui/select.d.ts +0 -52
  334. package/dist/client/components/ui/select.d.ts.map +0 -1
  335. package/dist/client/components/ui/sheet.d.ts +0 -14
  336. package/dist/client/components/ui/sheet.d.ts.map +0 -1
  337. package/dist/client/components/ui/skeleton.d.ts +0 -4
  338. package/dist/client/components/ui/skeleton.d.ts.map +0 -1
  339. package/dist/client/components/ui/spinner.d.ts +0 -3
  340. package/dist/client/components/ui/spinner.d.ts.map +0 -1
  341. package/dist/client/components/ui/switch.d.ts +0 -22
  342. package/dist/client/components/ui/switch.d.ts.map +0 -1
  343. package/dist/client/components/ui/table.d.ts +0 -9
  344. package/dist/client/components/ui/table.d.ts.map +0 -1
  345. package/dist/client/components/ui/tabs-subtle.d.ts +0 -25
  346. package/dist/client/components/ui/tabs-subtle.d.ts.map +0 -1
  347. package/dist/client/components/ui/text-shimmer.d.ts +0 -11
  348. package/dist/client/components/ui/text-shimmer.d.ts.map +0 -1
  349. package/dist/client/components/ui/textarea.d.ts +0 -4
  350. package/dist/client/components/ui/textarea.d.ts.map +0 -1
  351. package/dist/client/components/ui/tooltip.d.ts +0 -43
  352. package/dist/client/components/ui/tooltip.d.ts.map +0 -1
  353. package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts +0 -19
  354. package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts.map +0 -1
  355. package/dist/client/console-log-bus.d.ts +0 -24
  356. package/dist/client/console-log-bus.d.ts.map +0 -1
  357. package/dist/client/constants/debug-options.d.ts +0 -16
  358. package/dist/client/constants/debug-options.d.ts.map +0 -1
  359. package/dist/client/context/InspectorContext.d.ts +0 -134
  360. package/dist/client/context/InspectorContext.d.ts.map +0 -1
  361. package/dist/client/context/ThemeContext.d.ts +0 -17
  362. package/dist/client/context/ThemeContext.d.ts.map +0 -1
  363. package/dist/client/context/WidgetDebugContext.d.ts +0 -121
  364. package/dist/client/context/WidgetDebugContext.d.ts.map +0 -1
  365. package/dist/client/hooks/use-merge-split.d.ts +0 -36
  366. package/dist/client/hooks/use-merge-split.d.ts.map +0 -1
  367. package/dist/client/hooks/use-proximity-hover-index.d.ts +0 -27
  368. package/dist/client/hooks/use-proximity-hover-index.d.ts.map +0 -1
  369. package/dist/client/hooks/use-proximity-hover.d.ts +0 -26
  370. package/dist/client/hooks/use-proximity-hover.d.ts.map +0 -1
  371. package/dist/client/hooks/use-touch-primary.d.ts +0 -2
  372. package/dist/client/hooks/use-touch-primary.d.ts.map +0 -1
  373. package/dist/client/hooks/useDeviceViewport.d.ts +0 -18
  374. package/dist/client/hooks/useDeviceViewport.d.ts.map +0 -1
  375. package/dist/client/hooks/useHostedSession.d.ts +0 -9
  376. package/dist/client/hooks/useHostedSession.d.ts.map +0 -1
  377. package/dist/client/hooks/useIframeConsole.d.ts +0 -24
  378. package/dist/client/hooks/useIframeConsole.d.ts.map +0 -1
  379. package/dist/client/hooks/useKeyboardShortcuts.d.ts +0 -28
  380. package/dist/client/hooks/useKeyboardShortcuts.d.ts.map +0 -1
  381. package/dist/client/hooks/useMCPPrompts.d.ts +0 -94
  382. package/dist/client/hooks/useMCPPrompts.d.ts.map +0 -1
  383. package/dist/client/hooks/useMcpAppsHostContext.d.ts +0 -27
  384. package/dist/client/hooks/useMcpAppsHostContext.d.ts.map +0 -1
  385. package/dist/client/hooks/usePropsLLM.d.ts +0 -20
  386. package/dist/client/hooks/usePropsLLM.d.ts.map +0 -1
  387. package/dist/client/hooks/useResourceProps.d.ts +0 -14
  388. package/dist/client/hooks/useResourceProps.d.ts.map +0 -1
  389. package/dist/client/hooks/useSavedRequests.d.ts +0 -6
  390. package/dist/client/hooks/useSavedRequests.d.ts.map +0 -1
  391. package/dist/client/hooks/useViewHostProps.d.ts +0 -19
  392. package/dist/client/hooks/useViewHostProps.d.ts.map +0 -1
  393. package/dist/client/index.d.ts.map +0 -1
  394. package/dist/client/lib/elevated.d.ts +0 -28
  395. package/dist/client/lib/elevated.d.ts.map +0 -1
  396. package/dist/client/lib/font-weight.d.ts +0 -10
  397. package/dist/client/lib/font-weight.d.ts.map +0 -1
  398. package/dist/client/lib/icon-context.d.ts +0 -15
  399. package/dist/client/lib/icon-context.d.ts.map +0 -1
  400. package/dist/client/lib/shape-context.d.ts +0 -21
  401. package/dist/client/lib/shape-context.d.ts.map +0 -1
  402. package/dist/client/lib/springs.d.ts +0 -32
  403. package/dist/client/lib/springs.d.ts.map +0 -1
  404. package/dist/client/lib/surface-classes.d.ts +0 -2
  405. package/dist/client/lib/surface-classes.d.ts.map +0 -1
  406. package/dist/client/lib/surface-context.d.ts +0 -7
  407. package/dist/client/lib/surface-context.d.ts.map +0 -1
  408. package/dist/client/lib/utils.d.ts +0 -3
  409. package/dist/client/lib/utils.d.ts.map +0 -1
  410. package/dist/client/mcp-apps/csp.d.ts +0 -26
  411. package/dist/client/mcp-apps/csp.d.ts.map +0 -1
  412. package/dist/client/mcp-apps/debug/csp-suggestions.d.ts +0 -17
  413. package/dist/client/mcp-apps/debug/csp-suggestions.d.ts.map +0 -1
  414. package/dist/client/mcp-apps/logging-transport.d.ts +0 -13
  415. package/dist/client/mcp-apps/logging-transport.d.ts.map +0 -1
  416. package/dist/client/rpc-traffic-coalesce.d.ts +0 -7
  417. package/dist/client/rpc-traffic-coalesce.d.ts.map +0 -1
  418. package/dist/client/rpc-traffic-store.d.ts +0 -37
  419. package/dist/client/rpc-traffic-store.d.ts.map +0 -1
  420. package/dist/client/telemetry/capture.d.ts +0 -7
  421. package/dist/client/telemetry/capture.d.ts.map +0 -1
  422. package/dist/client/telemetry/events.d.ts +0 -168
  423. package/dist/client/telemetry/events.d.ts.map +0 -1
  424. package/dist/client/telemetry/index.d.ts +0 -5
  425. package/dist/client/telemetry/index.d.ts.map +0 -1
  426. package/dist/client/telemetry/init.d.ts +0 -2
  427. package/dist/client/telemetry/init.d.ts.map +0 -1
  428. package/dist/client/telemetry/utils.d.ts +0 -7
  429. package/dist/client/telemetry/utils.d.ts.map +0 -1
  430. package/dist/client/types/message-content-block.d.ts +0 -19
  431. package/dist/client/types/message-content-block.d.ts.map +0 -1
  432. package/dist/client/types/pending-requests.d.ts +0 -17
  433. package/dist/client/types/pending-requests.d.ts.map +0 -1
  434. package/dist/client/utils/basePath.d.ts +0 -34
  435. package/dist/client/utils/basePath.d.ts.map +0 -1
  436. package/dist/client/utils/browser.d.ts +0 -5
  437. package/dist/client/utils/browser.d.ts.map +0 -1
  438. package/dist/client/utils/format.d.ts +0 -4
  439. package/dist/client/utils/format.d.ts.map +0 -1
  440. package/dist/client/utils/highlightJson.d.ts +0 -11
  441. package/dist/client/utils/highlightJson.d.ts.map +0 -1
  442. package/dist/client/utils/jsonUtils.d.ts +0 -24
  443. package/dist/client/utils/jsonUtils.d.ts.map +0 -1
  444. package/dist/client/utils/mcpClientUtils.d.ts +0 -131
  445. package/dist/client/utils/mcpClientUtils.d.ts.map +0 -1
  446. package/dist/client/utils/servers.d.ts +0 -14
  447. package/dist/client/utils/servers.d.ts.map +0 -1
  448. package/dist/server/asset-urls.d.ts +0 -18
  449. package/dist/server/asset-urls.d.ts.map +0 -1
  450. package/dist/server/asset-urls.js +0 -17
  451. package/dist/server/cdn-shell.d.ts +0 -18
  452. package/dist/server/cdn-shell.d.ts.map +0 -1
  453. package/dist/server/cdn-shell.js +0 -12
  454. package/dist/server/chunk-5L3HMC5B.js +0 -72
  455. package/dist/server/chunk-BEJGHVKM.js +0 -148
  456. package/dist/server/chunk-H6ZCIKBS.js +0 -63
  457. package/dist/server/chunk-IKTZUWSX.js +0 -0
  458. package/dist/server/chunk-J4FNYLBF.js +0 -54
  459. package/dist/server/chunk-K2F2AJOI.js +0 -619
  460. package/dist/server/chunk-KD7K27XK.js +0 -77
  461. package/dist/server/chunk-M5TZA42I.js +0 -54
  462. package/dist/server/chunk-OWR2BIBW.js +0 -40
  463. package/dist/server/chunk-PGN3B3MQ.js +0 -156
  464. package/dist/server/chunk-PKBMQBKP.js +0 -7
  465. package/dist/server/chunk-UJLXHNQP.js +0 -43
  466. package/dist/server/chunk-WFT4JHYI.js +0 -24
  467. package/dist/server/chunk-XCNS5CIW.js +0 -199
  468. package/dist/server/cli.d.ts +0 -3
  469. package/dist/server/cli.d.ts.map +0 -1
  470. package/dist/server/cli.js +0 -141
  471. package/dist/server/create-dev-api-app.d.ts +0 -4
  472. package/dist/server/create-dev-api-app.d.ts.map +0 -1
  473. package/dist/server/create-dev-api-app.js +0 -11
  474. package/dist/server/dev-callback-redirect.d.ts +0 -3
  475. package/dist/server/dev-callback-redirect.d.ts.map +0 -1
  476. package/dist/server/dev-callback-redirect.js +0 -18
  477. package/dist/server/favicon-links.d.ts +0 -12
  478. package/dist/server/favicon-links.d.ts.map +0 -1
  479. package/dist/server/favicon-links.js +0 -11
  480. package/dist/server/favicon-static.d.ts +0 -4
  481. package/dist/server/favicon-static.d.ts.map +0 -1
  482. package/dist/server/favicon-static.js +0 -8
  483. package/dist/server/index.d.ts.map +0 -1
  484. package/dist/server/middleware.d.ts +0 -40
  485. package/dist/server/middleware.d.ts.map +0 -1
  486. package/dist/server/middleware.js +0 -17
  487. package/dist/server/proxy/index.d.ts +0 -3
  488. package/dist/server/proxy/index.d.ts.map +0 -1
  489. package/dist/server/proxy/index.js +0 -12
  490. package/dist/server/proxy/mcp-proxy.d.ts +0 -101
  491. package/dist/server/proxy/mcp-proxy.d.ts.map +0 -1
  492. package/dist/server/proxy/mcp-proxy.js +0 -10
  493. package/dist/server/proxy/oauth-proxy.d.ts +0 -26
  494. package/dist/server/proxy/oauth-proxy.d.ts.map +0 -1
  495. package/dist/server/proxy/oauth-proxy.js +0 -9
  496. package/dist/server/proxy-routes.d.ts +0 -16
  497. package/dist/server/proxy-routes.d.ts.map +0 -1
  498. package/dist/server/proxy-routes.js +0 -10
  499. package/dist/server/rpc-log-bus.d.ts +0 -17
  500. package/dist/server/rpc-log-bus.d.ts.map +0 -1
  501. package/dist/server/rpc-log-bus.js +0 -77
  502. package/dist/server/server.d.ts +0 -15
  503. package/dist/server/server.d.ts.map +0 -1
  504. package/dist/server/server.js +0 -66
  505. package/dist/server/static-assets.d.ts +0 -5
  506. package/dist/server/static-assets.d.ts.map +0 -1
  507. package/dist/server/static-assets.js +0 -9
  508. package/dist/server/utils.d.ts +0 -33
  509. package/dist/server/utils.d.ts.map +0 -1
  510. package/dist/server/utils.js +0 -17
  511. package/dist/server/version.d.ts +0 -7
  512. package/dist/server/version.d.ts.map +0 -1
  513. package/dist/server/version.js +0 -9
  514. package/dist/server/vite-dev-api-plugin.d.ts +0 -4
  515. package/dist/server/vite-dev-api-plugin.d.ts.map +0 -1
  516. package/dist/server/vite-dev-api-plugin.js +0 -30
  517. package/dist/web/apple-touch-icon.png +0 -0
  518. package/dist/web/assets/AnimatePresence-C5p0yiY1.js +0 -9
  519. package/dist/web/assets/ChatTab-B_5S87J1.js +0 -18
  520. package/dist/web/assets/ConnectionSettingsTab-XwjwKfsO.js +0 -1
  521. package/dist/web/assets/ElicitationTab-BD1tfmYR.js +0 -1
  522. package/dist/web/assets/FormContext-DH2caWKO.js +0 -1
  523. package/dist/web/assets/ListTabHeader-R17w_JsB.js +0 -1
  524. package/dist/web/assets/ManufactOAuthCallback-DD3qfIC3.js +0 -1
  525. package/dist/web/assets/MarkdownRenderer-DH-7vpw0.js +0 -47
  526. package/dist/web/assets/NotificationsTab-Cg48O6IH.js +0 -1
  527. package/dist/web/assets/OAuthCallback-4i2i3YpE.js +0 -1
  528. package/dist/web/assets/PromptsTab-pAR6izrQ.js +0 -15
  529. package/dist/web/assets/ResourcesTab-CgvfWrsU.js +0 -2
  530. package/dist/web/assets/SamplingTab-DfIWMQFY.js +0 -1
  531. package/dist/web/assets/ServerMetadataTab-Dsz8Qhyr.js +0 -1
  532. package/dist/web/assets/ToolsTab-ln9w58BW.js +0 -8
  533. package/dist/web/assets/ViewPreview-CQ3G3VP0.js +0 -1
  534. package/dist/web/assets/WidgetWrapper-A-zaxY5s.js +0 -34
  535. package/dist/web/assets/brush--0LobUi4.js +0 -1
  536. package/dist/web/assets/checkbox-DZWS_U_i.js +0 -1
  537. package/dist/web/assets/code-tME-5H6D.js +0 -1
  538. package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
  539. package/dist/web/assets/dist-DxRFPg-B.js +0 -21
  540. package/dist/web/assets/index-CoRK2C3M.js +0 -492
  541. package/dist/web/assets/index-fBX3akc8.css +0 -1
  542. package/dist/web/assets/input-CLYhA7PK.js +0 -1
  543. package/dist/web/assets/inspector-settings-layout-yjKRJDai.js +0 -1
  544. package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
  545. package/dist/web/assets/label-Cdim77Jw.js +0 -1
  546. package/dist/web/assets/maximize-2-BTT9QQU9.js +0 -1
  547. package/dist/web/assets/maximize-_O55kFcr.js +0 -1
  548. package/dist/web/assets/react-CU_d2d5K.js +0 -1
  549. package/dist/web/assets/refresh-cw-C9wQl8_d.js +0 -1
  550. package/dist/web/assets/save-B-MsgxX9.js +0 -1
  551. package/dist/web/assets/schemaHelpers-DLNTQr_6.js +0 -1
  552. package/dist/web/assets/select-CJ57-Bor.js +0 -1
  553. package/dist/web/assets/shared-Dbc2GbRx.js +0 -1
  554. package/dist/web/assets/sparkles-2OAsc1aP.js +0 -1
  555. package/dist/web/assets/tabs-subtle-CxMZqhP6.js +0 -1
  556. package/dist/web/assets/textarea-DLAmNVf_.js +0 -1
  557. package/dist/web/assets/useConfig-Cg-BtSHA.js +0 -1
  558. package/dist/web/assets/useViewHostProps-CMgPpdfy.js +0 -1
  559. package/dist/web/assets/zap-Du2Uc5pa.js +0 -1
  560. package/dist/web/favicon-96x96.png +0 -0
  561. package/dist/web/favicon-black.svg +0 -5
  562. package/dist/web/favicon-white.svg +0 -5
  563. package/dist/web/favicon.ico +0 -0
  564. package/dist/web/favicon.svg +0 -5
  565. package/dist/web/index.html +0 -89
  566. package/dist/web/providers/anthropic.png +0 -0
  567. package/dist/web/providers/google.png +0 -0
  568. package/dist/web/providers/openai.png +0 -0
  569. package/dist/web/site.webmanifest +0 -21
  570. package/dist/web/web-app-manifest-192x192.png +0 -0
  571. package/dist/web/web-app-manifest-512x512.png +0 -0
  572. /package/dist/{cdn → app}/apple-touch-icon.png +0 -0
  573. /package/dist/{cdn → app}/favicon-96x96.png +0 -0
  574. /package/dist/{cdn → app}/favicon-black.svg +0 -0
  575. /package/dist/{cdn → app}/favicon-white.svg +0 -0
  576. /package/dist/{cdn → app}/favicon.ico +0 -0
  577. /package/dist/{cdn → app}/favicon.svg +0 -0
  578. /package/dist/{cdn → app}/site.webmanifest +0 -0
  579. /package/dist/{cdn → app}/web-app-manifest-192x192.png +0 -0
  580. /package/dist/{cdn → app}/web-app-manifest-512x512.png +0 -0
@@ -1,1934 +0,0 @@
1
- import { i as e } from "./react-BIs9pQ3H.js";
2
- import { a as t, c as n, i as r, l as i, n as a, o, r as s, t as c } from "./cfWorker-Bxcs9rNe.js";
3
- //#region ../client/dist/index-browser.js
4
- var l = /* @__PURE__ */ e({
5
- BaseConnector: () => q,
6
- BrowserOAuthClientProvider: () => B,
7
- DialectJsonSchemaValidator: () => K,
8
- HttpConnector: () => Y,
9
- MCPClient: () => ze,
10
- MCPConnection: () => $,
11
- MCPSession: () => $,
12
- POSTHOG_API_KEY: () => se,
13
- POSTHOG_HOST: () => oe,
14
- SCARF_GATEWAY_URL: () => T,
15
- Tel: () => L,
16
- Telemetry: () => I,
17
- VERSION: () => x,
18
- capturePostHog: () => O,
19
- captureScarf: () => k,
20
- completeOAuthFlow: () => W,
21
- createOAuthProvider: () => V,
22
- getPackageVersion: () => S,
23
- isUnauthorized: () => U,
24
- logger: () => b,
25
- normalizeClientInfo: () => Q,
26
- resolveCallbacks: () => X,
27
- setTelemetrySource: () => R,
28
- shouldAutoProvisionOAuth: () => Z,
29
- telFetch: () => w
30
- }), u;
31
- function d(e) {
32
- u = e;
33
- }
34
- function f(e, t) {
35
- u?.addServer(e, t);
36
- }
37
- function p(e) {
38
- u?.removeServer(e);
39
- }
40
- var m;
41
- function h(e) {
42
- m = e;
43
- }
44
- function g(e) {
45
- m?.(e);
46
- }
47
- var _ = [
48
- "silent",
49
- "error",
50
- "warn",
51
- "info",
52
- "http",
53
- "verbose",
54
- "debug",
55
- "silly"
56
- ], v = {
57
- silent: "",
58
- error: "❌",
59
- warn: "⚠️",
60
- info: "ℹ️",
61
- http: "🌐",
62
- verbose: "📝",
63
- debug: "🔍",
64
- silly: "🤪"
65
- };
66
- function y() {
67
- let e;
68
- try {
69
- e = typeof process < "u" ? {}.MCP_USE_LOG_LEVEL ?? {}.DEBUG : void 0;
70
- } catch {}
71
- let t = e?.trim().toLowerCase();
72
- return t === "2" ? "debug" : t && _.includes(t) ? t : "info";
73
- }
74
- var ee = class {
75
- constructor(e = "mcp-use", t = "info", n = "minimal") {
76
- this.name = e, this.level = t, this.format = n;
77
- }
78
- write(e, t, n) {
79
- if (this.level === "silent" || _.indexOf(e) > _.indexOf(this.level)) return;
80
- let r = n.map((e) => {
81
- if (typeof e == "string") return e;
82
- try {
83
- return JSON.stringify(e);
84
- } catch {
85
- return String(e);
86
- }
87
- }).join(" "), i = r ? `${t} ${r}` : t, a = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), o = this.format === "minimal" ? e : e.toUpperCase(), s = this.format === "emoji" ? ` ${v[e]}` : "", c = `${a} [${this.name}]${s} ${o}: ${i}`;
88
- (e === "error" ? console.error : e === "warn" ? console.warn : e === "info" ? console.info : e === "debug" ? console.debug : console.log)(c);
89
- }
90
- error = (e, ...t) => this.write("error", e, t);
91
- warn = (e, ...t) => this.write("warn", e, t);
92
- info = (e, ...t) => this.write("info", e, t);
93
- debug = (e, ...t) => this.write("debug", e, t);
94
- http = (e, ...t) => this.write("http", e, t);
95
- verbose = (e, ...t) => this.write("verbose", e, t);
96
- silly = (e, ...t) => this.write("silly", e, t);
97
- setFormat(e) {
98
- this.format = e;
99
- }
100
- }, b = class {
101
- static instances = {};
102
- static currentFormat = "minimal";
103
- static currentLevel;
104
- static get(e = "mcp-use") {
105
- return this.instances[e] ??= new ee(e, this.currentLevel ?? y(), this.currentFormat);
106
- }
107
- static configure({ level: e = y(), format: t = "minimal" } = {}) {
108
- this.currentLevel = e, this.currentFormat = t;
109
- for (let n of Object.values(this.instances)) n.level = e, n.format = t;
110
- }
111
- static setDebug(e) {
112
- let t = e === 2 || e === !0 ? "debug" : "info";
113
- this.currentLevel = t;
114
- for (let e of Object.values(this.instances)) e.level = t;
115
- try {
116
- typeof process < "u" && ({}.MCP_USE_LOG_LEVEL = t);
117
- } catch {}
118
- }
119
- static setFormat(e) {
120
- this.configure({ format: e });
121
- }
122
- }.get(), x = "2.0.0-beta.2";
123
- function S() {
124
- return x;
125
- }
126
- var C = class {}, te = class extends C {
127
- constructor(e) {
128
- super(), this.data = e;
129
- }
130
- get name() {
131
- return "mcp_agent_execution";
132
- }
133
- get properties() {
134
- return {
135
- execution_method: this.data.executionMethod,
136
- query: this.data.query,
137
- query_length: this.data.query.length,
138
- success: this.data.success,
139
- model_provider: this.data.modelProvider,
140
- model_name: this.data.modelName,
141
- server_count: this.data.serverCount,
142
- server_identifiers: this.data.serverIdentifiers,
143
- total_tools_available: this.data.totalToolsAvailable,
144
- tools_available_names: this.data.toolsAvailableNames,
145
- max_steps_configured: this.data.maxStepsConfigured,
146
- memory_enabled: this.data.memoryEnabled,
147
- use_server_manager: this.data.useServerManager,
148
- max_steps_used: this.data.maxStepsUsed,
149
- manage_connector: this.data.manageConnector,
150
- external_history_used: this.data.externalHistoryUsed,
151
- steps_taken: this.data.stepsTaken ?? null,
152
- tools_used_count: this.data.toolsUsedCount ?? null,
153
- tools_used_names: this.data.toolsUsedNames ?? null,
154
- response: this.data.response ?? null,
155
- response_length: this.data.response ? this.data.response.length : null,
156
- execution_time_ms: this.data.executionTimeMs ?? null,
157
- error_type: this.data.errorType ?? null,
158
- conversation_history_length: this.data.conversationHistoryLength ?? null
159
- };
160
- }
161
- }, ne = class extends C {
162
- constructor(e) {
163
- super(), this.data = e;
164
- }
165
- get name() {
166
- return "mcpclient_init";
167
- }
168
- get properties() {
169
- return {
170
- code_mode: this.data.codeMode,
171
- sandbox: this.data.sandbox,
172
- all_callbacks: this.data.allCallbacks,
173
- verify: this.data.verify,
174
- servers: this.data.servers,
175
- num_servers: this.data.numServers,
176
- is_browser: this.data.isBrowser
177
- };
178
- }
179
- }, re = class extends C {
180
- constructor(e) {
181
- super(), this.data = e;
182
- }
183
- get name() {
184
- return "connector_init";
185
- }
186
- get properties() {
187
- return {
188
- connector_type: this.data.connectorType,
189
- server_command: this.data.serverCommand ?? null,
190
- server_args: this.data.serverArgs ?? null,
191
- server_url: this.data.serverUrl ?? null,
192
- public_identifier: this.data.publicIdentifier ?? null
193
- };
194
- }
195
- }, ie = class extends C {
196
- constructor(e) {
197
- super(), this.data = e;
198
- }
199
- get name() {
200
- return "client_add_server";
201
- }
202
- get properties() {
203
- let { serverName: e, serverConfig: t } = this.data, n = t.url;
204
- return {
205
- server_name: e,
206
- server_url_domain: n ? this._extractHostname(n) : null,
207
- transport: t.transport ?? null,
208
- has_auth: !!(t.authToken || t.authProvider)
209
- };
210
- }
211
- _extractHostname(e) {
212
- try {
213
- return new URL(e).hostname;
214
- } catch {
215
- return null;
216
- }
217
- }
218
- }, ae = class extends C {
219
- constructor(e) {
220
- super(), this.data = e;
221
- }
222
- get name() {
223
- return "client_remove_server";
224
- }
225
- get properties() {
226
- return { server_name: this.data.serverName };
227
- }
228
- };
229
- async function w(e, t) {
230
- try {
231
- await fetch(e, t);
232
- } catch {}
233
- }
234
- var oe = "https://eu.i.posthog.com", se = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", T = "https://mcpuse.gateway.scarf.sh/events-ts", E = "https://mcpuse.gateway.scarf.sh/simple/", D = 1800, ce = /* @__PURE__ */ new Set([
235
- "query",
236
- "response",
237
- "messages"
238
- ]);
239
- function le(e) {
240
- if (e == null) return "";
241
- if (typeof e == "string") return e;
242
- if (typeof e == "number" || typeof e == "boolean") return String(e);
243
- try {
244
- return JSON.stringify(e);
245
- } catch {
246
- return String(e);
247
- }
248
- }
249
- function ue(e, t = E) {
250
- let n = new URLSearchParams();
251
- for (let [t, r] of Object.entries(e)) {
252
- let e = le(r);
253
- ce.has(t) && e.length > 120 && (e = `${e.slice(0, 117)}...`), e !== "" && n.set(t, e);
254
- }
255
- let r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`;
256
- if (r.length <= D) return r;
257
- let i = [...n.keys()].sort((e, t) => (n.get(t)?.length ?? 0) - (n.get(e)?.length ?? 0));
258
- for (let e of i) {
259
- if (r.length <= D) break;
260
- e === "event" || e === "user_id" || (n.delete(e), r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`);
261
- }
262
- return r.slice(0, D);
263
- }
264
- function de(e, t) {
265
- return w(t, {
266
- method: "POST",
267
- headers: { "Content-Type": "application/json" },
268
- keepalive: !0,
269
- body: JSON.stringify(e)
270
- });
271
- }
272
- function fe(e, t) {
273
- try {
274
- let n = ue(e, t), r = new Image();
275
- r.referrerPolicy = "no-referrer-when-downgrade", r.src = n;
276
- } catch {}
277
- return Promise.resolve();
278
- }
279
- function O(e) {
280
- let t = e.host ?? "https://eu.i.posthog.com", n = e.apiKey ?? "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
281
- return w(`${t}/i/v0/e/`, {
282
- method: "POST",
283
- headers: { "Content-Type": "application/json" },
284
- keepalive: !0,
285
- body: JSON.stringify({
286
- api_key: n,
287
- event: e.event,
288
- distinct_id: e.distinctId,
289
- properties: e.properties,
290
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
291
- })
292
- });
293
- }
294
- function k(e, t = T) {
295
- return typeof window < "u" ? fe(e, t === "https://mcpuse.gateway.scarf.sh/events-ts" ? E : t) : de(e, t);
296
- }
297
- function A() {
298
- return globalThis.crypto.randomUUID();
299
- }
300
- function pe() {
301
- let e = new Uint8Array(8);
302
- return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
303
- }
304
- function me(e, t) {
305
- 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);
306
- for (let e = 0; e < a; e++) {
307
- let t = r[e] ?? 0, n = i[e] ?? 0;
308
- if (t !== n) return t > n;
309
- }
310
- return !1;
311
- }
312
- var j = "mcp_use_user_id", M = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", N = "https://eu.i.posthog.com", P = null;
313
- function F() {
314
- return typeof localStorage < "u" && typeof localStorage.getItem == "function" && typeof localStorage.setItem == "function" && typeof localStorage.removeItem == "function";
315
- }
316
- function he() {
317
- if (!F()) return null;
318
- try {
319
- localStorage.setItem("__mcp_use_test__", "1"), localStorage.removeItem("__mcp_use_test__");
320
- } catch {
321
- return null;
322
- }
323
- return {
324
- getUserId() {
325
- try {
326
- return localStorage.getItem(j);
327
- } catch {
328
- return null;
329
- }
330
- },
331
- setUserId(e) {
332
- try {
333
- localStorage.setItem(j, e);
334
- } catch {}
335
- },
336
- getDownloadedVersion: () => null,
337
- setDownloadedVersion: () => void 0
338
- };
339
- }
340
- function ge() {
341
- try {
342
- 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";
343
- } catch {
344
- return "unknown";
345
- }
346
- }
347
- function _e() {
348
- if (typeof process < "u" && {}.MCP_USE_TELEMETRY_SOURCE) return {}.MCP_USE_TELEMETRY_SOURCE;
349
- try {
350
- if (F()) return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE") ?? void 0;
351
- } catch {}
352
- }
353
- function ve() {
354
- if (typeof window < "u" && window.__MCP_USE_ANONYMIZED_TELEMETRY__ === !1 || typeof process < "u" && {}.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false") return !0;
355
- try {
356
- if (F() && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") return !0;
357
- } catch {}
358
- return !1;
359
- }
360
- function ye() {
361
- try {
362
- return `session-${A()}`;
363
- } catch {
364
- return `session-${Date.now()}-${pe()}`;
365
- }
366
- }
367
- var I = class e {
368
- static instance = null;
369
- UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
370
- _currUserId = null;
371
- _telemetryEnabled = !1;
372
- _pending = /* @__PURE__ */ new Set();
373
- _scarfEnabled = !1;
374
- _runtimeEnvironment;
375
- _storageCapability;
376
- _storage;
377
- _fsBacked;
378
- _source;
379
- _productVersion;
380
- constructor() {
381
- this._runtimeEnvironment = ge(), this._fsBacked = P !== null, this._storage = P ?? he() ?? null, this._storageCapability = this._storage ? "persistent" : "session-only", this._source = _e() || this._runtimeEnvironment;
382
- let e = ve(), t = this._runtimeEnvironment !== "unknown";
383
- e ? (this._telemetryEnabled = !1, b.debug("Telemetry disabled via opt-out")) : t ? (b.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0, this._scarfEnabled = !0, this._fsBacked && setTimeout(() => {
384
- this.trackPackageDownload({ triggered_by: "initialization" }).catch((e) => b.debug(`Failed to track package download: ${e}`));
385
- }, 0)) : (this._telemetryEnabled = !1, b.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
386
- }
387
- get runtimeEnvironment() {
388
- return this._runtimeEnvironment;
389
- }
390
- get storageCapability() {
391
- return this._storageCapability;
392
- }
393
- static getInstance() {
394
- return e.instance ||= new e(), e.instance;
395
- }
396
- setSource(e) {
397
- this._source = e;
398
- try {
399
- F() && localStorage.setItem("MCP_USE_TELEMETRY_SOURCE", e);
400
- } catch {}
401
- b.debug(`Telemetry source set to: ${e}`);
402
- }
403
- getSource() {
404
- return this._source;
405
- }
406
- setProductVersion(e) {
407
- this._productVersion = e;
408
- }
409
- get isEnabled() {
410
- return this._telemetryEnabled || this._scarfEnabled;
411
- }
412
- get userId() {
413
- if (this._currUserId) return this._currUserId;
414
- try {
415
- if (this._storage) {
416
- let e = this._storage.getUserId();
417
- if (e) return this._currUserId = e, e;
418
- let t = A();
419
- return this._storage.setUserId(t), this._currUserId = t, t;
420
- }
421
- this._currUserId = ye();
422
- } catch {
423
- this._currUserId = this.UNKNOWN_USER_ID;
424
- }
425
- return this._currUserId;
426
- }
427
- async capture(e) {
428
- if (!this._telemetryEnabled && !this._scarfEnabled) return;
429
- let t = this.userId, n = {
430
- ...e.properties,
431
- mcp_use_version: this._productVersion ?? S(),
432
- language: "typescript",
433
- source: this._source,
434
- runtime: this._runtimeEnvironment
435
- };
436
- if (this._telemetryEnabled) {
437
- let r = O({
438
- host: N,
439
- apiKey: M,
440
- event: e.name,
441
- distinctId: t,
442
- properties: n
443
- });
444
- this._pending.add(r), r.finally(() => this._pending.delete(r));
445
- }
446
- if (this._scarfEnabled) {
447
- let r = k({
448
- ...n,
449
- user_id: t,
450
- event: e.name
451
- });
452
- this._pending.add(r), r.finally(() => this._pending.delete(r));
453
- }
454
- }
455
- async trackPackageDownload(e) {
456
- if (!this._scarfEnabled || !this._fsBacked || !this._storage) return;
457
- let t = S(), n = this._storage.getDownloadedVersion(), r = !1, i = !1;
458
- n ? me(t, n) && (i = !0, this._storage.setDownloadedVersion(t)) : (i = !0, r = !0, this._storage.setDownloadedVersion(t)), i && await k({
459
- ...e || {},
460
- mcp_use_version: t,
461
- user_id: this.userId,
462
- event: "package_download",
463
- first_download: r,
464
- language: "typescript",
465
- source: this._source,
466
- runtime: this._runtimeEnvironment
467
- });
468
- }
469
- async trackAgentExecution(e) {
470
- this.isEnabled && await this.capture(new te(e));
471
- }
472
- async trackMCPClientInit(e) {
473
- this.isEnabled && await this.capture(new ne(e));
474
- }
475
- async trackConnectorInit(e) {
476
- this.isEnabled && await this.capture(new re(e));
477
- }
478
- async trackClientAddServer(e, t) {
479
- this.isEnabled && await this.capture(new ie({
480
- serverName: e,
481
- serverConfig: t
482
- }));
483
- }
484
- async trackClientRemoveServer(e) {
485
- this.isEnabled && await this.capture(new ae({ serverName: e }));
486
- }
487
- async trackUseMcpConnection(e) {
488
- this.isEnabled && await this.capture({
489
- name: "usemcp_connection",
490
- properties: {
491
- url_domain: new URL(e.url).hostname,
492
- transport_type: e.transportType,
493
- success: e.success,
494
- error_type: e.errorType ?? null,
495
- connection_time_ms: e.connectionTimeMs ?? null,
496
- has_oauth: e.hasOAuth,
497
- has_sampling: e.hasSampling,
498
- has_elicitation: e.hasElicitation
499
- }
500
- });
501
- }
502
- async trackUseMcpToolCall(e) {
503
- this.isEnabled && await this.capture({
504
- name: "usemcp_tool_call",
505
- properties: {
506
- tool_name: e.toolName,
507
- success: e.success,
508
- error_type: e.errorType ?? null,
509
- execution_time_ms: e.executionTimeMs ?? null
510
- }
511
- });
512
- }
513
- async trackUseMcpResourceRead(e) {
514
- this.isEnabled && await this.capture({
515
- name: "usemcp_resource_read",
516
- properties: {
517
- resource_uri_scheme: e.resourceUri.split(":")[0],
518
- success: e.success,
519
- error_type: e.errorType ?? null
520
- }
521
- });
522
- }
523
- identify(e, t) {
524
- this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled && O({
525
- host: N,
526
- apiKey: M,
527
- event: "$identify",
528
- distinctId: e,
529
- properties: { $set: t ?? {} }
530
- });
531
- }
532
- reset() {
533
- this._currUserId = null;
534
- }
535
- flush() {
536
- Promise.allSettled([...this._pending]);
537
- }
538
- async shutdown() {
539
- try {
540
- await Promise.allSettled([...this._pending]), b.debug("Telemetry fetch captures flushed");
541
- } catch (e) {
542
- b.debug(`Error flushing telemetry captures: ${e}`);
543
- }
544
- }
545
- }, L = I;
546
- function R(e) {
547
- L.getInstance().setSource(e);
548
- }
549
- d({
550
- addServer: (e, t) => I.getInstance().trackClientAddServer(e, t).catch(() => void 0),
551
- removeServer: (e) => I.getInstance().trackClientRemoveServer(e).catch(() => void 0)
552
- }), h((e) => I.getInstance().trackConnectorInit(e).catch(() => void 0));
553
- function z(e) {
554
- let t = () => {
555
- throw Error(`Invalid url to pass to open(): ${e}`);
556
- }, n;
557
- try {
558
- n = new URL(e);
559
- } catch {
560
- t();
561
- }
562
- return n.protocol !== "https:" && n.protocol !== "http:" && t(), n.hostname !== encodeURIComponent(n.hostname) && t(), n.username &&= encodeURIComponent(n.username), n.password &&= encodeURIComponent(n.password), n.pathname = n.pathname.slice(0, 1) + encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi, "/"), n.search = n.search.slice(0, 1) + Array.from(n.searchParams.entries()).map(be).join("&"), n.hash = n.hash.slice(0, 1) + encodeURIComponent(n.hash.slice(1)), n.href;
563
- }
564
- function be([e, t]) {
565
- return `${encodeURIComponent(e)}${t.length > 0 ? `=${encodeURIComponent(t)}` : ""}`;
566
- }
567
- var xe = class {
568
- get(e) {
569
- return localStorage.getItem(e);
570
- }
571
- set(e, t) {
572
- localStorage.setItem(e, t);
573
- }
574
- remove(e) {
575
- localStorage.removeItem(e);
576
- }
577
- keys() {
578
- let e = [];
579
- for (let t = 0; t < localStorage.length; t++) {
580
- let n = localStorage.key(t);
581
- n && e.push(n);
582
- }
583
- return e;
584
- }
585
- }, Se = class e {
586
- serverUrl;
587
- storageKeyPrefix;
588
- serverUrlHash;
589
- clientName;
590
- clientUri;
591
- logoUri;
592
- callbackUrl;
593
- clientMetadataUrl;
594
- scope;
595
- store;
596
- allowClientSecret;
597
- constructor(n, r, i) {
598
- t(r.clientMetadataUrl), this.serverUrl = n, this.storageKeyPrefix = r.storageKeyPrefix || "mcp:auth", this.serverUrlHash = e.hashString(n), this.clientName = r.clientName || "mcp-use", this.clientUri = r.clientUri || (typeof window < "u" ? window.location.origin : "https://mcp-use.com"), this.logoUri = r.logoUri || "https://mcp-use.com/logo.png", this.callbackUrl = z(r.callbackUrl || (typeof window < "u" ? new URL("/oauth/callback", window.location.origin).toString() : "/oauth/callback")), this.clientMetadataUrl = r.clientMetadataUrl, this.scope = r.scope, this.store = i, this.allowClientSecret = r.allowClientSecret ?? !0;
599
- }
600
- getKey(e) {
601
- return `${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`;
602
- }
603
- static hashString(e) {
604
- let t = 0;
605
- for (let n = 0; n < e.length; n++) {
606
- let r = e.charCodeAt(n);
607
- t = (t << 5) - t + r, t &= t;
608
- }
609
- return Math.abs(t).toString(16);
610
- }
611
- get redirectUrl() {
612
- return this.callbackUrl;
613
- }
614
- get clientMetadata() {
615
- return {
616
- redirect_uris: [this.redirectUrl],
617
- token_endpoint_auth_method: "none",
618
- grant_types: ["authorization_code", "refresh_token"],
619
- response_types: ["code"],
620
- client_name: this.clientName,
621
- client_uri: this.clientUri,
622
- logo_uri: this.logoUri,
623
- ...this.scope ? { scope: this.scope } : {}
624
- };
625
- }
626
- credentialKey(e, t) {
627
- return t ? this.getKey(`${e}_${encodeURIComponent(t.issuer)}`) : this.getKey(e);
628
- }
629
- async readCredential(e, t) {
630
- let n = this.credentialKey(e, t), r = await this.store.get(n);
631
- if (!r && t) {
632
- let r = this.credentialKey(e), i = await this.store.get(r);
633
- if (i) try {
634
- let e = JSON.parse(i);
635
- if (!e.issuer || e.issuer === t.issuer) {
636
- let i = {
637
- ...e,
638
- issuer: t.issuer
639
- }, a = JSON.stringify(i);
640
- return await this.store.set(n, a), await this.store.set(r, a), {
641
- key: n,
642
- value: i
643
- };
644
- }
645
- } catch {
646
- await this.store.remove(r);
647
- }
648
- return;
649
- }
650
- if (r) try {
651
- return {
652
- key: n,
653
- value: JSON.parse(r)
654
- };
655
- } catch (t) {
656
- console.warn(`[${this.storageKeyPrefix}] Failed to parse ${e.replace("_", " ")}:`, t), await this.store.remove(n);
657
- return;
658
- }
659
- }
660
- async tokens(e) {
661
- return (await this.readCredential("tokens", e))?.value;
662
- }
663
- async saveTokens(e, t) {
664
- let n = JSON.stringify(e);
665
- await this.store.set(this.credentialKey("tokens", t), n), t && await this.store.set(this.credentialKey("tokens"), n), await this.store.remove(this.getKey("code_verifier")), await this.store.remove(this.getKey("last_auth_url"));
666
- }
667
- async clientInformation(e) {
668
- let t = await this.readCredential("client_info", e);
669
- if (!t) return;
670
- let { key: n, value: r } = t;
671
- try {
672
- if (!this.allowClientSecret && r.client_secret) {
673
- await this.store.remove(n), e && await this.store.remove(this.credentialKey("client_info")), console.warn(`[${this.storageKeyPrefix}] Removed OAuth client information containing a browser client_secret.`);
674
- return;
675
- }
676
- let t = Array.isArray(r.redirect_uris) ? r.redirect_uris : [];
677
- if (!(t.length === 0 || t.includes(this.redirectUrl))) {
678
- console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`), await this.store.remove(n), await this.store.remove(this.credentialKey("tokens", e)), await this.store.remove(this.getKey("last_auth_url"));
679
- return;
680
- }
681
- return r;
682
- } catch {
683
- await this.store.remove(n);
684
- return;
685
- }
686
- }
687
- async saveClientInformation(e, t) {
688
- let n = e;
689
- if (!this.allowClientSecret && n.client_secret) throw await this.store.remove(this.credentialKey("client_info", t)), t && await this.store.remove(this.credentialKey("client_info")), Error("Browser OAuth clients must be public clients; client_secret persistence is not allowed.");
690
- let r = JSON.stringify(e);
691
- await this.store.set(this.credentialKey("client_info", t), r), t && await this.store.set(this.credentialKey("client_info"), r);
692
- }
693
- async saveCodeVerifier(e) {
694
- await this.store.set(this.getKey("code_verifier"), e);
695
- }
696
- async codeVerifier() {
697
- let e = this.getKey("code_verifier"), t = await this.store.get(e);
698
- if (!t) throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);
699
- return t;
700
- }
701
- async invalidateCredentials(e) {
702
- let t = async (e) => {
703
- let t = `${this.getKey(e)}_`;
704
- for (let n of await this.store.keys()) (n === this.getKey(e) || n.startsWith(t)) && await this.store.remove(n);
705
- };
706
- switch (e) {
707
- case "all":
708
- await t("tokens"), await t("client_info"), await this.store.remove(this.getKey("code_verifier")), await this.store.remove(this.getKey("last_auth_url")), await this.store.remove(this.getKey("discovery_state")), await this.store.remove(this.getKey("token_endpoint"));
709
- break;
710
- case "client":
711
- await t("client_info");
712
- break;
713
- case "tokens":
714
- await t("tokens");
715
- break;
716
- case "verifier":
717
- await this.store.remove(this.getKey("code_verifier"));
718
- break;
719
- case "discovery":
720
- await this.store.remove(this.getKey("discovery_state"));
721
- break;
722
- default: break;
723
- }
724
- }
725
- async saveDiscoveryState(e) {
726
- await this.store.set(this.getKey("discovery_state"), JSON.stringify(e));
727
- }
728
- async discoveryState() {
729
- let e = await this.store.get(this.getKey("discovery_state"));
730
- if (e) try {
731
- return JSON.parse(e);
732
- } catch {
733
- await this.store.remove(this.getKey("discovery_state"));
734
- return;
735
- }
736
- }
737
- async storeAuthorizationState(e, t = {}) {
738
- let n = globalThis.crypto.randomUUID(), r = `${this.storageKeyPrefix}:state_${n}`, i = {
739
- serverUrlHash: this.serverUrlHash,
740
- expiry: Date.now() + 1e3 * 60 * 10,
741
- providerOptions: {
742
- serverUrl: this.serverUrl,
743
- storageKeyPrefix: this.storageKeyPrefix,
744
- clientName: this.clientName,
745
- clientUri: this.clientUri,
746
- callbackUrl: this.callbackUrl,
747
- ...this.clientMetadataUrl ? { clientMetadataUrl: this.clientMetadataUrl } : {},
748
- ...t.extraProviderOptions ?? {}
749
- },
750
- flowType: t.flowType,
751
- returnUrl: t.returnUrl
752
- };
753
- e.searchParams.set("state", n);
754
- let a = z(e.toString());
755
- return await this.store.set(r, JSON.stringify(i)), await this.store.set(this.getKey("last_auth_url"), a), a;
756
- }
757
- async getTokenEndpoint() {
758
- return (await this.discoveryState())?.authorizationServerMetadata?.token_endpoint ?? null;
759
- }
760
- };
761
- async function Ce(e) {
762
- return typeof e == "string" ? e : e instanceof URLSearchParams || e instanceof FormData ? Object.fromEntries(e.entries()) : e instanceof Blob ? await e.text() : e;
763
- }
764
- var B = class {
765
- serverUrl;
766
- staticClientInfo;
767
- session;
768
- preventAutoAuth;
769
- useRedirectFlow;
770
- oauthProxyUrl;
771
- connectionUrl;
772
- proxyOAuthRequests;
773
- onPopupWindow;
774
- constructor(e, t = {}) {
775
- if (t.staticClientInfo?.client_secret) throw Error("Browser OAuth clients must be public clients; staticClientInfo.client_secret is not allowed.");
776
- this.serverUrl = e, this.session = new Se(e, {
777
- ...t,
778
- allowClientSecret: !1
779
- }, new xe()), this.preventAutoAuth = t.preventAutoAuth, this.useRedirectFlow = t.useRedirectFlow, this.oauthProxyUrl = t.oauthProxyUrl, this.connectionUrl = t.connectionUrl, this.proxyOAuthRequests = t.proxyOAuthRequests ?? !0, this.staticClientInfo = t.staticClientInfo, this.onPopupWindow = t.onPopupWindow;
780
- }
781
- get storageKeyPrefix() {
782
- return this.session.storageKeyPrefix;
783
- }
784
- get serverUrlHash() {
785
- return this.session.serverUrlHash;
786
- }
787
- get clientName() {
788
- return this.session.clientName;
789
- }
790
- get clientUri() {
791
- return this.session.clientUri;
792
- }
793
- get logoUri() {
794
- return this.session.logoUri;
795
- }
796
- get callbackUrl() {
797
- return this.session.callbackUrl;
798
- }
799
- get scope() {
800
- return this.session.scope;
801
- }
802
- get clientMetadataUrl() {
803
- return this.session.clientMetadataUrl;
804
- }
805
- getKey(e) {
806
- return this.session.getKey(e);
807
- }
808
- reanchorWellKnownUrl(e) {
809
- if (!this.connectionUrl) return e;
810
- try {
811
- let t = new URL(e), n = new URL(this.connectionUrl);
812
- if (t.origin !== n.origin || !t.pathname.startsWith("/.well-known/")) return e;
813
- let r = new URL(this.serverUrl), [i, ...a] = t.pathname.slice(13).split("/");
814
- if (!i) return e;
815
- let o = a.length ? `/${a.join("/")}` : "", s = n.pathname.replace(/\/+$/, ""), c = r.pathname.replace(/\/+$/, ""), l = o && o === s ? c : o;
816
- return `${r.origin}/.well-known/${i}${l}${t.search}`;
817
- } catch {
818
- return e;
819
- }
820
- }
821
- getProxyFetch(e) {
822
- if (!this.proxyOAuthRequests || !this.oauthProxyUrl) return e;
823
- let t = e ?? globalThis.fetch.bind(globalThis), n = this.oauthProxyUrl, r = /* @__PURE__ */ new Set(), i = !1;
824
- return async (e, a) => {
825
- let o = typeof e == "string" ? e : e instanceof URL ? e.toString() : e.url, s = this.reanchorWellKnownUrl(o), c;
826
- try {
827
- c = new URL(s).pathname;
828
- } catch {
829
- return await t(e, a);
830
- }
831
- let l = c.includes("/.well-known/");
832
- if (!i) {
833
- i = !0;
834
- let e = (await this.discoveryState())?.authorizationServerMetadata;
835
- for (let t of [
836
- "registration_endpoint",
837
- "token_endpoint",
838
- "revocation_endpoint",
839
- "introspection_endpoint"
840
- ]) typeof e?.[t] == "string" && r.add(e[t]);
841
- }
842
- let u = r.has(s) || /\/(?:register|registration|token|revoke|revocation|introspect|introspection)\/?$/.test(c);
843
- if (!l && !u) return await t(e, a);
844
- try {
845
- let r = new URL(s), i = new URL(n);
846
- if (r.origin === i.origin && (r.pathname.startsWith(i.pathname) || s.includes("/inspector/api/oauth"))) return await t(e, a);
847
- } catch {}
848
- let d = l ? `${n}/metadata?serverUrl=${encodeURIComponent(this.serverUrl)}&url=${encodeURIComponent(s)}` : `${n}/proxy`;
849
- if (l) {
850
- let e = await t(d, {
851
- ...a,
852
- method: "GET"
853
- });
854
- try {
855
- let t = await e.clone().json();
856
- for (let e of [
857
- "registration_endpoint",
858
- "token_endpoint",
859
- "revocation_endpoint",
860
- "introspection_endpoint"
861
- ]) typeof t[e] == "string" && r.add(t[e]);
862
- } catch {}
863
- return e;
864
- }
865
- let f = a?.body ? await Ce(a.body) : void 0, p = await (await t(d, {
866
- method: "POST",
867
- headers: { "Content-Type": "application/json" },
868
- body: JSON.stringify({
869
- serverUrl: this.serverUrl,
870
- url: s,
871
- method: a?.method || "POST",
872
- headers: a?.headers ? Object.fromEntries(new Headers(a.headers)) : {},
873
- body: f
874
- })
875
- })).json();
876
- return new Response(JSON.stringify(p.body), {
877
- status: p.status,
878
- statusText: p.statusText,
879
- headers: new Headers(p.headers)
880
- });
881
- };
882
- }
883
- get redirectUrl() {
884
- return this.session.redirectUrl;
885
- }
886
- get clientMetadata() {
887
- return this.session.clientMetadata;
888
- }
889
- tokens(e) {
890
- return this.session.tokens(e);
891
- }
892
- saveTokens(e, t) {
893
- return this.session.saveTokens(e, t);
894
- }
895
- async clientInformation(e) {
896
- return this.staticClientInfo ? this.staticClientInfo : this.session.clientInformation(e);
897
- }
898
- async saveClientInformation(e, t) {
899
- if (!this.staticClientInfo) return this.session.saveClientInformation(e, t);
900
- }
901
- codeVerifier() {
902
- return this.session.codeVerifier();
903
- }
904
- saveCodeVerifier(e) {
905
- return this.session.saveCodeVerifier(e);
906
- }
907
- invalidateCredentials(e) {
908
- return this.session.invalidateCredentials(e);
909
- }
910
- saveDiscoveryState(e) {
911
- return this.session.saveDiscoveryState(e);
912
- }
913
- discoveryState() {
914
- return this.session.discoveryState();
915
- }
916
- getTokenEndpoint() {
917
- return this.session.getTokenEndpoint();
918
- }
919
- async getClientCredentials() {
920
- let e = await this.clientInformation();
921
- return e?.client_id ? { client_id: e.client_id } : null;
922
- }
923
- async prepareAuthorizationUrl(e) {
924
- return this.session.storeAuthorizationState(e, {
925
- extraProviderOptions: {
926
- oauthProxyUrl: this.oauthProxyUrl,
927
- ...this.clientMetadataUrl ? { clientMetadataUrl: this.clientMetadataUrl } : {},
928
- ...this.staticClientInfo ? { staticClientInfo: this.staticClientInfo } : {},
929
- ...this.scope ? { scope: this.scope } : {}
930
- },
931
- flowType: this.useRedirectFlow ? "redirect" : "popup",
932
- returnUrl: typeof window < "u" ? window.location.href : void 0
933
- });
934
- }
935
- async redirectToAuthorization(e) {
936
- let t = await this.prepareAuthorizationUrl(e);
937
- if (this.preventAutoAuth) {
938
- console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);
939
- return;
940
- }
941
- if (this.useRedirectFlow) {
942
- console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`), window.location.href = t;
943
- return;
944
- }
945
- let n = "width=600,height=700,resizable=yes,scrollbars=yes,status=yes";
946
- try {
947
- let e = window.open(t, `mcp_auth_${this.serverUrlHash}`, n);
948
- this.onPopupWindow && this.onPopupWindow(t, n, e), !e || e.closed || e.closed === void 0 ? console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`) : (e.focus(), console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`));
949
- } catch (e) {
950
- console.error(`[${this.storageKeyPrefix}] Error opening popup window:`, e);
951
- }
952
- }
953
- getLastAttemptedAuthUrl() {
954
- let e = localStorage.getItem(this.getKey("last_auth_url"));
955
- return e ? z(e) : null;
956
- }
957
- clearStorage() {
958
- let e = `${this.storageKeyPrefix}_${this.serverUrlHash}_`, t = `${this.storageKeyPrefix}:state_`, n = [], r = 0;
959
- for (let r = 0; r < localStorage.length; r++) {
960
- let i = localStorage.key(r);
961
- if (i) {
962
- if (i.startsWith(e)) n.push(i);
963
- else if (i.startsWith(t)) try {
964
- let e = localStorage.getItem(i);
965
- e && JSON.parse(e).serverUrlHash === this.serverUrlHash && n.push(i);
966
- } catch (e) {
967
- console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`, e);
968
- }
969
- }
970
- }
971
- return [...new Set(n)].forEach((e) => {
972
- localStorage.removeItem(e), r++;
973
- }), r;
974
- }
975
- };
976
- async function V(e, t = {}) {
977
- return new B(e, t);
978
- }
979
- var we = "mcp_auth_callback", Te = "mcp_auth_callback";
980
- function H(e) {
981
- try {
982
- return typeof localStorage < "u" && !!localStorage.getItem(e);
983
- } catch {
984
- return !1;
985
- }
986
- }
987
- function Ee({ popup: e, state: t, tokensKey: n, timeoutMs: r = 5 * 6e4, closePollMs: i = 1e3, closeGraceMs: a = 2e4, expectedOrigin: o = typeof window < "u" ? window.location.origin : "" }) {
988
- return new Promise((s) => {
989
- let c = !1, l = null, u = null, d = null, f = null, p = () => {
990
- if (l &&= (clearInterval(l), null), u &&= (clearTimeout(u), null), d &&= (clearTimeout(d), null), typeof window < "u" && (window.removeEventListener("message", g), window.removeEventListener("storage", v)), f) {
991
- try {
992
- f.removeEventListener("message", _), f.close();
993
- } catch {}
994
- f = null;
995
- }
996
- }, m = (e) => {
997
- c || (c = !0, p(), s(e));
998
- }, h = (e) => {
999
- !e || e.type !== Te || e.state && t && e.state !== t || (e.success ? m({ kind: "success" }) : m({
1000
- kind: "error",
1001
- error: e.error ?? "Authentication failed in callback."
1002
- }));
1003
- }, g = (e) => {
1004
- o && e.origin !== o || h(e.data);
1005
- }, _ = (e) => {
1006
- h(e.data);
1007
- }, v = (e) => {
1008
- e.key === n && e.newValue && m({ kind: "success" });
1009
- };
1010
- if (typeof window < "u" && (window.addEventListener("message", g), window.addEventListener("storage", v)), typeof BroadcastChannel < "u") try {
1011
- f = new BroadcastChannel(we), f.addEventListener("message", _);
1012
- } catch {
1013
- f = null;
1014
- }
1015
- e && (l = setInterval(() => {
1016
- if (c) return;
1017
- let t = !1;
1018
- try {
1019
- t = e.closed;
1020
- } catch {
1021
- t = !1;
1022
- }
1023
- if (t) {
1024
- if (l &&= (clearInterval(l), null), H(n)) {
1025
- m({ kind: "success" });
1026
- return;
1027
- }
1028
- d = setTimeout(() => {
1029
- m(H(n) ? { kind: "success" } : { kind: "cancelled" });
1030
- }, a);
1031
- }
1032
- }, i)), u = setTimeout(() => {
1033
- m(H(n) ? { kind: "success" } : { kind: "timeout" });
1034
- }, r);
1035
- });
1036
- }
1037
- var De = 5 * 6e4;
1038
- function U(e, t = 0) {
1039
- if (!e || t > 5) return !1;
1040
- if (e instanceof s) return !0;
1041
- if (e instanceof Error) {
1042
- if (e.code === 401 || e.name === "UnauthorizedError") return !0;
1043
- let n = e.message ?? "";
1044
- if (n.includes("401") || n.includes("Unauthorized") || e.cause && U(e.cause, t + 1)) return !0;
1045
- let r = e.data;
1046
- if (r?.cause && U(r.cause, t + 1)) return !0;
1047
- }
1048
- return !1;
1049
- }
1050
- async function W(e, t, n = {}) {
1051
- let i = e, a = n.timeoutMs ?? De, o = n.fetchFn ?? i.getProxyFetch?.() ?? void 0;
1052
- if (!i.hasPendingFlow) {
1053
- let n = await r(e, {
1054
- serverUrl: t,
1055
- fetchFn: o
1056
- });
1057
- if (n === "AUTHORIZED") return;
1058
- if (n !== "REDIRECT") throw Error(`Unexpected OAuth auth() result: ${n}`);
1059
- }
1060
- if (typeof i.getAuthorizationCode == "function") {
1061
- await r(e, {
1062
- serverUrl: t,
1063
- authorizationCode: await i.getAuthorizationCode(),
1064
- fetchFn: o
1065
- });
1066
- return;
1067
- }
1068
- await G(i, a);
1069
- }
1070
- async function G(e, t) {
1071
- if (typeof window > "u") throw Error("OAuth redirect requires a browser environment or a provider with getAuthorizationCode()");
1072
- if (e.useRedirectFlow) return;
1073
- let n = e.getKey?.("tokens");
1074
- if (!n) throw Error("Browser OAuth provider must expose getKey() for token storage");
1075
- let r = null, i = e.getLastAttemptedAuthUrl?.();
1076
- if (i) try {
1077
- r = new URL(i).searchParams.get("state");
1078
- } catch {}
1079
- let a = await Ee({
1080
- popup: null,
1081
- state: r,
1082
- tokensKey: n,
1083
- timeoutMs: t
1084
- });
1085
- switch (a.kind) {
1086
- case "success": return;
1087
- case "cancelled": throw Error("OAuth authentication was cancelled.");
1088
- case "timeout": throw Error(`OAuth callback not received within ${t}ms. Ensure /oauth/callback calls onMcpAuthorization().`);
1089
- case "error": throw Error(a.error);
1090
- default: throw Error("Unexpected OAuth popup result");
1091
- }
1092
- }
1093
- var Oe = "http://json-schema.org/draft-04/schema", ke = /* @__PURE__ */ new Set(["http://json-schema.org/draft-07/schema", "https://json-schema.org/draft-07/schema"]), Ae = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]), je = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
1094
- function Me(e) {
1095
- if (!("$schema" in e) || typeof e.$schema != "string") return "2020-12";
1096
- let t = e.$schema.replace(/#$/, "");
1097
- if (t === Oe) return "4";
1098
- if (ke.has(t)) return "7";
1099
- if (Ae.has(t)) return "2019-09";
1100
- if (je.has(t)) return "2020-12";
1101
- }
1102
- var K = class {
1103
- getValidator(e) {
1104
- let t = Me(e);
1105
- return (t === void 0 ? new o() : new o({ draft: t })).getValidator(e);
1106
- }
1107
- }, Ne = { "~standard": {
1108
- version: 1,
1109
- vendor: "mcp-use",
1110
- validate: (e) => ({ value: e })
1111
- } }, q = class {
1112
- client = null;
1113
- connectionManager = null;
1114
- toolsCache = null;
1115
- capabilitiesCache = null;
1116
- serverInfoCache = null;
1117
- connected = !1;
1118
- opts;
1119
- notificationHandlers = [];
1120
- rootsCache = [];
1121
- activeProgressHandlers = /* @__PURE__ */ new Set();
1122
- constructor(e = {}) {
1123
- this.opts = e, e.roots && (this.rootsCache = [...e.roots]), e.onNotification && this.notificationHandlers.push(e.onNotification);
1124
- }
1125
- trackConnectorInit(e) {
1126
- let t = this.constructor.name;
1127
- g({
1128
- connectorType: t,
1129
- ...e
1130
- });
1131
- }
1132
- onNotification(e) {
1133
- this.notificationHandlers.push(e), this.client && this.setupNotificationHandler();
1134
- }
1135
- async forwardNotification(e) {
1136
- for (let t of this.notificationHandlers) try {
1137
- await t(e);
1138
- } catch (e) {
1139
- b.error("Error in notification handler:", e);
1140
- }
1141
- }
1142
- async handleListChanged(e, t, n) {
1143
- if (t) {
1144
- b.warn(`[Auto] ${e} refresh failed:`, t);
1145
- return;
1146
- }
1147
- e === "notifications/tools/list_changed" && n && (this.toolsCache = [...n]), await this.forwardNotification({ method: e });
1148
- }
1149
- setupNotificationHandler() {
1150
- if (!this.client) return;
1151
- this.client.fallbackNotificationHandler = async (e) => {
1152
- switch (e.method) {
1153
- case "notifications/tools/list_changed":
1154
- await this.refreshToolsCache();
1155
- break;
1156
- case "notifications/resources/list_changed":
1157
- await this.onResourcesListChanged();
1158
- break;
1159
- case "notifications/prompts/list_changed":
1160
- await this.onPromptsListChanged();
1161
- break;
1162
- default: break;
1163
- }
1164
- await this.forwardNotification(e);
1165
- };
1166
- let e = this.client._notificationHandlers;
1167
- for (let t of ["notifications/progress", "notifications/cancelled"]) {
1168
- let n = e.get(t);
1169
- n && e.set(t, async (e) => {
1170
- await n(e), await this.forwardNotification(e);
1171
- });
1172
- }
1173
- }
1174
- setupRoundProgressForwarding() {
1175
- if (!this.client) return;
1176
- let e = this.client, t = e._onnotification.bind(this.client);
1177
- e._onnotification = async (e) => {
1178
- e && typeof e == "object" && e.method === "notifications/progress" && this.forwardRoundProgress(e.params), await t?.(e);
1179
- };
1180
- }
1181
- forwardRoundProgress(e) {
1182
- if (this.activeProgressHandlers.size === 1) {
1183
- let [t] = this.activeProgressHandlers;
1184
- t?.(e);
1185
- }
1186
- }
1187
- async refreshToolsCache() {
1188
- if (this.client) try {
1189
- b.debug("[Auto] Refreshing tools cache due to list_changed notification");
1190
- let e = await this.client.listTools();
1191
- this.toolsCache = e.tools ?? [], b.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`);
1192
- } catch (e) {
1193
- b.warn("[Auto] Failed to refresh tools cache:", e);
1194
- }
1195
- }
1196
- async onResourcesListChanged() {
1197
- b.debug("[Auto] Resources list changed - clients should re-fetch if needed");
1198
- }
1199
- async onPromptsListChanged() {
1200
- b.debug("[Auto] Prompts list changed - clients should re-fetch if needed");
1201
- }
1202
- async setRoots(e) {
1203
- this.rootsCache = [...e], this.client && (b.debug(`Sending roots/list_changed notification with ${e.length} root(s)`), await this.client.sendRootsListChanged());
1204
- }
1205
- getRoots() {
1206
- return [...this.rootsCache];
1207
- }
1208
- setupRootsHandler() {
1209
- this.client && this.client.setRequestHandler("roots/list", async () => (b.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`), { roots: this.rootsCache }));
1210
- }
1211
- setupSamplingHandler() {
1212
- if (!this.client) {
1213
- b.debug("setupSamplingHandler: No client available");
1214
- return;
1215
- }
1216
- let e = this.opts.onSampling;
1217
- if (!e) {
1218
- b.debug("setupSamplingHandler: No sampling callback provided");
1219
- return;
1220
- }
1221
- b.debug("setupSamplingHandler: Setting up sampling request handler"), this.client.setRequestHandler("sampling/createMessage", async (t) => (b.debug("Server requested sampling, forwarding to callback"), await e(t.params))), b.debug("setupSamplingHandler: Sampling handler registered successfully");
1222
- }
1223
- setupElicitationHandler() {
1224
- if (!this.client) {
1225
- b.debug("setupElicitationHandler: No client available");
1226
- return;
1227
- }
1228
- let e = this.opts.onElicitation;
1229
- if (!e) {
1230
- b.debug("setupElicitationHandler: No elicitation callback provided");
1231
- return;
1232
- }
1233
- b.debug("setupElicitationHandler: Setting up elicitation request handler"), this.client.setRequestHandler("elicitation/create", async (t) => (b.debug("Server requested elicitation, forwarding to callback"), await e(t.params))), b.debug("setupElicitationHandler: Elicitation handler registered successfully");
1234
- }
1235
- async disconnect() {
1236
- if (!this.connected) {
1237
- b.debug("Not connected to MCP implementation");
1238
- return;
1239
- }
1240
- b.debug("Disconnecting from MCP implementation"), await this.cleanupResources(), this.connected = !1, b.debug("Disconnected from MCP implementation");
1241
- }
1242
- get isClientConnected() {
1243
- return this.client != null;
1244
- }
1245
- async initialize(e = this.opts.defaultRequestOptions ?? {}) {
1246
- if (!this.client) throw Error("MCP client is not connected");
1247
- b.debug("Caching server capabilities & tools");
1248
- let t = this.client.getServerCapabilities();
1249
- this.capabilitiesCache = t || null;
1250
- let n = this.client.getServerVersion();
1251
- this.serverInfoCache = n ? {
1252
- name: n.name,
1253
- version: n.version,
1254
- title: n.title,
1255
- description: n.description,
1256
- websiteUrl: n.websiteUrl,
1257
- icons: n.icons
1258
- } : null;
1259
- try {
1260
- let t = await this.client.listTools(void 0, e);
1261
- this.toolsCache = t.tools ?? [], b.debug(`Fetched ${this.toolsCache.length} tools from server`);
1262
- } catch (e) {
1263
- let t = e;
1264
- t.code === -32601 ? b.debug("Server does not implement tools/list, assuming no tools") : b.debug("Failed to list tools, assuming empty:", t.message), this.toolsCache = [];
1265
- }
1266
- return b.debug("Server capabilities:", t), b.debug("Server info:", n), t;
1267
- }
1268
- get tools() {
1269
- if (!this.toolsCache) throw Error("MCP client is not initialized; call initialize() first");
1270
- return this.toolsCache;
1271
- }
1272
- get serverCapabilities() {
1273
- return this.capabilitiesCache || {};
1274
- }
1275
- get serverInfo() {
1276
- return this.serverInfoCache;
1277
- }
1278
- get instructions() {
1279
- return this.client?.getInstructions?.();
1280
- }
1281
- get protocolEra() {
1282
- return this.client?.getProtocolEra?.();
1283
- }
1284
- get negotiatedProtocolVersion() {
1285
- return this.client?.getNegotiatedProtocolVersion?.();
1286
- }
1287
- async callTool(e, t, n) {
1288
- if (!this.client) throw Error("MCP client is not connected");
1289
- let r = n ? { ...n } : void 0;
1290
- r?.resetTimeoutOnProgress && !r.onprogress && (r.onprogress = () => {}, b.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)), b.debug(`Calling tool '${e}' with args`, t);
1291
- let i = r?.onprogress;
1292
- i && this.activeProgressHandlers.add(i);
1293
- try {
1294
- let n = await this.client.callTool({
1295
- name: e,
1296
- arguments: t
1297
- }, r);
1298
- return b.debug(`Tool '${e}' returned`, n), n;
1299
- } finally {
1300
- i && this.activeProgressHandlers.delete(i);
1301
- }
1302
- }
1303
- async listTools(e) {
1304
- if (!this.client) throw Error("MCP client is not connected");
1305
- b.debug("[listTools] Fetching fresh tools from server...");
1306
- let t = await this.client.listTools(void 0, e), n = t.tools ? [...t.tools] : [];
1307
- return b.debug(`[listTools] Returned ${n.length} tools:`, n.map((e) => e.name)), n;
1308
- }
1309
- async listResources(e, t) {
1310
- if (!this.client) throw Error("MCP client is not connected");
1311
- return b.debug("Listing resources", e ? `with cursor: ${e}` : ""), await this.client.listResources({ cursor: e }, t);
1312
- }
1313
- async listAllResources(e) {
1314
- if (!this.client) throw Error("MCP client is not connected");
1315
- if (!this.capabilitiesCache?.resources) return b.debug("Server does not advertise resources capability, skipping"), { resources: [] };
1316
- try {
1317
- b.debug("Listing all resources (with auto-pagination)");
1318
- let t = [], n;
1319
- do {
1320
- let r = await this.client.listResources({ cursor: n }, e);
1321
- t.push(...r.resources || []), n = r.nextCursor;
1322
- } while (n);
1323
- return { resources: t };
1324
- } catch (e) {
1325
- if (e.code === -32601) return b.debug("Server advertised resources but method not found"), { resources: [] };
1326
- throw e;
1327
- }
1328
- }
1329
- async listResourceTemplates(e) {
1330
- if (!this.client) throw Error("MCP client is not connected");
1331
- return b.debug("Listing resource templates"), await this.client.listResourceTemplates(void 0, e);
1332
- }
1333
- async complete(e, t) {
1334
- if (!this.client) throw Error("MCP client is not connected");
1335
- b.debug("[complete] Requesting completions for:", e.ref);
1336
- let n = await this.client.complete(e, t);
1337
- return b.debug(`[complete] Received ${n.completion.values.length} suggestions`), n;
1338
- }
1339
- async readResource(e, t) {
1340
- if (!this.client) throw Error("MCP client is not connected");
1341
- return b.debug(`Reading resource ${e}`), await this.client.readResource({ uri: e }, t);
1342
- }
1343
- async subscribeToResource(e, t) {
1344
- if (!this.client) throw Error("MCP client is not connected");
1345
- return b.debug(`Subscribing to resource: ${e}`), await this.client.subscribeResource({ uri: e }, t);
1346
- }
1347
- async unsubscribeFromResource(e, t) {
1348
- if (!this.client) throw Error("MCP client is not connected");
1349
- return b.debug(`Unsubscribing from resource: ${e}`), await this.client.unsubscribeResource({ uri: e }, t);
1350
- }
1351
- async listPrompts() {
1352
- if (!this.client) throw Error("MCP client is not connected");
1353
- if (!this.capabilitiesCache?.prompts) return b.debug("Server does not advertise prompts capability, skipping"), { prompts: [] };
1354
- try {
1355
- return b.debug("Listing prompts"), await this.client.listPrompts();
1356
- } catch (e) {
1357
- if (e.code === -32601) return b.debug("Server advertised prompts but method not found"), { prompts: [] };
1358
- throw e;
1359
- }
1360
- }
1361
- async getPrompt(e, t) {
1362
- if (!this.client) throw Error("MCP client is not connected");
1363
- return b.debug(`Getting prompt ${e}`), await this.client.getPrompt({
1364
- name: e,
1365
- arguments: t
1366
- });
1367
- }
1368
- async request(e, t = null, n) {
1369
- if (!this.client) throw Error("MCP client is not connected");
1370
- return b.debug(`Sending raw request '${e}' with params`, t), await this.client.request({
1371
- method: e,
1372
- params: t ?? {}
1373
- }, Ne, n);
1374
- }
1375
- async cleanupResources() {
1376
- let e = [];
1377
- if (this.client) try {
1378
- typeof this.client.close == "function" && await this.client.close();
1379
- } catch (t) {
1380
- let n = `Error closing client: ${t}`;
1381
- b.warn(n), e.push(n);
1382
- } finally {
1383
- this.client = null;
1384
- }
1385
- if (this.connectionManager) try {
1386
- await this.connectionManager.stop();
1387
- } catch (t) {
1388
- let n = `Error stopping connection manager: ${t}`;
1389
- b.warn(n), e.push(n);
1390
- } finally {
1391
- this.connectionManager = null;
1392
- }
1393
- this.toolsCache = null, e.length && b.warn(`Resource cleanup finished with ${e.length} issue(s)`);
1394
- }
1395
- };
1396
- function J(e, t = 0) {
1397
- if (!e || t > 5) return !1;
1398
- if (e instanceof s || e instanceof i && e.status === 401) return !0;
1399
- if (e instanceof Error) {
1400
- if (e.cause && J(e.cause, t + 1)) return !0;
1401
- let r = e instanceof n ? e.data : void 0;
1402
- if (r?.cause && J(r.cause, t + 1)) return !0;
1403
- }
1404
- return !1;
1405
- }
1406
- function Pe(e, t, n, r) {
1407
- let i = new URL(e), a = t.replace(/\/$/, "");
1408
- return async (e, t) => {
1409
- let o = new Request(e, t), s = new URL(o.url);
1410
- if (!(s.origin === i.origin && s.pathname === i.pathname)) return n(o);
1411
- let c = new Headers(o.headers);
1412
- c.set("X-Target-URL", o.url), r && c.set("X-Server-Id", r);
1413
- let l = o.method === "GET" || o.method === "HEAD" ? void 0 : await o.clone().arrayBuffer();
1414
- return n(new Request(a, {
1415
- method: o.method,
1416
- headers: c,
1417
- body: l,
1418
- signal: o.signal,
1419
- redirect: "manual"
1420
- }));
1421
- };
1422
- }
1423
- var Y = class extends q {
1424
- baseUrl;
1425
- headers;
1426
- timeout;
1427
- customFetch;
1428
- clientInfo;
1429
- protocolNegotiation;
1430
- gatewayUrl;
1431
- serverId;
1432
- reconnectionOptions;
1433
- transportType = null;
1434
- streamableTransport = null;
1435
- constructor(e, t = {}) {
1436
- super(t);
1437
- let n = e.replace(/\/$/, "");
1438
- this.baseUrl = n, this.headers = { ...t.headers ?? {} }, this.gatewayUrl = t.gatewayUrl, this.serverId = t.serverId, t.authToken && (this.headers.Authorization = `Bearer ${t.authToken}`), this.timeout = t.timeout ?? 1e4;
1439
- let r = t.fetch ?? globalThis.fetch.bind(globalThis);
1440
- this.customFetch = this.gatewayUrl ? Pe(n, this.gatewayUrl, r, this.serverId) : t.fetch, this.clientInfo = t.clientInfo ?? {
1441
- name: "http-connector",
1442
- version: "1.0.0"
1443
- }, this.protocolNegotiation = t.protocolNegotiation ?? "auto", this.reconnectionOptions = t.reconnectionOptions;
1444
- }
1445
- buildClientOptions() {
1446
- return {
1447
- ...this.opts.clientOptions || {},
1448
- jsonSchemaValidator: this.opts.clientOptions?.jsonSchemaValidator ?? new K(),
1449
- versionNegotiation: {
1450
- mode: this.protocolNegotiation,
1451
- ...this.opts.clientOptions?.versionNegotiation ?? {}
1452
- },
1453
- listChanged: {
1454
- tools: {
1455
- autoRefresh: !0,
1456
- onChanged: (e, t) => void this.handleListChanged("notifications/tools/list_changed", e, t)
1457
- },
1458
- resources: {
1459
- autoRefresh: !1,
1460
- onChanged: (e) => void this.handleListChanged("notifications/resources/list_changed", e)
1461
- },
1462
- prompts: {
1463
- autoRefresh: !1,
1464
- onChanged: (e) => void this.handleListChanged("notifications/prompts/list_changed", e)
1465
- },
1466
- ...this.opts.clientOptions?.listChanged ?? {}
1467
- },
1468
- capabilities: {
1469
- ...this.opts.clientOptions?.capabilities || {},
1470
- roots: { listChanged: !0 },
1471
- ...this.opts.onSampling ? { sampling: {} } : {},
1472
- ...this.opts.onElicitation ? { elicitation: {
1473
- form: {},
1474
- url: {}
1475
- } } : {}
1476
- }
1477
- };
1478
- }
1479
- unwrapStreamableError(e) {
1480
- return e instanceof i ? e : e instanceof Error && e.cause instanceof i ? e.cause : null;
1481
- }
1482
- classifyStreamableHttpFailure(e) {
1483
- let t = "Unknown error", n = !1, r, i = this.unwrapStreamableError(e);
1484
- if (i) {
1485
- let e = i.status;
1486
- return n = e === 401, r = e, e === 400 && i.message.includes("Missing session ID") ? (t = "Server requires session ID (FastMCP compatibility)", b.warn(`\u26A0\uFE0F ${t}`)) : e === 404 || e === 405 ? (t = `Server returned ${e} - server likely doesn't support streamable HTTP`, b.debug(t)) : (t = `Server returned ${e}: ${i.message}`, b.debug(t)), {
1487
- fallbackReason: t,
1488
- is401Error: n,
1489
- httpStatusCode: r
1490
- };
1491
- }
1492
- if (e instanceof Error) {
1493
- let r = e.toString(), i = e.message || "";
1494
- n = J(e) || r.includes("401") || i.includes("Unauthorized"), r.includes("Missing session ID") || r.includes("Bad Request: Missing session ID") || i.includes("FastMCP session ID error") ? (t = "Server requires session ID (FastMCP compatibility)", b.warn(`\u26A0\uFE0F ${t}`)) : r.includes("405 Method Not Allowed") || r.includes("404 Not Found") ? (t = "Server doesn't support streamable HTTP (405/404)", b.debug(t)) : (t = `Streamable HTTP failed: ${e.message}`, b.debug(t));
1495
- }
1496
- return {
1497
- fallbackReason: t,
1498
- is401Error: n,
1499
- httpStatusCode: r
1500
- };
1501
- }
1502
- async connect() {
1503
- if (this.connected) {
1504
- b.debug("Already connected to MCP implementation");
1505
- return;
1506
- }
1507
- let e = this.baseUrl;
1508
- b.debug(`Connecting to MCP implementation via HTTP: ${e}`);
1509
- try {
1510
- await this.connectWithStreamableHttp(e), b.debug("✅ Successfully connected via streamable HTTP");
1511
- } catch (e) {
1512
- b.debug("Streamable HTTP connect failed", e);
1513
- let { fallbackReason: t, is401Error: n, httpStatusCode: r } = this.classifyStreamableHttpFailure(e);
1514
- if (await this.cleanupResources(), n) {
1515
- b.info("Authentication required");
1516
- let e = /* @__PURE__ */ Error("Authentication required");
1517
- throw e.code = 401, e;
1518
- }
1519
- let i = /* @__PURE__ */ Error(`Could not connect via streamable HTTP: ${t}`);
1520
- throw r !== void 0 && Object.defineProperty(i, "code", {
1521
- value: r,
1522
- writable: !1,
1523
- enumerable: !0,
1524
- configurable: !0
1525
- }), i;
1526
- }
1527
- }
1528
- observeSseProgress(e) {
1529
- if (!e.body || !e.headers.get("content-type")?.includes("text/event-stream")) return e;
1530
- let [t, n] = e.body.tee();
1531
- return (async () => {
1532
- let e = n.getReader(), t = new TextDecoder(), r = "";
1533
- try {
1534
- for (;;) {
1535
- let { done: n, value: i } = await e.read();
1536
- if (n) break;
1537
- r += t.decode(i, { stream: !0 });
1538
- let a = r.split(/\r?\n\r?\n/);
1539
- r = a.pop() ?? "";
1540
- for (let e of a) for (let t of e.split(/\r?\n/)) if (t.startsWith("data:")) try {
1541
- let e = JSON.parse(t.slice(5).trim());
1542
- e.method === "notifications/progress" && this.forwardRoundProgress(e.params);
1543
- } catch {}
1544
- }
1545
- } catch (e) {
1546
- e instanceof DOMException && e.name === "AbortError" || b.debug("Progress observer stream ended:", e);
1547
- } finally {
1548
- e.releaseLock();
1549
- }
1550
- })(), new Response(t, {
1551
- status: e.status,
1552
- statusText: e.statusText,
1553
- headers: e.headers
1554
- });
1555
- }
1556
- async connectWithStreamableHttp(e) {
1557
- try {
1558
- b.debug("[HttpConnector] Connecting with Streamable HTTP", {
1559
- baseUrl: e,
1560
- originalUrl: this.baseUrl,
1561
- gatewayUrl: this.gatewayUrl || "none",
1562
- authProviderUrl: this.opts.authProvider && "serverUrl" in this.opts.authProvider && typeof this.opts.authProvider.serverUrl == "string" ? this.opts.authProvider.serverUrl : "none",
1563
- headers: this.headers
1564
- });
1565
- let t, n = new Promise((e) => {
1566
- t = e;
1567
- }), r = this.customFetch ?? globalThis.fetch.bind(globalThis), i = new a(new URL(e), {
1568
- authProvider: this.opts.authProvider,
1569
- fetch: async (e, n) => {
1570
- let i = await r(e, n), a = n?.method ?? (e instanceof Request ? e.method : "GET"), o = new Headers(e instanceof Request ? e.headers : void 0);
1571
- return new Headers(n?.headers).forEach((e, t) => {
1572
- o.set(t, e);
1573
- }), a.toUpperCase() === "GET" && i.ok && i.headers.get("content-type")?.includes("text/event-stream") && t?.(), o.get("mcp-method") === "subscriptions/listen" ? i : this.observeSseProgress(i);
1574
- },
1575
- requestInit: { headers: this.headers },
1576
- reconnectionOptions: {
1577
- maxReconnectionDelay: 3e4,
1578
- initialReconnectionDelay: 1e3,
1579
- reconnectionDelayGrowFactor: 1.5,
1580
- maxRetries: 2,
1581
- ...this.reconnectionOptions
1582
- }
1583
- }), o = i;
1584
- if (this.opts.wrapTransport) {
1585
- let e = this.baseUrl;
1586
- o = this.opts.wrapTransport(o, e);
1587
- }
1588
- let s = this.buildClientOptions();
1589
- b.debug("Creating Client with capabilities:", JSON.stringify(s.capabilities, null, 2)), this.client = new c(this.clientInfo, s), this.setupRootsHandler(), this.setupSamplingHandler(), this.setupElicitationHandler(), b.debug("Roots/sampling/elicitation handlers registered before connect");
1590
- try {
1591
- let e;
1592
- if (await Promise.race([this.client.connect(o), new Promise((t, n) => {
1593
- e = setTimeout(() => n(/* @__PURE__ */ Error(`MCP connection timed out after ${this.timeout}ms`)), this.timeout);
1594
- })]).finally(() => {
1595
- e !== void 0 && clearTimeout(e);
1596
- }), (this.client.getProtocolEra?.() ?? "legacy") === "legacy" && i.sessionId) {
1597
- let e, t = await Promise.race([n.then(() => !0), new Promise((t) => e = setTimeout(() => t(!1), Math.min(this.timeout, 5e3)))]);
1598
- e && clearTimeout(e), t || b.warn("Legacy server push stream did not attach before connect completed");
1599
- }
1600
- let t = i.sessionId;
1601
- t && b.debug(`Session ID obtained: ${t}`);
1602
- } catch (e) {
1603
- if (e instanceof Error) {
1604
- let t = e.message || e.toString();
1605
- if (t.includes("Missing session ID") || t.includes("Bad Request: Missing session ID") || t.includes("Mcp-Session-Id header is required")) {
1606
- let n = /* @__PURE__ */ Error(`Session ID error: ${t}. The SDK should automatically extract session ID from initialize response.`);
1607
- throw n.cause = e, n;
1608
- }
1609
- }
1610
- throw e;
1611
- }
1612
- this.streamableTransport = i, this.connectionManager = { stop: async () => {
1613
- if (this.streamableTransport) try {
1614
- await this.streamableTransport.close();
1615
- } catch (e) {
1616
- b.warn(`Error closing Streamable HTTP transport: ${e}`);
1617
- } finally {
1618
- this.streamableTransport = null;
1619
- }
1620
- } }, this.connected = !0, this.transportType = "streamable-http", this.setupNotificationHandler(), b.debug(`Successfully connected to MCP implementation via streamable HTTP: ${e}`), this.trackConnectorInit({
1621
- serverUrl: this.baseUrl,
1622
- publicIdentifier: `${this.baseUrl} (streamable-http)`
1623
- });
1624
- } catch (e) {
1625
- throw await this.cleanupResources(), e;
1626
- }
1627
- }
1628
- get publicIdentifier() {
1629
- return {
1630
- type: "http",
1631
- url: this.baseUrl,
1632
- transport: this.transportType || "unknown",
1633
- protocolEra: this.protocolEra ?? "unknown"
1634
- };
1635
- }
1636
- getTransportType() {
1637
- return this.transportType;
1638
- }
1639
- async cleanupResources() {
1640
- if (this.streamableTransport && this.protocolEra !== "modern") {
1641
- let e;
1642
- try {
1643
- await Promise.race([this.streamableTransport.terminateSession().then(() => !0), new Promise((t) => e = setTimeout(() => t(!1), Math.min(this.timeout, 5e3)))]) || b.debug("Timed out terminating legacy HTTP session; closing transport");
1644
- } catch (e) {
1645
- b.debug(`Error terminating Streamable HTTP session: ${e}`);
1646
- } finally {
1647
- e && clearTimeout(e);
1648
- }
1649
- }
1650
- await super.cleanupResources();
1651
- }
1652
- };
1653
- function X(e, t) {
1654
- return {
1655
- onSampling: e?.onSampling ?? t?.onSampling,
1656
- onElicitation: e?.onElicitation ?? t?.onElicitation,
1657
- onNotification: e?.onNotification ?? t?.onNotification
1658
- };
1659
- }
1660
- function Z(e) {
1661
- if (!("url" in e) || typeof e.url != "string" || e.authProvider || e.authToken || e.oauth === !1) return !1;
1662
- let t = e.headers;
1663
- if (t) {
1664
- for (let e of Object.keys(t)) if (e.toLowerCase() === "authorization") return !1;
1665
- }
1666
- return !0;
1667
- }
1668
- function Fe() {
1669
- return {
1670
- name: "mcp-use",
1671
- title: "mcp-use",
1672
- version: S(),
1673
- description: "mcp-use is a complete TypeScript framework for building and using MCP",
1674
- icons: [{ src: "https://mcp-use.com/logo.png" }],
1675
- websiteUrl: "https://mcp-use.com"
1676
- };
1677
- }
1678
- function Q(e) {
1679
- let t = Fe();
1680
- if (!e || typeof e != "object") return t;
1681
- let n = e;
1682
- return !n.name || !n.version ? t : {
1683
- ...t,
1684
- ...n
1685
- };
1686
- }
1687
- var $ = class {
1688
- connector;
1689
- autoConnect;
1690
- constructor(e, t = !0) {
1691
- this.connector = e, this.autoConnect = t;
1692
- }
1693
- async connect() {
1694
- await this.connector.connect();
1695
- }
1696
- async disconnect() {
1697
- await this.connector.disconnect();
1698
- }
1699
- async initialize() {
1700
- !this.isConnected && this.autoConnect && await this.connect(), await this.connector.initialize();
1701
- }
1702
- get isConnected() {
1703
- return this.connector && this.connector.isClientConnected;
1704
- }
1705
- on(e, t) {
1706
- e === "notification" && this.connector.onNotification(t);
1707
- }
1708
- async setRoots(e) {
1709
- return this.connector.setRoots(e);
1710
- }
1711
- getRoots() {
1712
- return this.connector.getRoots();
1713
- }
1714
- get tools() {
1715
- return this.connector.tools;
1716
- }
1717
- async listTools(e) {
1718
- return this.connector.listTools(e);
1719
- }
1720
- get serverCapabilities() {
1721
- return this.connector.serverCapabilities;
1722
- }
1723
- get serverInfo() {
1724
- return this.connector.serverInfo;
1725
- }
1726
- get protocolEra() {
1727
- return this.connector.protocolEra;
1728
- }
1729
- get negotiatedProtocolVersion() {
1730
- return this.connector.negotiatedProtocolVersion;
1731
- }
1732
- get info() {
1733
- let e = this.protocolEra, t = this.negotiatedProtocolVersion, n = this.serverInfo;
1734
- if (!e || !t || !n) throw Error("MCP connection is not initialized");
1735
- let r = this.serverCapabilities, i = r.extensions && typeof r.extensions == "object" && !Array.isArray(r.extensions) ? r.extensions : {};
1736
- return {
1737
- protocolEra: e,
1738
- protocolVersion: t,
1739
- server: n,
1740
- capabilities: r,
1741
- instructions: this.connector.instructions,
1742
- extensions: i
1743
- };
1744
- }
1745
- supports(e) {
1746
- return e in this.serverCapabilities;
1747
- }
1748
- async callTool(e, t = {}, n) {
1749
- return this.connector.callTool(e, t, n);
1750
- }
1751
- async listResources(e, t) {
1752
- return this.connector.listResources(e, t);
1753
- }
1754
- async listAllResources(e) {
1755
- return this.connector.listAllResources(e);
1756
- }
1757
- async listResourceTemplates(e) {
1758
- return this.connector.listResourceTemplates(e);
1759
- }
1760
- async complete(e, t) {
1761
- return this.connector.complete(e, t);
1762
- }
1763
- async readResource(e, t) {
1764
- return this.connector.readResource(e, t);
1765
- }
1766
- async subscribeToResource(e, t) {
1767
- return this.connector.subscribeToResource(e, t);
1768
- }
1769
- async unsubscribeFromResource(e, t) {
1770
- return this.connector.unsubscribeFromResource(e, t);
1771
- }
1772
- async listPrompts() {
1773
- return this.connector.listPrompts();
1774
- }
1775
- async getPrompt(e, t) {
1776
- return this.connector.getPrompt(e, t);
1777
- }
1778
- async request(e, t = null, n) {
1779
- return this.connector.request(e, t, n);
1780
- }
1781
- };
1782
- function Ie(e) {
1783
- return !!e && typeof e == "object" && "redirectUrl" in e && "clientMetadata" in e;
1784
- }
1785
- var Le = class {
1786
- config = {};
1787
- sessions = {};
1788
- activeSessions = [];
1789
- constructor(e) {
1790
- e && (this.config = e);
1791
- }
1792
- static fromDict(e) {
1793
- throw Error("fromDict must be implemented by concrete class");
1794
- }
1795
- addServer(e, t) {
1796
- this.config.mcpServers = this.config.mcpServers || {}, this.config.mcpServers[e] = t, f(e, t);
1797
- }
1798
- async removeServer(e) {
1799
- this.config.mcpServers?.[e] && (await this.closeSession(e), delete this.config.mcpServers[e], p(e));
1800
- }
1801
- getServerNames() {
1802
- return Object.keys(this.config.mcpServers ?? {});
1803
- }
1804
- getServerConfig(e) {
1805
- return this.config.mcpServers?.[e];
1806
- }
1807
- getConfig() {
1808
- return this.config ?? {};
1809
- }
1810
- async createSession(e, t = !0) {
1811
- let n = this.config.mcpServers ?? {};
1812
- if (Object.keys(n).length === 0 && b.warn("No MCP servers defined in config"), !n[e]) throw Error(`Server '${e}' not found in config`);
1813
- let r = { ...n[e] }, i;
1814
- if (Z(r)) {
1815
- let e = r.oauth === !1 ? void 0 : r.oauth ?? {};
1816
- i = await this.createDefaultOAuthProvider(r.url, e), r = {
1817
- ...r,
1818
- authProvider: i
1819
- };
1820
- } else "authProvider" in r && r.authProvider && Ie(r.authProvider) && (i = r.authProvider);
1821
- let a = async () => {
1822
- let e = new $(await Promise.resolve(this.createConnectorFromConfig(r)));
1823
- return t && await e.initialize(), e;
1824
- }, o;
1825
- try {
1826
- o = await a();
1827
- } catch (n) {
1828
- let s = r;
1829
- if (!t || !i || !("url" in s) || !U(n) || i.preventAutoAuth) throw n;
1830
- b.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await W(i, s.url), o = await a();
1831
- }
1832
- return this.sessions[e] = o, this.activeSessions.includes(e) || this.activeSessions.push(e), o;
1833
- }
1834
- async connect(e) {
1835
- return this.createSession(e);
1836
- }
1837
- async createAllSessions(e = !0) {
1838
- let t = this.config.mcpServers ?? {};
1839
- Object.keys(t).length === 0 && b.warn("No MCP servers defined in config");
1840
- for (let n of Object.keys(t)) await this.createSession(n, e);
1841
- return this.sessions;
1842
- }
1843
- async connectAll() {
1844
- return this.createAllSessions();
1845
- }
1846
- getSession(e) {
1847
- return this.sessions[e] || null;
1848
- }
1849
- requireSession(e) {
1850
- let t = this.sessions[e];
1851
- if (!t) throw Error(`Session '${e}' not found. Available sessions: ${this.activeSessions.join(", ") || "none"}`);
1852
- return t;
1853
- }
1854
- getAllActiveSessions() {
1855
- return Object.fromEntries(this.activeSessions.map((e) => [e, this.sessions[e]]));
1856
- }
1857
- async closeSession(e) {
1858
- let t = this.sessions[e];
1859
- if (!t) {
1860
- b.warn(`No session exists for server ${e}, nothing to close`);
1861
- return;
1862
- }
1863
- try {
1864
- b.debug(`Closing session for server ${e}`), await t.disconnect();
1865
- } catch (t) {
1866
- b.error(`Error closing session for server '${e}': ${t}`);
1867
- } finally {
1868
- this.sessions[e] === t && (delete this.sessions[e], this.activeSessions = this.activeSessions.filter((t) => t !== e));
1869
- }
1870
- }
1871
- async closeAllSessions() {
1872
- let e = Object.keys(this.sessions), t = [];
1873
- for (let n of e) try {
1874
- b.debug(`Closing session for server ${n}`), await this.closeSession(n);
1875
- } catch (e) {
1876
- let r = `Failed to close session for server '${n}': ${e}`;
1877
- b.error(r), t.push(r);
1878
- }
1879
- t.length ? b.error(`Encountered ${t.length} errors while closing sessions`) : b.debug("All sessions closed successfully");
1880
- }
1881
- async close() {
1882
- await this.closeAllSessions();
1883
- }
1884
- };
1885
- function Re(e) {
1886
- let t = Object.keys(e.mcpServers ?? {});
1887
- L.getInstance().trackMCPClientInit({
1888
- codeMode: !1,
1889
- sandbox: !1,
1890
- allCallbacks: !1,
1891
- verify: !1,
1892
- servers: t,
1893
- numServers: t.length,
1894
- isBrowser: !0
1895
- }).catch((e) => b.debug(`Failed to track BrowserMCPClient init: ${e}`));
1896
- }
1897
- var ze = class e extends Le {
1898
- static getPackageVersion() {
1899
- return S();
1900
- }
1901
- constructor(e) {
1902
- super(e), Re(this.config);
1903
- }
1904
- static fromDict(t) {
1905
- return new e(t);
1906
- }
1907
- async createDefaultOAuthProvider(e, t = {}) {
1908
- return V(e, t);
1909
- }
1910
- createConnectorFromConfig(e) {
1911
- let { url: t, headers: n, fetch: r, authToken: i, authProvider: a, wrapTransport: o, clientOptions: s, protocolNegotiation: c, timeout: l, gatewayUrl: u, serverId: d, reconnectionOptions: f } = e;
1912
- if (!t) throw Error("Server URL is required");
1913
- let p = this.config, m = X(e, p), h = Q(e.clientInfo ?? this.config.clientInfo), g = {
1914
- headers: n,
1915
- fetch: r ?? globalThis.fetch.bind(globalThis),
1916
- authToken: i,
1917
- authProvider: a,
1918
- wrapTransport: o,
1919
- clientOptions: s,
1920
- onSampling: m.onSampling,
1921
- onElicitation: m.onElicitation,
1922
- onNotification: m.onNotification,
1923
- protocolNegotiation: c,
1924
- timeout: l,
1925
- clientInfo: h,
1926
- gatewayUrl: u,
1927
- serverId: d,
1928
- reconnectionOptions: f
1929
- };
1930
- return b.debug(`[BrowserMCPClient] Connector options prepared (clientOptions: ${s ? "provided" : "none"})`), new Y(t, g);
1931
- }
1932
- };
1933
- //#endregion
1934
- export { b as a, l as i, L as n, R as o, k as r, T as t };