mcp-use 2.0.0-beta.9 → 2.0.0

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 (1237) hide show
  1. package/dist/bin.js +1 -179
  2. package/dist/branding.d.ts +7 -11
  3. package/dist/buffered-response.d.ts +27 -0
  4. package/dist/chunk-273ZVKJJ.js +2 -0
  5. package/dist/{chunk-GTOOHAI2.js → chunk-GX6PGIEO.js} +33 -143
  6. package/dist/chunk-IS7FKXFR.js +1 -0
  7. package/dist/chunk-KGTOBJW2.js +1 -0
  8. package/dist/chunk-MIZQEWZS.js +1 -0
  9. package/dist/chunk-OJF6B5EU.js +1 -0
  10. package/dist/chunk-PSKSL567.js +1 -0
  11. package/dist/chunk-XYHHP43G.js +1 -0
  12. package/dist/chunk-Y26DNVWA.js +3 -0
  13. package/dist/chunk-ZMU5USAZ.js +1 -0
  14. package/dist/completable.d.ts +0 -1
  15. package/dist/config.d.ts +24 -84
  16. package/dist/context.d.ts +154 -60
  17. package/dist/fetch-app.d.ts +3 -28
  18. package/dist/index-node.js +781 -0
  19. package/dist/index.d.ts +31 -14
  20. package/dist/index.js +41 -2548
  21. package/dist/internal/node-http-unavailable.js +1 -0
  22. package/dist/internal/node-http.js +1 -0
  23. package/dist/internal/resource-completion.js +1 -7
  24. package/dist/internal/usage.js +1 -0
  25. package/dist/landing-handler-TG6LVQBI.js +1 -0
  26. package/dist/landing-handler.d.ts +1 -2
  27. package/dist/landing.d.ts +19 -5
  28. package/dist/landing.js +1 -7
  29. package/dist/listen-address.d.ts +8 -0
  30. package/dist/logging.d.ts +0 -1
  31. package/dist/mcp-proxy-NETCUGUD.js +2 -0
  32. package/dist/mcp-proxy.d.ts +158 -0
  33. package/dist/middleware/cors.d.ts +0 -1
  34. package/dist/middleware/mcp-middleware.d.ts +178 -104
  35. package/dist/mount-mcp.d.ts +0 -1
  36. package/dist/next/config.d.ts +67 -0
  37. package/dist/next/handler.d.ts +32 -0
  38. package/dist/next/index.d.ts +9 -0
  39. package/dist/next/index.js +1 -0
  40. package/dist/node-bridge.d.ts +33 -4
  41. package/dist/node-bridge.js +1 -151
  42. package/dist/node-http-unavailable.d.ts +9 -0
  43. package/dist/node-http.d.ts +2 -0
  44. package/dist/oauth/adapters.d.ts +0 -1
  45. package/dist/oauth/auth0.d.ts +24 -1
  46. package/dist/oauth/auth0.js +1 -61
  47. package/dist/oauth/better-auth.d.ts +23 -1
  48. package/dist/oauth/better-auth.js +1 -76
  49. package/dist/oauth/clerk.d.ts +30 -3
  50. package/dist/oauth/clerk.js +1 -70
  51. package/dist/oauth/errors.d.ts +3 -0
  52. package/dist/oauth/guards.d.ts +0 -1
  53. package/dist/oauth/index.d.ts +0 -1
  54. package/dist/oauth/index.js +1 -28
  55. package/dist/oauth/internal.d.ts +0 -1
  56. package/dist/oauth/jwt.d.ts +10 -4
  57. package/dist/oauth/keycloak.d.ts +28 -1
  58. package/dist/oauth/keycloak.js +1 -94
  59. package/dist/oauth/provider.d.ts +17 -2
  60. package/dist/oauth/supabase.d.ts +38 -2
  61. package/dist/oauth/supabase.js +1 -101
  62. package/dist/oauth/workos.d.ts +27 -1
  63. package/dist/oauth/workos.js +1 -77
  64. package/dist/openapi/index.d.ts +0 -1
  65. package/dist/openapi/index.js +1 -7
  66. package/dist/openapi/types.d.ts +0 -1
  67. package/dist/prompts.d.ts +7 -4
  68. package/dist/public-route-DAQJGS6K.js +1 -0
  69. package/dist/react/components/error-boundary.d.ts +3 -1
  70. package/dist/react/components/image.d.ts +0 -1
  71. package/dist/react/components/model-context.d.ts +8 -57
  72. package/dist/react/components/theme-provider.d.ts +7 -4
  73. package/dist/react/components/view-controls.d.ts +0 -1
  74. package/dist/react/hooks/use-call-tool.d.ts +29 -12
  75. package/dist/react/hooks/use-display-mode.d.ts +0 -1
  76. package/dist/react/hooks/use-files.d.ts +0 -1
  77. package/dist/react/hooks/use-host-context.d.ts +5 -1
  78. package/dist/react/hooks/use-open-external.d.ts +0 -1
  79. package/dist/react/hooks/use-send-follow-up.d.ts +0 -1
  80. package/dist/react/hooks/use-send-size-changed.d.ts +0 -1
  81. package/dist/react/hooks/use-tool-context.d.ts +0 -1
  82. package/dist/react/hooks/use-view-state.d.ts +23 -0
  83. package/dist/react/hooks/use-view-theme.d.ts +0 -1
  84. package/dist/react/hooks/use-view-tool.d.ts +3 -4
  85. package/dist/react/index.d.ts +9 -9
  86. package/dist/react/index.js +286 -131
  87. package/dist/react/public-assets.d.ts +21 -6
  88. package/dist/react/runtime/bootstrap-view.d.ts +3 -4
  89. package/dist/react/runtime/model-context-store.d.ts +34 -69
  90. package/dist/react/runtime/view-config.d.ts +0 -1
  91. package/dist/react/runtime/view-runtime-context.d.ts +0 -1
  92. package/dist/react/runtime/view-runtime.d.ts +4 -6
  93. package/dist/react/types/file-types.d.ts +2 -1
  94. package/dist/react/types/host-types.d.ts +2 -1
  95. package/dist/react/types/register.d.ts +11 -4
  96. package/dist/react/types/result-types.d.ts +0 -1
  97. package/dist/resource-completion.d.ts +0 -1
  98. package/dist/resources.d.ts +14 -6
  99. package/dist/response-conversion.d.ts +25 -0
  100. package/dist/response-helpers.d.ts +231 -0
  101. package/dist/server.d.ts +118 -51
  102. package/dist/tools.d.ts +14 -14
  103. package/dist/usage.d.ts +14 -0
  104. package/dist/views/capabilities.d.ts +0 -1
  105. package/dist/views/constants.d.ts +1 -2
  106. package/dist/views/csp-env.d.ts +0 -1
  107. package/dist/views/document.d.ts +9 -11
  108. package/dist/views/index.d.ts +0 -1
  109. package/dist/views/origin.d.ts +0 -1
  110. package/dist/views/public-route.d.ts +2 -3
  111. package/dist/views/register.d.ts +1 -2
  112. package/dist/views/routes.d.ts +1 -2
  113. package/dist/views/types.d.ts +21 -17
  114. package/dist/views/wire.d.ts +7 -7
  115. package/dist/vite-client.d.ts +1 -0
  116. package/package.json +41 -21
  117. package/dist/.tsbuildinfo +0 -1
  118. package/dist/bin/args.d.ts +0 -61
  119. package/dist/bin/args.d.ts.map +0 -1
  120. package/dist/bin/main.d.ts +0 -32
  121. package/dist/bin/main.d.ts.map +0 -1
  122. package/dist/bin/start.d.ts +0 -40
  123. package/dist/bin/start.d.ts.map +0 -1
  124. package/dist/bin.d.ts +0 -3
  125. package/dist/bin.d.ts.map +0 -1
  126. package/dist/bin.js.map +0 -1
  127. package/dist/branding.d.ts.map +0 -1
  128. package/dist/chunk-AATFAERC.js +0 -384
  129. package/dist/chunk-AATFAERC.js.map +0 -1
  130. package/dist/chunk-DPL7OEXC.js +0 -518
  131. package/dist/chunk-DPL7OEXC.js.map +0 -1
  132. package/dist/chunk-DQ7LE4ZA.js +0 -237
  133. package/dist/chunk-DQ7LE4ZA.js.map +0 -1
  134. package/dist/chunk-FC2Z2VFO.js +0 -99
  135. package/dist/chunk-FC2Z2VFO.js.map +0 -1
  136. package/dist/chunk-GTOOHAI2.js.map +0 -1
  137. package/dist/chunk-IG2BCCMU.js +0 -98
  138. package/dist/chunk-IG2BCCMU.js.map +0 -1
  139. package/dist/chunk-KIZ72TIK.js +0 -38
  140. package/dist/chunk-KIZ72TIK.js.map +0 -1
  141. package/dist/chunk-QUUANIE4.js +0 -125
  142. package/dist/chunk-QUUANIE4.js.map +0 -1
  143. package/dist/chunk-RQRT27Q3.js +0 -454
  144. package/dist/chunk-RQRT27Q3.js.map +0 -1
  145. package/dist/chunk-SMN75YED.js +0 -66
  146. package/dist/chunk-SMN75YED.js.map +0 -1
  147. package/dist/chunk-STCR3P5O.js +0 -95
  148. package/dist/chunk-STCR3P5O.js.map +0 -1
  149. package/dist/chunk-XUD22N3Y.js +0 -156
  150. package/dist/chunk-XUD22N3Y.js.map +0 -1
  151. package/dist/chunk-Z326HADF.js +0 -82
  152. package/dist/chunk-Z326HADF.js.map +0 -1
  153. package/dist/chunk-ZMIKQPSO.js +0 -151
  154. package/dist/chunk-ZMIKQPSO.js.map +0 -1
  155. package/dist/cli/build.d.ts +0 -61
  156. package/dist/cli/build.d.ts.map +0 -1
  157. package/dist/cli/dev-api.d.ts +0 -49
  158. package/dist/cli/dev-api.d.ts.map +0 -1
  159. package/dist/cli/dev.d.ts +0 -101
  160. package/dist/cli/dev.d.ts.map +0 -1
  161. package/dist/cli/entry.d.ts +0 -31
  162. package/dist/cli/entry.d.ts.map +0 -1
  163. package/dist/cli/index.d.ts +0 -17
  164. package/dist/cli/index.d.ts.map +0 -1
  165. package/dist/cli/port.d.ts +0 -30
  166. package/dist/cli/port.d.ts.map +0 -1
  167. package/dist/cli/tools-declaration.d.ts +0 -22
  168. package/dist/cli/tools-declaration.d.ts.map +0 -1
  169. package/dist/cli/tunnel.d.ts +0 -46
  170. package/dist/cli/tunnel.d.ts.map +0 -1
  171. package/dist/cli/views-bindings.d.ts +0 -30
  172. package/dist/cli/views-bindings.d.ts.map +0 -1
  173. package/dist/cli/views-plugin.d.ts +0 -47
  174. package/dist/cli/views-plugin.d.ts.map +0 -1
  175. package/dist/cli/views.d.ts +0 -75
  176. package/dist/cli/views.d.ts.map +0 -1
  177. package/dist/cli/vite-config.d.ts +0 -21
  178. package/dist/cli/vite-config.d.ts.map +0 -1
  179. package/dist/cli/workspace.d.ts +0 -107
  180. package/dist/cli/workspace.d.ts.map +0 -1
  181. package/dist/commands/build.d.ts +0 -8
  182. package/dist/commands/build.d.ts.map +0 -1
  183. package/dist/commands/build.js +0 -374
  184. package/dist/commands/build.js.map +0 -1
  185. package/dist/commands/client.d.ts +0 -22
  186. package/dist/commands/client.d.ts.map +0 -1
  187. package/dist/commands/client.js +0 -14
  188. package/dist/commands/client.js.map +0 -1
  189. package/dist/commands/cloud-api.d.ts +0 -70
  190. package/dist/commands/cloud-api.d.ts.map +0 -1
  191. package/dist/commands/deploy.d.ts +0 -3
  192. package/dist/commands/deploy.d.ts.map +0 -1
  193. package/dist/commands/deploy.js +0 -242
  194. package/dist/commands/deploy.js.map +0 -1
  195. package/dist/commands/deployments.d.ts +0 -3
  196. package/dist/commands/deployments.d.ts.map +0 -1
  197. package/dist/commands/deployments.js +0 -213
  198. package/dist/commands/deployments.js.map +0 -1
  199. package/dist/commands/dev.d.ts +0 -8
  200. package/dist/commands/dev.d.ts.map +0 -1
  201. package/dist/commands/dev.js +0 -656
  202. package/dist/commands/dev.js.map +0 -1
  203. package/dist/commands/identity.d.ts +0 -3
  204. package/dist/commands/identity.d.ts.map +0 -1
  205. package/dist/commands/identity.js +0 -192
  206. package/dist/commands/identity.js.map +0 -1
  207. package/dist/commands/load-client.d.ts +0 -11
  208. package/dist/commands/load-client.d.ts.map +0 -1
  209. package/dist/commands/organizations.d.ts +0 -3
  210. package/dist/commands/organizations.d.ts.map +0 -1
  211. package/dist/commands/organizations.js +0 -97
  212. package/dist/commands/organizations.js.map +0 -1
  213. package/dist/commands/screenshot.d.ts +0 -3
  214. package/dist/commands/screenshot.d.ts.map +0 -1
  215. package/dist/commands/screenshot.js +0 -463
  216. package/dist/commands/screenshot.js.map +0 -1
  217. package/dist/commands/servers.d.ts +0 -3
  218. package/dist/commands/servers.d.ts.map +0 -1
  219. package/dist/commands/servers.js +0 -278
  220. package/dist/commands/servers.js.map +0 -1
  221. package/dist/commands/shared.d.ts +0 -44
  222. package/dist/commands/shared.d.ts.map +0 -1
  223. package/dist/commands/skills.d.ts +0 -3
  224. package/dist/commands/skills.d.ts.map +0 -1
  225. package/dist/commands/skills.js +0 -84
  226. package/dist/commands/skills.js.map +0 -1
  227. package/dist/commands/start.d.ts +0 -8
  228. package/dist/commands/start.d.ts.map +0 -1
  229. package/dist/commands/start.js +0 -72
  230. package/dist/commands/start.js.map +0 -1
  231. package/dist/completable.d.ts.map +0 -1
  232. package/dist/config.d.ts.map +0 -1
  233. package/dist/context.d.ts.map +0 -1
  234. package/dist/fetch-app.d.ts.map +0 -1
  235. package/dist/index.d.ts.map +0 -1
  236. package/dist/index.js.map +0 -1
  237. package/dist/inspector-shell.d.ts +0 -90
  238. package/dist/inspector-shell.d.ts.map +0 -1
  239. package/dist/internal/resource-completion.js.map +0 -1
  240. package/dist/landing-handler-3VN4BMR2.js +0 -34
  241. package/dist/landing-handler-3VN4BMR2.js.map +0 -1
  242. package/dist/landing-handler.d.ts.map +0 -1
  243. package/dist/landing.d.ts.map +0 -1
  244. package/dist/landing.js.map +0 -1
  245. package/dist/logging.d.ts.map +0 -1
  246. package/dist/middleware/cors.d.ts.map +0 -1
  247. package/dist/middleware/mcp-middleware.d.ts.map +0 -1
  248. package/dist/mount-mcp.d.ts.map +0 -1
  249. package/dist/node-bridge.d.ts.map +0 -1
  250. package/dist/node-bridge.js.map +0 -1
  251. package/dist/oauth/adapters.d.ts.map +0 -1
  252. package/dist/oauth/auth0.d.ts.map +0 -1
  253. package/dist/oauth/auth0.js.map +0 -1
  254. package/dist/oauth/better-auth.d.ts.map +0 -1
  255. package/dist/oauth/better-auth.js.map +0 -1
  256. package/dist/oauth/clerk.d.ts.map +0 -1
  257. package/dist/oauth/clerk.js.map +0 -1
  258. package/dist/oauth/guards.d.ts.map +0 -1
  259. package/dist/oauth/index.d.ts.map +0 -1
  260. package/dist/oauth/index.js.map +0 -1
  261. package/dist/oauth/internal.d.ts.map +0 -1
  262. package/dist/oauth/jwt.d.ts.map +0 -1
  263. package/dist/oauth/keycloak.d.ts.map +0 -1
  264. package/dist/oauth/keycloak.js.map +0 -1
  265. package/dist/oauth/provider.d.ts.map +0 -1
  266. package/dist/oauth/supabase.d.ts.map +0 -1
  267. package/dist/oauth/supabase.js.map +0 -1
  268. package/dist/oauth/workos.d.ts.map +0 -1
  269. package/dist/oauth/workos.js.map +0 -1
  270. package/dist/openapi/index.d.ts.map +0 -1
  271. package/dist/openapi/index.js.map +0 -1
  272. package/dist/openapi/types.d.ts.map +0 -1
  273. package/dist/prompts.d.ts.map +0 -1
  274. package/dist/public-route-5JEGFEIN.js +0 -9
  275. package/dist/public-route-5JEGFEIN.js.map +0 -1
  276. package/dist/react/components/error-boundary.d.ts.map +0 -1
  277. package/dist/react/components/image.d.ts.map +0 -1
  278. package/dist/react/components/model-context.d.ts.map +0 -1
  279. package/dist/react/components/theme-provider.d.ts.map +0 -1
  280. package/dist/react/components/view-controls.d.ts.map +0 -1
  281. package/dist/react/hooks/use-call-tool.d.ts.map +0 -1
  282. package/dist/react/hooks/use-display-mode.d.ts.map +0 -1
  283. package/dist/react/hooks/use-files.d.ts.map +0 -1
  284. package/dist/react/hooks/use-host-context.d.ts.map +0 -1
  285. package/dist/react/hooks/use-open-external.d.ts.map +0 -1
  286. package/dist/react/hooks/use-send-follow-up.d.ts.map +0 -1
  287. package/dist/react/hooks/use-send-size-changed.d.ts.map +0 -1
  288. package/dist/react/hooks/use-tool-context.d.ts.map +0 -1
  289. package/dist/react/hooks/use-view-theme.d.ts.map +0 -1
  290. package/dist/react/hooks/use-view-tool.d.ts.map +0 -1
  291. package/dist/react/index.d.ts.map +0 -1
  292. package/dist/react/index.js.map +0 -1
  293. package/dist/react/public-assets.d.ts.map +0 -1
  294. package/dist/react/runtime/bootstrap-view.d.ts.map +0 -1
  295. package/dist/react/runtime/model-context-store.d.ts.map +0 -1
  296. package/dist/react/runtime/view-config.d.ts.map +0 -1
  297. package/dist/react/runtime/view-runtime-context.d.ts.map +0 -1
  298. package/dist/react/runtime/view-runtime.d.ts.map +0 -1
  299. package/dist/react/types/file-types.d.ts.map +0 -1
  300. package/dist/react/types/host-types.d.ts.map +0 -1
  301. package/dist/react/types/register.d.ts.map +0 -1
  302. package/dist/react/types/result-types.d.ts.map +0 -1
  303. package/dist/resource-completion.d.ts.map +0 -1
  304. package/dist/resources.d.ts.map +0 -1
  305. package/dist/server.d.ts.map +0 -1
  306. package/dist/tools.d.ts.map +0 -1
  307. package/dist/views/capabilities.d.ts.map +0 -1
  308. package/dist/views/constants.d.ts.map +0 -1
  309. package/dist/views/csp-env.d.ts.map +0 -1
  310. package/dist/views/document.d.ts.map +0 -1
  311. package/dist/views/index.d.ts.map +0 -1
  312. package/dist/views/origin.d.ts.map +0 -1
  313. package/dist/views/public-route.d.ts.map +0 -1
  314. package/dist/views/register.d.ts.map +0 -1
  315. package/dist/views/routes.d.ts.map +0 -1
  316. package/dist/views/types.d.ts.map +0 -1
  317. package/dist/views/wire.d.ts.map +0 -1
  318. package/node_modules/@modelcontextprotocol/client/LICENSE +0 -216
  319. package/node_modules/@modelcontextprotocol/client/README.md +0 -26
  320. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-Asx17_Co.mjs +0 -7069
  321. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-Asx17_Co.mjs.map +0 -1
  322. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B7GnTXYx.d.mts +0 -1054
  323. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B7GnTXYx.d.mts.map +0 -1
  324. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B_4czhCS.d.cts +0 -1054
  325. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B_4czhCS.d.cts.map +0 -1
  326. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-DNzBrkxq.cjs +0 -7086
  327. package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-DNzBrkxq.cjs.map +0 -1
  328. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-D9GAttn8.d.cts +0 -59
  329. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-D9GAttn8.d.cts.map +0 -1
  330. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-DbU8BxXO.mjs +0 -970
  331. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-DbU8BxXO.mjs.map +0 -1
  332. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Djgwc46-.cjs +0 -976
  333. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Djgwc46-.cjs.map +0 -1
  334. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Xtj52JOa.d.mts +0 -59
  335. package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Xtj52JOa.d.mts.map +0 -1
  336. package/node_modules/@modelcontextprotocol/client/dist/chunk-Bnu9O96Y.cjs +0 -60
  337. package/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs +0 -42
  338. package/node_modules/@modelcontextprotocol/client/dist/index-ZagFkUbt.d.mts +0 -2675
  339. package/node_modules/@modelcontextprotocol/client/dist/index-ZagFkUbt.d.mts.map +0 -1
  340. package/node_modules/@modelcontextprotocol/client/dist/index-gN3EXmil.d.cts +0 -2678
  341. package/node_modules/@modelcontextprotocol/client/dist/index-gN3EXmil.d.cts.map +0 -1
  342. package/node_modules/@modelcontextprotocol/client/dist/index.cjs +0 -5427
  343. package/node_modules/@modelcontextprotocol/client/dist/index.cjs.map +0 -1
  344. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts +0 -3196
  345. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +0 -1
  346. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts +0 -3196
  347. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +0 -1
  348. package/node_modules/@modelcontextprotocol/client/dist/index.mjs +0 -5224
  349. package/node_modules/@modelcontextprotocol/client/dist/index.mjs.map +0 -1
  350. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs +0 -14
  351. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs.map +0 -1
  352. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts +0 -13
  353. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts.map +0 -1
  354. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts +0 -13
  355. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts.map +0 -1
  356. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs +0 -13
  357. package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs.map +0 -1
  358. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs +0 -14
  359. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs.map +0 -1
  360. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts +0 -13
  361. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts.map +0 -1
  362. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts +0 -13
  363. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts.map +0 -1
  364. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs +0 -13
  365. package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs.map +0 -1
  366. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +0 -21
  367. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs.map +0 -1
  368. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts +0 -13
  369. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts.map +0 -1
  370. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts +0 -13
  371. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts.map +0 -1
  372. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +0 -20
  373. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs.map +0 -1
  374. package/node_modules/@modelcontextprotocol/client/dist/src-BzzZSQyL.cjs +0 -7331
  375. package/node_modules/@modelcontextprotocol/client/dist/src-BzzZSQyL.cjs.map +0 -1
  376. package/node_modules/@modelcontextprotocol/client/dist/src-DGeA9On3.mjs +0 -6963
  377. package/node_modules/@modelcontextprotocol/client/dist/src-DGeA9On3.mjs.map +0 -1
  378. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +0 -181
  379. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs.map +0 -1
  380. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts +0 -87
  381. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts.map +0 -1
  382. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts +0 -87
  383. package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts.map +0 -1
  384. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +0 -176
  385. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs.map +0 -1
  386. package/node_modules/@modelcontextprotocol/client/dist/types-BDNQEPSs.d.mts +0 -1099
  387. package/node_modules/@modelcontextprotocol/client/dist/types-BDNQEPSs.d.mts.map +0 -1
  388. package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts +0 -1099
  389. package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts.map +0 -1
  390. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.cjs +0 -5
  391. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.cts +0 -2
  392. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.mts +0 -2
  393. package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.mjs +0 -3
  394. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.cjs +0 -3
  395. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.cts +0 -2
  396. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.mts +0 -2
  397. package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.mjs +0 -3
  398. package/node_modules/@modelcontextprotocol/client/package.json +0 -166
  399. package/node_modules/@modelcontextprotocol/core/LICENSE +0 -216
  400. package/node_modules/@modelcontextprotocol/core/README.md +0 -40
  401. package/node_modules/@modelcontextprotocol/core/dist/auth-BUWfrB3C.d.cts +0 -8198
  402. package/node_modules/@modelcontextprotocol/core/dist/auth-BUWfrB3C.d.cts.map +0 -1
  403. package/node_modules/@modelcontextprotocol/core/dist/auth-CEFpHq32.cjs +0 -2862
  404. package/node_modules/@modelcontextprotocol/core/dist/auth-CEFpHq32.cjs.map +0 -1
  405. package/node_modules/@modelcontextprotocol/core/dist/auth-CNbu4K4a.d.mts +0 -8198
  406. package/node_modules/@modelcontextprotocol/core/dist/auth-CNbu4K4a.d.mts.map +0 -1
  407. package/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs +0 -1653
  408. package/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs.map +0 -1
  409. package/node_modules/@modelcontextprotocol/core/dist/index.cjs +0 -174
  410. package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +0 -2
  411. package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +0 -2
  412. package/node_modules/@modelcontextprotocol/core/dist/index.mjs +0 -3
  413. package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +0 -199
  414. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +0 -87
  415. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts.map +0 -1
  416. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +0 -87
  417. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts.map +0 -1
  418. package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +0 -3
  419. package/node_modules/@modelcontextprotocol/core/package.json +0 -85
  420. package/node_modules/jose/LICENSE.md +0 -21
  421. package/node_modules/jose/README.md +0 -153
  422. package/node_modules/jose/dist/types/index.d.ts +0 -55
  423. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +0 -31
  424. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +0 -65
  425. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +0 -31
  426. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +0 -83
  427. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +0 -31
  428. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +0 -74
  429. package/node_modules/jose/dist/types/jwk/embedded.d.ts +0 -17
  430. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -32
  431. package/node_modules/jose/dist/types/jwks/local.d.ts +0 -29
  432. package/node_modules/jose/dist/types/jwks/remote.d.ts +0 -237
  433. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +0 -36
  434. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +0 -33
  435. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +0 -42
  436. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +0 -33
  437. package/node_modules/jose/dist/types/jws/general/sign.d.ts +0 -53
  438. package/node_modules/jose/dist/types/jws/general/verify.d.ts +0 -33
  439. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +0 -35
  440. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +0 -91
  441. package/node_modules/jose/dist/types/jwt/sign.d.ts +0 -43
  442. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +0 -43
  443. package/node_modules/jose/dist/types/jwt/verify.d.ts +0 -37
  444. package/node_modules/jose/dist/types/key/export.d.ts +0 -33
  445. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +0 -47
  446. package/node_modules/jose/dist/types/key/generate_secret.d.ts +0 -35
  447. package/node_modules/jose/dist/types/key/import.d.ts +0 -83
  448. package/node_modules/jose/dist/types/types.d.ts +0 -841
  449. package/node_modules/jose/dist/types/util/base64url.d.ts +0 -9
  450. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +0 -18
  451. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -17
  452. package/node_modules/jose/dist/types/util/errors.d.ts +0 -213
  453. package/node_modules/jose/dist/webapi/index.js +0 -32
  454. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +0 -27
  455. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +0 -27
  456. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +0 -165
  457. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +0 -169
  458. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +0 -31
  459. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +0 -187
  460. package/node_modules/jose/dist/webapi/jwk/embedded.js +0 -17
  461. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +0 -68
  462. package/node_modules/jose/dist/webapi/jwks/local.js +0 -119
  463. package/node_modules/jose/dist/webapi/jwks/remote.js +0 -179
  464. package/node_modules/jose/dist/webapi/jws/compact/sign.js +0 -18
  465. package/node_modules/jose/dist/webapi/jws/compact/verify.js +0 -21
  466. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +0 -92
  467. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +0 -120
  468. package/node_modules/jose/dist/webapi/jws/general/sign.js +0 -73
  469. package/node_modules/jose/dist/webapi/jws/general/verify.js +0 -24
  470. package/node_modules/jose/dist/webapi/jwt/decrypt.js +0 -23
  471. package/node_modules/jose/dist/webapi/jwt/encrypt.js +0 -108
  472. package/node_modules/jose/dist/webapi/jwt/sign.js +0 -52
  473. package/node_modules/jose/dist/webapi/jwt/unsecured.js +0 -63
  474. package/node_modules/jose/dist/webapi/jwt/verify.js +0 -15
  475. package/node_modules/jose/dist/webapi/key/export.js +0 -11
  476. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +0 -97
  477. package/node_modules/jose/dist/webapi/key/generate_secret.js +0 -40
  478. package/node_modules/jose/dist/webapi/key/import.js +0 -57
  479. package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -16
  480. package/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
  481. package/node_modules/jose/dist/webapi/lib/asn1.js +0 -243
  482. package/node_modules/jose/dist/webapi/lib/base64.js +0 -22
  483. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +0 -43
  484. package/node_modules/jose/dist/webapi/lib/cek.js +0 -19
  485. package/node_modules/jose/dist/webapi/lib/check_cek_length.js +0 -7
  486. package/node_modules/jose/dist/webapi/lib/check_iv_length.js +0 -7
  487. package/node_modules/jose/dist/webapi/lib/check_key_length.js +0 -8
  488. package/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
  489. package/node_modules/jose/dist/webapi/lib/crypto_key.js +0 -143
  490. package/node_modules/jose/dist/webapi/lib/decrypt.js +0 -106
  491. package/node_modules/jose/dist/webapi/lib/decrypt_key_management.js +0 -127
  492. package/node_modules/jose/dist/webapi/lib/digest.js +0 -4
  493. package/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
  494. package/node_modules/jose/dist/webapi/lib/encrypt.js +0 -74
  495. package/node_modules/jose/dist/webapi/lib/encrypt_key_management.js +0 -92
  496. package/node_modules/jose/dist/webapi/lib/get_sign_verify_key.js +0 -12
  497. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -27
  498. package/node_modules/jose/dist/webapi/lib/is_disjoint.js +0 -21
  499. package/node_modules/jose/dist/webapi/lib/is_jwk.js +0 -6
  500. package/node_modules/jose/dist/webapi/lib/is_key_like.js +0 -17
  501. package/node_modules/jose/dist/webapi/lib/is_object.js +0 -14
  502. package/node_modules/jose/dist/webapi/lib/iv.js +0 -19
  503. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +0 -109
  504. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +0 -238
  505. package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -31
  506. package/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -176
  507. package/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -39
  508. package/node_modules/jose/dist/webapi/lib/private_symbols.js +0 -1
  509. package/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
  510. package/node_modules/jose/dist/webapi/lib/sign.js +0 -9
  511. package/node_modules/jose/dist/webapi/lib/subtle_dsa.js +0 -31
  512. package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
  513. package/node_modules/jose/dist/webapi/lib/validate_crit.js +0 -33
  514. package/node_modules/jose/dist/webapi/lib/verify.js +0 -14
  515. package/node_modules/jose/dist/webapi/util/base64url.js +0 -30
  516. package/node_modules/jose/dist/webapi/util/decode_jwt.js +0 -32
  517. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +0 -34
  518. package/node_modules/jose/dist/webapi/util/errors.js +0 -99
  519. package/node_modules/jose/package.json +0 -200
  520. package/node_modules/zod/LICENSE +0 -21
  521. package/node_modules/zod/README.md +0 -191
  522. package/node_modules/zod/index.cjs +0 -33
  523. package/node_modules/zod/index.d.cts +0 -4
  524. package/node_modules/zod/index.d.ts +0 -4
  525. package/node_modules/zod/index.js +0 -4
  526. package/node_modules/zod/locales/index.cjs +0 -17
  527. package/node_modules/zod/locales/index.d.cts +0 -1
  528. package/node_modules/zod/locales/index.d.ts +0 -1
  529. package/node_modules/zod/locales/index.js +0 -1
  530. package/node_modules/zod/locales/package.json +0 -7
  531. package/node_modules/zod/mini/index.cjs +0 -32
  532. package/node_modules/zod/mini/index.d.cts +0 -3
  533. package/node_modules/zod/mini/index.d.ts +0 -3
  534. package/node_modules/zod/mini/index.js +0 -3
  535. package/node_modules/zod/mini/package.json +0 -7
  536. package/node_modules/zod/package.json +0 -135
  537. package/node_modules/zod/src/index.ts +0 -4
  538. package/node_modules/zod/src/locales/index.ts +0 -1
  539. package/node_modules/zod/src/mini/index.ts +0 -3
  540. package/node_modules/zod/src/v3/ZodError.ts +0 -330
  541. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  542. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  543. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  544. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  545. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  546. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  547. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  548. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  549. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  550. package/node_modules/zod/src/v3/errors.ts +0 -13
  551. package/node_modules/zod/src/v3/external.ts +0 -6
  552. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  553. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  554. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  555. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  556. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  557. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  558. package/node_modules/zod/src/v3/index.ts +0 -4
  559. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  560. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  561. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  562. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  563. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  564. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  565. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  566. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  567. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  568. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  569. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  570. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  571. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  572. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  573. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  574. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  575. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  576. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  577. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  578. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  579. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  580. package/node_modules/zod/src/v3/tests/error.test.ts +0 -551
  581. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  582. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  583. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  584. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  585. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  586. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
  587. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  588. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
  589. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  590. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  591. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  592. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  593. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  594. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  595. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  596. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  597. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  598. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  599. package/node_modules/zod/src/v3/tests/object.test.ts +0 -434
  600. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  601. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  602. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  603. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  604. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  605. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  606. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  607. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  608. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  609. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
  610. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  611. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  612. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  613. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  614. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  615. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  616. package/node_modules/zod/src/v3/tests/string.test.ts +0 -916
  617. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  618. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  619. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  620. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  621. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  622. package/node_modules/zod/src/v3/types.ts +0 -5138
  623. package/node_modules/zod/src/v4/classic/checks.ts +0 -32
  624. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  625. package/node_modules/zod/src/v4/classic/compat.ts +0 -70
  626. package/node_modules/zod/src/v4/classic/errors.ts +0 -82
  627. package/node_modules/zod/src/v4/classic/external.ts +0 -52
  628. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -659
  629. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  630. package/node_modules/zod/src/v4/classic/iso.ts +0 -90
  631. package/node_modules/zod/src/v4/classic/parse.ts +0 -82
  632. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2672
  633. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  634. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -59
  635. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  636. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -216
  637. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  638. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  639. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  640. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
  641. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  642. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -326
  643. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  644. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -573
  645. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -703
  646. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  647. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  648. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  649. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -62
  650. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -302
  651. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -409
  652. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  653. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  654. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -197
  655. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -694
  656. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
  657. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -807
  658. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
  659. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  660. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  661. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  662. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -895
  663. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -360
  664. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  665. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -39
  666. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -68
  667. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -939
  668. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -60
  669. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -198
  670. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -46
  671. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  672. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
  673. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -117
  674. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  675. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  676. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -330
  677. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  678. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  679. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  680. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  681. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -325
  682. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -717
  683. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -333
  684. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -450
  685. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  686. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  687. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -74
  688. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -26
  689. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  690. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  691. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  692. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  693. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
  694. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -717
  695. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -631
  696. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -633
  697. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  698. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -181
  699. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -134
  700. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  701. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1224
  702. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -106
  703. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -771
  704. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  705. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -3125
  706. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  707. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -496
  708. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -273
  709. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  710. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  711. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  712. package/node_modules/zod/src/v4/core/api.ts +0 -1823
  713. package/node_modules/zod/src/v4/core/checks.ts +0 -1293
  714. package/node_modules/zod/src/v4/core/config.ts +0 -15
  715. package/node_modules/zod/src/v4/core/core.ts +0 -153
  716. package/node_modules/zod/src/v4/core/doc.ts +0 -44
  717. package/node_modules/zod/src/v4/core/errors.ts +0 -455
  718. package/node_modules/zod/src/v4/core/index.ts +0 -16
  719. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -126
  720. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -666
  721. package/node_modules/zod/src/v4/core/json-schema.ts +0 -147
  722. package/node_modules/zod/src/v4/core/parse.ts +0 -195
  723. package/node_modules/zod/src/v4/core/regexes.ts +0 -190
  724. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  725. package/node_modules/zod/src/v4/core/schemas.ts +0 -4730
  726. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  727. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  728. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  729. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  730. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -215
  731. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  732. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -181
  733. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  734. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  735. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  736. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  737. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  738. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  739. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  740. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  741. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  742. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -622
  743. package/node_modules/zod/src/v4/core/util.ts +0 -983
  744. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  745. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  746. package/node_modules/zod/src/v4/index.ts +0 -4
  747. package/node_modules/zod/src/v4/locales/ar.ts +0 -115
  748. package/node_modules/zod/src/v4/locales/az.ts +0 -111
  749. package/node_modules/zod/src/v4/locales/be.ts +0 -176
  750. package/node_modules/zod/src/v4/locales/bg.ts +0 -128
  751. package/node_modules/zod/src/v4/locales/ca.ts +0 -116
  752. package/node_modules/zod/src/v4/locales/cs.ts +0 -118
  753. package/node_modules/zod/src/v4/locales/da.ts +0 -123
  754. package/node_modules/zod/src/v4/locales/de.ts +0 -116
  755. package/node_modules/zod/src/v4/locales/el.ts +0 -121
  756. package/node_modules/zod/src/v4/locales/en.ts +0 -123
  757. package/node_modules/zod/src/v4/locales/eo.ts +0 -118
  758. package/node_modules/zod/src/v4/locales/es.ts +0 -141
  759. package/node_modules/zod/src/v4/locales/fa.ts +0 -126
  760. package/node_modules/zod/src/v4/locales/fi.ts +0 -121
  761. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -116
  762. package/node_modules/zod/src/v4/locales/fr.ts +0 -132
  763. package/node_modules/zod/src/v4/locales/he.ts +0 -246
  764. package/node_modules/zod/src/v4/locales/hr.ts +0 -131
  765. package/node_modules/zod/src/v4/locales/hu.ts +0 -117
  766. package/node_modules/zod/src/v4/locales/hy.ts +0 -164
  767. package/node_modules/zod/src/v4/locales/id.ts +0 -115
  768. package/node_modules/zod/src/v4/locales/index.ts +0 -52
  769. package/node_modules/zod/src/v4/locales/is.ts +0 -119
  770. package/node_modules/zod/src/v4/locales/it.ts +0 -116
  771. package/node_modules/zod/src/v4/locales/ja.ts +0 -114
  772. package/node_modules/zod/src/v4/locales/ka.ts +0 -123
  773. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  774. package/node_modules/zod/src/v4/locales/km.ts +0 -119
  775. package/node_modules/zod/src/v4/locales/ko.ts +0 -121
  776. package/node_modules/zod/src/v4/locales/lt.ts +0 -239
  777. package/node_modules/zod/src/v4/locales/mk.ts +0 -118
  778. package/node_modules/zod/src/v4/locales/ms.ts +0 -115
  779. package/node_modules/zod/src/v4/locales/nl.ts +0 -121
  780. package/node_modules/zod/src/v4/locales/no.ts +0 -116
  781. package/node_modules/zod/src/v4/locales/ota.ts +0 -117
  782. package/node_modules/zod/src/v4/locales/pl.ts +0 -118
  783. package/node_modules/zod/src/v4/locales/ps.ts +0 -126
  784. package/node_modules/zod/src/v4/locales/pt.ts +0 -116
  785. package/node_modules/zod/src/v4/locales/ro.ts +0 -129
  786. package/node_modules/zod/src/v4/locales/ru.ts +0 -176
  787. package/node_modules/zod/src/v4/locales/sl.ts +0 -118
  788. package/node_modules/zod/src/v4/locales/sv.ts +0 -119
  789. package/node_modules/zod/src/v4/locales/ta.ts +0 -118
  790. package/node_modules/zod/src/v4/locales/th.ts +0 -119
  791. package/node_modules/zod/src/v4/locales/tr.ts +0 -111
  792. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  793. package/node_modules/zod/src/v4/locales/uk.ts +0 -117
  794. package/node_modules/zod/src/v4/locales/ur.ts +0 -119
  795. package/node_modules/zod/src/v4/locales/uz.ts +0 -117
  796. package/node_modules/zod/src/v4/locales/vi.ts +0 -117
  797. package/node_modules/zod/src/v4/locales/yo.ts +0 -124
  798. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -116
  799. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -115
  800. package/node_modules/zod/src/v4/mini/checks.ts +0 -32
  801. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  802. package/node_modules/zod/src/v4/mini/external.ts +0 -41
  803. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  804. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  805. package/node_modules/zod/src/v4/mini/parse.ts +0 -14
  806. package/node_modules/zod/src/v4/mini/schemas.ts +0 -1947
  807. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -24
  808. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
  809. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  810. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
  811. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -548
  812. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  813. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
  814. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -5
  815. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -993
  816. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
  817. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -227
  818. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  819. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -325
  820. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  821. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -352
  822. package/node_modules/zod/src/v4-mini/index.ts +0 -3
  823. package/node_modules/zod/v3/ZodError.cjs +0 -138
  824. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  825. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  826. package/node_modules/zod/v3/ZodError.js +0 -133
  827. package/node_modules/zod/v3/errors.cjs +0 -17
  828. package/node_modules/zod/v3/errors.d.cts +0 -5
  829. package/node_modules/zod/v3/errors.d.ts +0 -5
  830. package/node_modules/zod/v3/errors.js +0 -9
  831. package/node_modules/zod/v3/external.cjs +0 -22
  832. package/node_modules/zod/v3/external.d.cts +0 -6
  833. package/node_modules/zod/v3/external.d.ts +0 -6
  834. package/node_modules/zod/v3/external.js +0 -6
  835. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  836. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  837. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  838. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  839. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  840. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  841. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  842. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  843. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  844. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  845. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  846. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  847. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  848. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  849. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  850. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  851. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  852. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  853. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  854. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  855. package/node_modules/zod/v3/helpers/util.cjs +0 -137
  856. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  857. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  858. package/node_modules/zod/v3/helpers/util.js +0 -133
  859. package/node_modules/zod/v3/index.cjs +0 -33
  860. package/node_modules/zod/v3/index.d.cts +0 -4
  861. package/node_modules/zod/v3/index.d.ts +0 -4
  862. package/node_modules/zod/v3/index.js +0 -4
  863. package/node_modules/zod/v3/locales/en.cjs +0 -112
  864. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  865. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  866. package/node_modules/zod/v3/locales/en.js +0 -109
  867. package/node_modules/zod/v3/package.json +0 -7
  868. package/node_modules/zod/v3/standard-schema.cjs +0 -2
  869. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  870. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  871. package/node_modules/zod/v3/standard-schema.js +0 -1
  872. package/node_modules/zod/v3/types.cjs +0 -3777
  873. package/node_modules/zod/v3/types.d.cts +0 -1034
  874. package/node_modules/zod/v3/types.d.ts +0 -1034
  875. package/node_modules/zod/v3/types.js +0 -3695
  876. package/node_modules/zod/v4/classic/checks.cjs +0 -33
  877. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  878. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  879. package/node_modules/zod/v4/classic/checks.js +0 -1
  880. package/node_modules/zod/v4/classic/coerce.cjs +0 -47
  881. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  882. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  883. package/node_modules/zod/v4/classic/coerce.js +0 -17
  884. package/node_modules/zod/v4/classic/compat.cjs +0 -61
  885. package/node_modules/zod/v4/classic/compat.d.cts +0 -50
  886. package/node_modules/zod/v4/classic/compat.d.ts +0 -50
  887. package/node_modules/zod/v4/classic/compat.js +0 -31
  888. package/node_modules/zod/v4/classic/errors.cjs +0 -74
  889. package/node_modules/zod/v4/classic/errors.d.cts +0 -30
  890. package/node_modules/zod/v4/classic/errors.d.ts +0 -30
  891. package/node_modules/zod/v4/classic/errors.js +0 -48
  892. package/node_modules/zod/v4/classic/external.cjs +0 -73
  893. package/node_modules/zod/v4/classic/external.d.cts +0 -16
  894. package/node_modules/zod/v4/classic/external.d.ts +0 -16
  895. package/node_modules/zod/v4/classic/external.js +0 -20
  896. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -625
  897. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  898. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  899. package/node_modules/zod/v4/classic/from-json-schema.js +0 -599
  900. package/node_modules/zod/v4/classic/index.cjs +0 -33
  901. package/node_modules/zod/v4/classic/index.d.cts +0 -4
  902. package/node_modules/zod/v4/classic/index.d.ts +0 -4
  903. package/node_modules/zod/v4/classic/index.js +0 -4
  904. package/node_modules/zod/v4/classic/iso.cjs +0 -60
  905. package/node_modules/zod/v4/classic/iso.d.cts +0 -22
  906. package/node_modules/zod/v4/classic/iso.d.ts +0 -22
  907. package/node_modules/zod/v4/classic/iso.js +0 -30
  908. package/node_modules/zod/v4/classic/package.json +0 -7
  909. package/node_modules/zod/v4/classic/parse.cjs +0 -41
  910. package/node_modules/zod/v4/classic/parse.d.cts +0 -31
  911. package/node_modules/zod/v4/classic/parse.d.ts +0 -31
  912. package/node_modules/zod/v4/classic/parse.js +0 -15
  913. package/node_modules/zod/v4/classic/schemas.cjs +0 -1511
  914. package/node_modules/zod/v4/classic/schemas.d.cts +0 -767
  915. package/node_modules/zod/v4/classic/schemas.d.ts +0 -767
  916. package/node_modules/zod/v4/classic/schemas.js +0 -1395
  917. package/node_modules/zod/v4/core/api.cjs +0 -1227
  918. package/node_modules/zod/v4/core/api.d.cts +0 -325
  919. package/node_modules/zod/v4/core/api.d.ts +0 -325
  920. package/node_modules/zod/v4/core/api.js +0 -1087
  921. package/node_modules/zod/v4/core/checks.cjs +0 -601
  922. package/node_modules/zod/v4/core/checks.d.cts +0 -278
  923. package/node_modules/zod/v4/core/checks.d.ts +0 -278
  924. package/node_modules/zod/v4/core/checks.js +0 -575
  925. package/node_modules/zod/v4/core/core.cjs +0 -85
  926. package/node_modules/zod/v4/core/core.d.cts +0 -70
  927. package/node_modules/zod/v4/core/core.d.ts +0 -70
  928. package/node_modules/zod/v4/core/core.js +0 -78
  929. package/node_modules/zod/v4/core/doc.cjs +0 -39
  930. package/node_modules/zod/v4/core/doc.d.cts +0 -14
  931. package/node_modules/zod/v4/core/doc.d.ts +0 -14
  932. package/node_modules/zod/v4/core/doc.js +0 -35
  933. package/node_modules/zod/v4/core/errors.cjs +0 -216
  934. package/node_modules/zod/v4/core/errors.d.cts +0 -221
  935. package/node_modules/zod/v4/core/errors.d.ts +0 -221
  936. package/node_modules/zod/v4/core/errors.js +0 -185
  937. package/node_modules/zod/v4/core/index.cjs +0 -47
  938. package/node_modules/zod/v4/core/index.d.cts +0 -16
  939. package/node_modules/zod/v4/core/index.d.ts +0 -16
  940. package/node_modules/zod/v4/core/index.js +0 -16
  941. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -99
  942. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  943. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  944. package/node_modules/zod/v4/core/json-schema-generator.js +0 -95
  945. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -644
  946. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -49
  947. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -49
  948. package/node_modules/zod/v4/core/json-schema-processors.js +0 -601
  949. package/node_modules/zod/v4/core/json-schema.cjs +0 -2
  950. package/node_modules/zod/v4/core/json-schema.d.cts +0 -88
  951. package/node_modules/zod/v4/core/json-schema.d.ts +0 -88
  952. package/node_modules/zod/v4/core/json-schema.js +0 -1
  953. package/node_modules/zod/v4/core/package.json +0 -7
  954. package/node_modules/zod/v4/core/parse.cjs +0 -131
  955. package/node_modules/zod/v4/core/parse.d.cts +0 -49
  956. package/node_modules/zod/v4/core/parse.d.ts +0 -49
  957. package/node_modules/zod/v4/core/parse.js +0 -93
  958. package/node_modules/zod/v4/core/regexes.cjs +0 -172
  959. package/node_modules/zod/v4/core/regexes.d.cts +0 -85
  960. package/node_modules/zod/v4/core/regexes.d.ts +0 -85
  961. package/node_modules/zod/v4/core/regexes.js +0 -139
  962. package/node_modules/zod/v4/core/registries.cjs +0 -56
  963. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  964. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  965. package/node_modules/zod/v4/core/registries.js +0 -51
  966. package/node_modules/zod/v4/core/schemas.cjs +0 -2270
  967. package/node_modules/zod/v4/core/schemas.d.cts +0 -1184
  968. package/node_modules/zod/v4/core/schemas.d.ts +0 -1184
  969. package/node_modules/zod/v4/core/schemas.js +0 -2239
  970. package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  971. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  972. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  973. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  974. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -457
  975. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -114
  976. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -114
  977. package/node_modules/zod/v4/core/to-json-schema.js +0 -448
  978. package/node_modules/zod/v4/core/util.cjs +0 -734
  979. package/node_modules/zod/v4/core/util.d.cts +0 -200
  980. package/node_modules/zod/v4/core/util.d.ts +0 -200
  981. package/node_modules/zod/v4/core/util.js +0 -674
  982. package/node_modules/zod/v4/core/versions.cjs +0 -8
  983. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  984. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  985. package/node_modules/zod/v4/core/versions.js +0 -5
  986. package/node_modules/zod/v4/index.cjs +0 -22
  987. package/node_modules/zod/v4/index.d.cts +0 -3
  988. package/node_modules/zod/v4/index.d.ts +0 -3
  989. package/node_modules/zod/v4/index.js +0 -3
  990. package/node_modules/zod/v4/locales/ar.cjs +0 -133
  991. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  992. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  993. package/node_modules/zod/v4/locales/ar.js +0 -106
  994. package/node_modules/zod/v4/locales/az.cjs +0 -132
  995. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  996. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  997. package/node_modules/zod/v4/locales/az.js +0 -105
  998. package/node_modules/zod/v4/locales/be.cjs +0 -183
  999. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  1000. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  1001. package/node_modules/zod/v4/locales/be.js +0 -156
  1002. package/node_modules/zod/v4/locales/bg.cjs +0 -147
  1003. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  1004. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  1005. package/node_modules/zod/v4/locales/bg.js +0 -120
  1006. package/node_modules/zod/v4/locales/ca.cjs +0 -134
  1007. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  1008. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  1009. package/node_modules/zod/v4/locales/ca.js +0 -107
  1010. package/node_modules/zod/v4/locales/cs.cjs +0 -138
  1011. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  1012. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  1013. package/node_modules/zod/v4/locales/cs.js +0 -111
  1014. package/node_modules/zod/v4/locales/da.cjs +0 -142
  1015. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  1016. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  1017. package/node_modules/zod/v4/locales/da.js +0 -115
  1018. package/node_modules/zod/v4/locales/de.cjs +0 -135
  1019. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  1020. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  1021. package/node_modules/zod/v4/locales/de.js +0 -108
  1022. package/node_modules/zod/v4/locales/el.cjs +0 -136
  1023. package/node_modules/zod/v4/locales/el.d.cts +0 -5
  1024. package/node_modules/zod/v4/locales/el.d.ts +0 -4
  1025. package/node_modules/zod/v4/locales/el.js +0 -109
  1026. package/node_modules/zod/v4/locales/en.cjs +0 -140
  1027. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  1028. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  1029. package/node_modules/zod/v4/locales/en.js +0 -113
  1030. package/node_modules/zod/v4/locales/eo.cjs +0 -136
  1031. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  1032. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  1033. package/node_modules/zod/v4/locales/eo.js +0 -109
  1034. package/node_modules/zod/v4/locales/es.cjs +0 -159
  1035. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  1036. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  1037. package/node_modules/zod/v4/locales/es.js +0 -132
  1038. package/node_modules/zod/v4/locales/fa.cjs +0 -141
  1039. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  1040. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  1041. package/node_modules/zod/v4/locales/fa.js +0 -114
  1042. package/node_modules/zod/v4/locales/fi.cjs +0 -139
  1043. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  1044. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  1045. package/node_modules/zod/v4/locales/fi.js +0 -112
  1046. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -134
  1047. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  1048. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  1049. package/node_modules/zod/v4/locales/fr-CA.js +0 -107
  1050. package/node_modules/zod/v4/locales/fr.cjs +0 -152
  1051. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  1052. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  1053. package/node_modules/zod/v4/locales/fr.js +0 -125
  1054. package/node_modules/zod/v4/locales/he.cjs +0 -241
  1055. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  1056. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  1057. package/node_modules/zod/v4/locales/he.js +0 -214
  1058. package/node_modules/zod/v4/locales/hr.cjs +0 -149
  1059. package/node_modules/zod/v4/locales/hr.d.cts +0 -5
  1060. package/node_modules/zod/v4/locales/hr.d.ts +0 -4
  1061. package/node_modules/zod/v4/locales/hr.js +0 -122
  1062. package/node_modules/zod/v4/locales/hu.cjs +0 -135
  1063. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  1064. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  1065. package/node_modules/zod/v4/locales/hu.js +0 -108
  1066. package/node_modules/zod/v4/locales/hy.cjs +0 -174
  1067. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  1068. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  1069. package/node_modules/zod/v4/locales/hy.js +0 -147
  1070. package/node_modules/zod/v4/locales/id.cjs +0 -133
  1071. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  1072. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  1073. package/node_modules/zod/v4/locales/id.js +0 -106
  1074. package/node_modules/zod/v4/locales/index.cjs +0 -111
  1075. package/node_modules/zod/v4/locales/index.d.cts +0 -52
  1076. package/node_modules/zod/v4/locales/index.d.ts +0 -52
  1077. package/node_modules/zod/v4/locales/index.js +0 -52
  1078. package/node_modules/zod/v4/locales/is.cjs +0 -136
  1079. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  1080. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  1081. package/node_modules/zod/v4/locales/is.js +0 -109
  1082. package/node_modules/zod/v4/locales/it.cjs +0 -135
  1083. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  1084. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  1085. package/node_modules/zod/v4/locales/it.js +0 -108
  1086. package/node_modules/zod/v4/locales/ja.cjs +0 -134
  1087. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  1088. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  1089. package/node_modules/zod/v4/locales/ja.js +0 -107
  1090. package/node_modules/zod/v4/locales/ka.cjs +0 -139
  1091. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  1092. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  1093. package/node_modules/zod/v4/locales/ka.js +0 -112
  1094. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  1095. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  1096. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  1097. package/node_modules/zod/v4/locales/kh.js +0 -5
  1098. package/node_modules/zod/v4/locales/km.cjs +0 -137
  1099. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  1100. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  1101. package/node_modules/zod/v4/locales/km.js +0 -110
  1102. package/node_modules/zod/v4/locales/ko.cjs +0 -138
  1103. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  1104. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  1105. package/node_modules/zod/v4/locales/ko.js +0 -111
  1106. package/node_modules/zod/v4/locales/lt.cjs +0 -230
  1107. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  1108. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  1109. package/node_modules/zod/v4/locales/lt.js +0 -203
  1110. package/node_modules/zod/v4/locales/mk.cjs +0 -136
  1111. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  1112. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  1113. package/node_modules/zod/v4/locales/mk.js +0 -109
  1114. package/node_modules/zod/v4/locales/ms.cjs +0 -134
  1115. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  1116. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  1117. package/node_modules/zod/v4/locales/ms.js +0 -107
  1118. package/node_modules/zod/v4/locales/nl.cjs +0 -137
  1119. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  1120. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  1121. package/node_modules/zod/v4/locales/nl.js +0 -110
  1122. package/node_modules/zod/v4/locales/no.cjs +0 -135
  1123. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  1124. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  1125. package/node_modules/zod/v4/locales/no.js +0 -108
  1126. package/node_modules/zod/v4/locales/ota.cjs +0 -136
  1127. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  1128. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  1129. package/node_modules/zod/v4/locales/ota.js +0 -109
  1130. package/node_modules/zod/v4/locales/package.json +0 -7
  1131. package/node_modules/zod/v4/locales/pl.cjs +0 -136
  1132. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  1133. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  1134. package/node_modules/zod/v4/locales/pl.js +0 -109
  1135. package/node_modules/zod/v4/locales/ps.cjs +0 -141
  1136. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  1137. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  1138. package/node_modules/zod/v4/locales/ps.js +0 -114
  1139. package/node_modules/zod/v4/locales/pt.cjs +0 -135
  1140. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  1141. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  1142. package/node_modules/zod/v4/locales/pt.js +0 -108
  1143. package/node_modules/zod/v4/locales/ro.cjs +0 -146
  1144. package/node_modules/zod/v4/locales/ro.d.cts +0 -5
  1145. package/node_modules/zod/v4/locales/ro.d.ts +0 -4
  1146. package/node_modules/zod/v4/locales/ro.js +0 -119
  1147. package/node_modules/zod/v4/locales/ru.cjs +0 -183
  1148. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  1149. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  1150. package/node_modules/zod/v4/locales/ru.js +0 -156
  1151. package/node_modules/zod/v4/locales/sl.cjs +0 -136
  1152. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  1153. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  1154. package/node_modules/zod/v4/locales/sl.js +0 -109
  1155. package/node_modules/zod/v4/locales/sv.cjs +0 -137
  1156. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  1157. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  1158. package/node_modules/zod/v4/locales/sv.js +0 -110
  1159. package/node_modules/zod/v4/locales/ta.cjs +0 -137
  1160. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  1161. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  1162. package/node_modules/zod/v4/locales/ta.js +0 -110
  1163. package/node_modules/zod/v4/locales/th.cjs +0 -137
  1164. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  1165. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  1166. package/node_modules/zod/v4/locales/th.js +0 -110
  1167. package/node_modules/zod/v4/locales/tr.cjs +0 -132
  1168. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  1169. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  1170. package/node_modules/zod/v4/locales/tr.js +0 -105
  1171. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  1172. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  1173. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  1174. package/node_modules/zod/v4/locales/ua.js +0 -5
  1175. package/node_modules/zod/v4/locales/uk.cjs +0 -135
  1176. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  1177. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  1178. package/node_modules/zod/v4/locales/uk.js +0 -108
  1179. package/node_modules/zod/v4/locales/ur.cjs +0 -137
  1180. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  1181. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  1182. package/node_modules/zod/v4/locales/ur.js +0 -110
  1183. package/node_modules/zod/v4/locales/uz.cjs +0 -137
  1184. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  1185. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  1186. package/node_modules/zod/v4/locales/uz.js +0 -110
  1187. package/node_modules/zod/v4/locales/vi.cjs +0 -135
  1188. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  1189. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  1190. package/node_modules/zod/v4/locales/vi.js +0 -108
  1191. package/node_modules/zod/v4/locales/yo.cjs +0 -134
  1192. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  1193. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  1194. package/node_modules/zod/v4/locales/yo.js +0 -107
  1195. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -136
  1196. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  1197. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  1198. package/node_modules/zod/v4/locales/zh-CN.js +0 -109
  1199. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -134
  1200. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  1201. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  1202. package/node_modules/zod/v4/locales/zh-TW.js +0 -107
  1203. package/node_modules/zod/v4/mini/checks.cjs +0 -34
  1204. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  1205. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  1206. package/node_modules/zod/v4/mini/checks.js +0 -1
  1207. package/node_modules/zod/v4/mini/coerce.cjs +0 -52
  1208. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  1209. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  1210. package/node_modules/zod/v4/mini/coerce.js +0 -22
  1211. package/node_modules/zod/v4/mini/external.cjs +0 -63
  1212. package/node_modules/zod/v4/mini/external.d.cts +0 -13
  1213. package/node_modules/zod/v4/mini/external.d.ts +0 -13
  1214. package/node_modules/zod/v4/mini/external.js +0 -14
  1215. package/node_modules/zod/v4/mini/index.cjs +0 -32
  1216. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  1217. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  1218. package/node_modules/zod/v4/mini/index.js +0 -3
  1219. package/node_modules/zod/v4/mini/iso.cjs +0 -64
  1220. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  1221. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  1222. package/node_modules/zod/v4/mini/iso.js +0 -34
  1223. package/node_modules/zod/v4/mini/package.json +0 -7
  1224. package/node_modules/zod/v4/mini/parse.cjs +0 -16
  1225. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  1226. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  1227. package/node_modules/zod/v4/mini/parse.js +0 -1
  1228. package/node_modules/zod/v4/mini/schemas.cjs +0 -1083
  1229. package/node_modules/zod/v4/mini/schemas.d.cts +0 -445
  1230. package/node_modules/zod/v4/mini/schemas.d.ts +0 -445
  1231. package/node_modules/zod/v4/mini/schemas.js +0 -961
  1232. package/node_modules/zod/v4/package.json +0 -7
  1233. package/node_modules/zod/v4-mini/index.cjs +0 -32
  1234. package/node_modules/zod/v4-mini/index.d.cts +0 -3
  1235. package/node_modules/zod/v4-mini/index.d.ts +0 -3
  1236. package/node_modules/zod/v4-mini/index.js +0 -3
  1237. package/node_modules/zod/v4-mini/package.json +0 -7
package/dist/index.js CHANGED
@@ -1,2548 +1,41 @@
1
- import {
2
- resolvePublicFilePath,
3
- servePublicFile
4
- } from "./chunk-SMN75YED.js";
5
- import {
6
- registerOpenAPITools
7
- } from "./chunk-AATFAERC.js";
8
- import {
9
- completable,
10
- normalizeCompletions
11
- } from "./chunk-KIZ72TIK.js";
12
- import {
13
- synthesizeViewDocument
14
- } from "./chunk-STCR3P5O.js";
15
- import {
16
- hasExplicitAssetsBase,
17
- originFromAssetsBase,
18
- resolveAssetsBase,
19
- resolveServerOrigin
20
- } from "./chunk-FC2Z2VFO.js";
21
- import {
22
- authInfoFromRequest,
23
- getOAuthProtectedResourceMetadataUrl,
24
- oauthMetadata,
25
- requireBearerAuth
26
- } from "./chunk-Z326HADF.js";
27
- import {
28
- composeFetch,
29
- getRequestBag,
30
- hostValidationMiddleware,
31
- isHtmlNavigationRequest,
32
- jsonBodyMiddleware,
33
- matchesPath,
34
- matchesPathPrefix,
35
- originValidationMiddleware,
36
- pathUnderBase,
37
- pathnameOf,
38
- routeFetch,
39
- toFrameworkHandler
40
- } from "./chunk-QUUANIE4.js";
41
- import {
42
- getOAuthProviderOptions,
43
- resolveConfiguredOAuthResource,
44
- resolveLocalOAuthResource,
45
- wrapOAuthTokenVerifier
46
- } from "./chunk-DPL7OEXC.js";
47
-
48
- // src/server.ts
49
- import {
50
- localhostAllowedHostnames,
51
- localhostAllowedOrigins,
52
- McpServer as SdkMcpServer,
53
- ResourceTemplate,
54
- isInputRequiredResult
55
- } from "@modelcontextprotocol/server";
56
-
57
- // src/branding.ts
58
- var FAVICON_CACHE_CONTROL = "public, max-age=31536000, immutable";
59
- var FAVICON_REDIRECT_CACHE_CONTROL = "public, max-age=300";
60
- function protocolOf(value) {
61
- const match = /^([a-z][a-z\d+.-]*):/i.exec(value);
62
- return match?.[1]?.toLowerCase();
63
- }
64
- function publicAssetPath(basePath, source) {
65
- const prefix = basePath === "/" ? "" : basePath;
66
- return `${prefix}/_mcp-use/public/${source.split("/").map((segment) => encodeURIComponent(segment)).join("/")}`;
67
- }
68
- function isLocalPublicSource(source) {
69
- return protocolOf(source) === void 0;
70
- }
71
- function extensionPath(source) {
72
- const protocol = protocolOf(source);
73
- if (protocol === "data") {
74
- return "";
75
- }
76
- if (protocol === "http" || protocol === "https") {
77
- return new URL(source).pathname.toLowerCase();
78
- }
79
- return source.toLowerCase();
80
- }
81
- function dataUrlMimeType(source) {
82
- if (protocolOf(source) !== "data") {
83
- return void 0;
84
- }
85
- const comma = source.indexOf(",");
86
- if (comma < 0) {
87
- return void 0;
88
- }
89
- const mimeType = source.slice(5, comma).split(";", 1)[0]?.toLowerCase();
90
- return mimeType === "" ? void 0 : mimeType;
91
- }
92
- function iconMimeType(icon) {
93
- return icon.mimeType?.toLowerCase() ?? dataUrlMimeType(icon.src);
94
- }
95
- function isIco(icon) {
96
- const mimeType = iconMimeType(icon);
97
- return mimeType === "image/x-icon" || mimeType === "image/vnd.microsoft.icon" || extensionPath(icon.src).endsWith(".ico");
98
- }
99
- function isPng(icon) {
100
- return iconMimeType(icon) === "image/png" || extensionPath(icon.src).endsWith(".png");
101
- }
102
- function selectFaviconFromIcons(icons) {
103
- return icons.find(isIco) ?? icons.find(
104
- (icon) => isPng(icon) && icon.sizes?.some((size) => size === "16x16" || size === "32x32")
105
- ) ?? icons.find(isPng) ?? icons[0];
106
- }
107
- function assertLocalPublicSource(source, field) {
108
- if (source.startsWith("/") || source.includes("\\") || source.includes("?") || source.includes("#") || source.split("/").some((segment) => segment === "" || segment === "..")) {
109
- throw new TypeError(
110
- `${field} must be an http(s) URL, image data URL, or safe path relative to public/`
111
- );
112
- }
113
- }
114
- function parseDataImage(source, field) {
115
- const comma = source.indexOf(",");
116
- if (comma < 0) {
117
- throw new TypeError(`${field} must be a valid image data URL`);
118
- }
119
- const metadata = source.slice(5, comma);
120
- const payload = source.slice(comma + 1);
121
- const parts = metadata.split(";");
122
- const mimeType = parts[0]?.toLowerCase() ?? "";
123
- if (!mimeType.startsWith("image/")) {
124
- throw new TypeError(`${field} data URL must use an image MIME type`);
125
- }
126
- try {
127
- if (parts.includes("base64")) {
128
- const binary = atob(payload);
129
- return {
130
- mimeType,
131
- bytes: Uint8Array.from(binary, (character) => character.charCodeAt(0))
132
- };
133
- }
134
- return {
135
- mimeType,
136
- bytes: new TextEncoder().encode(decodeURIComponent(payload))
137
- };
138
- } catch {
139
- throw new TypeError(`${field} must be a valid image data URL`);
140
- }
141
- }
142
- function assertBrandingSource(source, field) {
143
- if (typeof source !== "string" || source.length === 0) {
144
- throw new TypeError(`${field} must be a non-empty string`);
145
- }
146
- const protocol = protocolOf(source);
147
- if (protocol === void 0) {
148
- assertLocalPublicSource(source, field);
149
- return source;
150
- }
151
- if (protocol === "data") {
152
- parseDataImage(source, field);
153
- return source;
154
- }
155
- if (protocol !== "http" && protocol !== "https") {
156
- throw new TypeError(
157
- `${field} must be an http(s) URL, image data URL, or safe path relative to public/`
158
- );
159
- }
160
- try {
161
- new URL(source);
162
- } catch {
163
- throw new TypeError(`${field} must be a valid absolute http(s) URL`);
164
- }
165
- return source;
166
- }
167
- function normalizeServerBranding(config) {
168
- let websiteUrl;
169
- if (config.websiteUrl !== void 0) {
170
- if (typeof config.websiteUrl !== "string" || config.websiteUrl.length === 0) {
171
- throw new TypeError(
172
- "websiteUrl must be a non-empty absolute http(s) URL"
173
- );
174
- }
175
- let parsed;
176
- try {
177
- parsed = new URL(config.websiteUrl);
178
- } catch {
179
- throw new TypeError(
180
- "websiteUrl must be a non-empty absolute http(s) URL"
181
- );
182
- }
183
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
184
- throw new TypeError(
185
- "websiteUrl must be a non-empty absolute http(s) URL"
186
- );
187
- }
188
- websiteUrl = config.websiteUrl;
189
- }
190
- let icons;
191
- if (config.icons !== void 0) {
192
- if (!Array.isArray(config.icons)) {
193
- throw new TypeError("icons must be an array of MCP Icon objects");
194
- }
195
- icons = Object.freeze(
196
- config.icons.map((value, index) => {
197
- if (typeof value !== "object" || value === null) {
198
- throw new TypeError(`icons[${index}] must be an MCP Icon object`);
199
- }
200
- const icon = value;
201
- const src = assertBrandingSource(icon["src"], `icons[${index}].src`);
202
- const mimeType = icon["mimeType"];
203
- if (mimeType !== void 0 && (typeof mimeType !== "string" || !mimeType.toLowerCase().startsWith("image/"))) {
204
- throw new TypeError(
205
- `icons[${index}].mimeType must be an image MIME type when provided`
206
- );
207
- }
208
- const sizes = icon["sizes"];
209
- if (sizes !== void 0 && (!Array.isArray(sizes) || sizes.some((size) => typeof size !== "string" || size.length === 0))) {
210
- throw new TypeError(
211
- `icons[${index}].sizes must be an array of non-empty strings when provided`
212
- );
213
- }
214
- const normalizedSizes = sizes === void 0 ? void 0 : sizes.map((size) => size);
215
- const theme = icon["theme"];
216
- if (theme !== void 0 && theme !== "light" && theme !== "dark") {
217
- throw new TypeError(
218
- `icons[${index}].theme must be "light" or "dark" when provided`
219
- );
220
- }
221
- return Object.freeze({
222
- src,
223
- ...mimeType !== void 0 && { mimeType },
224
- ...normalizedSizes !== void 0 && {
225
- sizes: Object.freeze(normalizedSizes)
226
- },
227
- ...theme !== void 0 && { theme }
228
- });
229
- })
230
- );
231
- }
232
- const explicitFavicon = config.favicon === void 0 ? void 0 : assertBrandingSource(config.favicon, "favicon");
233
- const inferred = explicitFavicon === void 0 ? selectFaviconFromIcons(icons ?? []) : void 0;
234
- const favicon = explicitFavicon ?? inferred?.src;
235
- const faviconMimeType = inferred?.mimeType ?? icons?.find((icon) => icon.src === explicitFavicon)?.mimeType;
236
- return Object.freeze({
237
- ...favicon !== void 0 && { favicon },
238
- ...faviconMimeType !== void 0 && { faviconMimeType },
239
- ...icons !== void 0 && { icons },
240
- ...websiteUrl !== void 0 && { websiteUrl }
241
- });
242
- }
243
- function resolveImplementationIcons(icons, request, basePath) {
244
- if (icons === void 0) {
245
- return void 0;
246
- }
247
- return icons.map((icon) => ({
248
- ...icon,
249
- src: request !== void 0 && isLocalPublicSource(icon.src) ? `${resolveAssetsBase(request)}${publicAssetPath(basePath, icon.src)}` : icon.src,
250
- ...icon.sizes !== void 0 && { sizes: [...icon.sizes] }
251
- }));
252
- }
253
- function hasLocalBrandingAsset(branding) {
254
- return branding.favicon !== void 0 && isLocalPublicSource(branding.favicon) || branding.icons?.some((icon) => isLocalPublicSource(icon.src)) === true;
255
- }
256
- function createFaviconHandler(branding, options) {
257
- const source = branding.favicon;
258
- if (source === void 0) {
259
- return void 0;
260
- }
261
- return async (request) => {
262
- if (request.method !== "GET" && request.method !== "HEAD") {
263
- return new Response("Method Not Allowed", {
264
- status: 405,
265
- headers: { Allow: "GET, HEAD" }
266
- });
267
- }
268
- if (new URL(request.url).pathname !== "/favicon.ico") {
269
- return new Response("Not Found", { status: 404 });
270
- }
271
- const protocol = protocolOf(source);
272
- if (protocol === "http" || protocol === "https") {
273
- return new Response(null, {
274
- status: 307,
275
- headers: {
276
- Location: source,
277
- "Cache-Control": FAVICON_REDIRECT_CACHE_CONTROL
278
- }
279
- });
280
- }
281
- if (protocol === "data") {
282
- const data = parseDataImage(source, "favicon");
283
- return new Response(
284
- request.method === "HEAD" ? null : data.bytes.buffer,
285
- {
286
- status: 200,
287
- headers: {
288
- "Content-Type": branding.faviconMimeType ?? data.mimeType,
289
- "Cache-Control": FAVICON_CACHE_CONTROL,
290
- "X-Content-Type-Options": "nosniff"
291
- }
292
- }
293
- );
294
- }
295
- const { join } = await import("path");
296
- const publicRoot = options.dev ? join(options.projectRoot, "public") : join(options.projectRoot, ".mcp-use/build/views/public");
297
- const diskPath = await resolvePublicFilePath(publicRoot, source);
298
- if (diskPath === null) {
299
- return new Response("Not Found", {
300
- status: 404,
301
- headers: { "Cache-Control": "no-store" }
302
- });
303
- }
304
- const response = await servePublicFile(diskPath, {
305
- ...options.deferCors === true && { deferCors: true },
306
- ...request.method === "HEAD" && { head: true }
307
- });
308
- response.headers.set("Cache-Control", FAVICON_CACHE_CONTROL);
309
- response.headers.set("X-Content-Type-Options", "nosniff");
310
- if (branding.faviconMimeType !== void 0) {
311
- response.headers.set("Content-Type", branding.faviconMimeType);
312
- }
313
- return response;
314
- };
315
- }
316
-
317
- // src/config.ts
318
- function assertServerConfig(config) {
319
- if (config.basePath !== void 0) {
320
- if (typeof config.basePath !== "string") {
321
- throw new TypeError(
322
- "basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace"
323
- );
324
- }
325
- const { basePath } = config;
326
- if (!basePath.startsWith("/") || basePath.includes("?") || basePath.includes("#") || /\s/.test(basePath) || basePath.includes("//") || basePath.length > 1 && basePath.endsWith("/")) {
327
- throw new TypeError(
328
- "basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace"
329
- );
330
- }
331
- }
332
- }
333
-
334
- // src/context.ts
335
- import {
336
- CLIENT_CAPABILITIES_META_KEY as CLIENT_CAPABILITIES_META_KEY2,
337
- inputRequired,
338
- inputResponse
339
- } from "@modelcontextprotocol/server";
340
-
341
- // src/views/capabilities.ts
342
- import {
343
- CLIENT_CAPABILITIES_META_KEY
344
- } from "@modelcontextprotocol/server";
345
-
346
- // src/views/constants.ts
347
- var UI_EXTENSION_ID = "io.modelcontextprotocol/ui";
348
- var UI_MIME_TYPE = "text/html;profile=mcp-app";
349
- var UI_RESOURCE_URI_PREFIX = "ui://views/";
350
- var UI_META_KEY = "ui";
351
- var UI_RESOURCE_URI_META_KEY = "ui/resourceUri";
352
- function viewResourceUri(viewName) {
353
- return `${UI_RESOURCE_URI_PREFIX}${viewName}.html`;
354
- }
355
-
356
- // src/views/capabilities.ts
357
- var clientCapabilitiesByRequest = /* @__PURE__ */ new WeakMap();
358
- function stashClientCapabilities(request, capabilities) {
359
- clientCapabilitiesByRequest.set(request, capabilities);
360
- }
361
- function extractClientCapabilitiesFromBody(body) {
362
- if (typeof body !== "object" || body === null) {
363
- return void 0;
364
- }
365
- const params = body["params"];
366
- if (typeof params !== "object" || params === null) {
367
- return void 0;
368
- }
369
- const meta = params["_meta"];
370
- if (typeof meta !== "object" || meta === null) {
371
- return void 0;
372
- }
373
- const capabilities = meta[CLIENT_CAPABILITIES_META_KEY];
374
- if (typeof capabilities !== "object" || capabilities === null) {
375
- return void 0;
376
- }
377
- return capabilities;
378
- }
379
- function supportsViews(capabilities) {
380
- const extensions = capabilities?.extensions;
381
- if (extensions === void 0) {
382
- return false;
383
- }
384
- const uiExtension = extensions[UI_EXTENSION_ID];
385
- if (typeof uiExtension !== "object" || uiExtension === null) {
386
- return false;
387
- }
388
- const mimeTypes = uiExtension["mimeTypes"];
389
- if (!Array.isArray(mimeTypes)) {
390
- return false;
391
- }
392
- return mimeTypes.includes(UI_MIME_TYPE);
393
- }
394
-
395
- // src/context.ts
396
- function requireOAuthAuthInfo(authInfo) {
397
- if (authInfo === void 0 || authInfo.extra === void 0 || authInfo.expiresAt === void 0) {
398
- throw new Error("OAuth callback did not receive mapped AuthInfo.extra");
399
- }
400
- }
401
- function toClientContext(ctx) {
402
- const envelopeCaps = ctx.mcpReq.envelope?.[CLIENT_CAPABILITIES_META_KEY2];
403
- return {
404
- supportsViews() {
405
- return supportsViews(envelopeCaps);
406
- }
407
- };
408
- }
409
- function createElicit(inputResponses) {
410
- return async function elicit(key, message, schemaOrUrl) {
411
- let request;
412
- let formSchema;
413
- if (typeof schemaOrUrl === "string") {
414
- request = inputRequired.elicitUrl({
415
- message,
416
- url: schemaOrUrl
417
- });
418
- } else if (schemaOrUrl !== void 0) {
419
- formSchema = schemaOrUrl;
420
- request = inputRequired.elicit({
421
- message,
422
- requestedSchema: schemaOrUrl
423
- });
424
- } else {
425
- throw new TypeError(
426
- "ctx.elicit(key, message, value) requires a form schema or URL string"
427
- );
428
- }
429
- const response = inputResponse(inputResponses, key);
430
- if (response.kind === "elicit") {
431
- if (response.action !== "accept") {
432
- return { status: response.action };
433
- }
434
- if (formSchema === void 0) {
435
- return { status: "accept" };
436
- }
437
- if (response.content !== void 0) {
438
- const outcome = await formSchema["~standard"].validate(
439
- response.content
440
- );
441
- if (outcome.issues === void 0) {
442
- return { status: "accept", data: outcome.value };
443
- }
444
- }
445
- }
446
- return {
447
- status: "required",
448
- result: inputRequired({ inputRequests: { [key]: request } })
449
- };
450
- };
451
- }
452
- function toRequestContext(ctx) {
453
- const request = ctx.http?.req;
454
- return {
455
- signal: ctx.mcpReq.signal,
456
- ...request !== void 0 && { request },
457
- ...ctx.mcpReq.inputResponses !== void 0 && {
458
- inputResponses: ctx.mcpReq.inputResponses
459
- },
460
- client: toClientContext(ctx),
461
- elicit: createElicit(ctx.mcpReq.inputResponses),
462
- requestState: () => ctx.mcpReq.requestState(),
463
- async reportProgress(progress, total, message) {
464
- const progressToken = ctx.mcpReq._meta?.progressToken;
465
- if (progressToken === void 0) return false;
466
- await ctx.mcpReq.notify({
467
- method: "notifications/progress",
468
- params: {
469
- progressToken,
470
- progress,
471
- ...total !== void 0 && { total },
472
- ...message !== void 0 && { message }
473
- }
474
- });
475
- return true;
476
- },
477
- async sendLog(level, data, logger) {
478
- await ctx.mcpReq.notify({
479
- method: "notifications/message",
480
- params: {
481
- level,
482
- data,
483
- ...logger !== void 0 && { logger }
484
- }
485
- });
486
- }
487
- };
488
- }
489
- function toAuthenticatedRequestContext(ctx) {
490
- const authInfo = ctx.http?.authInfo;
491
- requireOAuthAuthInfo(authInfo);
492
- return {
493
- ...toRequestContext(ctx),
494
- auth: {
495
- user: authInfo.extra.user,
496
- payload: authInfo.extra.payload,
497
- accessToken: authInfo.token,
498
- scopes: [...authInfo.scopes],
499
- permissions: [...authInfo.extra.permissions],
500
- ...authInfo.clientId.length > 0 && { clientId: authInfo.clientId },
501
- expiresAt: authInfo.expiresAt,
502
- ...authInfo.resource !== void 0 && { resource: authInfo.resource }
503
- }
504
- };
505
- }
506
-
507
- // src/middleware/cors.ts
508
- var DEFAULT_METHODS = ["GET", "HEAD", "POST", "OPTIONS"];
509
- var DEFAULT_ALLOWED_HEADERS = [
510
- "Content-Type",
511
- "Authorization",
512
- "mcp-protocol-version",
513
- "mcp-method",
514
- "mcp-name"
515
- ];
516
- function resolveAllowedOrigin(origin, requestOrigin) {
517
- if (origin === void 0) {
518
- return requestOrigin;
519
- }
520
- if (typeof origin === "function") {
521
- return origin(requestOrigin);
522
- }
523
- if (origin === "*") {
524
- return "*";
525
- }
526
- if (Array.isArray(origin)) {
527
- if (requestOrigin !== null && origin.includes(requestOrigin)) {
528
- return requestOrigin;
529
- }
530
- return null;
531
- }
532
- return origin;
533
- }
534
- function corsHeaders(options, request) {
535
- if (request.headers.has("Access-Control-Allow-Origin")) {
536
- return void 0;
537
- }
538
- const requestOrigin = request.headers.get("Origin");
539
- const allowedOrigin = resolveAllowedOrigin(options.origin, requestOrigin);
540
- if (allowedOrigin === null) {
541
- return void 0;
542
- }
543
- const headers = {
544
- "Access-Control-Allow-Origin": allowedOrigin,
545
- "Access-Control-Allow-Methods": options.methods.join(", "),
546
- "Access-Control-Allow-Headers": options.allowedHeaders.join(", ")
547
- };
548
- if (options.credentials) {
549
- headers["Access-Control-Allow-Credentials"] = "true";
550
- }
551
- if (allowedOrigin !== "*") {
552
- headers.Vary = "Origin";
553
- }
554
- return headers;
555
- }
556
- function mergeCorsHeaders(response, headers) {
557
- if (response.headers.has("Access-Control-Allow-Origin")) {
558
- return response;
559
- }
560
- const merged = new Headers(response.headers);
561
- const corsHeaders2 = new Headers(headers);
562
- corsHeaders2.forEach((value, key) => {
563
- merged.set(key, value);
564
- });
565
- return new Response(response.body, {
566
- status: response.status,
567
- statusText: response.statusText,
568
- headers: merged
569
- });
570
- }
571
- function corsFetchMiddleware(options) {
572
- const enabled = options.enabled !== false;
573
- if (!enabled) {
574
- return async (_request, next) => next();
575
- }
576
- const resolved = {
577
- ...options.origin !== void 0 && { origin: options.origin },
578
- methods: options.methods ?? DEFAULT_METHODS,
579
- allowedHeaders: options.allowedHeaders ?? DEFAULT_ALLOWED_HEADERS,
580
- credentials: options.credentials ?? false
581
- };
582
- return async (request, next) => {
583
- const headers = corsHeaders(resolved, request);
584
- if (headers === void 0) {
585
- return next();
586
- }
587
- if (request.method === "OPTIONS") {
588
- return new Response(null, { status: 204, headers });
589
- }
590
- const response = await next();
591
- return mergeCorsHeaders(response, headers);
592
- };
593
- }
594
- function isGlobalCorsEnabled(cors) {
595
- return cors !== void 0 && cors.enabled !== false;
596
- }
597
-
598
- // src/middleware/mcp-middleware.ts
599
- function matchesPattern(pattern, method) {
600
- if (pattern === "*") return true;
601
- if (pattern.endsWith("/*")) {
602
- const prefix = pattern.slice(0, -1);
603
- return method.startsWith(prefix);
604
- }
605
- return pattern === method;
606
- }
607
- function composeMiddleware(entries, method, innerFn) {
608
- const matching = entries.filter((e) => matchesPattern(e.pattern, method));
609
- if (matching.length === 0) {
610
- return (_ctx) => innerFn();
611
- }
612
- return (ctx) => {
613
- let index = -1;
614
- const dispatch = (i) => {
615
- if (i <= index) {
616
- return Promise.reject(new Error("next() called multiple times"));
617
- }
618
- index = i;
619
- if (i === matching.length) {
620
- return innerFn();
621
- }
622
- const entry = matching[i];
623
- return entry.handler(ctx, () => dispatch(i + 1));
624
- };
625
- return dispatch(0);
626
- };
627
- }
628
- function freezeMiddlewareContext(ctx) {
629
- return Object.freeze({
630
- method: ctx.method,
631
- params: Object.freeze({ ...ctx.params }),
632
- ...ctx.auth !== void 0 && { auth: ctx.auth },
633
- state: ctx.state
634
- });
635
- }
636
- async function runMcpOperation(middlewares, events, method, ctx, innerFn) {
637
- dispatchMcpEvents(events, method, "before", ctx);
638
- const chained = composeMiddleware(middlewares, method, innerFn);
639
- const result = await chained(ctx);
640
- dispatchMcpEvents(events, method, "complete", ctx, result);
641
- return result;
642
- }
643
- function dispatchMcpEvents(events, method, phase, ctx, result) {
644
- const frozen = freezeMiddlewareContext(ctx);
645
- for (const entry of events) {
646
- if (entry.phase !== phase || !matchesPattern(entry.pattern, method)) {
647
- continue;
648
- }
649
- try {
650
- if (phase === "before") {
651
- entry.handler(frozen);
652
- } else {
653
- entry.handler(frozen, result);
654
- }
655
- } catch (error) {
656
- console.error(
657
- `[mcp-use] MCP event listener for "${entry.pattern}" (${phase}) threw:`,
658
- error
659
- );
660
- }
661
- }
662
- }
663
- function parseMcpPattern(raw) {
664
- const pattern = raw.startsWith("mcp:") ? raw.slice(4) : raw;
665
- if (pattern.endsWith(":complete")) {
666
- return {
667
- pattern: pattern.slice(0, -":complete".length),
668
- phase: "complete"
669
- };
670
- }
671
- return { pattern, phase: "before" };
672
- }
673
- function normalizeMcpMiddlewarePattern(raw) {
674
- return raw.startsWith("mcp:") ? raw.slice(4) : raw;
675
- }
676
-
677
- // src/inspector-shell.ts
678
- var INSPECTOR_TAG = "beta";
679
- var DEFAULT_INSPECTOR_ASSETS_URL = `https://cdn.jsdelivr.net/npm/@mcp-use/inspector@${INSPECTOR_TAG}/dist/cdn/inspector.js`;
680
- function inspectorStylesUrl(assetsUrl) {
681
- return assetsUrl.replace(/\.js(?=$|[?#])/, ".css");
682
- }
683
- function isDefaultJsdelivrInspectorUrl(url) {
684
- return url.startsWith("https://cdn.jsdelivr.net/npm/@mcp-use/inspector@");
685
- }
686
- function withInspectorCacheBust(assetsUrl) {
687
- if (!isDefaultJsdelivrInspectorUrl(assetsUrl)) return assetsUrl;
688
- const sep = assetsUrl.includes("?") ? "&" : "?";
689
- return `${assetsUrl}${sep}cb=${crypto.randomUUID()}`;
690
- }
691
- function matchesInspectorShellPath(pathname, basePath) {
692
- const prefix = pathUnderBase(basePath, "inspector");
693
- if (pathname !== prefix && !pathname.startsWith(`${prefix}/`)) {
694
- return false;
695
- }
696
- const suffix = pathname.slice(prefix.length);
697
- return suffix !== "/api" && !suffix.startsWith("/api/");
698
- }
699
- function escapeHtml(value) {
700
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
701
- }
702
- function serializeForInlineScript(value) {
703
- return JSON.stringify(value).replaceAll("<", "\\u003c");
704
- }
705
- function renderInspectorShell(options) {
706
- const { serverName, basePath, faviconHref, assetsUrl, manufactChatUrl } = options;
707
- const serializedBasePath = serializeForInlineScript(basePath);
708
- const serializedManufactChatUrl = manufactChatUrl ? serializeForInlineScript(manufactChatUrl) : null;
709
- const rawUrl = assetsUrl ?? DEFAULT_INSPECTOR_ASSETS_URL;
710
- const bundleUrl = withInspectorCacheBust(rawUrl);
711
- const scriptSrc = escapeHtml(bundleUrl);
712
- const stylesHref = escapeHtml(inspectorStylesUrl(bundleUrl));
713
- return `<!doctype html>
714
- <html lang="en">
715
- <head>
716
- <meta charset="utf-8" />
717
- <meta name="viewport" content="width=device-width, initial-scale=1" />
718
- <title>${escapeHtml(serverName)} \u2014 MCP Inspector</title>
719
- ${faviconHref !== void 0 ? `<link rel="icon" href="${escapeHtml(faviconHref)}" />` : ""}
720
- <link rel="preconnect" href="https://fonts.googleapis.com" />
721
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
722
- <link
723
- href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&display=swap"
724
- rel="stylesheet"
725
- />
726
- <link rel="stylesheet" href="${stylesHref}" />
727
- <style>
728
- :root { color-scheme: light dark; }
729
- html, body { height: 100%; margin: 0; background-color: #f3f3f3; }
730
- </style>
731
- </head>
732
- <body>
733
- <div id="root"></div>
734
- <script>
735
- (function () {
736
- var basePath = ${serializedBasePath};
737
- // The connect URL is derived from the page's own origin: the server
738
- // never guesses the hostname a browser reached it by.
739
- window.__MCP_USE_INSPECTOR__ = {
740
- autoConnectUrl: window.location.origin + basePath,
741
- basePath: basePath,
742
- };
743
- // Read by the current inspector bundle to derive its own URLs.
744
- window.__MCP_BASE_PATH__ = basePath;
745
- ${serializedManufactChatUrl ? `window.__MANUFACT_CHAT_URL__ = ${serializedManufactChatUrl};` : ""}
746
- // The bundle carries Node-flavored dependencies that touch \`process\`
747
- // at module scope; give them the same browser polyfill the v1
748
- // inspector shell provides, or the bundle throws on load.
749
- if (typeof window.process === "undefined") {
750
- window.process = {
751
- env: {},
752
- platform: "browser",
753
- browser: true,
754
- version: "v18.0.0",
755
- versions: { node: "18.0.0" },
756
- cwd: function () { return "/"; },
757
- nextTick: function (fn) {
758
- var args = Array.prototype.slice.call(arguments, 1);
759
- queueMicrotask(function () { fn.apply(null, args); });
760
- },
761
- };
762
- }
763
- })();
764
- </script>
765
- <script type="module" src="${scriptSrc}"></script>
766
- </body>
767
- </html>
768
- `;
769
- }
770
- function createInspectorHandler(inspector, options) {
771
- if (inspector?.enabled === false) {
772
- return void 0;
773
- }
774
- const { assetsUrl: configAssetsUrl, manufactChatUrl: configManufactChatUrl } = inspector ?? {};
775
- const assetsUrl = configAssetsUrl ?? process.env["MCP_USE_INSPECTOR_ASSETS_URL"] ?? void 0;
776
- const manufactChatUrl = configManufactChatUrl ?? process.env["MANUFACT_CHAT_URL"] ?? void 0;
777
- const shellOptions = {
778
- serverName: options.serverName,
779
- basePath: options.basePath,
780
- ...options.faviconHref !== void 0 && {
781
- faviconHref: options.faviconHref
782
- },
783
- assetsUrl,
784
- manufactChatUrl
785
- };
786
- return async (request) => {
787
- if (request.method !== "GET" && request.method !== "HEAD") {
788
- return new Response("Method Not Allowed", { status: 405 });
789
- }
790
- const pathname = new URL(request.url).pathname;
791
- if (!matchesInspectorShellPath(pathname, options.basePath)) {
792
- return new Response("Not Found", { status: 404 });
793
- }
794
- const html = renderInspectorShell(shellOptions);
795
- return new Response(request.method === "HEAD" ? null : html, {
796
- status: 200,
797
- headers: { "content-type": "text/html; charset=utf-8" }
798
- });
799
- };
800
- }
801
-
802
- // src/logging.ts
803
- import {
804
- CLIENT_INFO_META_KEY,
805
- isJSONRPCRequest
806
- } from "@modelcontextprotocol/server";
807
- function colorsEnabled() {
808
- if (typeof process === "undefined") return false;
809
- if (process.env?.["NO_COLOR"] !== void 0) return false;
810
- return process.stdout?.isTTY === true;
811
- }
812
- function ansi(open, close) {
813
- return (text) => colorsEnabled() ? `\x1B[${open}m${text}\x1B[${close}m` : text;
814
- }
815
- var bold = ansi(1, 22);
816
- var dim = ansi(2, 22);
817
- var red = ansi(31, 39);
818
- var green = ansi(32, 39);
819
- var yellow = ansi(33, 39);
820
- var blue = ansi(34, 39);
821
- var magenta = ansi(35, 39);
822
- var cyan = ansi(36, 39);
823
- var gray = ansi(90, 39);
824
- function resolveLogLevel(configured) {
825
- const raw = typeof process === "undefined" ? void 0 : process.env?.["MCP_USE_LOG_LEVEL"]?.toLowerCase();
826
- if (raw === "info" || raw === "debug" || raw === "trace") return raw;
827
- return configured ?? "info";
828
- }
829
- function formatClientInfo(info) {
830
- if (info === void 0) return void 0;
831
- return typeof info.version === "string" && info.version !== "" ? `${info.name}/${info.version}` : info.name;
832
- }
833
- var detailFormatters = {
834
- initialize: (p) => ({ subject: formatClientInfo(p.clientInfo) }),
835
- ping: () => ({}),
836
- "server/discover": () => ({}),
837
- "completion/complete": (p) => ({
838
- subject: p.ref.type === "ref/prompt" ? p.ref.name : p.ref.uri,
839
- input: p.argument
840
- }),
841
- "logging/setLevel": (p) => ({ subject: p.level }),
842
- "prompts/get": (p) => ({ subject: p.name, input: p.arguments }),
843
- "prompts/list": () => ({}),
844
- "resources/list": () => ({}),
845
- "resources/templates/list": () => ({}),
846
- "resources/read": (p) => ({ subject: p.uri }),
847
- "resources/subscribe": (p) => ({ subject: p.uri }),
848
- "resources/unsubscribe": (p) => ({ subject: p.uri }),
849
- "subscriptions/listen": () => ({}),
850
- "tools/call": (p) => ({ subject: p.name, input: p.arguments }),
851
- "tools/list": () => ({}),
852
- "sampling/createMessage": () => ({}),
853
- "elicitation/create": () => ({}),
854
- "roots/list": () => ({})
855
- };
856
- function isKnownMethod(method) {
857
- return Object.prototype.hasOwnProperty.call(detailFormatters, method);
858
- }
859
- function formatDetail(message) {
860
- if (!isKnownMethod(message.method)) return {};
861
- try {
862
- const formatter = detailFormatters[message.method];
863
- const detail = formatter(message.params);
864
- return typeof detail.subject === "string" || detail.subject === void 0 ? detail : {};
865
- } catch {
866
- return {};
867
- }
868
- }
869
- var INLINE_JSON_MAX_LENGTH = 80;
870
- function inlineJson(value) {
871
- let text;
872
- try {
873
- text = JSON.stringify(value) ?? String(value);
874
- } catch {
875
- text = String(value);
876
- }
877
- return text.length > INLINE_JSON_MAX_LENGTH ? `${text.slice(0, INLINE_JSON_MAX_LENGTH)}...` : text;
878
- }
879
- function formatClientIdentity(message) {
880
- const meta = message.params?._meta;
881
- if (meta === void 0) return void 0;
882
- const info = meta[CLIENT_INFO_META_KEY];
883
- if (typeof info !== "object" || info === null || typeof info.name !== "string") {
884
- return void 0;
885
- }
886
- return formatClientInfo(info);
887
- }
888
- function sanitize(text) {
889
- return text.replace(/[\u0000-\u001F\u007F-\u009F]+/g, " ");
890
- }
891
- function methodStyle(method) {
892
- if (method.startsWith("tools/")) return cyan;
893
- if (method.startsWith("resources/")) return green;
894
- if (method.startsWith("prompts/")) return magenta;
895
- if (method === "initialize" || method === "ping") return gray;
896
- return blue;
897
- }
898
- var REDACTED_HEADERS = /* @__PURE__ */ new Set([
899
- "authorization",
900
- "proxy-authorization",
901
- "cookie",
902
- "set-cookie",
903
- "x-api-key"
904
- ]);
905
- function redactHeaders(headers) {
906
- return Object.fromEntries(
907
- Object.entries(headers).map(([name, value]) => [
908
- name,
909
- REDACTED_HEADERS.has(name.toLowerCase()) ? "[REDACTED]" : value
910
- ])
911
- );
912
- }
913
- async function extractResponseOutcome(res) {
914
- if (!res.body) return { errorMessage: null };
915
- let text;
916
- try {
917
- text = await res.clone().text();
918
- } catch {
919
- return { errorMessage: null };
920
- }
921
- if (!text) return { errorMessage: null };
922
- const isSse = (res.headers.get("content-type") ?? "").includes(
923
- "text/event-stream"
924
- );
925
- const payloads = [];
926
- const tryParse = (raw) => {
927
- try {
928
- payloads.push(JSON.parse(raw));
929
- } catch {
930
- }
931
- };
932
- if (isSse) {
933
- for (const line of text.split(/\r?\n/)) {
934
- if (line.startsWith("data:")) {
935
- const data = line.slice(5).trim();
936
- if (data) tryParse(data);
937
- }
938
- }
939
- } else {
940
- tryParse(text);
941
- }
942
- let result;
943
- for (const payload of payloads) {
944
- if (payload === null || typeof payload !== "object") continue;
945
- const message = payload;
946
- if (typeof message.error?.message === "string") {
947
- return { errorMessage: message.error.message };
948
- }
949
- if (message.result?.isError === true) {
950
- const blocks = Array.isArray(message.result.content) ? message.result.content : [];
951
- const textBlock = blocks.find(
952
- (b) => b?.type === "text" && typeof b.text === "string"
953
- );
954
- return {
955
- errorMessage: textBlock ? String(textBlock.text) : "tool error"
956
- };
957
- }
958
- if ("result" in message) result = message.result;
959
- }
960
- return { errorMessage: null, result };
961
- }
962
- function compactToolResult(result) {
963
- if (result === null || typeof result !== "object") return result;
964
- const { structuredContent, content } = result;
965
- if (structuredContent !== void 0) return structuredContent;
966
- if (Array.isArray(content)) {
967
- const [block] = content;
968
- if (content.length === 1 && block?.type === "text") return block.text;
969
- }
970
- return content;
971
- }
972
- function formatForDump(value) {
973
- function truncate(val) {
974
- if (typeof val === "string" && val.length > 100) {
975
- return `${val.slice(0, 100)}...`;
976
- }
977
- if (Array.isArray(val)) return val.map(truncate);
978
- if (val !== null && typeof val === "object") {
979
- return Object.fromEntries(
980
- Object.entries(val).map(([k, v]) => [
981
- k,
982
- truncate(v)
983
- ])
984
- );
985
- }
986
- return val;
987
- }
988
- try {
989
- return JSON.stringify(truncate(value), null, 2);
990
- } catch {
991
- return String(value);
992
- }
993
- }
994
- var DUMP_BODY_MAX_LENGTH = 1e4;
995
- async function printTraceDump(response, requestHeaders, requestBody, readResponseBody) {
996
- console.log(`
997
- ${cyan("=".repeat(80))}`);
998
- console.log(bold(cyan("[TRACE] Request Details")));
999
- console.log(cyan("-".repeat(80)));
1000
- if (Object.keys(requestHeaders).length > 0) {
1001
- console.log(yellow("Request Headers:"));
1002
- console.log(formatForDump(redactHeaders(requestHeaders)));
1003
- }
1004
- if (requestBody !== void 0) {
1005
- console.log(yellow("Request Body:"));
1006
- console.log(
1007
- typeof requestBody === "string" ? requestBody : formatForDump(requestBody)
1008
- );
1009
- }
1010
- const responseHeaders = {};
1011
- response.headers.forEach((value, key) => {
1012
- responseHeaders[key] = value;
1013
- });
1014
- if (Object.keys(responseHeaders).length > 0) {
1015
- console.log(yellow("Response Headers:"));
1016
- console.log(formatForDump(redactHeaders(responseHeaders)));
1017
- }
1018
- if (!readResponseBody) {
1019
- console.log(`${yellow("Response Body:")} (streaming \u2014 not dumped)`);
1020
- } else if (response.body === null) {
1021
- console.log(`${yellow("Response Body:")} (no body)`);
1022
- } else {
1023
- try {
1024
- const text = await response.clone().text();
1025
- if (text.length === 0) {
1026
- console.log(`${yellow("Response Body:")} (empty)`);
1027
- } else {
1028
- console.log(yellow("Response Body:"));
1029
- try {
1030
- console.log(formatForDump(JSON.parse(text)));
1031
- } catch {
1032
- console.log(
1033
- text.length > DUMP_BODY_MAX_LENGTH ? `${text.slice(0, DUMP_BODY_MAX_LENGTH)}
1034
- ... (truncated, ${text.length - DUMP_BODY_MAX_LENGTH} more characters)` : text
1035
- );
1036
- }
1037
- }
1038
- } catch {
1039
- console.log(`${yellow("Response Body:")} (unable to read)`);
1040
- }
1041
- }
1042
- console.log(`${cyan("=".repeat(80))}
1043
- `);
1044
- }
1045
- function styleStatus(status) {
1046
- const text = String(status);
1047
- if (status >= 500) return magenta(text);
1048
- if (status >= 400) return red(text);
1049
- if (status >= 300) return yellow(text);
1050
- return green(text);
1051
- }
1052
- function isNoisyRequest(httpMethod, pathname) {
1053
- if (httpMethod !== "GET" && httpMethod !== "HEAD") return false;
1054
- return pathname.includes("/inspector") || pathname.endsWith("/favicon.ico");
1055
- }
1056
- function requestLogger(options = {}) {
1057
- if (options.enabled === false) {
1058
- return (_request, next) => next();
1059
- }
1060
- return async (request, next) => {
1061
- const level = resolveLogLevel(options.level);
1062
- const startedAt = Date.now();
1063
- const httpMethod = request.method;
1064
- const pathname = new URL(request.url).pathname;
1065
- if (isNoisyRequest(httpMethod, pathname)) {
1066
- return next();
1067
- }
1068
- const requestHeaders = {};
1069
- if (level === "trace") {
1070
- request.headers.forEach((value, key) => {
1071
- requestHeaders[key] = value;
1072
- });
1073
- }
1074
- let requestBody;
1075
- if (httpMethod !== "GET" && httpMethod !== "HEAD") {
1076
- const parsedBody = getRequestBag(request).parsedBody;
1077
- if (parsedBody !== void 0) {
1078
- requestBody = parsedBody;
1079
- } else {
1080
- try {
1081
- requestBody = await request.clone().json();
1082
- } catch {
1083
- }
1084
- }
1085
- }
1086
- const response = await next();
1087
- const durationMs = Date.now() - startedAt;
1088
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().substring(11, 19);
1089
- const mcpRequest = isJSONRPCRequest(requestBody) ? requestBody : void 0;
1090
- const isStreamingMethod = mcpRequest?.method === "subscriptions/listen";
1091
- const lines = [
1092
- [
1093
- dim(timestamp),
1094
- bold(httpMethod),
1095
- pathname,
1096
- styleStatus(response.status),
1097
- dim(`in ${durationMs}ms`)
1098
- ].join(" ")
1099
- ];
1100
- if (mcpRequest !== void 0) {
1101
- const method = sanitize(mcpRequest.method);
1102
- const parts = [` ${methodStyle(method)(method)}`];
1103
- const detail = formatDetail(mcpRequest);
1104
- if (detail.subject !== void 0) {
1105
- parts.push(bold(sanitize(detail.subject)));
1106
- }
1107
- const echoPayloads = level !== "info";
1108
- if (echoPayloads && detail.input !== void 0) {
1109
- parts.push(inlineJson(detail.input));
1110
- }
1111
- const outcome = isStreamingMethod ? { errorMessage: null } : await extractResponseOutcome(response);
1112
- if (echoPayloads && mcpRequest.method === "tools/call" && outcome.errorMessage === null && outcome.result !== void 0) {
1113
- parts.push(dim("->"), inlineJson(compactToolResult(outcome.result)));
1114
- }
1115
- if (mcpRequest.method !== "initialize") {
1116
- const client = formatClientIdentity(mcpRequest);
1117
- if (client !== void 0) parts.push(dim(sanitize(client)));
1118
- }
1119
- if (outcome.errorMessage !== null) {
1120
- parts.push(red(`ERROR ${sanitize(outcome.errorMessage)}`));
1121
- } else if (response.status >= 400) {
1122
- parts.push(red(`ERROR (HTTP ${response.status})`));
1123
- }
1124
- lines.push(parts.join(" "));
1125
- }
1126
- console.log(lines.join("\n"));
1127
- if (level === "trace") {
1128
- await printTraceDump(
1129
- response,
1130
- requestHeaders,
1131
- requestBody,
1132
- !isStreamingMethod
1133
- );
1134
- }
1135
- return response;
1136
- };
1137
- }
1138
-
1139
- // src/mount-mcp.ts
1140
- import {
1141
- createMcpHandler
1142
- } from "@modelcontextprotocol/server";
1143
- function createMcpMount(factory, options = {}) {
1144
- const {
1145
- path = "/mcp",
1146
- handler: handlerOptions,
1147
- authInfo: getAuthInfo
1148
- } = options;
1149
- const legacyMode = handlerOptions?.legacy ?? "stateless";
1150
- const handler = createMcpHandler(factory, {
1151
- legacy: "stateless",
1152
- ...handlerOptions
1153
- });
1154
- const fetch = async (request) => {
1155
- if (!matchesPath(request, path)) {
1156
- return new Response("Not Found", { status: 404 });
1157
- }
1158
- if (legacyMode === "stateless") {
1159
- const method = request.method.toUpperCase();
1160
- if (method === "GET" || method === "DELETE" || method === "HEAD") {
1161
- return new Response(null, { status: 204 });
1162
- }
1163
- }
1164
- const bag = getRequestBag(request);
1165
- let parsedBody = bag.parsedBody;
1166
- if (parsedBody === void 0) {
1167
- try {
1168
- parsedBody = await request.clone().json();
1169
- } catch {
1170
- }
1171
- }
1172
- const capabilities = extractClientCapabilitiesFromBody(parsedBody);
1173
- if (capabilities !== void 0) {
1174
- stashClientCapabilities(request, capabilities);
1175
- }
1176
- const authInfo = getAuthInfo?.(request) ?? bag.authInfo;
1177
- return handler.fetch(request, {
1178
- ...parsedBody !== void 0 && { parsedBody },
1179
- ...authInfo !== void 0 && { authInfo }
1180
- });
1181
- };
1182
- return { handler, fetch };
1183
- }
1184
-
1185
- // src/tools.ts
1186
- function resolveToolInputSchema(definition) {
1187
- return definition.inputSchema ?? definition.schema;
1188
- }
1189
-
1190
- // src/views/register.ts
1191
- var registerViews = /* @__PURE__ */ Symbol("mcp-use/registerViews");
1192
-
1193
- // src/views/csp-env.ts
1194
- var CATEGORY_ENV = {
1195
- connectDomains: "CSP_CONNECT_DOMAINS",
1196
- resourceDomains: "CSP_RESOURCE_DOMAINS",
1197
- frameDomains: "CSP_FRAME_DOMAINS",
1198
- baseUriDomains: "CSP_BASE_URI_DOMAINS"
1199
- };
1200
- function parseDomainList(raw) {
1201
- if (raw === void 0 || raw.trim() === "") {
1202
- return [];
1203
- }
1204
- return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
1205
- }
1206
- function readEnvDomains(name) {
1207
- if (typeof process === "undefined") {
1208
- return void 0;
1209
- }
1210
- const raw = process.env[name];
1211
- if (raw === void 0 || raw.trim() === "") {
1212
- return void 0;
1213
- }
1214
- return parseDomainList(raw);
1215
- }
1216
- function readCspUrlsShortcut() {
1217
- return readEnvDomains("CSP_URLS") ?? [];
1218
- }
1219
- function readEnvDomainsForCategory(category) {
1220
- const perCategory = readEnvDomains(CATEGORY_ENV[category]);
1221
- if (perCategory !== void 0) {
1222
- return perCategory;
1223
- }
1224
- return readCspUrlsShortcut();
1225
- }
1226
- function mergeDomainLists(...segments) {
1227
- const seen = /* @__PURE__ */ new Set();
1228
- const out = [];
1229
- for (const segment of segments) {
1230
- for (const domain of segment) {
1231
- if (!seen.has(domain)) {
1232
- seen.add(domain);
1233
- out.push(domain);
1234
- }
1235
- }
1236
- }
1237
- return out;
1238
- }
1239
- function toWebSocketOrigin(serverOrigin) {
1240
- if (serverOrigin.startsWith("https://")) {
1241
- return `wss://${serverOrigin.slice("https://".length)}`;
1242
- }
1243
- if (serverOrigin.startsWith("http://")) {
1244
- return `ws://${serverOrigin.slice("http://".length)}`;
1245
- }
1246
- return serverOrigin;
1247
- }
1248
- function buildMergedResourceCsp(authorFacts, options) {
1249
- const author = authorFacts?.csp;
1250
- const mcpConnectAuto = [];
1251
- if (options.serverOrigin !== "") {
1252
- mcpConnectAuto.push(options.serverOrigin);
1253
- if (options.hmrWs === true) {
1254
- mcpConnectAuto.push(toWebSocketOrigin(options.serverOrigin));
1255
- }
1256
- }
1257
- const mcpResourceAuto = [];
1258
- const resourceOrigin = options.explicitAssetsBase ? options.assetsOrigin : options.serverOrigin;
1259
- if (resourceOrigin !== "") {
1260
- mcpResourceAuto.push(resourceOrigin);
1261
- }
1262
- const connectDomains = mergeDomainLists(
1263
- author?.connectDomains ?? [],
1264
- readEnvDomainsForCategory("connectDomains"),
1265
- mcpConnectAuto
1266
- );
1267
- const resourceDomains = mergeDomainLists(
1268
- author?.resourceDomains ?? [],
1269
- readEnvDomainsForCategory("resourceDomains"),
1270
- mcpResourceAuto
1271
- );
1272
- const frameDomains = mergeDomainLists(
1273
- author?.frameDomains ?? [],
1274
- readEnvDomainsForCategory("frameDomains")
1275
- );
1276
- const baseUriDomains = mergeDomainLists(
1277
- author?.baseUriDomains ?? [],
1278
- readEnvDomainsForCategory("baseUriDomains")
1279
- );
1280
- return {
1281
- ...author,
1282
- connectDomains,
1283
- resourceDomains,
1284
- frameDomains,
1285
- baseUriDomains
1286
- };
1287
- }
1288
-
1289
- // src/views/routes.ts
1290
- var PUBLIC_BUILD_DIR = ".mcp-use/build/views/public";
1291
- var PUBLIC_DEV_DIR = "public";
1292
- var VIEW_ASSETS_BUILD_ROOT = ".mcp-use/build/views";
1293
- function createViewAssetsHandler(basePath, views, options) {
1294
- if (views.size === 0) {
1295
- return void 0;
1296
- }
1297
- const assetsPrefix = pathUnderBase(basePath, "_mcp-use/views");
1298
- const projectRoot = options?.projectRoot ?? process.cwd();
1299
- return async (request) => {
1300
- if (request.method !== "GET" && request.method !== "HEAD") {
1301
- return new Response("Method Not Allowed", { status: 405 });
1302
- }
1303
- if (!matchesPathPrefix(request, assetsPrefix)) {
1304
- return new Response("Not Found", { status: 404 });
1305
- }
1306
- const pathname = pathnameOf(request);
1307
- const remainder = pathname.slice(assetsPrefix.length + 1);
1308
- const slash = remainder.indexOf("/");
1309
- if (slash <= 0 || slash === remainder.length - 1) {
1310
- return new Response("Not Found", { status: 404 });
1311
- }
1312
- const viewName = remainder.slice(0, slash);
1313
- const subpath = remainder.slice(slash + 1);
1314
- const entry = views.get(viewName);
1315
- if (entry === void 0 || entry.kind !== "external") {
1316
- return new Response("Not Found", { status: 404 });
1317
- }
1318
- const [{ join }, { resolvePublicFilePath: resolvePublicFilePath2, servePublicFile: servePublicFile2 }] = await Promise.all([import("path"), import("./public-route-5JEGFEIN.js")]);
1319
- const viewRoot = join(projectRoot, VIEW_ASSETS_BUILD_ROOT, viewName);
1320
- const diskPath = await resolvePublicFilePath2(viewRoot, subpath);
1321
- if (diskPath === null) {
1322
- return new Response("Not Found", { status: 404 });
1323
- }
1324
- return await servePublicFile2(diskPath, {
1325
- ...options?.deferCors === true && { deferCors: true },
1326
- ...request.method === "HEAD" && { head: true }
1327
- });
1328
- };
1329
- }
1330
- function createViewPublicHandler(basePath, views, options) {
1331
- if (views.size === 0 && options?.enabled !== true) {
1332
- return void 0;
1333
- }
1334
- const publicPrefix = pathUnderBase(basePath, "_mcp-use/public");
1335
- const subdir = options?.dev === true ? PUBLIC_DEV_DIR : PUBLIC_BUILD_DIR;
1336
- const projectRoot = options?.projectRoot ?? process.cwd();
1337
- return async (request) => {
1338
- if (request.method !== "GET" && request.method !== "HEAD") {
1339
- return new Response("Method Not Allowed", { status: 405 });
1340
- }
1341
- if (!matchesPathPrefix(request, publicPrefix)) {
1342
- return new Response("Not Found", { status: 404 });
1343
- }
1344
- const pathname = pathnameOf(request);
1345
- const encodedSubpath = pathname.slice(publicPrefix.length + 1);
1346
- let subpath;
1347
- try {
1348
- subpath = decodeURIComponent(encodedSubpath);
1349
- } catch {
1350
- return new Response("Not Found", { status: 404 });
1351
- }
1352
- if (subpath.length === 0) {
1353
- return new Response("Not Found", { status: 404 });
1354
- }
1355
- const [{ join }, { resolvePublicFilePath: resolvePublicFilePath2, servePublicFile: servePublicFile2 }] = await Promise.all([import("path"), import("./public-route-5JEGFEIN.js")]);
1356
- const publicRoot = join(projectRoot, subdir);
1357
- const diskPath = await resolvePublicFilePath2(publicRoot, subpath);
1358
- if (diskPath === null) {
1359
- return new Response("Not Found", { status: 404 });
1360
- }
1361
- return await servePublicFile2(diskPath, {
1362
- ...options?.deferCors === true && { deferCors: true },
1363
- ...request.method === "HEAD" && { head: true }
1364
- });
1365
- };
1366
- }
1367
-
1368
- // src/views/wire.ts
1369
- function buildToolUiMeta(viewName, visibility, existingMetadata) {
1370
- if (viewName === void 0 && visibility === void 0 && existingMetadata === void 0) {
1371
- return void 0;
1372
- }
1373
- const meta = { ...existingMetadata };
1374
- const existingUi = existingMetadata?.[UI_META_KEY];
1375
- const existingUiIsObject = typeof existingUi === "object" && existingUi !== null && !Array.isArray(existingUi);
1376
- const ui = existingUiIsObject ? { ...existingUi } : {};
1377
- if (viewName !== void 0) {
1378
- const resourceUri = viewResourceUri(viewName);
1379
- ui["resourceUri"] = resourceUri;
1380
- meta[UI_RESOURCE_URI_META_KEY] = resourceUri;
1381
- } else {
1382
- delete ui["resourceUri"];
1383
- delete meta[UI_RESOURCE_URI_META_KEY];
1384
- }
1385
- if (visibility !== void 0) {
1386
- ui["visibility"] = [visibility];
1387
- } else {
1388
- delete ui["visibility"];
1389
- }
1390
- if (viewName !== void 0 || visibility !== void 0 || existingUiIsObject) {
1391
- meta[UI_META_KEY] = ui;
1392
- }
1393
- return meta;
1394
- }
1395
- function buildToolResultUiMeta(viewName) {
1396
- const resourceUri = viewResourceUri(viewName);
1397
- return {
1398
- [UI_META_KEY]: { resourceUri },
1399
- [UI_RESOURCE_URI_META_KEY]: resourceUri
1400
- };
1401
- }
1402
- function resolveCspOptions(options) {
1403
- const request = options?.request;
1404
- const serverOrigin = options?.serverOrigin ?? (request !== void 0 ? resolveServerOrigin(request) : "");
1405
- const assetsBase = options?.assetsBase ?? (request !== void 0 ? resolveAssetsBase(request) : serverOrigin);
1406
- return {
1407
- serverOrigin,
1408
- assetsOrigin: originFromAssetsBase(assetsBase),
1409
- explicitAssetsBase: hasExplicitAssetsBase(),
1410
- ...options?.hmrWs === true ? { hmrWs: true } : {}
1411
- };
1412
- }
1413
- function buildResourceUiMeta(authorFacts, options) {
1414
- const csp = buildMergedResourceCsp(authorFacts, resolveCspOptions(options));
1415
- const ui = { csp };
1416
- if (authorFacts?.permissions !== void 0) {
1417
- ui["permissions"] = authorFacts.permissions;
1418
- }
1419
- if (authorFacts?.domain !== void 0) {
1420
- ui["domain"] = authorFacts.domain;
1421
- }
1422
- if (authorFacts?.prefersBorder !== void 0) {
1423
- ui["prefersBorder"] = authorFacts.prefersBorder;
1424
- }
1425
- return { [UI_META_KEY]: ui };
1426
- }
1427
- function viewResourceConfig(_viewName, _entry, authorFacts, options) {
1428
- return {
1429
- mimeType: UI_MIME_TYPE,
1430
- ...authorFacts?.description !== void 0 && {
1431
- description: authorFacts.description
1432
- },
1433
- _meta: buildResourceUiMeta(authorFacts, options)
1434
- };
1435
- }
1436
-
1437
- // src/server.ts
1438
- var MCPServer = class _MCPServer {
1439
- #config;
1440
- #branding;
1441
- #tools = /* @__PURE__ */ new Map();
1442
- #resources = /* @__PURE__ */ new Map();
1443
- #resourceTemplates = /* @__PURE__ */ new Map();
1444
- #prompts = /* @__PURE__ */ new Map();
1445
- #views = /* @__PURE__ */ new Map();
1446
- /**
1447
- * One-to-one tool→view bindings. Each view name maps to the single tool
1448
- * that bound it; that tool's `view:` config is the sole source of
1449
- * resource facts for the primed view resource.
1450
- */
1451
- #viewBindings = /* @__PURE__ */ new Map();
1452
- #viewsPrimed = false;
1453
- /** When true, resource CSP emission includes the HMR websocket origin. */
1454
- #viewsDevMode = false;
1455
- /** Project root for filesystem-backed view routes (dev `public/`). */
1456
- #viewsProjectRoot = process.cwd();
1457
- #fetchHandler;
1458
- #handler;
1459
- #httpServer;
1460
- #oauthResource;
1461
- #oauthResourceResolved = false;
1462
- #oauthResourceConfigurationAbsent = false;
1463
- /** Whether the mounted app validates Host headers (fixed at first mount). */
1464
- #hostValidated = false;
1465
- #mcpMiddlewares = [];
1466
- #mcpEventListeners = [];
1467
- /**
1468
- * Create an MCP server from a parsed, bundled OpenAPI document.
1469
- *
1470
- * Each included OpenAPI operation becomes a tool that validates its input,
1471
- * calls the matching upstream HTTP endpoint, and returns the response using
1472
- * the SDK's raw tool-result shape. External `$ref` values are not fetched;
1473
- * bundle the document before passing it in.
1474
- *
1475
- * @param options - OpenAPI document, operation filters, upstream URL, and
1476
- * request authentication options.
1477
- * @returns An unauthenticated MCP server populated with generated tools.
1478
- *
1479
- * @example
1480
- * ```ts
1481
- * const spec = await fetch("https://api.example.com/openapi.json")
1482
- * .then((response) => response.json());
1483
- * const server = MCPServer.fromOpenAPI({ spec });
1484
- * await server.listen(3000);
1485
- * ```
1486
- */
1487
- static fromOpenAPI(options) {
1488
- const server = new _MCPServer({
1489
- name: options.name ?? options.spec.info.title,
1490
- version: options.version ?? options.spec.info.version ?? "1.0.0"
1491
- });
1492
- registerOpenAPITools(server, options);
1493
- return server;
1494
- }
1495
- /**
1496
- * Create a server. `config.name` and `config.version` identify the server
1497
- * to clients during initialization. `config.basePath` (default `"/mcp"`)
1498
- * is both the MCP route and the path of the OAuth protected-resource
1499
- * identity, so any explicit OAuth resource URL must use that exact path.
1500
- * Nothing binds or listens until {@link MCPServer.listen} or
1501
- * {@link MCPServer.getHandler} is called.
1502
- */
1503
- constructor(config) {
1504
- assertServerConfig(config);
1505
- this.#config = config;
1506
- this.#branding = normalizeServerBranding(config);
1507
- if (config.oauth !== void 0) {
1508
- const mcpUrl = typeof process === "undefined" ? void 0 : process.env["MCP_URL"];
1509
- const resource = resolveConfiguredOAuthResource({
1510
- provider: config.oauth,
1511
- basePath: this.#basePath(),
1512
- ...mcpUrl !== void 0 && { mcpUrl }
1513
- });
1514
- this.#oauthResource = resource;
1515
- this.#oauthResourceResolved = resource !== void 0;
1516
- this.#oauthResourceConfigurationAbsent = resource === void 0;
1517
- }
1518
- }
1519
- /**
1520
- * The URL path prefix the MCP endpoint is mounted at.
1521
- *
1522
- * Reflects `config.basePath` (default `"/mcp"`). Exposed so tooling that
1523
- * imports the entry module — `mcp-use dev`'s startup log, for example —
1524
- * can build the endpoint and inspector URLs without assuming the default.
1525
- */
1526
- get basePath() {
1527
- return this.#basePath();
1528
- }
1529
- /**
1530
- * Immutable normalized branding shared by MCP identity and browser pages.
1531
- *
1532
- * `favicon` is the final source after explicit-favicon and icon-selection
1533
- * precedence. Landing-page integrations can use this accessor and link to
1534
- * the server's root-level `/favicon.ico` route without reading private
1535
- * configuration or depending on the inspector/view layers.
1536
- *
1537
- * @example
1538
- * ```ts
1539
- * if (server.branding.favicon) {
1540
- * console.log("Browser favicon: /favicon.ico");
1541
- * }
1542
- * ```
1543
- */
1544
- get branding() {
1545
- return this.#branding;
1546
- }
1547
- /**
1548
- * Register a tool. Input is validated against `inputSchema` before the callback
1549
- * runs; results carrying `structuredContent` are type-checked against
1550
- * `outputSchema` at the callback's return position.
1551
- *
1552
- * @returns A {@link ToolRef} carrying the tool name and phantom types for
1553
- * inference-based view typing.
1554
- */
1555
- tool(definition, callback) {
1556
- this.#assertNotStarted("tool", definition.name);
1557
- this.#validateToolViewBinding(definition);
1558
- this.#tools.set(definition.name, {
1559
- definition,
1560
- callback
1561
- });
1562
- return Object.freeze({
1563
- name: definition.name
1564
- });
1565
- }
1566
- /**
1567
- * Prime the views registry from a build/dev manifest.
1568
- *
1569
- * @param views - Manifest map keyed by view directory name.
1570
- * @param options - Priming options. When `dev` is true, resource CSP
1571
- * emission appends the serving origin's websocket variant to
1572
- * `connectDomains` so Vite HMR passes host-enforced CSP. Pass
1573
- * `projectRoot` in dev so the `public/` route resolves against the user's
1574
- * project directory rather than the CLI process cwd.
1575
- * @throws If views are already primed, or after the server has started.
1576
- *
1577
- * @internal
1578
- */
1579
- [registerViews](views, options) {
1580
- if (this.#viewsPrimed) {
1581
- throw new Error(
1582
- "Cannot prime views: the views registry is already primed on this server instance."
1583
- );
1584
- }
1585
- this.#assertNotStarted("views", "manifest");
1586
- this.#viewsDevMode = options?.dev === true;
1587
- if (options?.projectRoot !== void 0) {
1588
- this.#viewsProjectRoot = options.projectRoot;
1589
- }
1590
- for (const [name, entry] of Object.entries(views)) {
1591
- this.#views.set(name, entry);
1592
- }
1593
- this.#viewsPrimed = true;
1594
- }
1595
- /**
1596
- * Prime the views registry — string-keyed alias for {@link registerViews}
1597
- * used by the CLI when the symbol export cannot be shared across duplicate
1598
- * module copies (dev module runner with an externalized package).
1599
- *
1600
- * @param views - Manifest map keyed by view directory name.
1601
- * @param options - Priming options forwarded to {@link registerViews}.
1602
- * @throws If views are already primed, or after the server has started.
1603
- *
1604
- * @internal
1605
- */
1606
- __primeViews(views, options) {
1607
- this[registerViews](views, options);
1608
- }
1609
- /** Register a static resource readable at `definition.uri`. */
1610
- resource(definition, callback) {
1611
- this.#assertNotStarted("resource", definition.name);
1612
- this.#resources.set(definition.name, { definition, callback });
1613
- return this;
1614
- }
1615
- /**
1616
- * Register a parameterized resource. Reads matching `uriTemplate` invoke
1617
- * the callback with the extracted variables.
1618
- *
1619
- * The `const` type parameter keeps `uriTemplate` a string literal during
1620
- * inference (plain generic inference widens object-literal properties to
1621
- * `string`), which is what lets `InferTemplateParams` type the callback's
1622
- * `params` from the template's variables.
1623
- */
1624
- resourceTemplate(definition, callback) {
1625
- this.#assertNotStarted("resourceTemplate", definition.name);
1626
- const complete = definition.complete === void 0 ? void 0 : normalizeCompletions(definition.complete);
1627
- this.#resourceTemplates.set(definition.name, {
1628
- definition,
1629
- ...complete !== void 0 && { complete },
1630
- callback
1631
- });
1632
- return this;
1633
- }
1634
- /**
1635
- * Register a prompt template. Schema fields wrapped with `completable()`
1636
- * gain autocomplete via `completion/complete`.
1637
- */
1638
- prompt(definition, callback) {
1639
- this.#assertNotStarted("prompt", definition.name);
1640
- this.#prompts.set(definition.name, {
1641
- definition,
1642
- callback
1643
- });
1644
- return this;
1645
- }
1646
- /**
1647
- * Web-standard request handler for the whole app (MCP endpoint included) —
1648
- * usable directly on serverless/edge runtimes or in tests.
1649
- *
1650
- * The handler never binds a socket, so no Host/Origin validation applies
1651
- * by default: DNS rebinding targets locally bound servers, and platform
1652
- * edges (Vercel, Cloudflare, …) only route hostnames assigned to the
1653
- * deployment. Set `allowedHosts`/`allowedOrigins` to opt into validation
1654
- * (additive — localhost-class values stay allowed).
1655
- *
1656
- * Pass the same `bus` to multiple server instances when their handlers
1657
- * replace one another while existing `subscriptions/listen` streams remain
1658
- * open. The bus is fixed when this instance first mounts.
1659
- *
1660
- * @param options - Optional handler wiring.
1661
- *
1662
- * @example
1663
- * ```ts
1664
- * const handler = server.getHandler();
1665
- * export default { fetch: handler };
1666
- * ```
1667
- */
1668
- getHandler(options = {}) {
1669
- const { fetch } = this.#ensureMounted("handler", void 0, options.bus);
1670
- return toFrameworkHandler(fetch);
1671
- }
1672
- /**
1673
- * Node `(req, res) => void` handler for composing with an existing
1674
- * `http.Server`. Uses the same internal `toNodeHandler` bridge as
1675
- * {@link MCPServer.listen}; MCPServer users do not need to import
1676
- * `mcp-use/node`.
1677
- *
1678
- * @example
1679
- * ```ts
1680
- * import { createServer } from "node:http";
1681
- * const httpServer = createServer(await server.getNodeHandler());
1682
- * httpServer.listen(3000);
1683
- * ```
1684
- */
1685
- async getNodeHandler() {
1686
- const { fetch } = this.#ensureMounted("handler");
1687
- const { toNodeHandler } = await import("./node-bridge.js");
1688
- return toNodeHandler({ fetch });
1689
- }
1690
- /**
1691
- * Register MCP operation middleware that intercepts JSON-RPC dispatch.
1692
- *
1693
- * Patterns use an `mcp:` prefix (for example `mcp:tools/call`, `mcp:*`).
1694
- * Middleware runs in registration order; call `next()` to continue the chain.
1695
- *
1696
- * @example
1697
- * ```ts
1698
- * server.use("mcp:tools/call", async (ctx, next) => {
1699
- * console.log(`Calling tool: ${ctx.params.name}`);
1700
- * return next();
1701
- * });
1702
- * ```
1703
- */
1704
- use(pattern, handler) {
1705
- this.#assertNotStarted("middleware", pattern);
1706
- this.#mcpMiddlewares.push({
1707
- pattern: normalizeMcpMiddlewarePattern(pattern),
1708
- handler
1709
- });
1710
- return this;
1711
- }
1712
- /**
1713
- * Register a read-only MCP observer. Unlike {@link MCPServer.use}, listeners
1714
- * cannot block, override, or mutate params. Throwing is logged and does not
1715
- * fail the request.
1716
- *
1717
- * Append `:complete` to run after the handler (for example
1718
- * `mcp:tools/call:complete`).
1719
- *
1720
- * @example
1721
- * ```ts
1722
- * server.on("mcp:tools/call", (ctx) => {
1723
- * metrics.increment("tools.call", { tool: ctx.params.name });
1724
- * });
1725
- * ```
1726
- */
1727
- on(pattern, handler) {
1728
- this.#assertNotStarted("event listener", pattern);
1729
- const { pattern: stripped, phase } = parseMcpPattern(pattern);
1730
- this.#mcpEventListeners.push({
1731
- pattern: stripped,
1732
- phase,
1733
- handler
1734
- });
1735
- return this;
1736
- }
1737
- /**
1738
- * Publish a tools-list change to v2 clients with active subscriptions.
1739
- *
1740
- * @example
1741
- * ```ts
1742
- * await server.notifyToolsChanged();
1743
- * ```
1744
- */
1745
- async notifyToolsChanged() {
1746
- await this.#ensureMounted("handler").handler.notify.toolsChanged();
1747
- }
1748
- /**
1749
- * Publish a prompts-list change to v2 clients with active subscriptions.
1750
- *
1751
- * @example
1752
- * ```ts
1753
- * await server.notifyPromptsChanged();
1754
- * ```
1755
- */
1756
- async notifyPromptsChanged() {
1757
- await this.#ensureMounted("handler").handler.notify.promptsChanged();
1758
- }
1759
- /**
1760
- * Publish a resources-list change to v2 clients with active subscriptions.
1761
- *
1762
- * @example
1763
- * ```ts
1764
- * await server.notifyResourcesChanged();
1765
- * ```
1766
- */
1767
- async notifyResourcesChanged() {
1768
- await this.#ensureMounted("handler").handler.notify.resourcesChanged();
1769
- }
1770
- /**
1771
- * Publish a resource update to subscribed v2 clients.
1772
- *
1773
- * @param uri - Resource URI whose representation changed.
1774
- *
1775
- * @example
1776
- * ```ts
1777
- * await server.notifyResourceUpdated("config://settings");
1778
- * ```
1779
- */
1780
- async notifyResourceUpdated(uri) {
1781
- await this.#ensureMounted("handler").handler.notify.resourceUpdated(uri);
1782
- }
1783
- /**
1784
- * Serve over HTTP on Node. Pass port `0` for an ephemeral port.
1785
- *
1786
- * Binds `config.host` (default `127.0.0.1`). Localhost-class binds get
1787
- * DNS-rebinding protection automatically: `Host` on every request,
1788
- * `Origin` only on non-GET/HEAD (sandboxed view iframes send
1789
- * `Origin: null` on asset GETs). To serve publicly set `host: "0.0.0.0"`;
1790
- * behind a platform edge that is all that's needed, and `allowedHosts`
1791
- * restricts direct exposure (additive — localhost-class values stay allowed).
1792
- *
1793
- * With OAuth and no explicit resource or `MCP_URL`, a localhost listener
1794
- * derives its protected-resource URL from the actual bound port. Mounting
1795
- * therefore waits for the listener callback (especially for port `0`), and
1796
- * requests accepted before then are queued. Public/wildcard listeners must
1797
- * configure the resource before calling this method.
1798
- *
1799
- * @throws If called on a localhost-class bind after {@link MCPServer.getHandler}
1800
- * already mounted the app without Host validation.
1801
- */
1802
- async listen(port = 3e3) {
1803
- this.#assertListenOAuthConfiguration();
1804
- const { createServer } = await import("http");
1805
- const { toNodeHandler } = await import("./node-bridge.js");
1806
- const host = this.#config.host ?? "127.0.0.1";
1807
- return new Promise((resolve, reject) => {
1808
- let resolveFetch;
1809
- let rejectFetch;
1810
- const fetchReady = new Promise(
1811
- (resolveFetchPromise, rejectFetchPromise) => {
1812
- resolveFetch = resolveFetchPromise;
1813
- rejectFetch = rejectFetchPromise;
1814
- }
1815
- );
1816
- void fetchReady.catch(() => void 0);
1817
- let settled = false;
1818
- const rejectAndClose = (error) => {
1819
- if (!settled) {
1820
- settled = true;
1821
- reject(error);
1822
- }
1823
- rejectFetch?.(error);
1824
- void new Promise(
1825
- (closeResolve) => server.close(() => closeResolve())
1826
- ).catch(() => void 0).finally(() => {
1827
- if (this.#httpServer === server) {
1828
- this.#httpServer = void 0;
1829
- }
1830
- });
1831
- };
1832
- const nodeHandler = toNodeHandler({
1833
- fetch: async (request) => (await fetchReady)(request)
1834
- });
1835
- const server = createServer((req, res) => {
1836
- void nodeHandler(req, res);
1837
- });
1838
- server.once("error", rejectAndClose);
1839
- server.listen(port, host, () => {
1840
- try {
1841
- const address = server.address();
1842
- const boundPort = typeof address === "object" && address !== null ? address.port : port;
1843
- const { fetch } = this.#ensureMounted("listen", boundPort);
1844
- resolveFetch?.(fetch);
1845
- if (!settled) {
1846
- settled = true;
1847
- resolve({
1848
- port: boundPort,
1849
- url: `http://localhost:${boundPort}${this.#basePath()}`
1850
- });
1851
- }
1852
- } catch (error) {
1853
- rejectAndClose(error);
1854
- }
1855
- });
1856
- this.#httpServer = server;
1857
- });
1858
- }
1859
- /**
1860
- * Abort in-flight MCP exchanges and stop the HTTP listener.
1861
- *
1862
- * A closed server is done for good — the underlying MCP handler stays
1863
- * closed, so `listen()`/`getHandler()` cannot revive it. Create a new
1864
- * instance to serve again.
1865
- */
1866
- async close() {
1867
- await this.#handler?.close();
1868
- const httpServer = this.#httpServer;
1869
- if (httpServer !== void 0) {
1870
- await new Promise((resolve, reject) => {
1871
- httpServer.close((err) => err ? reject(err) : resolve());
1872
- });
1873
- this.#httpServer = void 0;
1874
- }
1875
- }
1876
- #basePath() {
1877
- return this.#config.basePath ?? "/mcp";
1878
- }
1879
- #resolveOAuthResource(mode, listenPort) {
1880
- if (this.#config.oauth === void 0) {
1881
- return void 0;
1882
- }
1883
- if (this.#oauthResourceResolved) {
1884
- return this.#oauthResource;
1885
- }
1886
- const host = this.#config.host ?? "127.0.0.1";
1887
- const localListen = mode === "listen" && listenPort !== void 0 && ["127.0.0.1", "localhost", "::1"].includes(host);
1888
- if (this.#oauthResourceConfigurationAbsent && localListen) {
1889
- this.#oauthResource = resolveLocalOAuthResource(
1890
- `http://localhost:${listenPort}`,
1891
- this.#basePath()
1892
- );
1893
- this.#oauthResourceResolved = true;
1894
- return this.#oauthResource;
1895
- }
1896
- throw new Error(
1897
- "OAuth requires an explicit resource or MCP_URL when using getHandler() or listening on a non-local host"
1898
- );
1899
- }
1900
- #assertListenOAuthConfiguration() {
1901
- if (this.#config.oauth === void 0) {
1902
- return;
1903
- }
1904
- const host = this.#config.host ?? "127.0.0.1";
1905
- if (["127.0.0.1", "localhost", "::1"].includes(host)) {
1906
- return;
1907
- }
1908
- if (!this.#oauthResourceResolved) {
1909
- throw new Error(
1910
- "OAuth listen() on a public or wildcard host requires an explicit provider resource or valid MCP_URL."
1911
- );
1912
- }
1913
- }
1914
- #assertNotStarted(kind, name) {
1915
- if (this.#handler !== void 0) {
1916
- throw new Error(
1917
- `Cannot register ${kind} "${name}" after the server has started: registrations are replayed per request from the registry, so register everything before listen()/getHandler().`
1918
- );
1919
- }
1920
- }
1921
- /**
1922
- * Effective Host/Origin allowlists for a mount mode; `undefined` means the
1923
- * corresponding validation is off.
1924
- *
1925
- * Configured lists are additive to the localhost-class allowlists, so local
1926
- * runs keep working when a deployment hostname is added. With nothing
1927
- * configured, `listen()` on a localhost-class bind validates against the
1928
- * localhost lists (the DNS-rebinding threat model), while `getHandler()` —
1929
- * which never binds — applies no validation. `allowedOrigins` defaults to
1930
- * mirroring the effective Host allowlist. Origin validation runs only on
1931
- * non-GET/HEAD requests.
1932
- */
1933
- #validationPolicy(mode) {
1934
- const { host = "127.0.0.1", allowedHosts, allowedOrigins } = this.#config;
1935
- const localhostBind = ["127.0.0.1", "localhost", "::1"].includes(host);
1936
- const hosts = allowedHosts !== void 0 ? [.../* @__PURE__ */ new Set([...localhostAllowedHostnames(), ...allowedHosts])] : mode === "listen" && localhostBind ? localhostAllowedHostnames() : void 0;
1937
- const origins = allowedOrigins !== void 0 ? [.../* @__PURE__ */ new Set([...localhostAllowedOrigins(), ...allowedOrigins])] : hosts;
1938
- return { hosts, origins };
1939
- }
1940
- #ensureMounted(mode, listenPort, bus) {
1941
- if (this.#fetchHandler === void 0 || this.#handler === void 0) {
1942
- const { hosts, origins } = this.#validationPolicy(mode);
1943
- const basePath = this.#basePath();
1944
- const nestedBasePath = basePath === "/" ? "" : basePath;
1945
- const middlewares = [
1946
- jsonBodyMiddleware(),
1947
- requestLogger(this.#config.logging)
1948
- ];
1949
- const corsConfig = this.#config.cors;
1950
- if (corsConfig !== void 0) {
1951
- middlewares.unshift(corsFetchMiddleware(corsConfig));
1952
- }
1953
- const deferViewCors = isGlobalCorsEnabled(corsConfig);
1954
- if (hosts !== void 0) {
1955
- middlewares.unshift(hostValidationMiddleware(hosts));
1956
- middlewares.push(originValidationMiddleware(origins ?? hosts));
1957
- } else {
1958
- if (origins !== void 0) {
1959
- middlewares.push(originValidationMiddleware(origins));
1960
- }
1961
- if (mode === "listen") {
1962
- console.warn(
1963
- `[mcp-use] listen() is serving on ${this.#config.host} without Host validation. Behind a platform edge that only routes your own domains this is expected; if this process is reachable directly, set allowedHosts to restrict it.`
1964
- );
1965
- }
1966
- }
1967
- this.#validateViewBindingsAtMount();
1968
- const resource = this.#resolveOAuthResource(mode, listenPort);
1969
- if (resource !== void 0) {
1970
- const provider = this.#config.oauth;
1971
- middlewares.push(oauthMetadata(provider, resource));
1972
- }
1973
- const { handler, fetch: mcpFetch } = createMcpMount(
1974
- (ctx) => this.#buildSdkServer(ctx),
1975
- {
1976
- path: basePath,
1977
- ...(this.#config.legacy !== void 0 || bus !== void 0) && {
1978
- handler: {
1979
- ...this.#config.legacy !== void 0 && {
1980
- legacy: this.#config.legacy
1981
- },
1982
- ...bus !== void 0 && { bus }
1983
- }
1984
- },
1985
- ...resource !== void 0 && {
1986
- authInfo: (request) => authInfoFromRequest(request)
1987
- }
1988
- }
1989
- );
1990
- let protectWithBearer = async (_request, next) => next();
1991
- if (resource !== void 0) {
1992
- const provider = this.#config.oauth;
1993
- const providerOptions = getOAuthProviderOptions(provider);
1994
- const gate = requireBearerAuth({
1995
- verifier: wrapOAuthTokenVerifier(provider, resource),
1996
- resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource),
1997
- ...providerOptions.requiredScopes !== void 0 && {
1998
- requiredScopes: providerOptions.requiredScopes
1999
- }
2000
- });
2001
- protectWithBearer = async (request, next) => {
2002
- const result = await gate(request);
2003
- if (result instanceof Response) {
2004
- return result;
2005
- }
2006
- const bag = getRequestBag(request);
2007
- bag.authInfo = result;
2008
- return next();
2009
- };
2010
- }
2011
- const mcpRouteHandler = (request) => protectWithBearer(request, () => mcpFetch(request));
2012
- const endpointHandler = async (request) => {
2013
- if (!isHtmlNavigationRequest(request)) {
2014
- return mcpRouteHandler(request);
2015
- }
2016
- const respond = async () => {
2017
- const { createLandingPageResponse } = await import("./landing-handler-3VN4BMR2.js");
2018
- return createLandingPageResponse(
2019
- request,
2020
- basePath,
2021
- this.#config,
2022
- this.#branding,
2023
- this.#tools.values(),
2024
- this.#prompts.values(),
2025
- this.#resources.values()
2026
- );
2027
- };
2028
- if (resource !== void 0 && this.#config.publicLandingPage !== true) {
2029
- return protectWithBearer(request, respond);
2030
- }
2031
- return respond();
2032
- };
2033
- const routes = [];
2034
- const brandingDevMode = this.#viewsPrimed ? this.#viewsDevMode : process.env["NODE_ENV"] !== "production";
2035
- const faviconHandler = createFaviconHandler(this.#branding, {
2036
- dev: brandingDevMode,
2037
- projectRoot: this.#viewsProjectRoot,
2038
- deferCors: deferViewCors
2039
- });
2040
- if (faviconHandler !== void 0) {
2041
- routes.push({
2042
- match: (request) => new URL(request.url).pathname === "/favicon.ico",
2043
- handler: faviconHandler
2044
- });
2045
- }
2046
- const viewHandler = createViewPublicHandler(basePath, this.#views, {
2047
- dev: this.#viewsPrimed ? this.#viewsDevMode : brandingDevMode,
2048
- projectRoot: this.#viewsProjectRoot,
2049
- enabled: hasLocalBrandingAsset(this.#branding),
2050
- deferCors: deferViewCors
2051
- });
2052
- if (viewHandler !== void 0) {
2053
- routes.push({
2054
- match: (request) => request.method === "GET" || request.method === "HEAD" ? new URL(request.url).pathname.startsWith(
2055
- `${nestedBasePath}/_mcp-use/public/`
2056
- ) : false,
2057
- handler: viewHandler
2058
- });
2059
- }
2060
- if (!this.#viewsDevMode) {
2061
- const viewAssetsHandler = createViewAssetsHandler(
2062
- basePath,
2063
- this.#views,
2064
- { projectRoot: this.#viewsProjectRoot, deferCors: deferViewCors }
2065
- );
2066
- if (viewAssetsHandler !== void 0) {
2067
- routes.push({
2068
- match: (request) => request.method === "GET" || request.method === "HEAD" ? new URL(request.url).pathname.startsWith(
2069
- `${nestedBasePath}/_mcp-use/views/`
2070
- ) : false,
2071
- handler: viewAssetsHandler
2072
- });
2073
- }
2074
- }
2075
- const inspectorHandler = createInspectorHandler(this.#config.inspector, {
2076
- serverName: this.#config.name,
2077
- basePath,
2078
- ...faviconHandler !== void 0 && { faviconHref: "/favicon.ico" }
2079
- });
2080
- if (inspectorHandler !== void 0) {
2081
- routes.push({
2082
- match: (request) => {
2083
- if (request.method !== "GET" && request.method !== "HEAD") {
2084
- return false;
2085
- }
2086
- const pathname = new URL(request.url).pathname;
2087
- return matchesInspectorShellPath(pathname, basePath);
2088
- },
2089
- handler: inspectorHandler
2090
- });
2091
- }
2092
- routes.push({
2093
- match: (request) => matchesPath(request, basePath),
2094
- handler: endpointHandler
2095
- });
2096
- const terminal = routeFetch(routes);
2097
- this.#fetchHandler = composeFetch(terminal, ...middlewares);
2098
- this.#handler = handler;
2099
- this.#hostValidated = hosts !== void 0;
2100
- } else if (bus !== void 0 && this.#handler.bus !== bus) {
2101
- throw new Error(
2102
- "Cannot change the MCP event bus after the server has started."
2103
- );
2104
- } else if (mode === "listen" && !this.#hostValidated && this.#validationPolicy("listen").hosts !== void 0) {
2105
- throw new Error(
2106
- "Cannot listen() on a localhost bind after getHandler(): the app is already mounted without Host validation (getHandler() expects a platform edge in front). Call listen() first, or set allowedHosts."
2107
- );
2108
- }
2109
- return { fetch: this.#fetchHandler, handler: this.#handler };
2110
- }
2111
- #validateToolViewBinding(definition) {
2112
- const view = definition.view;
2113
- if (view === void 0) {
2114
- return;
2115
- }
2116
- if (definition.outputSchema === void 0) {
2117
- throw new Error(
2118
- `Tool "${definition.name}" declares view "${view.name}" but has no outputSchema. View-bound tools require an outputSchema \u2014 the view reads structuredContent typed from it. Use outputSchema: z.object({}) for a view that takes no structured output.`
2119
- );
2120
- }
2121
- const existing = this.#viewBindings.get(view.name);
2122
- if (existing !== void 0) {
2123
- throw new Error(
2124
- `View "${view.name}" is already bound to tool "${existing.toolName}"; tool "${definition.name}" cannot bind the same view. Each view may be bound to one tool.`
2125
- );
2126
- }
2127
- this.#viewBindings.set(view.name, {
2128
- toolName: definition.name,
2129
- config: view
2130
- });
2131
- }
2132
- #validateViewBindingsAtMount() {
2133
- if (this.#viewBindings.size > 0 && !this.#viewsPrimed) {
2134
- const first = [...this.#tools.values()].find(
2135
- (entry) => entry.definition.view !== void 0
2136
- );
2137
- const viewName = first?.definition.view?.name ?? "unknown";
2138
- throw new Error(
2139
- `Tool "${first?.definition.name ?? "unknown"}" is bound to view "${viewName}" but no views were primed. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`
2140
- );
2141
- }
2142
- for (const entry of this.#tools.values()) {
2143
- const viewName = entry.definition.view?.name;
2144
- if (viewName !== void 0 && !this.#views.has(viewName)) {
2145
- throw new Error(
2146
- `Tool "${entry.definition.name}" is bound to view "${viewName}" which is not in the primed views registry. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`
2147
- );
2148
- }
2149
- }
2150
- for (const viewName of this.#views.keys()) {
2151
- if (!this.#viewBindings.has(viewName)) {
2152
- console.warn(
2153
- `[mcp-use] View "${viewName}" is registered but no tool binds it.`
2154
- );
2155
- }
2156
- }
2157
- }
2158
- /** Build a fresh SDK server from the registry (runs once per request). */
2159
- #buildSdkServer(ctx) {
2160
- const { name, version, title, description, instructions } = this.#config;
2161
- const authInfo = ctx.authInfo;
2162
- const server = new SdkMcpServer(
2163
- {
2164
- name,
2165
- version,
2166
- ...title !== void 0 && { title },
2167
- ...description !== void 0 && { description },
2168
- ...this.#branding.websiteUrl !== void 0 && {
2169
- websiteUrl: this.#branding.websiteUrl
2170
- },
2171
- ...this.#branding.icons !== void 0 && {
2172
- icons: resolveImplementationIcons(
2173
- this.#branding.icons,
2174
- ctx.requestInfo,
2175
- this.#basePath()
2176
- )
2177
- }
2178
- },
2179
- {
2180
- capabilities: {
2181
- tools: { listChanged: true },
2182
- prompts: { listChanged: true },
2183
- resources: { listChanged: true, subscribe: true }
2184
- },
2185
- ...instructions !== void 0 && { instructions },
2186
- ...authInfo !== void 0 && { authInfo },
2187
- ...this.#config.requestState !== void 0 && {
2188
- requestState: this.#config.requestState
2189
- }
2190
- }
2191
- );
2192
- const request = ctx.requestInfo;
2193
- const viewMetaOptions = request !== void 0 ? { request, hmrWs: this.#viewsDevMode } : { hmrWs: this.#viewsDevMode };
2194
- const basePath = this.#basePath();
2195
- for (const entry of this.#tools.values()) {
2196
- this.#registerTool(server, entry);
2197
- }
2198
- for (const entry of this.#resources.values()) {
2199
- this.#registerResource(server, entry);
2200
- }
2201
- for (const entry of this.#resourceTemplates.values()) {
2202
- this.#registerResourceTemplate(server, entry);
2203
- }
2204
- for (const entry of this.#prompts.values()) {
2205
- this.#registerPrompt(server, entry);
2206
- }
2207
- for (const [viewName, viewEntry] of this.#views.entries()) {
2208
- this.#registerViewResource(
2209
- server,
2210
- viewName,
2211
- viewEntry,
2212
- viewMetaOptions,
2213
- basePath
2214
- );
2215
- }
2216
- this.#wrapListHandlers(server);
2217
- return server;
2218
- }
2219
- #createMiddlewareContext(method, params, ctx) {
2220
- return {
2221
- method,
2222
- params,
2223
- ...ctx.http?.authInfo !== void 0 && { auth: ctx.http.authInfo },
2224
- state: /* @__PURE__ */ new Map()
2225
- };
2226
- }
2227
- #runMcpHook(method, ctx, innerFn) {
2228
- return runMcpOperation(
2229
- this.#mcpMiddlewares,
2230
- this.#mcpEventListeners,
2231
- method,
2232
- ctx,
2233
- innerFn
2234
- );
2235
- }
2236
- /**
2237
- * Wrap native SDK list handlers with the MCP middleware chain.
2238
- *
2239
- * ponytail: uses SDK-private `_requestHandlers`; pin compile-time test.
2240
- *
2241
- * @internal
2242
- */
2243
- #wrapListHandlers(server) {
2244
- const handlers = server.server._requestHandlers;
2245
- if (handlers === void 0) {
2246
- return;
2247
- }
2248
- const wrapListMethod = (method, resultKey) => {
2249
- const original = handlers.get(method);
2250
- if (original === void 0) {
2251
- return;
2252
- }
2253
- if (original.__mcpListWrapped) {
2254
- return;
2255
- }
2256
- const wrapped = async (request, extra) => {
2257
- const authInfo = extra?.http?.authInfo;
2258
- const mwCtx = {
2259
- method,
2260
- params: {},
2261
- ...authInfo !== void 0 && { auth: authInfo },
2262
- state: /* @__PURE__ */ new Map()
2263
- };
2264
- const innerFn = async () => {
2265
- const result = await original(request, extra);
2266
- return result[resultKey] ?? result;
2267
- };
2268
- const filtered = await this.#runMcpHook(method, mwCtx, innerFn);
2269
- if (Array.isArray(filtered)) {
2270
- return { [resultKey]: filtered };
2271
- }
2272
- return filtered;
2273
- };
2274
- wrapped.__mcpListWrapped = true;
2275
- handlers.set(method, wrapped);
2276
- };
2277
- wrapListMethod("tools/list", "tools");
2278
- wrapListMethod("resources/list", "resources");
2279
- wrapListMethod("prompts/list", "prompts");
2280
- }
2281
- #registerTool(server, { definition, callback }) {
2282
- const view = definition.view;
2283
- const toolMeta = buildToolUiMeta(
2284
- view?.name,
2285
- definition.visibility,
2286
- definition._meta
2287
- );
2288
- const config = {
2289
- ...definition.title !== void 0 && { title: definition.title },
2290
- ...definition.description !== void 0 && {
2291
- description: definition.description
2292
- },
2293
- ...definition.annotations !== void 0 && {
2294
- annotations: definition.annotations
2295
- },
2296
- ...definition.outputSchema !== void 0 && {
2297
- outputSchema: definition.outputSchema
2298
- },
2299
- ...toolMeta !== void 0 && { _meta: toolMeta }
2300
- };
2301
- const wireResultMeta = view !== void 0 ? buildToolResultUiMeta(view.name) : void 0;
2302
- const inputSchema = resolveToolInputSchema(definition);
2303
- const invokeTool = async (args, ctx) => {
2304
- const mwCtx = this.#createMiddlewareContext(
2305
- "tools/call",
2306
- { name: definition.name, arguments: args },
2307
- ctx
2308
- );
2309
- const innerFn = async () => {
2310
- const effectiveArgs = mwCtx.params.arguments ?? {};
2311
- const result = await callback(
2312
- effectiveArgs,
2313
- this.#toRequestContext(ctx)
2314
- );
2315
- if (isInputRequiredResult(result) || wireResultMeta === void 0 || result.isError === true) {
2316
- return result;
2317
- }
2318
- return {
2319
- ...result,
2320
- _meta: { ...result._meta, ...wireResultMeta }
2321
- };
2322
- };
2323
- return await this.#runMcpHook("tools/call", mwCtx, innerFn);
2324
- };
2325
- if (inputSchema !== void 0) {
2326
- server.registerTool(
2327
- definition.name,
2328
- { ...config, inputSchema },
2329
- async (args, ctx) => invokeTool(args, ctx)
2330
- );
2331
- } else {
2332
- server.registerTool(
2333
- definition.name,
2334
- config,
2335
- async (ctx) => invokeTool({}, ctx)
2336
- );
2337
- }
2338
- }
2339
- #registerViewResource(server, viewName, entry, metaOptions, basePath) {
2340
- const uri = viewResourceUri(viewName);
2341
- const authorFacts = this.#viewResourceFacts(
2342
- this.#viewBindings.get(viewName)?.config
2343
- );
2344
- const resourceConfig = viewResourceConfig(
2345
- viewName,
2346
- entry,
2347
- authorFacts,
2348
- metaOptions
2349
- );
2350
- server.registerResource(
2351
- viewName,
2352
- uri,
2353
- resourceConfig,
2354
- async (readUri, ctx) => {
2355
- const req = ctx.http?.req;
2356
- const readOptions = req !== void 0 ? {
2357
- request: req,
2358
- ...metaOptions.hmrWs === true ? { hmrWs: true } : {}
2359
- } : metaOptions.hmrWs === true ? { hmrWs: true } : {};
2360
- const assetsBase = req !== void 0 ? resolveAssetsBase(req) : metaOptions.request !== void 0 ? resolveAssetsBase(metaOptions.request) : "";
2361
- const html = synthesizeViewDocument(
2362
- entry,
2363
- assetsBase,
2364
- basePath,
2365
- viewName
2366
- );
2367
- return {
2368
- contents: [
2369
- {
2370
- uri: readUri.href,
2371
- mimeType: resourceConfig.mimeType,
2372
- text: html,
2373
- _meta: buildResourceUiMeta(authorFacts, readOptions)
2374
- }
2375
- ]
2376
- };
2377
- }
2378
- );
2379
- }
2380
- #registerResource(server, { definition, callback }) {
2381
- server.registerResource(
2382
- definition.name,
2383
- definition.uri,
2384
- {
2385
- ...definition.title !== void 0 && { title: definition.title },
2386
- ...definition.description !== void 0 && {
2387
- description: definition.description
2388
- },
2389
- ...definition.mimeType !== void 0 && {
2390
- mimeType: definition.mimeType
2391
- },
2392
- ...definition.annotations !== void 0 && {
2393
- annotations: definition.annotations
2394
- },
2395
- ...definition._meta !== void 0 && {
2396
- _meta: { ...definition._meta }
2397
- }
2398
- },
2399
- async (uri, ctx) => {
2400
- const mwCtx = this.#createMiddlewareContext(
2401
- "resources/read",
2402
- { uri: uri.href },
2403
- ctx
2404
- );
2405
- const innerFn = async () => callback(uri, this.#toRequestContext(ctx));
2406
- return await this.#runMcpHook(
2407
- "resources/read",
2408
- mwCtx,
2409
- innerFn
2410
- );
2411
- }
2412
- );
2413
- }
2414
- #registerResourceTemplate(server, { definition, callback, complete }) {
2415
- const template = new ResourceTemplate(definition.uriTemplate, {
2416
- list: void 0,
2417
- ...complete !== void 0 && { complete }
2418
- });
2419
- server.registerResource(
2420
- definition.name,
2421
- template,
2422
- {
2423
- ...definition.title !== void 0 && { title: definition.title },
2424
- ...definition.description !== void 0 && {
2425
- description: definition.description
2426
- },
2427
- ...definition.mimeType !== void 0 && {
2428
- mimeType: definition.mimeType
2429
- },
2430
- ...definition.annotations !== void 0 && {
2431
- annotations: definition.annotations
2432
- },
2433
- ...definition._meta !== void 0 && {
2434
- _meta: { ...definition._meta }
2435
- }
2436
- },
2437
- async (uri, variables, ctx) => {
2438
- const mwCtx = this.#createMiddlewareContext(
2439
- "resources/read",
2440
- { uri: uri.href },
2441
- ctx
2442
- );
2443
- const innerFn = async () => callback(
2444
- uri,
2445
- variables,
2446
- this.#toRequestContext(ctx)
2447
- );
2448
- return await this.#runMcpHook(
2449
- "resources/read",
2450
- mwCtx,
2451
- innerFn
2452
- );
2453
- }
2454
- );
2455
- }
2456
- #viewResourceFacts(viewConfig) {
2457
- if (viewConfig === void 0) {
2458
- return void 0;
2459
- }
2460
- return {
2461
- ...viewConfig.description !== void 0 && {
2462
- description: viewConfig.description
2463
- },
2464
- ...viewConfig.csp !== void 0 && { csp: viewConfig.csp },
2465
- ...viewConfig.permissions !== void 0 && {
2466
- permissions: viewConfig.permissions
2467
- },
2468
- ...viewConfig.domain !== void 0 && { domain: viewConfig.domain },
2469
- ...viewConfig.prefersBorder !== void 0 && {
2470
- prefersBorder: viewConfig.prefersBorder
2471
- }
2472
- };
2473
- }
2474
- #registerPrompt(server, { definition, callback }) {
2475
- const config = {
2476
- ...definition.title !== void 0 && { title: definition.title },
2477
- ...definition.description !== void 0 && {
2478
- description: definition.description
2479
- }
2480
- };
2481
- const invokePrompt = async (args, ctx) => {
2482
- const mwCtx = this.#createMiddlewareContext(
2483
- "prompts/get",
2484
- { name: definition.name, arguments: args },
2485
- ctx
2486
- );
2487
- const innerFn = async () => {
2488
- const effectiveArgs = mwCtx.params.arguments ?? {};
2489
- return callback(effectiveArgs, this.#toRequestContext(ctx));
2490
- };
2491
- return await this.#runMcpHook("prompts/get", mwCtx, innerFn);
2492
- };
2493
- if (definition.schema !== void 0) {
2494
- server.registerPrompt(
2495
- definition.name,
2496
- { ...config, argsSchema: definition.schema },
2497
- async (args, ctx) => invokePrompt(args, ctx)
2498
- );
2499
- } else {
2500
- const handler = async (ctx) => invokePrompt({}, ctx);
2501
- server.registerPrompt(
2502
- definition.name,
2503
- config,
2504
- handler
2505
- );
2506
- }
2507
- }
2508
- #toRequestContext(ctx) {
2509
- if (this.#config.oauth === void 0) {
2510
- return toRequestContext(ctx);
2511
- }
2512
- return toAuthenticatedRequestContext(ctx);
2513
- }
2514
- };
2515
-
2516
- // src/index.ts
2517
- import {
2518
- acceptedContent,
2519
- createRequestStateCodec,
2520
- inputRequired as inputRequired2,
2521
- inputResponse as inputResponse2,
2522
- isInputRequiredResult as isInputRequiredResult2
2523
- } from "@modelcontextprotocol/server";
2524
- export {
2525
- MCPServer,
2526
- acceptedContent,
2527
- completable,
2528
- composeFetch,
2529
- composeMiddleware,
2530
- createMcpMount,
2531
- createRequestStateCodec,
2532
- getRequestBag,
2533
- hostValidationMiddleware,
2534
- inputRequired2 as inputRequired,
2535
- inputResponse2 as inputResponse,
2536
- isInputRequiredResult2 as isInputRequiredResult,
2537
- jsonBodyMiddleware,
2538
- matchesPath,
2539
- matchesPathPrefix,
2540
- matchesPattern,
2541
- originValidationMiddleware,
2542
- pathnameOf,
2543
- registerViews,
2544
- requestLogger,
2545
- routeFetch,
2546
- toFrameworkHandler
2547
- };
2548
- //# sourceMappingURL=index.js.map
1
+ import{resolvePublicFilePath,servePublicFile}from"./chunk-ZMU5USAZ.js";import{hasExplicitAssetsBase,originFromAssetsBase,resolveAssetsBase,resolveServerOrigin}from"./chunk-PSKSL567.js";import{registerOpenAPITools}from"./chunk-Y26DNVWA.js";import{completable,normalizeCompletions}from"./chunk-OJF6B5EU.js";import{isUsageDisabled,recordUsage}from"./chunk-273ZVKJJ.js";import{inheritBufferedResponse,toNodeHandler,trackBufferedResponse}from"./chunk-XYHHP43G.js";import{authInfoFromRequest,composeFetch,getOAuthProtectedResourceMetadataUrl,getRequestBag,hostValidationMiddleware,isHtmlNavigationRequest,jsonBodyMiddleware,matchesPath,matchesPathPrefix,oauthMetadata,originValidationMiddleware,pathUnderBase,pathnameOf,requireBearerAuth}from"./chunk-MIZQEWZS.js";import{getOAuthProviderOptions,resolveConfiguredOAuthResource,resolveLocalOAuthResource,wrapOAuthTokenVerifier}from"./chunk-IS7FKXFR.js";import{localhostAllowedHostnames,localhostAllowedOrigins,McpServer as SdkMcpServer,ResourceTemplate,CLIENT_CAPABILITIES_META_KEY as CLIENT_CAPABILITIES_META_KEY3,CLIENT_INFO_META_KEY as CLIENT_INFO_META_KEY3,PROTOCOL_VERSION_META_KEY,isJSONRPCRequest as isJSONRPCRequest2,isInputRequiredResult as isInputRequiredResult2}from"@modelcontextprotocol/server";import{createServer as createNodeHttpServer}from"#mcp-use-node-http";import{Hono}from"hono";var FAVICON_CACHE_CONTROL="public, max-age=31536000, immutable",FAVICON_REDIRECT_CACHE_CONTROL="public, max-age=300";function protocolOf(value){return/^([a-z][a-z\d+.-]*):/i.exec(value)?.[1]?.toLowerCase()}function publicAssetPath(basePath,source){return`${basePath==="/"?"":basePath}/_mcp-use/public/${source.split("/").map(segment=>encodeURIComponent(segment)).join("/")}`}function isLocalPublicSource(source){return protocolOf(source)===void 0}function selectFaviconFromIcons(icons){return icons[0]}function assertLocalPublicSource(source,field){if(source.startsWith("/")||source.includes("\\")||source.includes("?")||source.includes("#")||source.split("/").some(segment=>segment===""||segment===".."))throw new TypeError(`${field} must be an http(s) URL, image data URL, or safe path relative to public/`)}function parseDataImage(source,field){let comma=source.indexOf(",");if(comma<0)throw new TypeError(`${field} must be a valid image data URL`);let metadata=source.slice(5,comma),payload=source.slice(comma+1),parts=metadata.split(";"),mimeType=parts[0]?.toLowerCase()??"";if(!mimeType.startsWith("image/"))throw new TypeError(`${field} data URL must use an image MIME type`);try{if(parts.includes("base64")){let binary2=atob(payload);return{mimeType,bytes:Uint8Array.from(binary2,character=>character.charCodeAt(0))}}return{mimeType,bytes:new TextEncoder().encode(decodeURIComponent(payload))}}catch{throw new TypeError(`${field} must be a valid image data URL`)}}function assertBrandingSource(source,field){if(typeof source!="string"||source.length===0)throw new TypeError(`${field} must be a non-empty string`);let protocol=protocolOf(source);if(protocol===void 0)return assertLocalPublicSource(source,field),source;if(protocol==="data")return parseDataImage(source,field),source;if(protocol!=="http"&&protocol!=="https")throw new TypeError(`${field} must be an http(s) URL, image data URL, or safe path relative to public/`);try{new URL(source)}catch{throw new TypeError(`${field} must be a valid absolute http(s) URL`)}return source}function normalizeServerBranding(config){let websiteUrl;if(config.websiteUrl!==void 0){if(typeof config.websiteUrl!="string"||config.websiteUrl.length===0)throw new TypeError("websiteUrl must be a non-empty absolute http(s) URL");let parsed;try{parsed=new URL(config.websiteUrl)}catch{throw new TypeError("websiteUrl must be a non-empty absolute http(s) URL")}if(parsed.protocol!=="http:"&&parsed.protocol!=="https:")throw new TypeError("websiteUrl must be a non-empty absolute http(s) URL");websiteUrl=config.websiteUrl}let icons;if(config.icons!==void 0){if(!Array.isArray(config.icons))throw new TypeError("icons must be an array of MCP Icon objects");icons=Object.freeze(config.icons.map((value,index)=>{if(typeof value!="object"||value===null)throw new TypeError(`icons[${index}] must be an MCP Icon object`);let icon=value,src=assertBrandingSource(icon.src,`icons[${index}].src`),mimeType=icon.mimeType;if(mimeType!==void 0&&(typeof mimeType!="string"||!mimeType.toLowerCase().startsWith("image/")))throw new TypeError(`icons[${index}].mimeType must be an image MIME type when provided`);let sizes=icon.sizes;if(sizes!==void 0&&(!Array.isArray(sizes)||sizes.some(size=>typeof size!="string"||size.length===0)))throw new TypeError(`icons[${index}].sizes must be an array of non-empty strings when provided`);let normalizedSizes=sizes===void 0?void 0:sizes.map(size=>size),theme=icon.theme;if(theme!==void 0&&theme!=="light"&&theme!=="dark")throw new TypeError(`icons[${index}].theme must be "light" or "dark" when provided`);return Object.freeze({src,...mimeType!==void 0&&{mimeType},...normalizedSizes!==void 0&&{sizes:Object.freeze(normalizedSizes)},...theme!==void 0&&{theme}})}))}let explicitFavicon=config.favicon===void 0?void 0:assertBrandingSource(config.favicon,"favicon"),inferred=explicitFavicon===void 0?selectFaviconFromIcons(icons??[]):void 0,favicon=explicitFavicon??inferred?.src,faviconMimeType=inferred?.mimeType??icons?.find(icon=>icon.src===explicitFavicon)?.mimeType;return Object.freeze({...favicon!==void 0&&{favicon},...faviconMimeType!==void 0&&{faviconMimeType},...icons!==void 0&&{icons},...websiteUrl!==void 0&&{websiteUrl}})}function resolveImplementationIcons(icons,request,basePath){if(icons!==void 0)return icons.map(icon=>({...icon,src:request!==void 0&&isLocalPublicSource(icon.src)?`${resolveAssetsBase(request)}${publicAssetPath(basePath,icon.src)}`:icon.src,...icon.sizes!==void 0&&{sizes:[...icon.sizes]}}))}function hasLocalBrandingAsset(branding){return branding.favicon!==void 0&&isLocalPublicSource(branding.favicon)||branding.icons?.some(icon=>isLocalPublicSource(icon.src))===!0}function createFaviconHandler(branding,options){let source=branding.favicon;if(source!==void 0)return async request=>{if(request.method!=="GET"&&request.method!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});if(new URL(request.url).pathname!=="/favicon.ico")return new Response("Not Found",{status:404});let protocol=protocolOf(source);if(protocol==="http"||protocol==="https")return new Response(null,{status:307,headers:{Location:source,"Cache-Control":FAVICON_REDIRECT_CACHE_CONTROL}});if(protocol==="data"){let data=parseDataImage(source,"favicon");return new Response(request.method==="HEAD"?null:data.bytes.buffer,{status:200,headers:{"Content-Type":branding.faviconMimeType??data.mimeType,"Cache-Control":FAVICON_CACHE_CONTROL,"X-Content-Type-Options":"nosniff"}})}let{join}=await import("path"),publicRoot=options.dev?join(options.projectRoot,"public"):join(options.projectRoot,".mcp-use/build/views/public"),diskPath=await resolvePublicFilePath(publicRoot,source);if(diskPath===null)return new Response("Not Found",{status:404,headers:{"Cache-Control":"no-store"}});let response=await servePublicFile(diskPath,{...options.deferCors===!0&&{deferCors:!0},...request.method==="HEAD"&&{head:!0}});return response.headers.set("Cache-Control",FAVICON_CACHE_CONTROL),response.headers.set("X-Content-Type-Options","nosniff"),branding.faviconMimeType!==void 0&&response.headers.set("Content-Type",branding.faviconMimeType),response}}function assertServerConfig(config){if(config.basePath!==void 0){if(typeof config.basePath!="string")throw new TypeError("basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace");let{basePath}=config;if(!basePath.startsWith("/")||basePath.includes("?")||basePath.includes("#")||/\s/.test(basePath)||basePath.includes("//")||basePath.length>1&&basePath.endsWith("/"))throw new TypeError("basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace")}if(config.port!==void 0&&(typeof config.port!="number"||!Number.isInteger(config.port)||config.port<0||config.port>65535))throw new TypeError("port must be an integer between 0 and 65535")}var DEFAULT_LISTEN_HOST="127.0.0.1";function resolveListenHost(explicitHost,configuredHost,env=process.env){if(explicitHost!==void 0)return explicitHost;let envHost=env.HOST?.trim();return envHost!==void 0&&envHost!==""?envHost:configuredHost??DEFAULT_LISTEN_HOST}function resolveListenPort(explicitPort,configuredPort,env=process.env){if(explicitPort!==void 0)return explicitPort;let envPort=parsePort(env.PORT);return envPort!==void 0?envPort:configuredPort??3e3}function parsePort(value){if(value===void 0||value.trim()==="")return;let port=Number(value);return Number.isInteger(port)&&port>=0&&port<=65535?port:void 0}import{CLIENT_CAPABILITIES_META_KEY as CLIENT_CAPABILITIES_META_KEY2,CLIENT_INFO_META_KEY}from"@modelcontextprotocol/server";import{HonoRequest}from"hono/request";import{CLIENT_CAPABILITIES_META_KEY}from"@modelcontextprotocol/server";var UI_EXTENSION_ID="io.modelcontextprotocol/ui",UI_MIME_TYPE="text/html;profile=mcp-app",UI_RESOURCE_URI_PREFIX="ui://views/";var UI_RESOURCE_URI_META_KEY="ui/resourceUri";function viewResourceUri(viewName){return`${UI_RESOURCE_URI_PREFIX}${viewName}.html`}var clientCapabilitiesByRequest=new WeakMap;function stashClientCapabilities(request,capabilities){clientCapabilitiesByRequest.set(request,capabilities)}function extractClientCapabilitiesFromBody(body){if(typeof body!="object"||body===null)return;let params=body.params;if(typeof params!="object"||params===null)return;let meta=params._meta;if(typeof meta!="object"||meta===null)return;let capabilities=meta[CLIENT_CAPABILITIES_META_KEY];if(!(typeof capabilities!="object"||capabilities===null))return capabilities}function supportsViews(capabilities){let extensions=capabilities?.extensions;if(extensions===void 0)return!1;let uiExtension=extensions[UI_EXTENSION_ID];if(typeof uiExtension!="object"||uiExtension===null)return!1;let mimeTypes=uiExtension.mimeTypes;return Array.isArray(mimeTypes)?mimeTypes.includes(UI_MIME_TYPE):!1}function requireOAuthAuthInfo(authInfo){if(authInfo===void 0||authInfo.extra===void 0||authInfo.expiresAt===void 0)throw new Error("OAuth callback did not receive mapped AuthInfo.extra")}function stringValue(value){return typeof value=="string"?value:void 0}function coordinateValue(value){return typeof value=="string"||typeof value=="number"&&Number.isFinite(value)?value:void 0}function normalizeUserContext(meta){if(meta===void 0)return;let locale=stringValue(meta["openai/locale"])??stringValue(meta["webplus/i18n"]),userAgent=stringValue(meta["openai/userAgent"]),subject=stringValue(meta["openai/subject"]),conversationId=stringValue(meta["openai/session"]),organizationId=stringValue(meta["openai/organization"]),rawLocation=meta["openai/userLocation"],location;if(typeof rawLocation=="object"&&rawLocation!==null&&!Array.isArray(rawLocation)){let values=rawLocation,normalized={city:stringValue(values.city),region:stringValue(values.region),country:stringValue(values.country),timezone:stringValue(values.timezone),latitude:coordinateValue(values.latitude),longitude:coordinateValue(values.longitude)},entries=Object.entries(normalized).filter(entry=>entry[1]!==void 0);entries.length>0&&(location=Object.fromEntries(entries))}if(!(locale===void 0&&userAgent===void 0&&location===void 0&&subject===void 0&&conversationId===void 0&&organizationId===void 0))return{...locale!==void 0&&{locale},...userAgent!==void 0&&{userAgent},...location!==void 0&&{location},...subject!==void 0&&{subject},...conversationId!==void 0&&{conversationId},...organizationId!==void 0&&{organizationId}}}function toClientContext(ctx){let envelope=ctx.mcpReq.envelope,capabilities={...envelope?.[CLIENT_CAPABILITIES_META_KEY2]??{}},info={...envelope?.[CLIENT_INFO_META_KEY]??{}},user=normalizeUserContext(ctx.mcpReq._meta);return{can(capability){return Object.hasOwn(capabilities,capability)},capabilities(){return{...capabilities}},extension(id){let settings=capabilities.extensions?.[id];return settings===void 0?void 0:{...settings}},info(){return{...info}},user(){return user===void 0?void 0:{...user,...user.location!==void 0&&{location:{...user.location}}}},supportsViews(){return supportsViews(capabilities)}}}function toRequestContext(ctx){let rawRequest=ctx.http?.req,http=rawRequest===void 0?void 0:getRequestBag(rawRequest).honoContext,request=http?.req??(rawRequest===void 0?void 0:new HonoRequest(rawRequest)),additions={signal:ctx.mcpReq.signal,...request!==void 0&&{request},...ctx.mcpReq.inputResponses!==void 0&&{inputResponses:ctx.mcpReq.inputResponses},client:toClientContext(ctx),requestState:()=>ctx.mcpReq.requestState(),async sendNotification(method,params){await ctx.mcpReq.notify({method,...params!==void 0&&{params}})},async reportProgress(progress,total,message){let progressToken=ctx.mcpReq._meta?.progressToken;return progressToken===void 0?!1:(await ctx.mcpReq.notify({method:"notifications/progress",params:{progressToken,progress,...total!==void 0&&{total},...message!==void 0&&{message}}}),!0)},async sendLog(level,data,logger){await ctx.mcpReq.notify({method:"notifications/message",params:{level,data,...logger!==void 0&&{logger}}})}};return http!==void 0?Object.assign(http,additions):{...additions,...request!==void 0&&{req:request}}}function toAuthenticatedRequestContext(ctx){let authInfo=ctx.http?.authInfo;return requireOAuthAuthInfo(authInfo),Object.assign(toRequestContext(ctx),{auth:{user:authInfo.extra.user,payload:authInfo.extra.payload,accessToken:authInfo.token,scopes:[...authInfo.scopes],permissions:[...authInfo.extra.permissions],...authInfo.clientId.length>0&&{clientId:authInfo.clientId},expiresAt:authInfo.expiresAt,...authInfo.resource!==void 0&&{resource:authInfo.resource}}})}function isReadResourceResult(result){return"contents"in result&&Array.isArray(result.contents)}function isGetPromptResult(result){return"messages"in result&&Array.isArray(result.messages)}function toResourceResult(result,uri){if(isReadResourceResult(result))return result;let mime=result._meta&&typeof result._meta=="object"&&typeof result._meta.mimeType=="string"?result._meta.mimeType:void 0,contents=[];for(let block of result.content??[]){let mapped=contentBlockToResourceContents(block,uri,mime);mapped!==void 0&&contents.push(mapped)}return contents.length===0&&result.structuredContent!==void 0&&contents.push({uri,mimeType:"application/json",text:JSON.stringify(result.structuredContent)}),contents.length===0&&contents.push({uri,mimeType:"text/plain",text:""}),{contents}}function contentBlockToResourceContents(block,uri,mimeHint){if(block.type==="text")return{uri,mimeType:mimeHint??"text/plain",text:block.text};if(block.type==="image"||block.type==="audio")return{uri,mimeType:block.mimeType,blob:block.data};if(block.type==="resource")return{...block.resource}}function toPromptResult(result){if(isGetPromptResult(result))return result;let messages=(result.content??[]).map(content=>({role:"user",content}));return messages.length===0&&result.structuredContent!==void 0&&messages.push({role:"user",content:{type:"text",text:JSON.stringify(result.structuredContent)}}),messages.length===0&&messages.push({role:"user",content:{type:"text",text:""}}),{messages}}var DEFAULT_METHODS=["GET","HEAD","POST","OPTIONS"],DEFAULT_ALLOWED_HEADERS=["Content-Type","Authorization","mcp-protocol-version","mcp-method","mcp-name"];function resolveAllowedOrigin(origin,requestOrigin){return origin===void 0?requestOrigin:typeof origin=="function"?origin(requestOrigin):origin==="*"?"*":Array.isArray(origin)?requestOrigin!==null&&origin.includes(requestOrigin)?requestOrigin:null:origin}function corsHeaders(options,request){if(request.headers.has("Access-Control-Allow-Origin"))return;let requestOrigin=request.headers.get("Origin"),allowedOrigin=resolveAllowedOrigin(options.origin,requestOrigin);if(allowedOrigin===null)return;let headers={"Access-Control-Allow-Origin":allowedOrigin,"Access-Control-Allow-Methods":options.methods.join(", "),"Access-Control-Allow-Headers":options.allowedHeaders.join(", ")};return options.credentials&&(headers["Access-Control-Allow-Credentials"]="true"),allowedOrigin!=="*"&&(headers.Vary="Origin"),headers}function mergeCorsHeaders(response,headers){if(response.headers.has("Access-Control-Allow-Origin"))return response;let merged=new Headers(response.headers);return new Headers(headers).forEach((value,key)=>{merged.set(key,value)}),inheritBufferedResponse(response,new Response(response.body,{status:response.status,statusText:response.statusText,headers:merged}))}function corsFetchMiddleware(options){if(!(options.enabled!==!1))return async(_request,next)=>next();let resolved={...options.origin!==void 0&&{origin:options.origin},methods:options.methods??DEFAULT_METHODS,allowedHeaders:options.allowedHeaders??DEFAULT_ALLOWED_HEADERS,credentials:options.credentials??!1};return async(request,next)=>{let headers=corsHeaders(resolved,request);if(headers===void 0)return next();if(request.method==="OPTIONS")return new Response(null,{status:204,headers});let response=await next();return mergeCorsHeaders(response,headers)}}function isGlobalCorsEnabled(cors){return cors!==void 0&&cors.enabled!==!1}import{CallToolResultSchema,GetPromptResultSchema,ListPromptsResultSchema,ListResourcesResultSchema,ListToolsResultSchema,ReadResourceResultSchema}from"@modelcontextprotocol/core";import{isInputRequiredResult}from"@modelcontextprotocol/server";var MCP_MIDDLEWARE_METHODS=["tools/call","tools/list","resources/read","resources/list","prompts/get","prompts/list"];function withMcpMiddlewareParams(request,params){if(typeof request!="object"||request===null||Array.isArray(request))throw new TypeError("[mcp-use] MCP middleware received an invalid downstream request");return{...request,params}}function createMcpMiddlewareEntry(pattern,handler){let normalizedPattern=normalizeMcpMiddlewarePattern(pattern),invoke=handler;if(normalizedPattern!=="*"&&!isMcpMiddlewareMethod(normalizedPattern))throw new TypeError(`Unsupported MCP middleware pattern "${pattern}". Use an exact MCP method or "mcp:*".`);return normalizedPattern==="*"?{pattern:normalizedPattern,handler:async(ctx,next)=>{let downstreamCalled=!1,downstreamResult;if(await invoke(ctx,async()=>{downstreamResult=await next(),downstreamCalled=!0}),!downstreamCalled)throw new Error(`Wildcard MCP middleware "${normalizedPattern}" must call next()`);return downstreamResult}}:{pattern:normalizedPattern,handler:(ctx,next)=>invoke(ctx,next)}}function createMcpEventListenerEntry(pattern,handler){let{pattern:normalizedPattern,phase}=parseMcpPattern(pattern),invoke=handler;return{pattern:normalizedPattern,phase,handler:(ctx,result)=>invoke(ctx,result)}}function matchesPattern(pattern,method){if(pattern==="*")return!0;if(pattern.endsWith("/*")){let prefix=pattern.slice(0,-1);return method.startsWith(prefix)}return pattern===method}function isMcpMiddlewareMethod(value){return MCP_MIDDLEWARE_METHODS.some(method=>method===value)}function composeMiddleware(entries,method,innerFn){let matching=entries.filter(entry=>matchesPattern(entry.pattern,method));return matching.length===0?_ctx=>innerFn():ctx=>{let index=-1,dispatch=i=>i<=index?Promise.reject(new Error("next() called multiple times")):(index=i,i===matching.length?innerFn():matching[i].handler(ctx,()=>dispatch(i+1)));return dispatch(0)}}function freezeMiddlewareContext(ctx){return Object.freeze({method:ctx.method,params:Object.freeze({...ctx.params}),...ctx.request!==void 0&&{request:ctx.request},...ctx.req!==void 0&&{req:ctx.req},...ctx.session!==void 0&&{session:Object.freeze({...ctx.session})},...ctx.auth!==void 0&&{auth:ctx.auth},state:new Map(ctx.state)})}async function runMcpOperation(middlewares,events,method,ctx,innerFn){dispatchMcpEvents(events,method,"before",ctx);let result=await composeMiddleware(middlewares,method,innerFn)(ctx);return assertValidMiddlewareResult(method,result),dispatchMcpEvents(events,method,"complete",ctx,result),result}function assertValidMiddlewareResult(method,result){if((method==="tools/call"||method==="resources/read"||method==="prompts/get")&&isInputRequiredResult(result))return;let validation=(()=>{switch(method){case"tools/call":return assertArrayProperty(method,result,"content"),CallToolResultSchema.safeParse(result);case"tools/list":return assertArrayResult(method,result),ListToolsResultSchema.safeParse({tools:result});case"resources/read":return assertArrayProperty(method,result,"contents"),ReadResourceResultSchema.safeParse(result);case"resources/list":return assertArrayResult(method,result),ListResourcesResultSchema.safeParse({resources:result});case"prompts/get":return assertArrayProperty(method,result,"messages"),GetPromptResultSchema.safeParse(result);case"prompts/list":return assertArrayResult(method,result),ListPromptsResultSchema.safeParse({prompts:result});default:throw new TypeError(`Unsupported MCP middleware method "${method}"`)}})();if(!validation.success)throw new TypeError(`[mcp-use] ${method} middleware returned an invalid result: ${validation.error.message}`)}function assertArrayResult(method,result){if(!Array.isArray(result))throw new TypeError(`[mcp-use] ${method} middleware returned an invalid result: expected an array`)}function assertArrayProperty(method,result,property){if(typeof result!="object"||result===null||!Array.isArray(result[property]))throw new TypeError(`[mcp-use] ${method} middleware returned an invalid result: expected a ${property} array`)}function dispatchMcpEvents(events,method,phase,ctx,result){let frozen=freezeMiddlewareContext(ctx);for(let entry of events)if(!(entry.phase!==phase||!matchesPattern(entry.pattern,method)))try{entry.handler(frozen,result)}catch(error2){console.error(`[mcp-use] MCP event listener for "${entry.pattern}" (${phase}) threw:`,error2)}}function parseMcpPattern(raw){let pattern=raw.startsWith("mcp:")?raw.slice(4):raw;return pattern.endsWith(":complete")?{pattern:pattern.slice(0,-9),phase:"complete"}:{pattern,phase:"before"}}function normalizeMcpMiddlewarePattern(raw){return raw.startsWith("mcp:")?raw.slice(4):raw}import{CLIENT_INFO_META_KEY as CLIENT_INFO_META_KEY2,isJSONRPCRequest}from"@modelcontextprotocol/server";function colorsEnabled(){return typeof process>"u"||process.env?.NO_COLOR!==void 0?!1:process.stdout?.isTTY===!0}function ansi(open,close){return text2=>colorsEnabled()?`\x1B[${open}m${text2}\x1B[${close}m`:text2}var bold=ansi(1,22),dim=ansi(2,22),red=ansi(31,39),green=ansi(32,39),yellow=ansi(33,39),blue=ansi(34,39),magenta=ansi(35,39),cyan=ansi(36,39),gray=ansi(90,39);function resolveLogLevel(configured){let raw=typeof process>"u"?void 0:process.env?.MCP_USE_LOG_LEVEL?.toLowerCase();return raw==="info"||raw==="debug"||raw==="trace"?raw:configured??"info"}function formatClientInfo(info){if(info!==void 0)return typeof info.version=="string"&&info.version!==""?`${info.name}/${info.version}`:info.name}var detailFormatters={initialize:p=>({subject:formatClientInfo(p.clientInfo)}),ping:()=>({}),"server/discover":()=>({}),"completion/complete":p=>({subject:p.ref.type==="ref/prompt"?p.ref.name:p.ref.uri,input:p.argument}),"logging/setLevel":p=>({subject:p.level}),"prompts/get":p=>({subject:p.name,input:p.arguments}),"prompts/list":()=>({}),"resources/list":()=>({}),"resources/templates/list":()=>({}),"resources/read":p=>({subject:p.uri}),"resources/subscribe":p=>({subject:p.uri}),"resources/unsubscribe":p=>({subject:p.uri}),"subscriptions/listen":()=>({}),"tools/call":p=>({subject:p.name,input:p.arguments}),"tools/list":()=>({}),"sampling/createMessage":()=>({}),"elicitation/create":()=>({}),"roots/list":()=>({})};function isKnownMethod(method){return Object.prototype.hasOwnProperty.call(detailFormatters,method)}function formatDetail(message){if(!isKnownMethod(message.method))return{};try{let formatter=detailFormatters[message.method],detail=formatter(message.params);return typeof detail.subject=="string"||detail.subject===void 0?detail:{}}catch{return{}}}var INLINE_JSON_MAX_LENGTH=80;function inlineJson(value){let text2;try{text2=JSON.stringify(value)??String(value)}catch{text2=String(value)}return text2.length>INLINE_JSON_MAX_LENGTH?`${text2.slice(0,INLINE_JSON_MAX_LENGTH)}...`:text2}function formatClientIdentity(message){let meta=message.params?._meta;if(meta===void 0)return;let info=meta[CLIENT_INFO_META_KEY2];if(!(typeof info!="object"||info===null||typeof info.name!="string"))return formatClientInfo(info)}function sanitize(text2){return text2.replace(/[\u0000-\u001F\u007F-\u009F]+/g," ")}function methodStyle(method){return method.startsWith("tools/")?cyan:method.startsWith("resources/")?green:method.startsWith("prompts/")?magenta:method==="initialize"||method==="ping"?gray:blue}var REDACTED_HEADERS=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key"]);function redactHeaders(headers){return Object.fromEntries(Object.entries(headers).map(([name,value])=>[name,REDACTED_HEADERS.has(name.toLowerCase())?"[REDACTED]":value]))}async function extractResponseOutcome(res){if(!res.body)return{errorMessage:null};let text2;try{text2=await res.clone().text()}catch{return{errorMessage:null}}if(!text2)return{errorMessage:null};let isSse=(res.headers.get("content-type")??"").includes("text/event-stream"),payloads=[],tryParse=raw=>{try{payloads.push(JSON.parse(raw))}catch{}};if(isSse){for(let line of text2.split(/\r?\n/))if(line.startsWith("data:")){let data=line.slice(5).trim();data&&tryParse(data)}}else tryParse(text2);let result;for(let payload of payloads){if(payload===null||typeof payload!="object")continue;let message=payload;if(typeof message.error?.message=="string")return{errorMessage:message.error.message};if(message.result?.isError===!0){let textBlock=(Array.isArray(message.result.content)?message.result.content:[]).find(b=>b?.type==="text"&&typeof b.text=="string");return{errorMessage:textBlock?String(textBlock.text):"tool error"}}"result"in message&&(result=message.result)}return{errorMessage:null,result}}function compactToolResult(result){if(result===null||typeof result!="object")return result;let{structuredContent,content}=result;if(structuredContent!==void 0)return structuredContent;if(Array.isArray(content)){let[block]=content;if(content.length===1&&block?.type==="text")return block.text}return content}function formatForDump(value){function truncate(val){return typeof val=="string"&&val.length>100?`${val.slice(0,100)}...`:Array.isArray(val)?val.map(truncate):val!==null&&typeof val=="object"?Object.fromEntries(Object.entries(val).map(([k,v])=>[k,truncate(v)])):val}try{return JSON.stringify(truncate(value),null,2)}catch{return String(value)}}var DUMP_BODY_MAX_LENGTH=1e4;async function printTraceDump(response,requestHeaders,requestBody,readResponseBody){console.log(`
2
+ ${cyan("=".repeat(80))}`),console.log(bold(cyan("[TRACE] Request Details"))),console.log(cyan("-".repeat(80))),Object.keys(requestHeaders).length>0&&(console.log(yellow("Request Headers:")),console.log(formatForDump(redactHeaders(requestHeaders)))),requestBody!==void 0&&(console.log(yellow("Request Body:")),console.log(typeof requestBody=="string"?requestBody:formatForDump(requestBody)));let responseHeaders={};if(response.headers.forEach((value,key)=>{responseHeaders[key]=value}),Object.keys(responseHeaders).length>0&&(console.log(yellow("Response Headers:")),console.log(formatForDump(redactHeaders(responseHeaders)))),!readResponseBody)console.log(`${yellow("Response Body:")} (streaming \u2014 not dumped)`);else if(response.body===null)console.log(`${yellow("Response Body:")} (no body)`);else try{let text2=await response.clone().text();if(text2.length===0)console.log(`${yellow("Response Body:")} (empty)`);else{console.log(yellow("Response Body:"));try{console.log(formatForDump(JSON.parse(text2)))}catch{console.log(text2.length>DUMP_BODY_MAX_LENGTH?`${text2.slice(0,DUMP_BODY_MAX_LENGTH)}
3
+ ... (truncated, ${text2.length-DUMP_BODY_MAX_LENGTH} more characters)`:text2)}}}catch{console.log(`${yellow("Response Body:")} (unable to read)`)}console.log(`${cyan("=".repeat(80))}
4
+ `)}function styleStatus(status){let text2=String(status);return status>=500?magenta(text2):status>=400?red(text2):status>=300?yellow(text2):green(text2)}function isNoisyRequest(httpMethod,pathname){return httpMethod!=="GET"&&httpMethod!=="HEAD"?!1:pathname.endsWith("/favicon.ico")}function requestLogger(options={}){return options.enabled===!1?(_request,next)=>next():async(request,next)=>{let level=resolveLogLevel(options.level),startedAt=Date.now(),httpMethod=request.method,pathname=new URL(request.url).pathname;if(isNoisyRequest(httpMethod,pathname))return next();let requestHeaders={};level==="trace"&&request.headers.forEach((value,key)=>{requestHeaders[key]=value});let requestBody;if(httpMethod!=="GET"&&httpMethod!=="HEAD"){let parsedBody=getRequestBag(request).parsedBody;if(parsedBody!==void 0)requestBody=parsedBody;else try{requestBody=await request.clone().json()}catch{}}let response=await next(),durationMs=Date.now()-startedAt,timestamp=new Date().toISOString().substring(11,19),mcpRequest=isJSONRPCRequest(requestBody)?requestBody:void 0,isStreamingMethod=mcpRequest?.method==="subscriptions/listen",lines=[[dim(timestamp),bold(httpMethod),pathname,styleStatus(response.status),dim(`in ${durationMs}ms`)].join(" ")];if(mcpRequest!==void 0){let method=sanitize(mcpRequest.method),parts=[` ${methodStyle(method)(method)}`],detail=formatDetail(mcpRequest);detail.subject!==void 0&&parts.push(bold(sanitize(detail.subject)));let echoPayloads=level!=="info";echoPayloads&&detail.input!==void 0&&parts.push(inlineJson(detail.input));let outcome=isStreamingMethod?{errorMessage:null}:await extractResponseOutcome(response);if(echoPayloads&&mcpRequest.method==="tools/call"&&outcome.errorMessage===null&&outcome.result!==void 0&&parts.push(dim("->"),inlineJson(compactToolResult(outcome.result))),mcpRequest.method!=="initialize"){let client=formatClientIdentity(mcpRequest);client!==void 0&&parts.push(dim(sanitize(client)))}outcome.errorMessage!==null?parts.push(red(`ERROR ${sanitize(outcome.errorMessage)}`)):response.status>=400&&parts.push(red(`ERROR (HTTP ${response.status})`)),lines.push(parts.join(" "))}return console.log(lines.join(`
5
+ `)),level==="trace"&&await printTraceDump(response,requestHeaders,requestBody,!isStreamingMethod),response}}import{createMcpHandler}from"@modelcontextprotocol/server";function createMcpMount(factory,options={}){let{path="/mcp",handler:handlerOptions,authInfo:getAuthInfo}=options,legacyMode=handlerOptions?.legacy??"stateless",handler=createMcpHandler(factory,{legacy:"stateless",...handlerOptions});return{handler,fetch:async request=>{if(!matchesPath(request,path))return new Response("Not Found",{status:404});if(legacyMode==="stateless"){let method=request.method.toUpperCase();if(method==="GET"||method==="DELETE"||method==="HEAD")return new Response(null,{status:204})}let bag=getRequestBag(request),parsedBody=bag.parsedBody;if(parsedBody===void 0)try{parsedBody=await request.clone().json()}catch{}let capabilities=extractClientCapabilitiesFromBody(parsedBody);capabilities!==void 0&&stashClientCapabilities(request,capabilities);let authInfo=getAuthInfo?.(request)??bag.authInfo,response=await handler.fetch(request,{...parsedBody!==void 0&&{parsedBody},...authInfo!==void 0&&{authInfo}});return response.headers.get("content-type")?.toLowerCase().includes("application/json")?"Bun"in globalThis&&response.body!==null?new Response(await response.arrayBuffer(),{status:response.status,statusText:response.statusText,headers:response.headers}):trackBufferedResponse(request,response):response}}}function resolveToolInputSchema(definition){return definition.inputSchema??definition.schema}var registerViews=Symbol("mcp-use/registerViews");function resolveAssetUrl(assetPath,origin){if(!assetPath.startsWith("/"))throw new Error(`View manifest asset path must be origin-absolute (start with "/"); got ${JSON.stringify(assetPath)}`);return`${origin}${assetPath}`}function viewAssetsBasePath(basePath,viewName){return`${pathUnderBase(basePath,`_mcp-use/views/${viewName}`)}/`}function resolveExternalAssetUrl(assetPath,assetsBase,basePath,viewName){return assetPath.startsWith("http://")||assetPath.startsWith("https://")||assetPath.startsWith("data:")?assetPath:assetPath.startsWith("/")?resolveAssetUrl(assetPath,assetsBase):`${assetsBase}${viewAssetsBasePath(basePath,viewName)}${assetPath.replace(/^\/+/,"")}`}function resolvePublicBase(assetsBase,basePath){return`${assetsBase}${pathUnderBase(basePath,"_mcp-use/public")}/`}function escapeInlineScript(code){return code.replaceAll(/<\/script/gi,"<\\/script").replaceAll("<!--","\\x3C!--")}function escapeInlineStyle(css2){return css2.replaceAll(/<\/style/gi,"<\\/style")}function escapeHtml(value){return value.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;")}var VIEW_BOOTSTRAP_STYLE=`<style>
6
+ html,body,#root{background:transparent}
7
+ html,body{margin:0}
8
+ #root[data-mcp-use-loading]{display:flex;min-height:100vh;align-items:center;justify-content:center;flex-direction:column;gap:10px;color:rgba(127,127,127,.9)}
9
+ #root[data-mcp-use-loading]::before{width:20px;height:20px;box-sizing:border-box;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;content:"";animation:mcp-use-view-spin .7s linear infinite}
10
+ #root[data-mcp-use-loading]::after{color:rgba(127,127,127,.9);content:"Compiling...";font:500 13px/1.2 ui-sans-serif,system-ui,sans-serif}
11
+ @keyframes mcp-use-view-spin{to{transform:rotate(360deg)}}
12
+ @media (prefers-reduced-motion:reduce){#root[data-mcp-use-loading]::before{animation-duration:1.4s}}
13
+ </style>`;function synthesizeViewDocument(entry,assetsBase,basePath,viewName){let viewConfig={publicBase:resolvePublicBase(assetsBase,basePath)},configScript=`<script>globalThis.__mcpUseViewConfig=${JSON.stringify(viewConfig)};</script>`;if(entry.kind==="inline"){let styleTag=entry.css.length>0?`<style>${escapeInlineStyle(entry.css)}</style>`:"",moduleScript=`<script type="module">${escapeInlineScript(entry.js)}</script>`;return`<!doctype html>
14
+ <html>
15
+ <head>
16
+ <meta charset="utf-8">
17
+ ${configScript}
18
+ ${VIEW_BOOTSTRAP_STYLE}
19
+ ${styleTag}
20
+ </head>
21
+ <body>
22
+ <div id="root" data-mcp-use-loading></div>
23
+ ${moduleScript}
24
+ </body>
25
+ </html>`}if(viewName===void 0)throw new Error("viewName is required when synthesizing an external view document.");let cssLinks=entry.css.map(path=>`<link rel="stylesheet" href="${escapeHtml(resolveExternalAssetUrl(path,assetsBase,basePath,viewName))}">`).join(`
26
+ `),scriptTags=(entry.scripts??[]).map(path=>`<script type="module" src="${escapeHtml(resolveExternalAssetUrl(path,assetsBase,basePath,viewName))}"></script>`).join(`
27
+ `),devImportMap=entry.entry.startsWith("/")&&(entry.scripts??[]).includes("/@vite/client")?`<script type="importmap">${escapeInlineScript(JSON.stringify({imports:{"/":`${assetsBase.replace(/\/+$/,"")}/`}}))}</script>`:"",entryUrl=resolveExternalAssetUrl(entry.entry,assetsBase,basePath,viewName);return`<!doctype html>
28
+ <html>
29
+ <head>
30
+ <meta charset="utf-8">
31
+ ${configScript}
32
+ ${devImportMap}
33
+ ${VIEW_BOOTSTRAP_STYLE}
34
+ ${cssLinks}
35
+ </head>
36
+ <body>
37
+ <div id="root" data-mcp-use-loading></div>
38
+ ${scriptTags}
39
+ <script type="module" src="${escapeHtml(entryUrl)}"></script>
40
+ </body>
41
+ </html>`}var CATEGORY_ENV={connectDomains:"CSP_CONNECT_DOMAINS",resourceDomains:"CSP_RESOURCE_DOMAINS",frameDomains:"CSP_FRAME_DOMAINS",baseUriDomains:"CSP_BASE_URI_DOMAINS"};function parseDomainList(raw){return raw===void 0||raw.trim()===""?[]:raw.split(",").map(s=>s.trim()).filter(s=>s.length>0)}function readEnvDomains(name){if(typeof process>"u")return;let raw=process.env[name];if(!(raw===void 0||raw.trim()===""))return parseDomainList(raw)}function readCspUrlsShortcut(){return readEnvDomains("CSP_URLS")??[]}function readEnvDomainsForCategory(category){let perCategory=readEnvDomains(CATEGORY_ENV[category]);return perCategory!==void 0?perCategory:readCspUrlsShortcut()}function mergeDomainLists(...segments){let seen=new Set,out=[];for(let segment of segments)for(let domain of segment)seen.has(domain)||(seen.add(domain),out.push(domain));return out}function toWebSocketOrigin(serverOrigin){return serverOrigin.startsWith("https://")?`wss://${serverOrigin.slice(8)}`:serverOrigin.startsWith("http://")?`ws://${serverOrigin.slice(7)}`:serverOrigin}function buildMergedResourceCsp(authorFacts,options){let author=authorFacts?.csp,mcpConnectAuto=[];options.serverOrigin!==""&&(mcpConnectAuto.push(options.serverOrigin),options.hmrWs===!0&&mcpConnectAuto.push(toWebSocketOrigin(options.serverOrigin)));let mcpResourceAuto=[],resourceOrigin=options.explicitAssetsBase?options.assetsOrigin:options.serverOrigin;resourceOrigin!==""&&mcpResourceAuto.push(resourceOrigin);let connectDomains=mergeDomainLists(author?.connectDomains??[],readEnvDomainsForCategory("connectDomains"),mcpConnectAuto),resourceDomains=mergeDomainLists(author?.resourceDomains??[],readEnvDomainsForCategory("resourceDomains"),mcpResourceAuto),frameDomains=mergeDomainLists(author?.frameDomains??[],readEnvDomainsForCategory("frameDomains")),baseUriDomains=mergeDomainLists(author?.baseUriDomains??[],readEnvDomainsForCategory("baseUriDomains"));return{...author,connectDomains,resourceDomains,frameDomains,baseUriDomains}}var PUBLIC_BUILD_DIR=".mcp-use/build/views/public",PUBLIC_DEV_DIR="public",VIEW_ASSETS_BUILD_ROOT=".mcp-use/build/views";function createViewAssetsHandler(basePath,views,options){if(views.size===0)return;let assetsPrefix=pathUnderBase(basePath,"_mcp-use/views"),projectRoot=options?.projectRoot??process.cwd();return async request=>{if(request.method!=="GET"&&request.method!=="HEAD")return new Response("Method Not Allowed",{status:405});if(!matchesPathPrefix(request,assetsPrefix))return new Response("Not Found",{status:404});let remainder=pathnameOf(request).slice(assetsPrefix.length+1),slash=remainder.indexOf("/");if(slash<=0||slash===remainder.length-1)return new Response("Not Found",{status:404});let viewName=remainder.slice(0,slash),subpath=remainder.slice(slash+1),entry=views.get(viewName);if(entry===void 0||entry.kind!=="external")return new Response("Not Found",{status:404});let[{join},{resolvePublicFilePath:resolvePublicFilePath2,servePublicFile:servePublicFile2}]=await Promise.all([import("path"),import("./public-route-DAQJGS6K.js")]),viewRoot=join(projectRoot,VIEW_ASSETS_BUILD_ROOT,viewName),diskPath=await resolvePublicFilePath2(viewRoot,subpath);return diskPath===null?new Response("Not Found",{status:404}):await servePublicFile2(diskPath,{...options?.deferCors===!0&&{deferCors:!0},...request.method==="HEAD"&&{head:!0}})}}function createViewPublicHandler(basePath,views,options){if(views.size===0&&options?.enabled!==!0)return;let publicPrefix=pathUnderBase(basePath,"_mcp-use/public"),subdir=options?.dev===!0?PUBLIC_DEV_DIR:PUBLIC_BUILD_DIR,projectRoot=options?.projectRoot??process.cwd();return async request=>{if(request.method!=="GET"&&request.method!=="HEAD")return new Response("Method Not Allowed",{status:405});if(!matchesPathPrefix(request,publicPrefix))return new Response("Not Found",{status:404});let encodedSubpath=pathnameOf(request).slice(publicPrefix.length+1),subpath;try{subpath=decodeURIComponent(encodedSubpath)}catch{return new Response("Not Found",{status:404})}if(subpath.length===0)return new Response("Not Found",{status:404});let[{join},{resolvePublicFilePath:resolvePublicFilePath2,servePublicFile:servePublicFile2}]=await Promise.all([import("path"),import("./public-route-DAQJGS6K.js")]),publicRoot=join(projectRoot,subdir),diskPath=await resolvePublicFilePath2(publicRoot,subpath);return diskPath===null?new Response("Not Found",{status:404}):await servePublicFile2(diskPath,{...options?.deferCors===!0&&{deferCors:!0},...request.method==="HEAD"&&{head:!0}})}}function buildToolUiMeta(viewName,visibility,existingMetadata){if(viewName===void 0&&visibility===void 0&&existingMetadata===void 0)return;let meta={...existingMetadata},existingUi=existingMetadata?.["ui"],existingUiIsObject=typeof existingUi=="object"&&existingUi!==null&&!Array.isArray(existingUi),ui=existingUiIsObject?{...existingUi}:{};if(viewName!==void 0){let resourceUri=viewResourceUri(viewName);ui.resourceUri=resourceUri,meta[UI_RESOURCE_URI_META_KEY]=resourceUri}else delete ui.resourceUri,delete meta[UI_RESOURCE_URI_META_KEY];return visibility!==void 0?ui.visibility=[visibility]:delete ui.visibility,(viewName!==void 0||visibility!==void 0||existingUiIsObject)&&(meta["ui"]=ui),meta}function buildToolResultUiMeta(viewName){let resourceUri=viewResourceUri(viewName);return{ui:{resourceUri},[UI_RESOURCE_URI_META_KEY]:resourceUri}}function resolveCspOptions(options){let request=options?.request,serverOrigin=options?.serverOrigin??(request!==void 0?resolveServerOrigin(request):""),assetsBase=options?.assetsBase??(request!==void 0?resolveAssetsBase(request):serverOrigin);return{serverOrigin,assetsOrigin:originFromAssetsBase(assetsBase),explicitAssetsBase:hasExplicitAssetsBase(),...options?.hmrWs===!0?{hmrWs:!0}:{}}}function buildResourceUiMeta(authorFacts,options){let ui={csp:buildMergedResourceCsp(authorFacts,resolveCspOptions(options))};return authorFacts?.permissions!==void 0&&(ui.permissions=authorFacts.permissions),authorFacts?.domain!==void 0&&(ui.domain=authorFacts.domain),authorFacts?.prefersBorder!==void 0&&(ui.prefersBorder=authorFacts.prefersBorder),{ui}}function viewResourceConfig(_viewName,_entry,authorFacts,options){return{mimeType:UI_MIME_TYPE,...authorFacts?.description!==void 0&&{description:authorFacts.description},_meta:buildResourceUiMeta(authorFacts,options)}}function record(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)?value:void 0}function productId(value,fallback){if(typeof value!="string")return fallback;let normalized=value.trim();return normalized.length>0&&normalized.length<=64&&![...normalized].some(character=>{let code=character.charCodeAt(0);return code<32||code===127})?normalized:fallback}function clientUsageFromBody(body){if(!isJSONRPCRequest2(body))return;let params=record(body.params);if(body.method==="initialize"){let info2=record(params?.clientInfo),capabilities2=record(params?.capabilities)??{};return clientUsage(info2,capabilities2,params?.protocolVersion,"legacy")}let meta=record(params?._meta),info=record(meta?.[CLIENT_INFO_META_KEY3]),capabilities=record(meta?.[CLIENT_CAPABILITIES_META_KEY3]);if(!(info===void 0||capabilities===void 0))return clientUsage(info,capabilities,meta?.[PROTOCOL_VERSION_META_KEY],"modern")}function clientUsage(info,capabilities,protocolVersion,era){let typedCapabilities=capabilities;return{client_name:productId(info?.name,"other"),client_version:productId(info?.version,"unknown"),protocol_era:era,protocol_version:productId(protocolVersion,"unknown"),connection_mode:era==="modern"?"stateless_request":"legacy_session",sampling_capability:Object.hasOwn(capabilities,"sampling"),elicitation_capability:Object.hasOwn(capabilities,"elicitation"),roots_capability:Object.hasOwn(capabilities,"roots"),extensions_capability:Object.hasOwn(capabilities,"extensions"),views_capability:supportsViews(typedCapabilities),capability_count:Object.keys(capabilities).length}}function omitRootSchemaDialect(schema){if(typeof schema!="object"||schema===null||Array.isArray(schema)||!("$schema"in schema))return schema;let emittedSchema={...schema};return delete emittedSchema.$schema,emittedSchema}function omitToolSchemaDialects(tools){return tools.map(tool=>({...tool,inputSchema:omitRootSchemaDialect(tool.inputSchema),...tool.outputSchema===void 0?{}:{outputSchema:omitRootSchemaDialect(tool.outputSchema)}}))}function registerFetchMiddleware(app,middleware){app.use("*",async(context,next)=>{let response=await middleware(context.req.raw,async()=>(await next(),context.res));return context.res=response,response})}var MCPServer=class _MCPServer{#config;#branding;#tools=new Map;#resources=new Map;#resourceTemplates=new Map;#prompts=new Map;#views=new Map;#viewBindings=new Map;#viewsPrimed=!1;#viewsDevMode=!1;#viewsProjectRoot=process.cwd();#fetchHandler;#httpApp;#handler;#eventBus;#httpServer;#oauthResource;#oauthResourceResolved=!1;#oauthResourceConfigurationAbsent=!1;#hostValidated=!1;#mcpMiddlewares=[];#mcpEventListeners=[];#usageScope;#openApiTools=new Set;#proxiedTools=new Set;#proxiedResources=new Set;#proxiedPrompts=new Set;#httpMiddlewareCount=0;#proxyServersConfigured=0;#proxyServersConnected=0;#proxyToolsDiscovered=0;#proxyResourcesDiscovered=0;#proxyPromptsDiscovered=0;#proxyOwners=[];#proxyOperations=new Set;#closed=!1;app;get;post;put;patch;delete;all;fetch;static fromOpenAPI(options){let server=new _MCPServer({name:options.name??options.spec.info.title,version:options.version??options.spec.info.version??"1.0.0"});registerOpenAPITools(server,options);for(let name of server.#tools.keys())server.#openApiTools.add(name);return server}constructor(config){if(assertServerConfig(config),this.#config=config,this.#branding=normalizeServerBranding(config),this.app=new Hono,this.app.use("*",async(context,next)=>{getRequestBag(context.req.raw).honoContext=context,await next()}),this.get=this.app.get.bind(this.app),this.post=this.app.post.bind(this.app),this.put=this.app.put.bind(this.app),this.patch=this.app.patch.bind(this.app),this.delete=this.app.delete.bind(this.app),this.all=this.app.all.bind(this.app),this.fetch=async(request,env,executionCtx)=>(this.#ensureMounted("handler"),this.#httpApp.fetch(request,env,executionCtx)),config.oauth!==void 0){let mcpUrl=typeof process>"u"?void 0:process.env.MCP_URL,resource2=resolveConfiguredOAuthResource({provider:config.oauth,basePath:this.#basePath(),...mcpUrl!==void 0&&{mcpUrl}});this.#oauthResource=resource2,this.#oauthResourceResolved=resource2!==void 0,this.#oauthResourceConfigurationAbsent=resource2===void 0}}get basePath(){return this.#basePath()}get host(){return this.#config.host}get port(){return this.#config.port}get branding(){return this.#branding}getHandler(){return this.fetch}tool(definition,callback){return this.#assertNotStarted("tool",definition.name),this.#validateToolViewBinding(definition),this.#openApiTools.delete(definition.name),this.#proxiedTools.delete(definition.name),this.#tools.set(definition.name,{definition,callback}),Object.freeze({name:definition.name})}[registerViews](views,options){if(this.#viewsPrimed)throw new Error("Cannot prime views: the views registry is already primed on this server instance.");this.#assertNotStarted("views","manifest"),this.#viewsDevMode=options?.dev===!0,options?.projectRoot!==void 0&&(this.#viewsProjectRoot=options.projectRoot);for(let[name,entry]of Object.entries(views))this.#views.set(name,entry);this.#viewsPrimed=!0}__primeViews(views,options){this[registerViews](views,options)}resource(definition,callback){this.#assertNotStarted("resource",definition.name);let previous=this.#resources.get(definition.name);return previous!==void 0&&this.#proxiedResources.delete(previous.definition.uri),this.#resources.set(definition.name,{definition,callback}),this}resourceTemplate(definition,callback){this.#assertNotStarted("resourceTemplate",definition.name);let complete=definition.complete===void 0?void 0:normalizeCompletions(definition.complete);return this.#resourceTemplates.set(definition.name,{definition,...complete!==void 0&&{complete},callback}),this}prompt(definition,callback){return this.#assertNotStarted("prompt",definition.name),this.#proxiedPrompts.delete(definition.name),this.#prompts.set(definition.name,{definition,callback}),this}async proxy(input){this.#assertOpen("proxy()");let operation=(async()=>{let{isProxyConnection,mountProxyConnection,mountProxyServers}=await import("./mcp-proxy-NETCUGUD.js");if(isProxyConnection(input)){this.#proxyServersConfigured+=1,await mountProxyConnection(this.#proxyHost(),input);return}this.#proxyServersConfigured+=Object.keys(input).length,await mountProxyServers(this.#proxyHost(),input)})();this.#proxyOperations.add(operation);try{await operation}finally{this.#proxyOperations.delete(operation)}}use(patternOrHandler,...handlers){if(typeof patternOrHandler=="string"&&patternOrHandler.startsWith("mcp:")){this.#assertNotStarted("middleware",patternOrHandler);let handler=handlers[0];return this.#mcpMiddlewares.push(createMcpMiddlewareEntry(patternOrHandler,handler)),this}return this.app.use.call(this.app,patternOrHandler,...handlers),this.#httpMiddlewareCount+=typeof patternOrHandler=="function"?1:handlers.length,this}on(pattern,handler){return this.#assertNotStarted("event listener",pattern),this.#mcpEventListeners.push(createMcpEventListenerEntry(pattern,handler)),this}__setEventBus(bus){this.#assertNotStarted("event bus","shared"),this.#eventBus=bus}__mount(){this.#ensureMounted("handler")}async notifyToolsChanged(){await this.#ensureMounted("handler").handler.notify.toolsChanged()}async notifyPromptsChanged(){await this.#ensureMounted("handler").handler.notify.promptsChanged()}async notifyResourcesChanged(){await this.#ensureMounted("handler").handler.notify.resourcesChanged()}async notifyResourceUpdated(uri){await this.#ensureMounted("handler").handler.notify.resourceUpdated(uri)}async listen(port=void 0,options={}){this.#assertOpen("listen()");let host=resolveListenHost(options.host,this.#config.host),requestedPort=resolveListenPort(port,this.#config.port);return this.#assertListenOAuthConfiguration(host),new Promise((resolve,reject)=>{let resolveFetch,rejectFetch,fetchReady=new Promise((resolveFetchPromise,rejectFetchPromise)=>{resolveFetch=resolveFetchPromise,rejectFetch=rejectFetchPromise});fetchReady.catch(()=>{});let settled=!1,rejectAndClose=error2=>{settled||(settled=!0,reject(error2)),rejectFetch?.(error2),new Promise(closeResolve=>server.close(()=>closeResolve())).catch(()=>{}).finally(()=>{this.#httpServer===server&&(this.#httpServer=void 0)})},nodeHandler=toNodeHandler({fetch:async request=>(await fetchReady)(request)}),server=createNodeHttpServer((req,res)=>{nodeHandler(req,res)});server.once("error",rejectAndClose),server.listen(requestedPort,host,()=>{try{let address=server.address(),boundPort=typeof address=="object"&&address!==null?address.port:requestedPort,{fetch}=this.#ensureMounted("listen",boundPort,host);resolveFetch?.(fetch),settled||(settled=!0,resolve({port:boundPort,url:`http://localhost:${boundPort}${this.#basePath()}`}))}catch(error2){rejectAndClose(error2)}}),this.#httpServer=server})}async close(){this.#closed=!0,await Promise.allSettled([...this.#proxyOperations]);let errors=[],proxyOwners=this.#proxyOwners.splice(0),ownerResults=await Promise.allSettled(proxyOwners.map(owner=>owner.close()));for(let result of ownerResults)result.status==="rejected"&&errors.push(result.reason);try{await this.#handler?.close()}catch(error2){errors.push(error2)}let httpServer=this.#httpServer;if(httpServer!==void 0)try{await new Promise((resolve,reject)=>{httpServer.close(err=>err?reject(err):resolve())}),this.#httpServer=void 0}catch(error2){errors.push(error2)}if(errors.length>0)throw new AggregateError(errors,"Failed to close MCP server cleanly")}#assertOpen(operation){if(this.#closed)throw operation!==void 0?new Error(`Cannot call ${operation} after the server has closed.`):new Error("Cannot use the server after it has closed.")}#basePath(){return this.#config.basePath??"/mcp"}#resolveOAuthResource(mode,listenPort,listenHost){if(this.#config.oauth===void 0)return;if(this.#oauthResourceResolved)return this.#oauthResource;let host=listenHost??this.#config.host??"127.0.0.1",localListen=mode==="listen"&&listenPort!==void 0&&["127.0.0.1","localhost","::1"].includes(host);if(this.#oauthResourceConfigurationAbsent&&localListen)return this.#oauthResource=resolveLocalOAuthResource(`http://localhost:${listenPort}`,this.#basePath()),this.#oauthResourceResolved=!0,this.#oauthResource;throw new Error("OAuth requires an explicit resource or MCP_URL when using server.fetch or listening on a non-local host")}#assertListenOAuthConfiguration(host){if(this.#config.oauth!==void 0&&!["127.0.0.1","localhost","::1"].includes(host)&&!this.#oauthResourceResolved)throw new Error("OAuth listen() on a public or wildcard host requires an explicit provider resource or valid MCP_URL.")}#assertNotStarted(kind,name){if(this.#handler!==void 0)throw new Error(`Cannot register ${kind} "${name}" after the server has started: registrations are replayed per request from the registry, so register everything before listen()/server.fetch.`)}#trackConfigured(){recordUsage("server","configured",{tools_total:this.#tools.size,tools_local:this.#tools.size-this.#openApiTools.size-this.#proxiedTools.size,tools_openapi:this.#openApiTools.size,tools_proxied:this.#proxiedTools.size,resources:this.#resources.size,resource_templates:this.#resourceTemplates.size,prompts:this.#prompts.size,views:this.#views.size,proxy_servers_configured:this.#proxyServersConfigured,proxy_servers_connected:this.#proxyServersConnected,proxy_tools_discovered:this.#proxyToolsDiscovered,proxy_resources_discovered:this.#proxyResourcesDiscovered,proxy_prompts_discovered:this.#proxyPromptsDiscovered,proxy_tools_mounted:this.#proxiedTools.size,proxy_resources_mounted:this.#proxiedResources.size,proxy_prompts_mounted:this.#proxiedPrompts.size,http_middleware:this.#httpMiddlewareCount,mcp_middleware:this.#mcpMiddlewares.length,observers_before:this.#mcpEventListeners.filter(({phase})=>phase==="before").length,observers_complete:this.#mcpEventListeners.filter(({phase})=>phase==="complete").length,oauth_configured:this.#config.oauth!==void 0,cors_configured:this.#config.cors!==void 0,request_state_configured:this.#config.requestState!==void 0,legacy_policy:this.#config.legacy??"stateless"},{onceKey:`${this.#usageScopeId()}:server`,serverRoot:this.#viewsProjectRoot})}#trackClient(body){let client=clientUsageFromBody(body);client!==void 0&&recordUsage("client","observed",{...client},{onceKey:`${this.#usageScopeId()}:client:${JSON.stringify(client)}`,serverRoot:this.#viewsProjectRoot})}#usageScopeId(){return this.#usageScope??=crypto.randomUUID(),this.#usageScope}#proxyHost(){return{isStarted:()=>this.#handler!==void 0,hasTool:name=>this.#tools.has(name),hasResource:name=>this.#resources.has(name),hasPrompt:name=>this.#prompts.has(name),registerTool:(definition,callback)=>{this.#assertNotStarted("tool",definition.name),this.#proxiedTools.add(definition.name),this.#tools.set(definition.name,{definition,callback})},registerResource:(definition,callback)=>{this.#assertNotStarted("resource",definition.name),this.#proxiedResources.add(definition.uri),this.#resources.set(definition.name,{definition,callback})},registerPrompt:(definition,callback)=>{this.#assertNotStarted("prompt",definition.name),this.#proxiedPrompts.add(definition.name),this.#prompts.set(definition.name,{definition,callback})},trackOwner:owner=>{this.#proxyOwners.push(owner)},trackNamespace:({tools,resources,prompts})=>{this.#proxyServersConnected+=1,this.#proxyToolsDiscovered+=tools,this.#proxyResourcesDiscovered+=resources,this.#proxyPromptsDiscovered+=prompts}}}#validationPolicy(mode,listenHost){let{allowedHosts,allowedOrigins}=this.#config,host=listenHost??this.#config.host??"127.0.0.1",localhostBind=["127.0.0.1","localhost","::1"].includes(host),hosts=allowedHosts!==void 0?[...new Set([...localhostAllowedHostnames(),...allowedHosts])]:mode==="listen"&&localhostBind?localhostAllowedHostnames():void 0,origins=allowedOrigins!==void 0?[...new Set([...localhostAllowedOrigins(),...allowedOrigins])]:void 0;return{hosts,origins}}#ensureMounted(mode,listenPort,listenHost){if(this.#assertOpen(),this.#fetchHandler===void 0||this.#handler===void 0){let{hosts,origins}=this.#validationPolicy(mode,listenHost),basePath=this.#basePath(),nestedBasePath=basePath==="/"?"":basePath,httpApp=new Hono,middlewares=[jsonBodyMiddleware(),requestLogger(this.#config.logging)],corsConfig=this.#config.cors;corsConfig!==void 0&&middlewares.unshift(corsFetchMiddleware(corsConfig));let deferViewCors=isGlobalCorsEnabled(corsConfig);hosts!==void 0&&middlewares.unshift(hostValidationMiddleware(hosts)),origins!==void 0&&middlewares.push(originValidationMiddleware(origins)),hosts===void 0&&mode==="listen"&&console.warn(`[mcp-use] listen() is serving on ${listenHost} without Host validation. Behind a platform edge that only routes your own domains this is expected; if this process is reachable directly, set allowedHosts to restrict it.`),this.#validateViewBindingsAtMount();let resource2=this.#resolveOAuthResource(mode,listenPort,listenHost);if(resource2!==void 0){let provider=this.#config.oauth;middlewares.push(oauthMetadata(provider,resource2))}for(let middleware of middlewares)registerFetchMiddleware(httpApp,middleware);let{handler,fetch:mcpFetch}=createMcpMount(ctx=>this.#buildSdkServer(ctx),{path:basePath,...(this.#config.legacy!==void 0||this.#eventBus!==void 0)&&{handler:{...this.#config.legacy!==void 0&&{legacy:this.#config.legacy},...this.#eventBus!==void 0&&{bus:this.#eventBus}}},...resource2!==void 0&&{authInfo:request=>authInfoFromRequest(request)}}),protectWithBearer=async(_request,next)=>next();if(resource2!==void 0){let provider=this.#config.oauth,providerOptions=getOAuthProviderOptions(provider),gate=requireBearerAuth({verifier:wrapOAuthTokenVerifier(provider,resource2),resourceMetadataUrl:getOAuthProtectedResourceMetadataUrl(resource2),...providerOptions.requiredScopes!==void 0&&{requiredScopes:providerOptions.requiredScopes}});protectWithBearer=async(request,next)=>{let result=await gate(request);if(result instanceof Response)return result;let bag=getRequestBag(request);return bag.authInfo=result,next()},httpApp.use("*",async(context,next)=>{if(new URL(context.req.url).pathname!==basePath){await next();return}if(this.#config.publicLandingPage===!0&&isHtmlNavigationRequest(context.req.raw)){await next();return}let response=await protectWithBearer(context.req.raw,async()=>(await next(),context.res));return context.res=response,response})}let mcpRouteHandler=request=>{let body=getRequestBag(request).parsedBody;return isJSONRPCRequest2(body)&&(this.#trackConfigured(),this.#trackClient(body)),mcpFetch(request)},endpointHandler=async request=>isHtmlNavigationRequest(request)?(async()=>{let{createLandingPageResponse}=await import("./landing-handler-TG6LVQBI.js");return createLandingPageResponse(request,basePath,this.#config,this.#branding,this.#tools.values(),this.#prompts.values(),this.#resources.values())})():mcpRouteHandler(request),brandingDevMode=this.#viewsPrimed?this.#viewsDevMode:process.env.NODE_ENV!=="production",faviconHandler=createFaviconHandler(this.#branding,{dev:brandingDevMode,projectRoot:this.#viewsProjectRoot,deferCors:deferViewCors});faviconHandler!==void 0&&this.app.all("/favicon.ico",context=>faviconHandler(context.req.raw));let viewHandler=createViewPublicHandler(basePath,this.#views,{dev:this.#viewsPrimed?this.#viewsDevMode:brandingDevMode,projectRoot:this.#viewsProjectRoot,enabled:hasLocalBrandingAsset(this.#branding),deferCors:deferViewCors});if(viewHandler!==void 0&&this.app.on(["GET","HEAD"],`${nestedBasePath}/_mcp-use/public/*`,context=>viewHandler(context.req.raw)),!this.#viewsDevMode){let viewAssetsHandler=createViewAssetsHandler(basePath,this.#views,{projectRoot:this.#viewsProjectRoot,deferCors:deferViewCors});viewAssetsHandler!==void 0&&this.app.on(["GET","HEAD"],`${nestedBasePath}/_mcp-use/views/*`,context=>viewAssetsHandler(context.req.raw))}this.app.all(basePath,context=>endpointHandler(context.req.raw)),httpApp.route("/",this.app),this.#httpApp=httpApp,this.#fetchHandler=async request=>httpApp.fetch(request),this.#handler=handler,this.#hostValidated=hosts!==void 0}else if(mode==="listen"&&!this.#hostValidated&&this.#validationPolicy("listen",listenHost).hosts!==void 0)throw new Error("Cannot listen() on a localhost bind after server.fetch mounted the app without Host validation (server.fetch expects a platform edge in front). Call listen() first, or set allowedHosts.");return{fetch:this.#fetchHandler,handler:this.#handler}}#validateToolViewBinding(definition){let view=definition.view;if(view===void 0)return;if(definition.outputSchema===void 0)throw new Error(`Tool "${definition.name}" declares view "${view.name}" but has no outputSchema. View-bound tools require an outputSchema \u2014 the view reads structuredContent typed from it. Use outputSchema: z.object({}) for a view that takes no structured output.`);let existing=this.#viewBindings.get(view.name);if(existing!==void 0)throw new Error(`View "${view.name}" is already bound to tool "${existing.toolName}"; tool "${definition.name}" cannot bind the same view. Each view may be bound to one tool.`);this.#viewBindings.set(view.name,{toolName:definition.name,config:view})}#validateViewBindingsAtMount(){if(this.#viewBindings.size>0&&!this.#viewsPrimed){let first=[...this.#tools.values()].find(entry=>entry.definition.view!==void 0),viewName=first?.definition.view?.name??"unknown";throw new Error(`Tool "${first?.definition.name??"unknown"}" is bound to view "${viewName}" but no views were primed. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`)}for(let entry of this.#tools.values()){let viewName=entry.definition.view?.name;if(viewName!==void 0&&!this.#views.has(viewName))throw new Error(`Tool "${entry.definition.name}" is bound to view "${viewName}" which is not in the primed views registry. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`)}for(let viewName of this.#views.keys())this.#viewBindings.has(viewName)||console.warn(`[mcp-use] View "${viewName}" is registered but no tool binds it.`)}#buildSdkServer(ctx){let{name,version,title,description,instructions}=this.#config,authInfo=ctx.authInfo,server=new SdkMcpServer({name,version,...title!==void 0&&{title},...description!==void 0&&{description},...this.#branding.websiteUrl!==void 0&&{websiteUrl:this.#branding.websiteUrl},...this.#branding.icons!==void 0&&{icons:resolveImplementationIcons(this.#branding.icons,ctx.requestInfo,this.#basePath())}},{capabilities:{logging:{},tools:{listChanged:!0},prompts:{listChanged:!0},resources:{listChanged:!0,subscribe:!0}},...instructions!==void 0&&{instructions},...authInfo!==void 0&&{authInfo},...this.#config.requestState!==void 0&&{requestState:this.#config.requestState}}),request=ctx.requestInfo,viewMetaOptions=request!==void 0?{request,hmrWs:this.#viewsDevMode}:{hmrWs:this.#viewsDevMode},basePath=this.#basePath();for(let entry of this.#tools.values())this.#registerTool(server,entry);for(let entry of this.#resources.values())this.#registerResource(server,entry);for(let entry of this.#resourceTemplates.values())this.#registerResourceTemplate(server,entry);for(let entry of this.#prompts.values())this.#registerPrompt(server,entry);for(let[viewName,viewEntry]of this.#views.entries())this.#registerViewResource(server,viewName,viewEntry,viewMetaOptions,basePath);return this.#wrapListHandlers(server),server}#createMiddlewareContext(method,params,ctx){let requestContext=toRequestContext(ctx);return Object.assign(requestContext,{method,params,...ctx.sessionId!==void 0&&{session:{sessionId:ctx.sessionId}},...ctx.http?.authInfo!==void 0&&{auth:ctx.http.authInfo},state:new Map})}#runMcpHook(method,ctx,innerFn){let runOperation=method==="tools/call"&&this.#mcpMiddlewares.length===0&&this.#mcpEventListeners.length===0?innerFn:()=>runMcpOperation(this.#mcpMiddlewares,this.#mcpEventListeners,method,ctx,innerFn);if(isUsageDisabled())return runOperation();let startedAt=performance.now(),matchedMiddleware=this.#mcpMiddlewares.filter(entry=>matchesPattern(entry.pattern,method)).length,matchedObservers=phase=>this.#mcpEventListeners.filter(entry=>entry.phase===phase&&matchesPattern(entry.pattern,method)).length,request=ctx.request?.raw,client=request===void 0?void 0:clientUsageFromBody(getRequestBag(request).parsedBody),capture=(outcome,completedPhase)=>{recordUsage("operation","completed",{method,outcome,duration_ms:Math.max(0,Math.round(performance.now()-startedAt)),primitive_origin:this.#primitiveOrigin(method,ctx.params),matched_middleware:matchedMiddleware,observers_before:matchedObservers("before"),observers_complete:completedPhase?matchedObservers("complete"):0,...client?.protocol_era==="modern"?client:{client_name:"unknown",protocol_era:"legacy"}},{sampleRate:outcome==="success"?.1:1,serverRoot:this.#viewsProjectRoot})};return runOperation().then(result=>{let outcome=isInputRequiredResult2(result)?"input_required":method==="tools/call"&&typeof result=="object"&&result!==null&&"isError"in result&&result.isError===!0?"error":"success";return capture(outcome,!0),result},error2=>{throw capture("error",!1),error2})}#primitiveOrigin(method,params){if(method==="tools/call"){let name=String(params.name);return this.#proxiedTools.has(name)?"proxied":this.#openApiTools.has(name)?"openapi":"local"}return method==="resources/read"?this.#proxiedResources.has(String(params.uri))?"proxied":"local":method==="prompts/get"?this.#proxiedPrompts.has(String(params.name))?"proxied":"local":"mixed"}#wrapListHandlers(server){let handlers=server.server._requestHandlers;if(handlers===void 0)return;let wrapListMethod=(method,resultKey,transform)=>{let original=handlers.get(method);if(original===void 0||original.__mcpListWrapped)return;let wrapped=async(request,extra)=>{let serverContext=extra,params=request.params??{},mwCtx=this.#createMiddlewareContext(method,params,serverContext),originalEnvelope,innerFn=async()=>{let downstreamRequest=withMcpMiddlewareParams(request,mwCtx.params),result=await original(downstreamRequest,extra);if(typeof result!="object"||result===null)throw new TypeError(`[mcp-use] ${method} handler returned a non-object result`);originalEnvelope=result;let items=originalEnvelope[resultKey];if(!Array.isArray(items))throw new TypeError(`[mcp-use] ${method} handler result is missing a ${resultKey} array`);return items},filtered=await this.#runMcpHook(method,mwCtx,innerFn);if(!Array.isArray(filtered))throw new TypeError(`[mcp-use] ${method} middleware must return a ${resultKey} array`);let emitted=transform?.(filtered)??filtered;return{...originalEnvelope,[resultKey]:emitted}};wrapped.__mcpListWrapped=!0,handlers.set(method,wrapped)};wrapListMethod("tools/list","tools",omitToolSchemaDialects),wrapListMethod("resources/list","resources"),wrapListMethod("prompts/list","prompts")}#registerTool(server,{definition,callback}){let view=definition.view,toolMeta=buildToolUiMeta(view?.name,definition.visibility,definition._meta),config={...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description},...definition.annotations!==void 0&&{annotations:definition.annotations},...definition.outputSchema!==void 0&&{outputSchema:definition.outputSchema},...toolMeta!==void 0&&{_meta:toolMeta}},wireResultMeta=view!==void 0?buildToolResultUiMeta(view.name):void 0,inputSchema=resolveToolInputSchema(definition),invokeTool=async(args,ctx)=>{let mwCtx=this.#createMiddlewareContext("tools/call",{name:definition.name,arguments:args,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>{let effectiveArgs=mwCtx.params.arguments??{},result=await callback(effectiveArgs,this.#toRequestContext(ctx));return isInputRequiredResult2(result)||wireResultMeta===void 0||result.isError===!0?result:{...result,_meta:{...result._meta,...wireResultMeta}}};return await this.#runMcpHook("tools/call",mwCtx,innerFn)};inputSchema!==void 0?server.registerTool(definition.name,{...config,inputSchema},async(args,ctx)=>invokeTool(args,ctx)):server.registerTool(definition.name,config,async ctx=>invokeTool({},ctx))}#registerViewResource(server,viewName,entry,metaOptions,basePath){let uri=viewResourceUri(viewName),authorFacts=this.#viewResourceFacts(this.#viewBindings.get(viewName)?.config),resourceConfig=viewResourceConfig(viewName,entry,authorFacts,metaOptions);server.registerResource(viewName,uri,resourceConfig,async(readUri,ctx)=>{let req=ctx.http?.req,readOptions=req!==void 0?{request:req,...metaOptions.hmrWs===!0?{hmrWs:!0}:{}}:metaOptions.hmrWs===!0?{hmrWs:!0}:{},assetsBase=req!==void 0?resolveAssetsBase(req):metaOptions.request!==void 0?resolveAssetsBase(metaOptions.request):"",html2=synthesizeViewDocument(entry,assetsBase,basePath,viewName);return{contents:[{uri:readUri.href,mimeType:resourceConfig.mimeType,text:html2,_meta:buildResourceUiMeta(authorFacts,readOptions)}]}})}#registerResource(server,{definition,callback}){server.registerResource(definition.name,definition.uri,{...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description},...definition.mimeType!==void 0&&{mimeType:definition.mimeType},...definition.annotations!==void 0&&{annotations:definition.annotations},...definition._meta!==void 0&&{_meta:{...definition._meta}}},async(uri,ctx)=>{let mwCtx=this.#createMiddlewareContext("resources/read",{uri:uri.href,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>toResourceResult(await callback(uri,this.#toRequestContext(ctx)),uri.href);return await this.#runMcpHook("resources/read",mwCtx,innerFn)})}#registerResourceTemplate(server,{definition,callback,complete}){let template=new ResourceTemplate(definition.uriTemplate,{list:void 0,...complete!==void 0&&{complete}});server.registerResource(definition.name,template,{...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description},...definition.mimeType!==void 0&&{mimeType:definition.mimeType},...definition.annotations!==void 0&&{annotations:definition.annotations},...definition._meta!==void 0&&{_meta:{...definition._meta}}},async(uri,variables,ctx)=>{let mwCtx=this.#createMiddlewareContext("resources/read",{uri:uri.href,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>toResourceResult(await callback(uri,variables,this.#toRequestContext(ctx)),uri.href);return await this.#runMcpHook("resources/read",mwCtx,innerFn)})}#viewResourceFacts(viewConfig){if(viewConfig!==void 0)return{...viewConfig.description!==void 0&&{description:viewConfig.description},...viewConfig.csp!==void 0&&{csp:viewConfig.csp},...viewConfig.permissions!==void 0&&{permissions:viewConfig.permissions},...viewConfig.domain!==void 0&&{domain:viewConfig.domain},...viewConfig.prefersBorder!==void 0&&{prefersBorder:viewConfig.prefersBorder}}}#registerPrompt(server,{definition,callback}){let config={...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description}},invokePrompt=async(args,ctx)=>{let mwCtx=this.#createMiddlewareContext("prompts/get",{name:definition.name,arguments:args,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>{let effectiveArgs=mwCtx.params.arguments??{};return toPromptResult(await callback(effectiveArgs,this.#toRequestContext(ctx)))};return await this.#runMcpHook("prompts/get",mwCtx,innerFn)};if(definition.schema!==void 0)server.registerPrompt(definition.name,{...config,argsSchema:definition.schema},async(args,ctx)=>invokePrompt(args,ctx));else{let handler=async ctx=>invokePrompt({},ctx);server.registerPrompt(definition.name,config,handler)}}#toRequestContext(ctx){return this.#config.oauth===void 0?toRequestContext(ctx):toAuthenticatedRequestContext(ctx)}};import{acceptedContent,createRequestStateCodec,inputRequired,inputResponse,isInputRequiredResult as isInputRequiredResult3}from"@modelcontextprotocol/server";function text(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/plain"}}}function markdown(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/markdown"}}}function html(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/html"}}}function xml(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/xml"}}}function css(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/css"}}}function javascript(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/javascript"}}}function image(data,mimeType="image/png"){return{content:[{type:"image",data,mimeType}],_meta:{mimeType,isImage:!0}}}function audio(data,mimeType="audio/wav"){return{content:[{type:"audio",data,mimeType}],_meta:{mimeType,isAudio:!0}}}function binary(base64Data,mimeType){return{content:[{type:"text",text:base64Data}],_meta:{mimeType,isBinary:!0}}}function resource(uri,mimeTypeOrContent,text2){if(typeof mimeTypeOrContent=="object"&&mimeTypeOrContent!==null&&"content"in mimeTypeOrContent){let contentResult=mimeTypeOrContent,extractedText,extractedMimeType;if(contentResult._meta&&typeof contentResult._meta=="object"){let meta=contentResult._meta;typeof meta.mimeType=="string"&&(extractedMimeType=meta.mimeType)}let first=contentResult.content?.[0];return first?.type==="text"&&"text"in first&&(extractedText=first.text),{content:[{type:"resource",resource:{uri,...extractedMimeType!==void 0&&{mimeType:extractedMimeType},text:extractedText??""}}]}}let mimeType=mimeTypeOrContent;return{content:[{type:"resource",resource:{uri,...mimeType!==void 0&&mimeType!==""&&{mimeType},text:text2??""}}]}}function error(message){return{isError:!0,content:[{type:"text",text:message}]}}function object(data){return Array.isArray(data)?array(data):{content:[{type:"text",text:JSON.stringify(data,null,2)}],structuredContent:data,_meta:{mimeType:"application/json"}}}function array(data){return{content:[{type:"text",text:JSON.stringify(data,null,2)}],structuredContent:data}}function widget(config){let props=config.props??config.data??{},{output,message,metadata}=config,result={content:message?[{type:"text",text:message}]:Array.isArray(output?.content)&&output.content.length>0?output.content:[{type:"text",text:""}]};return metadata!==void 0&&Object.keys(metadata).length>0&&(result._meta=metadata),output?.structuredContent!==void 0?result.structuredContent=output.structuredContent:Object.keys(props).length>0&&(result.structuredContent=props),result}function mix(...results){let withStructured=results.filter(result=>result.structuredContent!==void 0),structuredContent=withStructured.length>0?withStructured.map(result=>result.structuredContent).reduce((acc,value)=>({...acc,...typeof value=="object"&&value!==null?value:{}}),{}):void 0,withMeta=results.filter(result=>result._meta!==void 0),_meta=withMeta.length>0?withMeta.map(result=>result._meta).reduce((acc,value)=>({...acc,...value!==void 0?value:{}}),{}):void 0;return{content:results.flatMap(result=>result.content),...structuredContent!==void 0&&Object.keys(structuredContent).length>0&&{structuredContent},..._meta!==void 0&&Object.keys(_meta).length>0&&{_meta}}}export{MCPServer,acceptedContent,array,audio,binary,completable,composeFetch,composeMiddleware,createMcpEventListenerEntry,createMcpMiddlewareEntry,createMcpMount,createRequestStateCodec,css,error,getRequestBag,hostValidationMiddleware,html,image,inputRequired,inputResponse,isInputRequiredResult3 as isInputRequiredResult,javascript,jsonBodyMiddleware,markdown,matchesPath,matchesPathPrefix,matchesPattern,mix,object,originValidationMiddleware,pathnameOf,registerViews,requestLogger,resource,text,widget,xml};