outask 0.0.0-stage → 1.7.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 (831) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +38 -2
  3. package/bin/outask +7 -0
  4. package/bin/tasks +7 -0
  5. package/cli.mjs +151 -0
  6. package/mcp/package-lock.json +175 -0
  7. package/mcp/package.json +15 -0
  8. package/mcp/server.mjs +132 -0
  9. package/node_modules/@modelcontextprotocol/core/LICENSE +216 -0
  10. package/node_modules/@modelcontextprotocol/core/README.md +40 -0
  11. package/node_modules/@modelcontextprotocol/core/dist/auth-Anm-lwWi.d.mts +8507 -0
  12. package/node_modules/@modelcontextprotocol/core/dist/auth-Anm-lwWi.d.mts.map +1 -0
  13. package/node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs +1681 -0
  14. package/node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs.map +1 -0
  15. package/node_modules/@modelcontextprotocol/core/dist/auth-D1CeV_Jr.cjs +2902 -0
  16. package/node_modules/@modelcontextprotocol/core/dist/auth-D1CeV_Jr.cjs.map +1 -0
  17. package/node_modules/@modelcontextprotocol/core/dist/auth-V9XJSCfa.d.cts +8507 -0
  18. package/node_modules/@modelcontextprotocol/core/dist/auth-V9XJSCfa.d.cts.map +1 -0
  19. package/node_modules/@modelcontextprotocol/core/dist/index.cjs +175 -0
  20. package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +2 -0
  21. package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +2 -0
  22. package/node_modules/@modelcontextprotocol/core/dist/index.mjs +3 -0
  23. package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +201 -0
  24. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +99 -0
  25. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts.map +1 -0
  26. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +99 -0
  27. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts.map +1 -0
  28. package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +3 -0
  29. package/node_modules/@modelcontextprotocol/core/package.json +85 -0
  30. package/node_modules/@modelcontextprotocol/server/LICENSE +216 -0
  31. package/node_modules/@modelcontextprotocol/server/README.md +30 -0
  32. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs +7514 -0
  33. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs.map +1 -0
  34. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CgI-5L6O.d.mts +1071 -0
  35. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CgI-5L6O.d.mts.map +1 -0
  36. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-FOQRM7up.d.cts +1071 -0
  37. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-FOQRM7up.d.cts.map +1 -0
  38. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-ZaoO9afR.cjs +7531 -0
  39. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-ZaoO9afR.cjs.map +1 -0
  40. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-BwbPzsdI.cjs +986 -0
  41. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-BwbPzsdI.cjs.map +1 -0
  42. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-C03CSigr.d.mts +74 -0
  43. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-C03CSigr.d.mts.map +1 -0
  44. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-doTkZbTr.d.cts +74 -0
  45. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-doTkZbTr.d.cts.map +1 -0
  46. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-p3WaZPqB.mjs +981 -0
  47. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-p3WaZPqB.mjs.map +1 -0
  48. package/node_modules/@modelcontextprotocol/server/dist/chunk-Bnu9O96Y.cjs +60 -0
  49. package/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs +42 -0
  50. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-D4NN8WsG.d.mts +4168 -0
  51. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-D4NN8WsG.d.mts.map +1 -0
  52. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-DZmmlN8e.d.cts +4170 -0
  53. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-DZmmlN8e.d.cts.map +1 -0
  54. package/node_modules/@modelcontextprotocol/server/dist/dialects-D8eXzoGv.cjs +46 -0
  55. package/node_modules/@modelcontextprotocol/server/dist/dialects-D8eXzoGv.cjs.map +1 -0
  56. package/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs +34 -0
  57. package/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs.map +1 -0
  58. package/node_modules/@modelcontextprotocol/server/dist/index.cjs +1978 -0
  59. package/node_modules/@modelcontextprotocol/server/dist/index.cjs.map +1 -0
  60. package/node_modules/@modelcontextprotocol/server/dist/index.d.cts +810 -0
  61. package/node_modules/@modelcontextprotocol/server/dist/index.d.cts.map +1 -0
  62. package/node_modules/@modelcontextprotocol/server/dist/index.d.mts +810 -0
  63. package/node_modules/@modelcontextprotocol/server/dist/index.d.mts.map +1 -0
  64. package/node_modules/@modelcontextprotocol/server/dist/index.mjs +1790 -0
  65. package/node_modules/@modelcontextprotocol/server/dist/index.mjs.map +1 -0
  66. package/node_modules/@modelcontextprotocol/server/dist/mcp-BumlNux0.cjs +2477 -0
  67. package/node_modules/@modelcontextprotocol/server/dist/mcp-BumlNux0.cjs.map +1 -0
  68. package/node_modules/@modelcontextprotocol/server/dist/mcp-DIH4cS6P.mjs +2326 -0
  69. package/node_modules/@modelcontextprotocol/server/dist/mcp-DIH4cS6P.mjs.map +1 -0
  70. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.cjs +23 -0
  71. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.cjs.map +1 -0
  72. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.cts +11 -0
  73. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.cts.map +1 -0
  74. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.mts +11 -0
  75. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.mts.map +1 -0
  76. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.mjs +22 -0
  77. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.mjs.map +1 -0
  78. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.cjs +12 -0
  79. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.d.cts +3 -0
  80. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.d.mts +3 -0
  81. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs +4 -0
  82. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs +30 -0
  83. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs.map +1 -0
  84. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.cts +10 -0
  85. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.cts.map +1 -0
  86. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.mts +10 -0
  87. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.mts.map +1 -0
  88. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs +29 -0
  89. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs.map +1 -0
  90. package/node_modules/@modelcontextprotocol/server/dist/src-BhnGYybN.cjs +8200 -0
  91. package/node_modules/@modelcontextprotocol/server/dist/src-BhnGYybN.cjs.map +1 -0
  92. package/node_modules/@modelcontextprotocol/server/dist/src-Cqbh3MYc.mjs +7702 -0
  93. package/node_modules/@modelcontextprotocol/server/dist/src-Cqbh3MYc.mjs.map +1 -0
  94. package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs +591 -0
  95. package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs.map +1 -0
  96. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts +115 -0
  97. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts.map +1 -0
  98. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts +115 -0
  99. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts.map +1 -0
  100. package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs +589 -0
  101. package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs.map +1 -0
  102. package/node_modules/@modelcontextprotocol/server/dist/types-DUs7mGBv.d.mts +1099 -0
  103. package/node_modules/@modelcontextprotocol/server/dist/types-DUs7mGBv.d.mts.map +1 -0
  104. package/node_modules/@modelcontextprotocol/server/dist/types-DsbMXNFL.d.cts +1099 -0
  105. package/node_modules/@modelcontextprotocol/server/dist/types-DsbMXNFL.d.cts.map +1 -0
  106. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.cjs +5 -0
  107. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.d.cts +2 -0
  108. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.d.mts +2 -0
  109. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.mjs +3 -0
  110. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.cjs +3 -0
  111. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.d.cts +2 -0
  112. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.d.mts +2 -0
  113. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.mjs +3 -0
  114. package/node_modules/@modelcontextprotocol/server/package.json +160 -0
  115. package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  116. package/node_modules/jsonc-parser/LICENSE.md +21 -0
  117. package/node_modules/jsonc-parser/README.md +364 -0
  118. package/node_modules/jsonc-parser/SECURITY.md +41 -0
  119. package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  120. package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  121. package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  122. package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  123. package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  124. package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  125. package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  126. package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  127. package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  128. package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  129. package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  130. package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  131. package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  132. package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  133. package/node_modules/jsonc-parser/package.json +37 -0
  134. package/node_modules/zod/LICENSE +21 -0
  135. package/node_modules/zod/README.md +218 -0
  136. package/node_modules/zod/compile.cjs +96 -0
  137. package/node_modules/zod/compile.d.cts +1 -0
  138. package/node_modules/zod/compile.d.ts +1 -0
  139. package/node_modules/zod/compile.js +52 -0
  140. package/node_modules/zod/index.cjs +52 -0
  141. package/node_modules/zod/index.d.cts +3 -0
  142. package/node_modules/zod/index.d.ts +3 -0
  143. package/node_modules/zod/index.js +7 -0
  144. package/node_modules/zod/locales/index.cjs +36 -0
  145. package/node_modules/zod/locales/index.d.cts +1 -0
  146. package/node_modules/zod/locales/index.d.ts +1 -0
  147. package/node_modules/zod/locales/index.js +1 -0
  148. package/node_modules/zod/locales/package.json +7 -0
  149. package/node_modules/zod/mini/index.cjs +51 -0
  150. package/node_modules/zod/mini/index.d.cts +3 -0
  151. package/node_modules/zod/mini/index.d.ts +3 -0
  152. package/node_modules/zod/mini/index.js +3 -0
  153. package/node_modules/zod/mini/package.json +7 -0
  154. package/node_modules/zod/package.json +147 -0
  155. package/node_modules/zod/src/compile.ts +56 -0
  156. package/node_modules/zod/src/index.ts +7 -0
  157. package/node_modules/zod/src/locales/index.ts +1 -0
  158. package/node_modules/zod/src/mini/index.ts +3 -0
  159. package/node_modules/zod/src/v3/ZodError.ts +340 -0
  160. package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  161. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  162. package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  163. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  164. package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  165. package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  166. package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  167. package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  168. package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  169. package/node_modules/zod/src/v3/errors.ts +13 -0
  170. package/node_modules/zod/src/v3/external.ts +6 -0
  171. package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  172. package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  173. package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  174. package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  175. package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  176. package/node_modules/zod/src/v3/helpers/util.ts +224 -0
  177. package/node_modules/zod/src/v3/index.ts +4 -0
  178. package/node_modules/zod/src/v3/locales/en.ts +124 -0
  179. package/node_modules/zod/src/v3/standard-schema.ts +113 -0
  180. package/node_modules/zod/src/v3/types.ts +5138 -0
  181. package/node_modules/zod/src/v4/classic/checks.ts +33 -0
  182. package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
  183. package/node_modules/zod/src/v4/classic/compat.ts +78 -0
  184. package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
  185. package/node_modules/zod/src/v4/classic/errors.ts +97 -0
  186. package/node_modules/zod/src/v4/classic/external.ts +57 -0
  187. package/node_modules/zod/src/v4/classic/from-json-schema.ts +944 -0
  188. package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
  189. package/node_modules/zod/src/v4/classic/index.ts +5 -0
  190. package/node_modules/zod/src/v4/classic/iso.ts +20 -0
  191. package/node_modules/zod/src/v4/classic/parse.ts +88 -0
  192. package/node_modules/zod/src/v4/classic/schemas.ts +2937 -0
  193. package/node_modules/zod/src/v4/core/api.ts +1875 -0
  194. package/node_modules/zod/src/v4/core/checks.ts +1266 -0
  195. package/node_modules/zod/src/v4/core/compile.ts +2322 -0
  196. package/node_modules/zod/src/v4/core/core.ts +230 -0
  197. package/node_modules/zod/src/v4/core/doc.ts +52 -0
  198. package/node_modules/zod/src/v4/core/errors.ts +543 -0
  199. package/node_modules/zod/src/v4/core/index.ts +19 -0
  200. package/node_modules/zod/src/v4/core/json-schema-generator.ts +131 -0
  201. package/node_modules/zod/src/v4/core/json-schema-processors.ts +934 -0
  202. package/node_modules/zod/src/v4/core/json-schema.ts +148 -0
  203. package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
  204. package/node_modules/zod/src/v4/core/parse.ts +309 -0
  205. package/node_modules/zod/src/v4/core/regexes.ts +217 -0
  206. package/node_modules/zod/src/v4/core/registries.ts +105 -0
  207. package/node_modules/zod/src/v4/core/schemas.ts +5226 -0
  208. package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
  209. package/node_modules/zod/src/v4/core/to-json-schema.ts +857 -0
  210. package/node_modules/zod/src/v4/core/util.ts +1293 -0
  211. package/node_modules/zod/src/v4/core/versions.ts +5 -0
  212. package/node_modules/zod/src/v4/core/visit.ts +193 -0
  213. package/node_modules/zod/src/v4/core/zsf.ts +323 -0
  214. package/node_modules/zod/src/v4/index.ts +4 -0
  215. package/node_modules/zod/src/v4/locales/ar.ts +120 -0
  216. package/node_modules/zod/src/v4/locales/az.ts +116 -0
  217. package/node_modules/zod/src/v4/locales/be.ts +188 -0
  218. package/node_modules/zod/src/v4/locales/bg.ts +133 -0
  219. package/node_modules/zod/src/v4/locales/bn.ts +123 -0
  220. package/node_modules/zod/src/v4/locales/ca.ts +121 -0
  221. package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
  222. package/node_modules/zod/src/v4/locales/cs.ts +123 -0
  223. package/node_modules/zod/src/v4/locales/da.ts +128 -0
  224. package/node_modules/zod/src/v4/locales/de.ts +121 -0
  225. package/node_modules/zod/src/v4/locales/el.ts +124 -0
  226. package/node_modules/zod/src/v4/locales/en.ts +136 -0
  227. package/node_modules/zod/src/v4/locales/eo.ts +123 -0
  228. package/node_modules/zod/src/v4/locales/es.ts +145 -0
  229. package/node_modules/zod/src/v4/locales/fa.ts +131 -0
  230. package/node_modules/zod/src/v4/locales/fi.ts +126 -0
  231. package/node_modules/zod/src/v4/locales/fr-CA.ts +121 -0
  232. package/node_modules/zod/src/v4/locales/fr.ts +139 -0
  233. package/node_modules/zod/src/v4/locales/gu.ts +123 -0
  234. package/node_modules/zod/src/v4/locales/he.ts +253 -0
  235. package/node_modules/zod/src/v4/locales/hi.ts +126 -0
  236. package/node_modules/zod/src/v4/locales/hr.ts +135 -0
  237. package/node_modules/zod/src/v4/locales/hu.ts +122 -0
  238. package/node_modules/zod/src/v4/locales/hy.ts +175 -0
  239. package/node_modules/zod/src/v4/locales/id.ts +120 -0
  240. package/node_modules/zod/src/v4/locales/index.ts +63 -0
  241. package/node_modules/zod/src/v4/locales/is.ts +124 -0
  242. package/node_modules/zod/src/v4/locales/it.ts +121 -0
  243. package/node_modules/zod/src/v4/locales/ja.ts +119 -0
  244. package/node_modules/zod/src/v4/locales/ka.ts +128 -0
  245. package/node_modules/zod/src/v4/locales/kh.ts +7 -0
  246. package/node_modules/zod/src/v4/locales/km.ts +124 -0
  247. package/node_modules/zod/src/v4/locales/kn.ts +126 -0
  248. package/node_modules/zod/src/v4/locales/ko.ts +126 -0
  249. package/node_modules/zod/src/v4/locales/lt.ts +243 -0
  250. package/node_modules/zod/src/v4/locales/mk.ts +123 -0
  251. package/node_modules/zod/src/v4/locales/ms.ts +120 -0
  252. package/node_modules/zod/src/v4/locales/ne.ts +128 -0
  253. package/node_modules/zod/src/v4/locales/nl.ts +126 -0
  254. package/node_modules/zod/src/v4/locales/nn.ts +121 -0
  255. package/node_modules/zod/src/v4/locales/no.ts +121 -0
  256. package/node_modules/zod/src/v4/locales/ota.ts +122 -0
  257. package/node_modules/zod/src/v4/locales/pl.ts +123 -0
  258. package/node_modules/zod/src/v4/locales/ps.ts +131 -0
  259. package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
  260. package/node_modules/zod/src/v4/locales/pt.ts +159 -0
  261. package/node_modules/zod/src/v4/locales/ro.ts +132 -0
  262. package/node_modules/zod/src/v4/locales/ru.ts +188 -0
  263. package/node_modules/zod/src/v4/locales/sk.ts +123 -0
  264. package/node_modules/zod/src/v4/locales/sl.ts +123 -0
  265. package/node_modules/zod/src/v4/locales/sv.ts +124 -0
  266. package/node_modules/zod/src/v4/locales/ta.ts +123 -0
  267. package/node_modules/zod/src/v4/locales/tg.ts +135 -0
  268. package/node_modules/zod/src/v4/locales/th.ts +124 -0
  269. package/node_modules/zod/src/v4/locales/tk.ts +113 -0
  270. package/node_modules/zod/src/v4/locales/tr.ts +116 -0
  271. package/node_modules/zod/src/v4/locales/ua.ts +7 -0
  272. package/node_modules/zod/src/v4/locales/uk.ts +122 -0
  273. package/node_modules/zod/src/v4/locales/ur.ts +124 -0
  274. package/node_modules/zod/src/v4/locales/uz.ts +120 -0
  275. package/node_modules/zod/src/v4/locales/vi.ts +122 -0
  276. package/node_modules/zod/src/v4/locales/yo.ts +129 -0
  277. package/node_modules/zod/src/v4/locales/zh-CN.ts +121 -0
  278. package/node_modules/zod/src/v4/locales/zh-TW.ts +120 -0
  279. package/node_modules/zod/src/v4/mini/checks.ts +33 -0
  280. package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
  281. package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
  282. package/node_modules/zod/src/v4/mini/external.ts +52 -0
  283. package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
  284. package/node_modules/zod/src/v4/mini/index.ts +3 -0
  285. package/node_modules/zod/src/v4/mini/iso.ts +66 -0
  286. package/node_modules/zod/src/v4/mini/parse.ts +16 -0
  287. package/node_modules/zod/src/v4/mini/schemas.ts +2051 -0
  288. package/node_modules/zod/src/v4-mini/index.ts +3 -0
  289. package/node_modules/zod/v3/ZodError.cjs +167 -0
  290. package/node_modules/zod/v3/ZodError.d.cts +164 -0
  291. package/node_modules/zod/v3/ZodError.d.ts +164 -0
  292. package/node_modules/zod/v3/ZodError.js +143 -0
  293. package/node_modules/zod/v3/errors.cjs +36 -0
  294. package/node_modules/zod/v3/errors.d.cts +5 -0
  295. package/node_modules/zod/v3/errors.d.ts +5 -0
  296. package/node_modules/zod/v3/errors.js +9 -0
  297. package/node_modules/zod/v3/external.cjs +41 -0
  298. package/node_modules/zod/v3/external.d.cts +6 -0
  299. package/node_modules/zod/v3/external.d.ts +6 -0
  300. package/node_modules/zod/v3/external.js +6 -0
  301. package/node_modules/zod/v3/helpers/enumUtil.cjs +21 -0
  302. package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  303. package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  304. package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
  305. package/node_modules/zod/v3/helpers/errorUtil.cjs +28 -0
  306. package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  307. package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  308. package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
  309. package/node_modules/zod/v3/helpers/parseUtil.cjs +143 -0
  310. package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  311. package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  312. package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
  313. package/node_modules/zod/v3/helpers/partialUtil.cjs +21 -0
  314. package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  315. package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  316. package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
  317. package/node_modules/zod/v3/helpers/typeAliases.cjs +21 -0
  318. package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  319. package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  320. package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  321. package/node_modules/zod/v3/helpers/util.cjs +156 -0
  322. package/node_modules/zod/v3/helpers/util.d.cts +85 -0
  323. package/node_modules/zod/v3/helpers/util.d.ts +85 -0
  324. package/node_modules/zod/v3/helpers/util.js +133 -0
  325. package/node_modules/zod/v3/index.cjs +52 -0
  326. package/node_modules/zod/v3/index.d.cts +4 -0
  327. package/node_modules/zod/v3/index.d.ts +4 -0
  328. package/node_modules/zod/v3/index.js +4 -0
  329. package/node_modules/zod/v3/locales/en.cjs +112 -0
  330. package/node_modules/zod/v3/locales/en.d.cts +3 -0
  331. package/node_modules/zod/v3/locales/en.d.ts +3 -0
  332. package/node_modules/zod/v3/locales/en.js +109 -0
  333. package/node_modules/zod/v3/package.json +7 -0
  334. package/node_modules/zod/v3/standard-schema.cjs +21 -0
  335. package/node_modules/zod/v3/standard-schema.d.cts +102 -0
  336. package/node_modules/zod/v3/standard-schema.d.ts +102 -0
  337. package/node_modules/zod/v3/standard-schema.js +1 -0
  338. package/node_modules/zod/v3/types.cjs +3798 -0
  339. package/node_modules/zod/v3/types.d.cts +1034 -0
  340. package/node_modules/zod/v3/types.d.ts +1034 -0
  341. package/node_modules/zod/v3/types.js +3697 -0
  342. package/node_modules/zod/v4/classic/checks.cjs +53 -0
  343. package/node_modules/zod/v4/classic/checks.d.cts +1 -0
  344. package/node_modules/zod/v4/classic/checks.d.ts +1 -0
  345. package/node_modules/zod/v4/classic/checks.js +1 -0
  346. package/node_modules/zod/v4/classic/coerce.cjs +66 -0
  347. package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
  348. package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
  349. package/node_modules/zod/v4/classic/coerce.js +17 -0
  350. package/node_modules/zod/v4/classic/compat.cjs +80 -0
  351. package/node_modules/zod/v4/classic/compat.d.cts +48 -0
  352. package/node_modules/zod/v4/classic/compat.d.ts +48 -0
  353. package/node_modules/zod/v4/classic/compat.js +31 -0
  354. package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
  355. package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
  356. package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
  357. package/node_modules/zod/v4/classic/deep-partial.js +13 -0
  358. package/node_modules/zod/v4/classic/errors.cjs +102 -0
  359. package/node_modules/zod/v4/classic/errors.d.cts +29 -0
  360. package/node_modules/zod/v4/classic/errors.d.ts +29 -0
  361. package/node_modules/zod/v4/classic/errors.js +57 -0
  362. package/node_modules/zod/v4/classic/external.cjs +97 -0
  363. package/node_modules/zod/v4/classic/external.d.cts +19 -0
  364. package/node_modules/zod/v4/classic/external.d.ts +19 -0
  365. package/node_modules/zod/v4/classic/external.js +17 -0
  366. package/node_modules/zod/v4/classic/from-json-schema.cjs +926 -0
  367. package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
  368. package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
  369. package/node_modules/zod/v4/classic/from-json-schema.js +881 -0
  370. package/node_modules/zod/v4/classic/in-out.cjs +82 -0
  371. package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
  372. package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
  373. package/node_modules/zod/v4/classic/in-out.js +36 -0
  374. package/node_modules/zod/v4/classic/index.cjs +52 -0
  375. package/node_modules/zod/v4/classic/index.d.cts +3 -0
  376. package/node_modules/zod/v4/classic/index.d.ts +3 -0
  377. package/node_modules/zod/v4/classic/index.js +4 -0
  378. package/node_modules/zod/v4/classic/iso.cjs +68 -0
  379. package/node_modules/zod/v4/classic/iso.d.cts +7 -0
  380. package/node_modules/zod/v4/classic/iso.d.ts +7 -0
  381. package/node_modules/zod/v4/classic/iso.js +15 -0
  382. package/node_modules/zod/v4/classic/package.json +7 -0
  383. package/node_modules/zod/v4/classic/parse.cjs +63 -0
  384. package/node_modules/zod/v4/classic/parse.d.cts +44 -0
  385. package/node_modules/zod/v4/classic/parse.d.ts +44 -0
  386. package/node_modules/zod/v4/classic/parse.js +16 -0
  387. package/node_modules/zod/v4/classic/schemas.cjs +1676 -0
  388. package/node_modules/zod/v4/classic/schemas.d.cts +816 -0
  389. package/node_modules/zod/v4/classic/schemas.d.ts +816 -0
  390. package/node_modules/zod/v4/classic/schemas.js +1535 -0
  391. package/node_modules/zod/v4/core/api.cjs +1269 -0
  392. package/node_modules/zod/v4/core/api.d.cts +335 -0
  393. package/node_modules/zod/v4/core/api.d.ts +335 -0
  394. package/node_modules/zod/v4/core/api.js +1107 -0
  395. package/node_modules/zod/v4/core/checks.cjs +561 -0
  396. package/node_modules/zod/v4/core/checks.d.cts +294 -0
  397. package/node_modules/zod/v4/core/checks.d.ts +294 -0
  398. package/node_modules/zod/v4/core/checks.js +516 -0
  399. package/node_modules/zod/v4/core/compile.cjs +1916 -0
  400. package/node_modules/zod/v4/core/compile.d.cts +65 -0
  401. package/node_modules/zod/v4/core/compile.d.ts +65 -0
  402. package/node_modules/zod/v4/core/compile.js +1866 -0
  403. package/node_modules/zod/v4/core/core.cjs +167 -0
  404. package/node_modules/zod/v4/core/core.d.cts +82 -0
  405. package/node_modules/zod/v4/core/core.d.ts +82 -0
  406. package/node_modules/zod/v4/core/core.js +141 -0
  407. package/node_modules/zod/v4/core/doc.cjs +61 -0
  408. package/node_modules/zod/v4/core/doc.d.cts +16 -0
  409. package/node_modules/zod/v4/core/doc.d.ts +16 -0
  410. package/node_modules/zod/v4/core/doc.js +38 -0
  411. package/node_modules/zod/v4/core/errors.cjs +317 -0
  412. package/node_modules/zod/v4/core/errors.d.cts +225 -0
  413. package/node_modules/zod/v4/core/errors.d.ts +225 -0
  414. package/node_modules/zod/v4/core/errors.js +267 -0
  415. package/node_modules/zod/v4/core/index.cjs +70 -0
  416. package/node_modules/zod/v4/core/index.d.cts +19 -0
  417. package/node_modules/zod/v4/core/index.d.ts +19 -0
  418. package/node_modules/zod/v4/core/index.js +19 -0
  419. package/node_modules/zod/v4/core/json-schema-generator.cjs +122 -0
  420. package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
  421. package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
  422. package/node_modules/zod/v4/core/json-schema-generator.js +99 -0
  423. package/node_modules/zod/v4/core/json-schema-processors.cjs +929 -0
  424. package/node_modules/zod/v4/core/json-schema-processors.d.cts +65 -0
  425. package/node_modules/zod/v4/core/json-schema-processors.d.ts +65 -0
  426. package/node_modules/zod/v4/core/json-schema-processors.js +843 -0
  427. package/node_modules/zod/v4/core/json-schema.cjs +21 -0
  428. package/node_modules/zod/v4/core/json-schema.d.cts +89 -0
  429. package/node_modules/zod/v4/core/json-schema.d.ts +89 -0
  430. package/node_modules/zod/v4/core/json-schema.js +1 -0
  431. package/node_modules/zod/v4/core/memoizer.cjs +360 -0
  432. package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
  433. package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
  434. package/node_modules/zod/v4/core/memoizer.js +311 -0
  435. package/node_modules/zod/v4/core/package.json +7 -0
  436. package/node_modules/zod/v4/core/parse.cjs +233 -0
  437. package/node_modules/zod/v4/core/parse.d.cts +52 -0
  438. package/node_modules/zod/v4/core/parse.d.ts +52 -0
  439. package/node_modules/zod/v4/core/parse.js +175 -0
  440. package/node_modules/zod/v4/core/regexes.cjs +209 -0
  441. package/node_modules/zod/v4/core/regexes.d.cts +90 -0
  442. package/node_modules/zod/v4/core/regexes.d.ts +90 -0
  443. package/node_modules/zod/v4/core/regexes.js +156 -0
  444. package/node_modules/zod/v4/core/registries.cjs +75 -0
  445. package/node_modules/zod/v4/core/registries.d.cts +35 -0
  446. package/node_modules/zod/v4/core/registries.d.ts +35 -0
  447. package/node_modules/zod/v4/core/registries.js +51 -0
  448. package/node_modules/zod/v4/core/schemas.cjs +2699 -0
  449. package/node_modules/zod/v4/core/schemas.d.cts +1275 -0
  450. package/node_modules/zod/v4/core/schemas.d.ts +1275 -0
  451. package/node_modules/zod/v4/core/schemas.js +2636 -0
  452. package/node_modules/zod/v4/core/standard-schema.cjs +21 -0
  453. package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
  454. package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
  455. package/node_modules/zod/v4/core/standard-schema.js +1 -0
  456. package/node_modules/zod/v4/core/to-json-schema.cjs +681 -0
  457. package/node_modules/zod/v4/core/to-json-schema.d.cts +154 -0
  458. package/node_modules/zod/v4/core/to-json-schema.d.ts +154 -0
  459. package/node_modules/zod/v4/core/to-json-schema.js +651 -0
  460. package/node_modules/zod/v4/core/util.cjs +964 -0
  461. package/node_modules/zod/v4/core/util.d.cts +280 -0
  462. package/node_modules/zod/v4/core/util.d.ts +280 -0
  463. package/node_modules/zod/v4/core/util.js +873 -0
  464. package/node_modules/zod/v4/core/versions.cjs +27 -0
  465. package/node_modules/zod/v4/core/versions.d.cts +5 -0
  466. package/node_modules/zod/v4/core/versions.d.ts +5 -0
  467. package/node_modules/zod/v4/core/versions.js +5 -0
  468. package/node_modules/zod/v4/core/visit.cjs +214 -0
  469. package/node_modules/zod/v4/core/visit.d.cts +30 -0
  470. package/node_modules/zod/v4/core/visit.d.ts +30 -0
  471. package/node_modules/zod/v4/core/visit.js +169 -0
  472. package/node_modules/zod/v4/index.cjs +51 -0
  473. package/node_modules/zod/v4/index.d.cts +3 -0
  474. package/node_modules/zod/v4/index.d.ts +3 -0
  475. package/node_modules/zod/v4/index.js +4 -0
  476. package/node_modules/zod/v4/locales/ar.cjs +138 -0
  477. package/node_modules/zod/v4/locales/ar.d.cts +5 -0
  478. package/node_modules/zod/v4/locales/ar.d.ts +4 -0
  479. package/node_modules/zod/v4/locales/ar.js +111 -0
  480. package/node_modules/zod/v4/locales/az.cjs +137 -0
  481. package/node_modules/zod/v4/locales/az.d.cts +5 -0
  482. package/node_modules/zod/v4/locales/az.d.ts +4 -0
  483. package/node_modules/zod/v4/locales/az.js +110 -0
  484. package/node_modules/zod/v4/locales/be.cjs +195 -0
  485. package/node_modules/zod/v4/locales/be.d.cts +5 -0
  486. package/node_modules/zod/v4/locales/be.d.ts +4 -0
  487. package/node_modules/zod/v4/locales/be.js +168 -0
  488. package/node_modules/zod/v4/locales/bg.cjs +152 -0
  489. package/node_modules/zod/v4/locales/bg.d.cts +5 -0
  490. package/node_modules/zod/v4/locales/bg.d.ts +4 -0
  491. package/node_modules/zod/v4/locales/bg.js +125 -0
  492. package/node_modules/zod/v4/locales/bn.cjs +140 -0
  493. package/node_modules/zod/v4/locales/bn.d.cts +5 -0
  494. package/node_modules/zod/v4/locales/bn.d.ts +4 -0
  495. package/node_modules/zod/v4/locales/bn.js +113 -0
  496. package/node_modules/zod/v4/locales/ca.cjs +139 -0
  497. package/node_modules/zod/v4/locales/ca.d.cts +5 -0
  498. package/node_modules/zod/v4/locales/ca.d.ts +4 -0
  499. package/node_modules/zod/v4/locales/ca.js +112 -0
  500. package/node_modules/zod/v4/locales/ckb.cjs +160 -0
  501. package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
  502. package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
  503. package/node_modules/zod/v4/locales/ckb.js +133 -0
  504. package/node_modules/zod/v4/locales/cs.cjs +143 -0
  505. package/node_modules/zod/v4/locales/cs.d.cts +5 -0
  506. package/node_modules/zod/v4/locales/cs.d.ts +4 -0
  507. package/node_modules/zod/v4/locales/cs.js +116 -0
  508. package/node_modules/zod/v4/locales/da.cjs +147 -0
  509. package/node_modules/zod/v4/locales/da.d.cts +5 -0
  510. package/node_modules/zod/v4/locales/da.d.ts +4 -0
  511. package/node_modules/zod/v4/locales/da.js +120 -0
  512. package/node_modules/zod/v4/locales/de.cjs +140 -0
  513. package/node_modules/zod/v4/locales/de.d.cts +5 -0
  514. package/node_modules/zod/v4/locales/de.d.ts +4 -0
  515. package/node_modules/zod/v4/locales/de.js +113 -0
  516. package/node_modules/zod/v4/locales/el.cjs +139 -0
  517. package/node_modules/zod/v4/locales/el.d.cts +5 -0
  518. package/node_modules/zod/v4/locales/el.d.ts +4 -0
  519. package/node_modules/zod/v4/locales/el.js +112 -0
  520. package/node_modules/zod/v4/locales/en.cjs +152 -0
  521. package/node_modules/zod/v4/locales/en.d.cts +5 -0
  522. package/node_modules/zod/v4/locales/en.d.ts +4 -0
  523. package/node_modules/zod/v4/locales/en.js +125 -0
  524. package/node_modules/zod/v4/locales/eo.cjs +141 -0
  525. package/node_modules/zod/v4/locales/eo.d.cts +5 -0
  526. package/node_modules/zod/v4/locales/eo.d.ts +4 -0
  527. package/node_modules/zod/v4/locales/eo.js +114 -0
  528. package/node_modules/zod/v4/locales/es.cjs +163 -0
  529. package/node_modules/zod/v4/locales/es.d.cts +5 -0
  530. package/node_modules/zod/v4/locales/es.d.ts +4 -0
  531. package/node_modules/zod/v4/locales/es.js +136 -0
  532. package/node_modules/zod/v4/locales/fa.cjs +146 -0
  533. package/node_modules/zod/v4/locales/fa.d.cts +5 -0
  534. package/node_modules/zod/v4/locales/fa.d.ts +4 -0
  535. package/node_modules/zod/v4/locales/fa.js +119 -0
  536. package/node_modules/zod/v4/locales/fi.cjs +144 -0
  537. package/node_modules/zod/v4/locales/fi.d.cts +5 -0
  538. package/node_modules/zod/v4/locales/fi.d.ts +4 -0
  539. package/node_modules/zod/v4/locales/fi.js +117 -0
  540. package/node_modules/zod/v4/locales/fr-CA.cjs +139 -0
  541. package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  542. package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  543. package/node_modules/zod/v4/locales/fr-CA.js +112 -0
  544. package/node_modules/zod/v4/locales/fr.cjs +156 -0
  545. package/node_modules/zod/v4/locales/fr.d.cts +5 -0
  546. package/node_modules/zod/v4/locales/fr.d.ts +4 -0
  547. package/node_modules/zod/v4/locales/fr.js +129 -0
  548. package/node_modules/zod/v4/locales/gu.cjs +140 -0
  549. package/node_modules/zod/v4/locales/gu.d.cts +5 -0
  550. package/node_modules/zod/v4/locales/gu.d.ts +4 -0
  551. package/node_modules/zod/v4/locales/gu.js +113 -0
  552. package/node_modules/zod/v4/locales/he.cjs +248 -0
  553. package/node_modules/zod/v4/locales/he.d.cts +5 -0
  554. package/node_modules/zod/v4/locales/he.d.ts +4 -0
  555. package/node_modules/zod/v4/locales/he.js +221 -0
  556. package/node_modules/zod/v4/locales/hi.cjs +138 -0
  557. package/node_modules/zod/v4/locales/hi.d.cts +5 -0
  558. package/node_modules/zod/v4/locales/hi.d.ts +4 -0
  559. package/node_modules/zod/v4/locales/hi.js +111 -0
  560. package/node_modules/zod/v4/locales/hr.cjs +153 -0
  561. package/node_modules/zod/v4/locales/hr.d.cts +5 -0
  562. package/node_modules/zod/v4/locales/hr.d.ts +4 -0
  563. package/node_modules/zod/v4/locales/hr.js +126 -0
  564. package/node_modules/zod/v4/locales/hu.cjs +140 -0
  565. package/node_modules/zod/v4/locales/hu.d.cts +5 -0
  566. package/node_modules/zod/v4/locales/hu.d.ts +4 -0
  567. package/node_modules/zod/v4/locales/hu.js +113 -0
  568. package/node_modules/zod/v4/locales/hy.cjs +185 -0
  569. package/node_modules/zod/v4/locales/hy.d.cts +5 -0
  570. package/node_modules/zod/v4/locales/hy.d.ts +4 -0
  571. package/node_modules/zod/v4/locales/hy.js +158 -0
  572. package/node_modules/zod/v4/locales/id.cjs +138 -0
  573. package/node_modules/zod/v4/locales/id.d.cts +5 -0
  574. package/node_modules/zod/v4/locales/id.d.ts +4 -0
  575. package/node_modules/zod/v4/locales/id.js +111 -0
  576. package/node_modules/zod/v4/locales/index.cjs +152 -0
  577. package/node_modules/zod/v4/locales/index.d.cts +63 -0
  578. package/node_modules/zod/v4/locales/index.d.ts +63 -0
  579. package/node_modules/zod/v4/locales/index.js +63 -0
  580. package/node_modules/zod/v4/locales/is.cjs +141 -0
  581. package/node_modules/zod/v4/locales/is.d.cts +5 -0
  582. package/node_modules/zod/v4/locales/is.d.ts +4 -0
  583. package/node_modules/zod/v4/locales/is.js +114 -0
  584. package/node_modules/zod/v4/locales/it.cjs +140 -0
  585. package/node_modules/zod/v4/locales/it.d.cts +5 -0
  586. package/node_modules/zod/v4/locales/it.d.ts +4 -0
  587. package/node_modules/zod/v4/locales/it.js +113 -0
  588. package/node_modules/zod/v4/locales/ja.cjs +139 -0
  589. package/node_modules/zod/v4/locales/ja.d.cts +5 -0
  590. package/node_modules/zod/v4/locales/ja.d.ts +4 -0
  591. package/node_modules/zod/v4/locales/ja.js +112 -0
  592. package/node_modules/zod/v4/locales/ka.cjs +144 -0
  593. package/node_modules/zod/v4/locales/ka.d.cts +5 -0
  594. package/node_modules/zod/v4/locales/ka.d.ts +4 -0
  595. package/node_modules/zod/v4/locales/ka.js +117 -0
  596. package/node_modules/zod/v4/locales/kh.cjs +12 -0
  597. package/node_modules/zod/v4/locales/kh.d.cts +5 -0
  598. package/node_modules/zod/v4/locales/kh.d.ts +5 -0
  599. package/node_modules/zod/v4/locales/kh.js +5 -0
  600. package/node_modules/zod/v4/locales/km.cjs +142 -0
  601. package/node_modules/zod/v4/locales/km.d.cts +5 -0
  602. package/node_modules/zod/v4/locales/km.d.ts +4 -0
  603. package/node_modules/zod/v4/locales/km.js +115 -0
  604. package/node_modules/zod/v4/locales/kn.cjs +143 -0
  605. package/node_modules/zod/v4/locales/kn.d.cts +5 -0
  606. package/node_modules/zod/v4/locales/kn.d.ts +4 -0
  607. package/node_modules/zod/v4/locales/kn.js +116 -0
  608. package/node_modules/zod/v4/locales/ko.cjs +143 -0
  609. package/node_modules/zod/v4/locales/ko.d.cts +5 -0
  610. package/node_modules/zod/v4/locales/ko.d.ts +4 -0
  611. package/node_modules/zod/v4/locales/ko.js +116 -0
  612. package/node_modules/zod/v4/locales/lt.cjs +234 -0
  613. package/node_modules/zod/v4/locales/lt.d.cts +5 -0
  614. package/node_modules/zod/v4/locales/lt.d.ts +4 -0
  615. package/node_modules/zod/v4/locales/lt.js +207 -0
  616. package/node_modules/zod/v4/locales/mk.cjs +141 -0
  617. package/node_modules/zod/v4/locales/mk.d.cts +5 -0
  618. package/node_modules/zod/v4/locales/mk.d.ts +4 -0
  619. package/node_modules/zod/v4/locales/mk.js +114 -0
  620. package/node_modules/zod/v4/locales/ms.cjs +139 -0
  621. package/node_modules/zod/v4/locales/ms.d.cts +5 -0
  622. package/node_modules/zod/v4/locales/ms.d.ts +4 -0
  623. package/node_modules/zod/v4/locales/ms.js +112 -0
  624. package/node_modules/zod/v4/locales/ne.cjs +138 -0
  625. package/node_modules/zod/v4/locales/ne.d.cts +5 -0
  626. package/node_modules/zod/v4/locales/ne.d.ts +4 -0
  627. package/node_modules/zod/v4/locales/ne.js +111 -0
  628. package/node_modules/zod/v4/locales/nl.cjs +142 -0
  629. package/node_modules/zod/v4/locales/nl.d.cts +5 -0
  630. package/node_modules/zod/v4/locales/nl.d.ts +4 -0
  631. package/node_modules/zod/v4/locales/nl.js +115 -0
  632. package/node_modules/zod/v4/locales/nn.cjs +140 -0
  633. package/node_modules/zod/v4/locales/nn.d.cts +5 -0
  634. package/node_modules/zod/v4/locales/nn.d.ts +4 -0
  635. package/node_modules/zod/v4/locales/nn.js +113 -0
  636. package/node_modules/zod/v4/locales/no.cjs +140 -0
  637. package/node_modules/zod/v4/locales/no.d.cts +5 -0
  638. package/node_modules/zod/v4/locales/no.d.ts +4 -0
  639. package/node_modules/zod/v4/locales/no.js +113 -0
  640. package/node_modules/zod/v4/locales/ota.cjs +141 -0
  641. package/node_modules/zod/v4/locales/ota.d.cts +5 -0
  642. package/node_modules/zod/v4/locales/ota.d.ts +4 -0
  643. package/node_modules/zod/v4/locales/ota.js +114 -0
  644. package/node_modules/zod/v4/locales/package.json +7 -0
  645. package/node_modules/zod/v4/locales/pl.cjs +141 -0
  646. package/node_modules/zod/v4/locales/pl.d.cts +5 -0
  647. package/node_modules/zod/v4/locales/pl.d.ts +4 -0
  648. package/node_modules/zod/v4/locales/pl.js +114 -0
  649. package/node_modules/zod/v4/locales/ps.cjs +146 -0
  650. package/node_modules/zod/v4/locales/ps.d.cts +5 -0
  651. package/node_modules/zod/v4/locales/ps.d.ts +4 -0
  652. package/node_modules/zod/v4/locales/ps.js +119 -0
  653. package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
  654. package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
  655. package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
  656. package/node_modules/zod/v4/locales/pt-BR.js +143 -0
  657. package/node_modules/zod/v4/locales/pt.cjs +169 -0
  658. package/node_modules/zod/v4/locales/pt.d.cts +5 -0
  659. package/node_modules/zod/v4/locales/pt.d.ts +4 -0
  660. package/node_modules/zod/v4/locales/pt.js +142 -0
  661. package/node_modules/zod/v4/locales/ro.cjs +149 -0
  662. package/node_modules/zod/v4/locales/ro.d.cts +5 -0
  663. package/node_modules/zod/v4/locales/ro.d.ts +4 -0
  664. package/node_modules/zod/v4/locales/ro.js +122 -0
  665. package/node_modules/zod/v4/locales/ru.cjs +195 -0
  666. package/node_modules/zod/v4/locales/ru.d.cts +5 -0
  667. package/node_modules/zod/v4/locales/ru.d.ts +4 -0
  668. package/node_modules/zod/v4/locales/ru.js +168 -0
  669. package/node_modules/zod/v4/locales/sk.cjs +143 -0
  670. package/node_modules/zod/v4/locales/sk.d.cts +5 -0
  671. package/node_modules/zod/v4/locales/sk.d.ts +4 -0
  672. package/node_modules/zod/v4/locales/sk.js +116 -0
  673. package/node_modules/zod/v4/locales/sl.cjs +141 -0
  674. package/node_modules/zod/v4/locales/sl.d.cts +5 -0
  675. package/node_modules/zod/v4/locales/sl.d.ts +4 -0
  676. package/node_modules/zod/v4/locales/sl.js +114 -0
  677. package/node_modules/zod/v4/locales/sv.cjs +142 -0
  678. package/node_modules/zod/v4/locales/sv.d.cts +5 -0
  679. package/node_modules/zod/v4/locales/sv.d.ts +4 -0
  680. package/node_modules/zod/v4/locales/sv.js +115 -0
  681. package/node_modules/zod/v4/locales/ta.cjs +142 -0
  682. package/node_modules/zod/v4/locales/ta.d.cts +5 -0
  683. package/node_modules/zod/v4/locales/ta.d.ts +4 -0
  684. package/node_modules/zod/v4/locales/ta.js +115 -0
  685. package/node_modules/zod/v4/locales/tg.cjs +144 -0
  686. package/node_modules/zod/v4/locales/tg.d.cts +5 -0
  687. package/node_modules/zod/v4/locales/tg.d.ts +4 -0
  688. package/node_modules/zod/v4/locales/tg.js +117 -0
  689. package/node_modules/zod/v4/locales/th.cjs +142 -0
  690. package/node_modules/zod/v4/locales/th.d.cts +5 -0
  691. package/node_modules/zod/v4/locales/th.d.ts +4 -0
  692. package/node_modules/zod/v4/locales/th.js +115 -0
  693. package/node_modules/zod/v4/locales/tk.cjs +134 -0
  694. package/node_modules/zod/v4/locales/tk.d.cts +5 -0
  695. package/node_modules/zod/v4/locales/tk.d.ts +4 -0
  696. package/node_modules/zod/v4/locales/tk.js +107 -0
  697. package/node_modules/zod/v4/locales/tr.cjs +137 -0
  698. package/node_modules/zod/v4/locales/tr.d.cts +5 -0
  699. package/node_modules/zod/v4/locales/tr.d.ts +4 -0
  700. package/node_modules/zod/v4/locales/tr.js +110 -0
  701. package/node_modules/zod/v4/locales/ua.cjs +12 -0
  702. package/node_modules/zod/v4/locales/ua.d.cts +5 -0
  703. package/node_modules/zod/v4/locales/ua.d.ts +5 -0
  704. package/node_modules/zod/v4/locales/ua.js +5 -0
  705. package/node_modules/zod/v4/locales/uk.cjs +140 -0
  706. package/node_modules/zod/v4/locales/uk.d.cts +5 -0
  707. package/node_modules/zod/v4/locales/uk.d.ts +4 -0
  708. package/node_modules/zod/v4/locales/uk.js +113 -0
  709. package/node_modules/zod/v4/locales/ur.cjs +142 -0
  710. package/node_modules/zod/v4/locales/ur.d.cts +5 -0
  711. package/node_modules/zod/v4/locales/ur.d.ts +4 -0
  712. package/node_modules/zod/v4/locales/ur.js +115 -0
  713. package/node_modules/zod/v4/locales/uz.cjs +140 -0
  714. package/node_modules/zod/v4/locales/uz.d.cts +5 -0
  715. package/node_modules/zod/v4/locales/uz.d.ts +4 -0
  716. package/node_modules/zod/v4/locales/uz.js +113 -0
  717. package/node_modules/zod/v4/locales/vi.cjs +140 -0
  718. package/node_modules/zod/v4/locales/vi.d.cts +5 -0
  719. package/node_modules/zod/v4/locales/vi.d.ts +4 -0
  720. package/node_modules/zod/v4/locales/vi.js +113 -0
  721. package/node_modules/zod/v4/locales/yo.cjs +139 -0
  722. package/node_modules/zod/v4/locales/yo.d.cts +5 -0
  723. package/node_modules/zod/v4/locales/yo.d.ts +4 -0
  724. package/node_modules/zod/v4/locales/yo.js +112 -0
  725. package/node_modules/zod/v4/locales/zh-CN.cjs +141 -0
  726. package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  727. package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  728. package/node_modules/zod/v4/locales/zh-CN.js +114 -0
  729. package/node_modules/zod/v4/locales/zh-TW.cjs +139 -0
  730. package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  731. package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  732. package/node_modules/zod/v4/locales/zh-TW.js +112 -0
  733. package/node_modules/zod/v4/mini/checks.cjs +54 -0
  734. package/node_modules/zod/v4/mini/checks.d.cts +1 -0
  735. package/node_modules/zod/v4/mini/checks.d.ts +1 -0
  736. package/node_modules/zod/v4/mini/checks.js +1 -0
  737. package/node_modules/zod/v4/mini/coerce.cjs +71 -0
  738. package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
  739. package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
  740. package/node_modules/zod/v4/mini/coerce.js +22 -0
  741. package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
  742. package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
  743. package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
  744. package/node_modules/zod/v4/mini/deep-partial.js +13 -0
  745. package/node_modules/zod/v4/mini/external.cjs +95 -0
  746. package/node_modules/zod/v4/mini/external.d.cts +16 -0
  747. package/node_modules/zod/v4/mini/external.d.ts +16 -0
  748. package/node_modules/zod/v4/mini/external.js +16 -0
  749. package/node_modules/zod/v4/mini/in-out.cjs +82 -0
  750. package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
  751. package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
  752. package/node_modules/zod/v4/mini/in-out.js +36 -0
  753. package/node_modules/zod/v4/mini/index.cjs +51 -0
  754. package/node_modules/zod/v4/mini/index.d.cts +3 -0
  755. package/node_modules/zod/v4/mini/index.d.ts +3 -0
  756. package/node_modules/zod/v4/mini/index.js +3 -0
  757. package/node_modules/zod/v4/mini/iso.cjs +83 -0
  758. package/node_modules/zod/v4/mini/iso.d.cts +22 -0
  759. package/node_modules/zod/v4/mini/iso.d.ts +22 -0
  760. package/node_modules/zod/v4/mini/iso.js +34 -0
  761. package/node_modules/zod/v4/mini/package.json +7 -0
  762. package/node_modules/zod/v4/mini/parse.cjs +37 -0
  763. package/node_modules/zod/v4/mini/parse.d.cts +1 -0
  764. package/node_modules/zod/v4/mini/parse.d.ts +1 -0
  765. package/node_modules/zod/v4/mini/parse.js +1 -0
  766. package/node_modules/zod/v4/mini/schemas.cjs +1147 -0
  767. package/node_modules/zod/v4/mini/schemas.d.cts +480 -0
  768. package/node_modules/zod/v4/mini/schemas.d.ts +480 -0
  769. package/node_modules/zod/v4/mini/schemas.js +1002 -0
  770. package/node_modules/zod/v4/package.json +7 -0
  771. package/node_modules/zod/v4-mini/index.cjs +51 -0
  772. package/node_modules/zod/v4-mini/index.d.cts +3 -0
  773. package/node_modules/zod/v4-mini/index.d.ts +3 -0
  774. package/node_modules/zod/v4-mini/index.js +3 -0
  775. package/node_modules/zod/v4-mini/package.json +7 -0
  776. package/package.json +32 -4
  777. package/runtime.cjs +14 -0
  778. package/scripts/arguments.mjs +77 -0
  779. package/scripts/continuation.mjs +31 -0
  780. package/scripts/create-task.mjs +27 -0
  781. package/scripts/delete-task.mjs +3 -0
  782. package/scripts/entry.mjs +6 -0
  783. package/scripts/get-task.mjs +40 -0
  784. package/scripts/get-tasks.mjs +84 -0
  785. package/scripts/hook.mjs +89 -0
  786. package/scripts/inspect-blockers.mjs +76 -0
  787. package/scripts/install-launcher.mjs +28 -0
  788. package/scripts/install-migration.mjs +82 -0
  789. package/scripts/install-path.mjs +105 -0
  790. package/scripts/install-release.mjs +252 -0
  791. package/scripts/lifecycle.mjs +35 -0
  792. package/scripts/list-tasks.mjs +117 -0
  793. package/scripts/output.mjs +67 -0
  794. package/scripts/schema.mjs +41 -0
  795. package/scripts/search-tasks.mjs +96 -0
  796. package/scripts/task-write-input.mjs +80 -0
  797. package/scripts/transition-task.mjs +3 -0
  798. package/scripts/update-release.mjs +82 -0
  799. package/scripts/update-task.mjs +29 -0
  800. package/scripts/validate-task-stores.mjs +34 -0
  801. package/src/blockers.mjs +134 -0
  802. package/src/cache.mjs +50 -0
  803. package/src/config.mjs +30 -0
  804. package/src/create.mjs +145 -0
  805. package/src/cursor.mjs +30 -0
  806. package/src/destinations.mjs +74 -0
  807. package/src/errors.mjs +16 -0
  808. package/src/field-rules.mjs +105 -0
  809. package/src/fields.mjs +32 -0
  810. package/src/input.mjs +146 -0
  811. package/src/limits.mjs +5 -0
  812. package/src/locations.mjs +19 -0
  813. package/src/pagination.mjs +30 -0
  814. package/src/project-lock.mjs +74 -0
  815. package/src/projects.mjs +33 -0
  816. package/src/response.mjs +75 -0
  817. package/src/schema.mjs +76 -0
  818. package/src/search-index-worker.mjs +10 -0
  819. package/src/search-index.mjs +639 -0
  820. package/src/search.mjs +228 -0
  821. package/src/service.mjs +260 -0
  822. package/src/source.mjs +48 -0
  823. package/src/sqlite.mjs +17 -0
  824. package/src/storage-format.mjs +15 -0
  825. package/src/stores.mjs +337 -0
  826. package/src/tasks.mjs +290 -0
  827. package/src/timestamps.mjs +22 -0
  828. package/src/transition.mjs +181 -0
  829. package/src/update.mjs +56 -0
  830. package/src/validation.mjs +144 -0
  831. package/src/version.mjs +5 -0
@@ -0,0 +1,2477 @@
1
+ const require_chunk = require('./chunk-Bnu9O96Y.cjs');
2
+ const require_src = require('./src-BhnGYybN.cjs');
3
+ let _modelcontextprotocol_server__shims = require("@modelcontextprotocol/server/_shims");
4
+ let _modelcontextprotocol_core_internal = require("@modelcontextprotocol/core/internal");
5
+
6
+ //#region src/server/completable.ts
7
+ const COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
8
+ /**
9
+ * Wraps a schema to provide autocompletion capabilities. Useful for, e.g., prompt arguments in MCP.
10
+ *
11
+ * @example
12
+ * ```ts source="./completable.examples.ts#completable_basicUsage"
13
+ * server.registerPrompt(
14
+ * 'review-code',
15
+ * {
16
+ * title: 'Code Review',
17
+ * argsSchema: z.object({
18
+ * language: completable(z.string().describe('Programming language'), value =>
19
+ * ['typescript', 'javascript', 'python', 'rust', 'go'].filter(lang => lang.startsWith(value))
20
+ * )
21
+ * })
22
+ * },
23
+ * ({ language }) => ({
24
+ * messages: [
25
+ * {
26
+ * role: 'user' as const,
27
+ * content: {
28
+ * type: 'text' as const,
29
+ * text: `Review this ${language} code.`
30
+ * }
31
+ * }
32
+ * ]
33
+ * })
34
+ * );
35
+ * ```
36
+ *
37
+ * @see {@linkcode server/mcp.McpServer.registerPrompt | McpServer.registerPrompt} for using completable schemas in prompt argument definitions
38
+ */
39
+ function completable(schema, complete) {
40
+ Object.defineProperty(schema, COMPLETABLE_SYMBOL, {
41
+ value: { complete },
42
+ enumerable: false,
43
+ writable: false,
44
+ configurable: false
45
+ });
46
+ return schema;
47
+ }
48
+ /**
49
+ * Checks if a schema is completable (has completion metadata).
50
+ */
51
+ function isCompletable(schema) {
52
+ return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
53
+ }
54
+ /**
55
+ * Gets the completer callback from a completable schema, if it exists.
56
+ */
57
+ function getCompleter(schema) {
58
+ return schema[COMPLETABLE_SYMBOL]?.complete;
59
+ }
60
+
61
+ //#endregion
62
+ //#region src/server/sseKeepAlive.ts
63
+ /** Default interval between SSE keep-alive comment frames. */
64
+ const DEFAULT_SSE_KEEP_ALIVE_MS = 15e3;
65
+ const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
66
+ /** Arms an unref'd timer, or disables keep-alive for invalid delays. */
67
+ function armSseKeepAlive(intervalMs, onTick) {
68
+ if (!Number.isFinite(intervalMs) || intervalMs < 1) return;
69
+ const timer = setInterval(onTick, Math.min(intervalMs, MAX_TIMER_DELAY_MS));
70
+ timer.unref?.();
71
+ return timer;
72
+ }
73
+
74
+ //#endregion
75
+ //#region src/server/serverEventBus.ts
76
+ /**
77
+ * A `ServerEventBus` backed by an in-process listener set.
78
+ *
79
+ * `publish()` delivers synchronously to the live listener set (a listener
80
+ * unsubscribing itself mid-dispatch is safe; the entry's listen-router
81
+ * listeners never unsubscribe peers). A throwing listener does not stop
82
+ * delivery to the others.
83
+ */
84
+ var InMemoryServerEventBus = class {
85
+ _listeners = /* @__PURE__ */ new Set();
86
+ /**
87
+ * @param onerror - Optional callback for errors thrown by listeners
88
+ * during dispatch.
89
+ */
90
+ constructor(onerror) {
91
+ this.onerror = onerror;
92
+ }
93
+ publish(event) {
94
+ for (const listener of this._listeners) try {
95
+ listener(event);
96
+ } catch (error) {
97
+ this.onerror?.(error instanceof Error ? error : new Error(String(error)));
98
+ }
99
+ }
100
+ subscribe(listener) {
101
+ this._listeners.add(listener);
102
+ let live = true;
103
+ return () => {
104
+ if (!live) return;
105
+ live = false;
106
+ this._listeners.delete(listener);
107
+ };
108
+ }
109
+ /** The number of currently registered listeners (test/introspection only — the routers track capacity via their own open-subscription set). */
110
+ get listenerCount() {
111
+ return this._listeners.size;
112
+ }
113
+ };
114
+ /** Build a {@linkcode ServerNotifier} over a bus. */
115
+ function createServerNotifier(bus) {
116
+ return {
117
+ toolsChanged: () => bus.publish({ kind: "tools_list_changed" }),
118
+ promptsChanged: () => bus.publish({ kind: "prompts_list_changed" }),
119
+ resourcesChanged: () => bus.publish({ kind: "resources_list_changed" }),
120
+ resourceUpdated: (uri) => bus.publish({
121
+ kind: "resource_updated",
122
+ uri
123
+ })
124
+ };
125
+ }
126
+ /**
127
+ * Whether a `subscriptions/listen` filter accepts a given change event.
128
+ *
129
+ * Pure: no I/O, no mutation. The filter governs ONLY the four
130
+ * subscription-gated change types — non-gated notifications never reach the
131
+ * bus and are not modeled here.
132
+ *
133
+ * `resource_updated` matches only when `resourceSubscriptions` is present and
134
+ * contains the event's URI exactly (per the spec: "for these resource URIs").
135
+ */
136
+ function listenFilterAccepts(filter, event) {
137
+ switch (event.kind) {
138
+ case "tools_list_changed": return filter.toolsListChanged === true;
139
+ case "prompts_list_changed": return filter.promptsListChanged === true;
140
+ case "resources_list_changed": return filter.resourcesListChanged === true;
141
+ case "resource_updated": return filter.resourceSubscriptions !== void 0 && filter.resourceSubscriptions.includes(event.uri);
142
+ }
143
+ }
144
+ /**
145
+ * The honored subset of a requested filter: keeps only the fields the client
146
+ * explicitly opted in to (drops `false` and absent fields), narrowed against
147
+ * the server's declared capabilities when supplied. The serving entry sends
148
+ * this back in `notifications/subscriptions/acknowledged` so the ack reflects
149
+ * what the server can actually deliver.
150
+ *
151
+ * - `toolsListChanged` is honored only when `capabilities.tools.listChanged`
152
+ * is advertised; likewise `promptsListChanged` / `resourcesListChanged`.
153
+ * - `resourceSubscriptions` is honored only when
154
+ * `capabilities.resources.subscribe` is advertised.
155
+ *
156
+ * `capabilities` is optional on this pure helper for test convenience only —
157
+ * both wired routers REQUIRE capabilities at the call site (the HTTP router's
158
+ * `serve()` takes a required parameter; `StdioListenRouter.serve()` throws
159
+ * before `setServerCapabilities()` was called), so the fail-open
160
+ * `undefined → honor everything` branch is never reachable on a wired entry.
161
+ */
162
+ function honoredSubset(requested, capabilities) {
163
+ const honored = {};
164
+ const allow = (bit) => capabilities === void 0 || bit === true;
165
+ if (requested.toolsListChanged === true && allow(capabilities?.tools?.listChanged)) honored.toolsListChanged = true;
166
+ if (requested.promptsListChanged === true && allow(capabilities?.prompts?.listChanged)) honored.promptsListChanged = true;
167
+ if (requested.resourcesListChanged === true && allow(capabilities?.resources?.listChanged)) honored.resourcesListChanged = true;
168
+ if (requested.resourceSubscriptions !== void 0 && requested.resourceSubscriptions.length > 0 && allow(capabilities?.resources?.subscribe)) honored.resourceSubscriptions = [...requested.resourceSubscriptions];
169
+ return honored;
170
+ }
171
+ /** Map a {@linkcode ServerEvent} onto its wire notification `{method, params}`. */
172
+ function serverEventToNotification(event) {
173
+ switch (event.kind) {
174
+ case "tools_list_changed": return { method: "notifications/tools/list_changed" };
175
+ case "prompts_list_changed": return { method: "notifications/prompts/list_changed" };
176
+ case "resources_list_changed": return { method: "notifications/resources/list_changed" };
177
+ case "resource_updated": return {
178
+ method: "notifications/resources/updated",
179
+ params: { uri: event.uri }
180
+ };
181
+ }
182
+ }
183
+
184
+ //#endregion
185
+ //#region src/server/listenRouter.ts
186
+ /** Default capacity guard: refuse a new subscription when this many are already open. */
187
+ const DEFAULT_MAX_SUBSCRIPTIONS = 1024;
188
+ function jsonRpcError(id, code, message) {
189
+ return Response.json({
190
+ jsonrpc: "2.0",
191
+ error: {
192
+ code,
193
+ message
194
+ },
195
+ id
196
+ }, { status: 200 });
197
+ }
198
+ /** Stamp the subscription id onto a notification's `_meta`. Non-mutating. */
199
+ function stampSubscriptionId(notification, subscriptionId) {
200
+ return {
201
+ method: notification.method,
202
+ params: {
203
+ ...notification.params,
204
+ _meta: {
205
+ ...notification.params?._meta,
206
+ [_modelcontextprotocol_core_internal.SUBSCRIPTION_ID_META_KEY]: subscriptionId
207
+ }
208
+ }
209
+ };
210
+ }
211
+ /**
212
+ * Read the requested filter off a `subscriptions/listen` request body.
213
+ * Returns the validated filter, or `undefined` when `params.notifications`
214
+ * is absent or fails the schema (the caller answers `-32602` — the spec
215
+ * marks `notifications` REQUIRED on the listen request).
216
+ */
217
+ function parseListenFilter(message) {
218
+ const outcome = require_src.codecForVersion(require_src.MODERN_WIRE_REVISION).validateRequest("subscriptions/listen", message);
219
+ return outcome.ok ? outcome.value.params?.notifications : void 0;
220
+ }
221
+ function createListenRouter(options) {
222
+ const { bus, onerror } = options;
223
+ const maxSubscriptions = options.maxSubscriptions ?? DEFAULT_MAX_SUBSCRIPTIONS;
224
+ const keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
225
+ const open = /* @__PURE__ */ new Set();
226
+ function serve(message, signal, capabilities, serverInfo) {
227
+ if (open.size >= maxSubscriptions) {
228
+ onerror?.(/* @__PURE__ */ new Error(`subscriptions/listen refused: subscription limit reached (${maxSubscriptions})`));
229
+ return jsonRpcError(message.id, -32603, "Subscription limit reached");
230
+ }
231
+ const filter = parseListenFilter(message);
232
+ if (filter === void 0) return jsonRpcError(message.id, -32602, "Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");
233
+ const honored = honoredSubset(filter, capabilities);
234
+ const subscriptionId = message.id;
235
+ const encoder = new TextEncoder();
236
+ let controller;
237
+ let closed = false;
238
+ let unsubscribe;
239
+ let keepAliveTimer;
240
+ let abortCleanup;
241
+ const writeFrame = (frame) => {
242
+ if (closed) return;
243
+ try {
244
+ controller.enqueue(encoder.encode(frame));
245
+ } catch (error) {
246
+ onerror?.(error instanceof Error ? error : new Error(String(error)));
247
+ }
248
+ };
249
+ const writeNotification = (method, params) => {
250
+ writeFrame(`event: message\ndata: ${JSON.stringify({
251
+ jsonrpc: "2.0",
252
+ method,
253
+ params
254
+ })}\n\n`);
255
+ };
256
+ const teardown = (graceful) => {
257
+ if (closed) return;
258
+ if (graceful) writeFrame(`event: message\ndata: ${JSON.stringify({
259
+ jsonrpc: "2.0",
260
+ id: subscriptionId,
261
+ result: {
262
+ resultType: "complete",
263
+ _meta: {
264
+ [_modelcontextprotocol_core_internal.SUBSCRIPTION_ID_META_KEY]: subscriptionId,
265
+ [_modelcontextprotocol_core_internal.SERVER_INFO_META_KEY]: serverInfo
266
+ }
267
+ }
268
+ })}\n\n`);
269
+ closed = true;
270
+ try {
271
+ unsubscribe?.();
272
+ } catch (error) {
273
+ onerror?.(error instanceof Error ? error : new Error(String(error)));
274
+ }
275
+ if (keepAliveTimer !== void 0) clearInterval(keepAliveTimer);
276
+ abortCleanup?.();
277
+ open.delete(teardown);
278
+ try {
279
+ controller.close();
280
+ } catch {}
281
+ };
282
+ const readable = new ReadableStream({
283
+ start(streamController) {
284
+ controller = streamController;
285
+ const ack = stampSubscriptionId({
286
+ method: "notifications/subscriptions/acknowledged",
287
+ params: { notifications: honored }
288
+ }, subscriptionId);
289
+ writeNotification(ack.method, ack.params);
290
+ if (Object.keys(honored).length === 0) {
291
+ teardown(true);
292
+ return;
293
+ }
294
+ unsubscribe = bus.subscribe((event) => {
295
+ if (closed || !listenFilterAccepts(honored, event)) return;
296
+ const note = stampSubscriptionId(serverEventToNotification(event), subscriptionId);
297
+ writeNotification(note.method, note.params);
298
+ });
299
+ keepAliveTimer = armSseKeepAlive(keepAliveMs, () => writeFrame(": keepalive\n\n"));
300
+ open.add(teardown);
301
+ },
302
+ cancel() {
303
+ teardown(false);
304
+ }
305
+ });
306
+ if (signal !== void 0) if (signal.aborted) teardown(false);
307
+ else {
308
+ const onAbort = () => teardown(false);
309
+ signal.addEventListener("abort", onAbort, { once: true });
310
+ abortCleanup = () => signal.removeEventListener("abort", onAbort);
311
+ }
312
+ return new Response(readable, {
313
+ status: 200,
314
+ headers: {
315
+ "Content-Type": "text/event-stream",
316
+ "Cache-Control": "no-cache, no-transform",
317
+ Connection: "keep-alive",
318
+ "X-Accel-Buffering": "no"
319
+ }
320
+ });
321
+ }
322
+ return {
323
+ serve,
324
+ closeAll() {
325
+ for (const teardown of open) teardown(true);
326
+ },
327
+ get openCount() {
328
+ return open.size;
329
+ }
330
+ };
331
+ }
332
+ const CHANGE_NOTIFICATION_METHODS = new Set([
333
+ "notifications/tools/list_changed",
334
+ "notifications/prompts/list_changed",
335
+ "notifications/resources/list_changed",
336
+ "notifications/resources/updated"
337
+ ]);
338
+ /**
339
+ * Per-connection listen state for the stdio entry. One instance is held by
340
+ * `serveStdio` for the connection lifetime; it routes inbound
341
+ * `subscriptions/listen` / `notifications/cancelled` and rewrites outbound
342
+ * change notifications onto the active subscriptions. No bus — the long-lived
343
+ * pinned instance's existing `send*ListChanged()` calls feed straight into
344
+ * `routeOutbound()`.
345
+ */
346
+ var StdioListenRouter = class {
347
+ /** Active subscriptions, keyed by the listen request's JSON-RPC id verbatim. */
348
+ _subs = /* @__PURE__ */ new Map();
349
+ /**
350
+ * The serving instance's declared capabilities. Filled in by the entry
351
+ * once the modern instance is constructed (the router is created before
352
+ * the instance exists), so the acknowledged filter is narrowed against
353
+ * what the server can actually deliver.
354
+ */
355
+ _serverCapabilities;
356
+ /**
357
+ * The serving instance's identity, stamped onto the graceful-close
358
+ * results' `_meta` (the spec's `SubscriptionsListenResultMetaObject` extends
359
+ * `ResultMetaObject`). Handed over together with the capabilities.
360
+ */
361
+ _serverInfo;
362
+ constructor(_maxSubscriptions = DEFAULT_MAX_SUBSCRIPTIONS, serverCapabilities, serverInfo) {
363
+ this._maxSubscriptions = _maxSubscriptions;
364
+ this._serverCapabilities = serverCapabilities;
365
+ this._serverInfo = serverInfo;
366
+ }
367
+ /**
368
+ * Record the serving instance's declared capabilities and identity once
369
+ * it has been constructed. Called by `serveStdio`'s connect path;
370
+ * subsequent `serve()` calls narrow the honored filter against the
371
+ * capabilities, and `teardownAll()` stamps the identity.
372
+ */
373
+ setServerCapabilities(capabilities, serverInfo) {
374
+ this._serverCapabilities = capabilities;
375
+ if (serverInfo !== void 0) this._serverInfo = serverInfo;
376
+ }
377
+ /** Whether `id` is an active listen subscription on this connection. */
378
+ has(id) {
379
+ return this._subs.has(id);
380
+ }
381
+ /**
382
+ * Serve one inbound `subscriptions/listen` request: registers the
383
+ * subscription and returns the stamped acknowledged notification (or, on
384
+ * capacity / params rejection, the in-band JSON-RPC error response).
385
+ *
386
+ * @throws when called before {@linkcode setServerCapabilities} (or the
387
+ * constructor) has supplied the serving instance's capabilities. Honoring a
388
+ * filter without knowing the server's advertised capabilities would fail
389
+ * open (deliver unadvertised types); the entry guarantees capabilities are
390
+ * set before any listen request is routed here.
391
+ */
392
+ serve(message) {
393
+ if (this._serverCapabilities === void 0) throw new Error("StdioListenRouter.serve() called before setServerCapabilities(); refusing to honor a filter without capabilities");
394
+ if (this._subs.size >= this._maxSubscriptions) return {
395
+ jsonrpc: "2.0",
396
+ id: message.id,
397
+ error: {
398
+ code: -32603,
399
+ message: "Subscription limit reached"
400
+ }
401
+ };
402
+ const filter = parseListenFilter(message);
403
+ if (filter === void 0) return {
404
+ jsonrpc: "2.0",
405
+ id: message.id,
406
+ error: {
407
+ code: -32602,
408
+ message: "Invalid params: 'notifications' is required and must be a valid SubscriptionFilter"
409
+ }
410
+ };
411
+ const honored = honoredSubset(filter, this._serverCapabilities);
412
+ this._subs.set(message.id, honored);
413
+ return stampSubscriptionId({
414
+ method: "notifications/subscriptions/acknowledged",
415
+ params: { notifications: honored }
416
+ }, message.id);
417
+ }
418
+ /**
419
+ * Tear down one subscription (inbound `notifications/cancelled`). Returns
420
+ * `true` when a subscription was removed. After this call NOTHING further
421
+ * is delivered for that subscription id (the post-cancel hardening).
422
+ */
423
+ cancel(id) {
424
+ return this._subs.delete(id);
425
+ }
426
+ /**
427
+ * Route an outbound notification through the active subscriptions.
428
+ *
429
+ * - For a subscription-gated change notification, returns one stamped copy
430
+ * per subscription that opted in to it (an empty array means it is
431
+ * dropped — the modern era never delivers an un-requested change type).
432
+ * - For any other outbound message, returns `'passthrough'` (the entry
433
+ * forwards it as-is).
434
+ */
435
+ routeOutbound(message) {
436
+ if (!CHANGE_NOTIFICATION_METHODS.has(message.method)) return "passthrough";
437
+ const uriParam = message.params?.["uri"];
438
+ const uri = typeof uriParam === "string" ? uriParam : void 0;
439
+ const event = notificationToServerEvent(message.method, uri);
440
+ const out = [];
441
+ for (const [subscriptionId, filter] of this._subs) if (listenFilterAccepts(filter, event)) out.push(stampSubscriptionId({
442
+ method: message.method,
443
+ params: message.params ?? {}
444
+ }, subscriptionId));
445
+ return out;
446
+ }
447
+ /**
448
+ * Server-side graceful teardown of every active subscription: returns the
449
+ * empty `subscriptions/listen` JSON-RPC result for each subscription id —
450
+ * the spec's graceful-close signal, `_meta` carrying the subscription id
451
+ * and the serving instance's identity — for the entry to emit before
452
+ * closing the wire. Clears the set so nothing further is delivered.
453
+ */
454
+ teardownAll() {
455
+ const out = [];
456
+ for (const id of this._subs.keys()) out.push({
457
+ jsonrpc: "2.0",
458
+ id,
459
+ result: {
460
+ resultType: "complete",
461
+ _meta: {
462
+ [_modelcontextprotocol_core_internal.SUBSCRIPTION_ID_META_KEY]: id,
463
+ ...this._serverInfo !== void 0 && { [_modelcontextprotocol_core_internal.SERVER_INFO_META_KEY]: this._serverInfo }
464
+ }
465
+ }
466
+ });
467
+ this._subs.clear();
468
+ return out;
469
+ }
470
+ };
471
+ function notificationToServerEvent(method, uri) {
472
+ switch (method) {
473
+ case "notifications/tools/list_changed": return { kind: "tools_list_changed" };
474
+ case "notifications/prompts/list_changed": return { kind: "prompts_list_changed" };
475
+ case "notifications/resources/list_changed": return { kind: "resources_list_changed" };
476
+ default: return {
477
+ kind: "resource_updated",
478
+ uri: uri ?? ""
479
+ };
480
+ }
481
+ }
482
+
483
+ //#endregion
484
+ //#region src/server/middleware/bearerAuth.ts
485
+ function comparableResource(value) {
486
+ const text = String(value);
487
+ const hash = text.indexOf("#");
488
+ return (hash === -1 ? text : text.slice(0, hash)).replace(/\/$/, "");
489
+ }
490
+ function sameResource(reported, expected) {
491
+ if (!reported) return false;
492
+ return comparableResource(reported) === comparableResource(expected);
493
+ }
494
+ function headerQuotedValue(value) {
495
+ return value.replaceAll(/[\\"]/g, String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g, " ");
496
+ }
497
+ /**
498
+ * Build a `WWW-Authenticate: Bearer …` challenge header value (RFC 6750).
499
+ *
500
+ * The single formatter behind every challenge this package emits — the
501
+ * bearer-auth 401/403 answers and the per-operation scope-challenge 403 — so
502
+ * all challenges from one server agree on parameter order and quoting. Every
503
+ * parameter value is emitted as an HTTP quoted-string with `\` and `"`
504
+ * escaped and non-printable characters replaced.
505
+ */
506
+ function buildWwwAuthenticateHeader(errorCode, description, requiredScopes, resourceMetadataUrl) {
507
+ let header = `Bearer error="${headerQuotedValue(errorCode)}", error_description="${headerQuotedValue(description)}"`;
508
+ if (requiredScopes.length > 0) header += `, scope="${headerQuotedValue(requiredScopes.join(" "))}"`;
509
+ if (resourceMetadataUrl) header += `, resource_metadata="${headerQuotedValue(resourceMetadataUrl)}"`;
510
+ return header;
511
+ }
512
+ /**
513
+ * Validate a raw `Authorization` header value as a Bearer token and return
514
+ * the verified {@link AuthInfo}.
515
+ *
516
+ * The runtime-neutral core of Bearer authentication: it parses the header,
517
+ * runs the verifier, compares the token's resource with `expectedResource`,
518
+ * enforces `requiredScopes`, and rejects tokens without an
519
+ * expiration or past it. On any failure it throws an {@link OAuthError} —
520
+ * pass that to {@link bearerAuthChallengeResponse} for the matching HTTP
521
+ * answer, or use {@link requireBearerAuth} to get both steps as one call.
522
+ *
523
+ * Framework adapters build on this: `requireBearerAuth` from
524
+ * `@modelcontextprotocol/express` feeds it `req.headers.authorization`.
525
+ */
526
+ async function verifyBearerToken(authorizationHeader, options) {
527
+ const { verifier, requiredScopes = [], expectedResource } = options;
528
+ if (!authorizationHeader) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Missing Authorization header");
529
+ const [type, token] = authorizationHeader.split(" ");
530
+ if (type?.toLowerCase() !== "bearer" || !token) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Invalid Authorization header format, expected 'Bearer TOKEN'");
531
+ const authInfo = await verifier.verifyAccessToken(token);
532
+ if (expectedResource !== void 0 && !sameResource(authInfo.resource, expectedResource)) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Token was not issued for this resource");
533
+ if (requiredScopes.length > 0) {
534
+ if (!requiredScopes.every((scope) => authInfo.scopes.includes(scope))) throw new require_src.OAuthError(require_src.OAuthErrorCode.InsufficientScope, "Insufficient scope");
535
+ }
536
+ if (typeof authInfo.expiresAt !== "number" || Number.isNaN(authInfo.expiresAt)) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Token has no expiration time");
537
+ else if (authInfo.expiresAt < Date.now() / 1e3) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Token has expired");
538
+ if (options.resourceMetadataUrl !== void 0 && authInfo.resourceMetadataUrl === void 0) return {
539
+ ...authInfo,
540
+ resourceMetadataUrl: options.resourceMetadataUrl
541
+ };
542
+ return authInfo;
543
+ }
544
+ /**
545
+ * Build the HTTP answer for a Bearer authentication failure.
546
+ *
547
+ * Maps an {@link OAuthError} to its status — `401` for `invalid_token` and
548
+ * `403` for `insufficient_scope` (both carrying the `WWW-Authenticate: Bearer …`
549
+ * challenge, with `resource_metadata` when configured so clients can discover
550
+ * the Authorization Server), `500` for `server_error`, `400` for anything
551
+ * else. A non-`OAuthError` value answers `500 server_error`. The body is the
552
+ * OAuth error JSON.
553
+ */
554
+ function bearerAuthChallengeResponse(error, options) {
555
+ const { requiredScopes = [], resourceMetadataUrl } = options ?? {};
556
+ if (!(error instanceof require_src.OAuthError)) {
557
+ const serverError = new require_src.OAuthError(require_src.OAuthErrorCode.ServerError, "Internal Server Error");
558
+ return Response.json(serverError.toResponseObject(), { status: 500 });
559
+ }
560
+ switch (error.code) {
561
+ case require_src.OAuthErrorCode.InvalidToken: {
562
+ const challenge = buildWwwAuthenticateHeader(error.code, error.message, requiredScopes, resourceMetadataUrl);
563
+ return Response.json(error.toResponseObject(), {
564
+ status: 401,
565
+ headers: { "WWW-Authenticate": challenge }
566
+ });
567
+ }
568
+ case require_src.OAuthErrorCode.InsufficientScope: {
569
+ const challenge = buildWwwAuthenticateHeader(error.code, error.message, requiredScopes, resourceMetadataUrl);
570
+ return Response.json(error.toResponseObject(), {
571
+ status: 403,
572
+ headers: { "WWW-Authenticate": challenge }
573
+ });
574
+ }
575
+ case require_src.OAuthErrorCode.ServerError: return Response.json(error.toResponseObject(), { status: 500 });
576
+ default: return Response.json(error.toResponseObject(), { status: 400 });
577
+ }
578
+ }
579
+ /**
580
+ * Require a valid Bearer token on web-standard requests.
581
+ *
582
+ * The framework-free counterpart of `requireBearerAuth` from
583
+ * `@modelcontextprotocol/express`, for hosts whose HTTP surface is a
584
+ * `fetch(request)` handler — Cloudflare Workers, Deno, Bun, Hono. The
585
+ * returned gate resolves to the verified {@link AuthInfo}, or to the
586
+ * ready-to-return challenge `Response` when the request must be refused.
587
+ *
588
+ * @example
589
+ * ```ts source="./bearerAuth.examples.ts#requireBearerAuth_fetchGate"
590
+ * const gate = requireBearerAuth({ verifier, requiredScopes: ['mcp'] });
591
+ *
592
+ * async function fetchHandler(request: Request): Promise<Response> {
593
+ * const auth: AuthInfo | Response = await gate(request);
594
+ * if (auth instanceof Response) return auth;
595
+ * return handler.fetch(request, { authInfo: auth });
596
+ * }
597
+ * ```
598
+ */
599
+ function requireBearerAuth(options) {
600
+ const { verifier, requiredScopes = [], resourceMetadataUrl, expectedResource } = options;
601
+ const resolved = {
602
+ verifier,
603
+ requiredScopes,
604
+ resourceMetadataUrl,
605
+ expectedResource
606
+ };
607
+ return async (request) => {
608
+ const [authorizationHeader] = (request.headers.get("authorization") ?? "").split(",");
609
+ try {
610
+ return await verifyBearerToken(authorizationHeader || void 0, resolved);
611
+ } catch (error) {
612
+ return bearerAuthChallengeResponse(error, resolved);
613
+ }
614
+ };
615
+ }
616
+
617
+ //#endregion
618
+ //#region src/server/middleware/oauthMetadata.ts
619
+ function checkIssuerUrl(issuer, allowInsecure) {
620
+ if (issuer.protocol !== "https:" && issuer.hostname !== "localhost" && issuer.hostname !== "127.0.0.1" && !allowInsecure) throw new Error("Issuer URL must be HTTPS");
621
+ if (issuer.hash) throw new Error(`Issuer URL must not have a fragment: ${issuer}`);
622
+ if (issuer.search) throw new Error(`Issuer URL must not have a query string: ${issuer}`);
623
+ }
624
+ /**
625
+ * Derive the RFC 9728 Protected Resource Metadata document from
626
+ * {@link AuthMetadataOptions}, validating the Authorization Server issuer URL
627
+ * (HTTPS required outside localhost) in the process.
628
+ *
629
+ * `oauthMetadataResponse` and the Express `mcpAuthMetadataRouter` both build
630
+ * on this; use it directly when serving the document through your own
631
+ * routing — or call it once at startup to fail fast on a misconfigured
632
+ * issuer before any request arrives.
633
+ */
634
+ function buildOAuthProtectedResourceMetadata(options) {
635
+ checkIssuerUrl(new URL(options.oauthMetadata.issuer), options.dangerouslyAllowInsecureIssuerUrl);
636
+ return {
637
+ resource: options.resourceServerUrl.href,
638
+ authorization_servers: [options.oauthMetadata.issuer],
639
+ scopes_supported: options.scopesSupported,
640
+ resource_name: options.resourceName,
641
+ resource_documentation: options.serviceDocumentationUrl?.href
642
+ };
643
+ }
644
+ /**
645
+ * Builds the RFC 9728 Protected Resource Metadata URL for a given MCP server
646
+ * URL by inserting `/.well-known/oauth-protected-resource` ahead of the path.
647
+ *
648
+ * @example
649
+ * ```ts
650
+ * getOAuthProtectedResourceMetadataUrl(new URL('https://api.example.com/mcp'))
651
+ * // → 'https://api.example.com/.well-known/oauth-protected-resource/mcp'
652
+ * ```
653
+ */
654
+ function getOAuthProtectedResourceMetadataUrl(serverUrl) {
655
+ const metadataUrl = new URL(serverUrl);
656
+ metadataUrl.pathname = protectedResourceMetadataPath(serverUrl);
657
+ metadataUrl.hash = "";
658
+ return metadataUrl.href;
659
+ }
660
+ /** The RFC 9728 path-aware well-known path for a resource URL. */
661
+ function protectedResourceMetadataPath(resourceServerUrl) {
662
+ const rsPath = stripTrailingSlash(resourceServerUrl.pathname);
663
+ return `/.well-known/oauth-protected-resource${rsPath === "/" ? "" : rsPath}`;
664
+ }
665
+ function stripTrailingSlash(path) {
666
+ return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
667
+ }
668
+ const ALLOWED_METHODS = "GET, HEAD, OPTIONS";
669
+ function metadataDocumentResponse(request, metadata) {
670
+ if (request.method === "OPTIONS") {
671
+ const requestedHeaders = request.headers.get("access-control-request-headers");
672
+ return new Response(null, {
673
+ status: 204,
674
+ headers: {
675
+ "Access-Control-Allow-Origin": "*",
676
+ "Access-Control-Allow-Methods": ALLOWED_METHODS,
677
+ ...requestedHeaders === null ? {} : {
678
+ "Access-Control-Allow-Headers": requestedHeaders,
679
+ Vary: "Access-Control-Request-Headers"
680
+ }
681
+ }
682
+ });
683
+ }
684
+ if (request.method !== "GET" && request.method !== "HEAD") {
685
+ const error = new require_src.OAuthError(require_src.OAuthErrorCode.MethodNotAllowed, `The method ${request.method} is not allowed for this endpoint`);
686
+ return Response.json(error.toResponseObject(), {
687
+ status: 405,
688
+ headers: {
689
+ Allow: ALLOWED_METHODS,
690
+ "Access-Control-Allow-Origin": "*"
691
+ }
692
+ });
693
+ }
694
+ const response = Response.json(metadata, { headers: { "Access-Control-Allow-Origin": "*" } });
695
+ return request.method === "HEAD" ? new Response(null, {
696
+ status: response.status,
697
+ headers: response.headers
698
+ }) : response;
699
+ }
700
+ /**
701
+ * Serve the two OAuth discovery documents an MCP server acting as a Resource
702
+ * Server exposes, from a web-standard `fetch(request)` handler:
703
+ *
704
+ * - `/.well-known/oauth-protected-resource[/<path>]` — RFC 9728 Protected
705
+ * Resource Metadata, derived from the supplied options (path-aware: the
706
+ * resource URL's path is reflected in the route).
707
+ * - `/.well-known/oauth-authorization-server` — RFC 8414 Authorization
708
+ * Server Metadata, passed through verbatim.
709
+ *
710
+ * Returns the matched document `Response` (JSON with permissive CORS, `405`
711
+ * with an `Allow` header for non-GET methods, `204` for CORS preflight), or
712
+ * `undefined` when the request path is neither well-known route — fall
713
+ * through to your own routing. The framework-free counterpart of
714
+ * `mcpAuthMetadataRouter` from `@modelcontextprotocol/express`; pair it with
715
+ * `requireBearerAuth` and `getOAuthProtectedResourceMetadataUrl` so
716
+ * unauthenticated clients can discover the AS from the `401` challenge.
717
+ *
718
+ * @example
719
+ * ```ts source="./oauthMetadata.examples.ts#oauthMetadataResponse_fetchHandler"
720
+ * async function fetchHandler(request: Request): Promise<Response> {
721
+ * return oauthMetadataResponse(request, options) ?? serveMcp(request);
722
+ * }
723
+ * ```
724
+ */
725
+ function oauthMetadataResponse(request, options) {
726
+ const requestPath = stripTrailingSlash(new URL(request.url).pathname);
727
+ if (requestPath === protectedResourceMetadataPath(options.resourceServerUrl)) return metadataDocumentResponse(request, buildOAuthProtectedResourceMetadata(options));
728
+ if (requestPath === "/.well-known/oauth-authorization-server") {
729
+ buildOAuthProtectedResourceMetadata(options);
730
+ return metadataDocumentResponse(request, options.oauthMetadata);
731
+ }
732
+ }
733
+
734
+ //#endregion
735
+ //#region src/server/scopeChallenge.ts
736
+ /** @internal */
737
+ function supportsScopeChallengeResolver(transport) {
738
+ return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
739
+ }
740
+ function assertScope(scope, location) {
741
+ if (typeof scope !== "string" || !/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(scope)) throw new TypeError(`${location} must satisfy the OAuth scope-token grammar`);
742
+ }
743
+ function validateScopeChallenge(challenge) {
744
+ if (challenge === null || typeof challenge !== "object" || !Array.isArray(challenge.scopes) || challenge.scopes.length === 0) throw new TypeError("scope challenge must contain at least one scope");
745
+ for (const [index, scope] of challenge.scopes.entries()) assertScope(scope, `scope challenge scopes[${index}]`);
746
+ if (challenge.errorDescription !== void 0 && typeof challenge.errorDescription !== "string") throw new TypeError("scope challenge errorDescription must be a string");
747
+ if (challenge.errorDescription !== void 0 && !/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(challenge.errorDescription)) throw new TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");
748
+ return challenge;
749
+ }
750
+ /**
751
+ * Creates a handler that requires every supplied scope exactly.
752
+ *
753
+ * Requests without authentication are left to the server's authentication gate.
754
+ */
755
+ function requireScopes(...scopes) {
756
+ if (scopes.length === 0) throw new TypeError("requireScopes must contain at least one scope");
757
+ for (const [index, scope] of scopes.entries()) assertScope(scope, `requireScopes scope[${index}]`);
758
+ const requiredScopes = [...scopes];
759
+ return ({ authInfo }) => {
760
+ if (authInfo === void 0) return;
761
+ const activeScopes = new Set(authInfo.scopes);
762
+ if (requiredScopes.every((scope) => activeScopes.has(scope))) return;
763
+ return { scopes: requiredScopes };
764
+ };
765
+ }
766
+ /** @internal */
767
+ async function findScopeChallenge(requests, authInfo, resolve) {
768
+ for (const request of requests) {
769
+ const challenge = await resolve({
770
+ request,
771
+ ...authInfo !== void 0 && { authInfo }
772
+ });
773
+ if (challenge !== void 0) return validateScopeChallenge(challenge);
774
+ }
775
+ }
776
+ /**
777
+ * The RFC 9728 Protected Resource Metadata URL to advertise on a scope
778
+ * challenge, derived from the verified {@link AuthInfo}: the URL the
779
+ * authentication gate stamped (`authInfo.resourceMetadataUrl`, set by the
780
+ * bearer-auth helpers from their `resourceMetadataUrl` option), falling back
781
+ * to the well-known location for an HTTP(S) RFC 8707 `resource` identifier, or
782
+ * `undefined` when neither is available (the `resource_metadata` parameter is
783
+ * then omitted, matching the bearer-auth challenges).
784
+ *
785
+ * @internal
786
+ */
787
+ function scopeChallengeResourceMetadataUrl(authInfo) {
788
+ if (authInfo?.resourceMetadataUrl !== void 0) return authInfo.resourceMetadataUrl;
789
+ if (authInfo?.resource?.protocol === "https:" || authInfo?.resource?.protocol === "http:") return getOAuthProtectedResourceMetadataUrl(authInfo.resource);
790
+ }
791
+ /** @internal */
792
+ function createScopeChallengeResponse(challenge, resourceMetadataUrl) {
793
+ return bearerAuthChallengeResponse(new require_src.OAuthError(require_src.OAuthErrorCode.InsufficientScope, challenge.errorDescription ?? "Insufficient scope"), {
794
+ requiredScopes: [...challenge.scopes],
795
+ resourceMetadataUrl
796
+ });
797
+ }
798
+
799
+ //#endregion
800
+ //#region src/server/legacyInputRequiredShim.ts
801
+ /**
802
+ * Default handler re-entries per originating request — tighter than the
803
+ * client driver's 10 because the shim holds a live wire request open.
804
+ */
805
+ const DEFAULT_LEGACY_SHIM_MAX_ROUNDS = 8;
806
+ /** Default per-leg timeout: legs are human-paced, so the 60s protocol default is wrong. */
807
+ const DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS = 6e5;
808
+ /** Resolves and validates `ServerOptions.inputRequired`, failing loudly at construction time. */
809
+ function resolveLegacyShimOptions(options) {
810
+ if (options?.maxRounds !== void 0 && (!Number.isInteger(options.maxRounds) || options.maxRounds < 1)) throw new RangeError(`inputRequired.maxRounds must be a positive integer (got ${options.maxRounds})`);
811
+ if (options?.roundTimeoutMs !== void 0 && (!Number.isFinite(options.roundTimeoutMs) || options.roundTimeoutMs <= 0)) throw new RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${options.roundTimeoutMs})`);
812
+ return {
813
+ maxRounds: options?.maxRounds ?? DEFAULT_LEGACY_SHIM_MAX_ROUNDS,
814
+ roundTimeoutMs: options?.roundTimeoutMs ?? DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS,
815
+ legacyShim: options?.legacyShim ?? true
816
+ };
817
+ }
818
+ /**
819
+ * Validates one `inputRequests` entry: malformed or unknown kinds are server
820
+ * bugs and fail loudly on both eras. Shared by the modern seam's capability
821
+ * check and the shim's gate.
822
+ */
823
+ function coerceEmbeddedInputRequest(method, key, entry) {
824
+ if (entry === null || typeof entry !== "object" || typeof entry.method !== "string") throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an invalid input request '${key}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);
825
+ const embedded = entry;
826
+ const required = require_src.requiredClientCapabilitiesForInputRequest(embedded);
827
+ if (required === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key}' of kind '${embedded.method}', which is not an embedded request the 2026-07-28 revision defines`);
828
+ return {
829
+ embedded,
830
+ required
831
+ };
832
+ }
833
+ /**
834
+ * The 2025-11-25 URL-mode wire shape requires an `elicitationId`; the 2026
835
+ * in-band shape has none, so URL legs mint one (CSPRNG-backed, with a
836
+ * getRandomValues fallback for runtimes without `randomUUID`).
837
+ */
838
+ function syntheticElicitationId() {
839
+ const webCrypto = globalThis.crypto;
840
+ if (webCrypto?.randomUUID !== void 0) return webCrypto.randomUUID();
841
+ const bytes = new Uint8Array(16);
842
+ webCrypto.getRandomValues(bytes);
843
+ bytes[6] = bytes[6] & 15 | 64;
844
+ bytes[8] = bytes[8] & 63 | 128;
845
+ const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
846
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
847
+ }
848
+ /** Per-family surfacing: tools/call → isError result (the 2025 idiom); prompts/resources → JSON-RPC error. */
849
+ function legacyShimFailure(method, message) {
850
+ if (method === "tools/call") return {
851
+ content: [{
852
+ type: "text",
853
+ text: message
854
+ }],
855
+ isError: true
856
+ };
857
+ throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, message);
858
+ }
859
+ /** The fulfilment loop — see the module doc for the contract. */
860
+ var LegacyInputRequiredShim = class {
861
+ constructor(_host) {
862
+ this._host = _host;
863
+ }
864
+ async fulfill(method, handler, request, ctx, firstResult) {
865
+ const { maxRounds, roundTimeoutMs } = this._host;
866
+ const outerSignal = ctx.mcpReq.signal;
867
+ let current = firstResult;
868
+ let round = 0;
869
+ while (true) {
870
+ round += 1;
871
+ if (round > maxRounds) return legacyShimFailure(method, require_src.inputRequiredRoundsExceededMessage(method, maxRounds));
872
+ const inputRequests = current.inputRequests;
873
+ const hasInputRequests = inputRequests != null && Object.keys(inputRequests).length > 0;
874
+ const requestState = typeof current.requestState === "string" ? current.requestState : void 0;
875
+ if (!hasInputRequests && requestState === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);
876
+ let responses;
877
+ if (hasInputRequests) {
878
+ const declared = this._host.resolvedClientCapabilities(ctx);
879
+ const coerced = [];
880
+ for (const [key, entry] of Object.entries(inputRequests)) {
881
+ const { embedded, required } = coerceEmbeddedInputRequest(method, key, entry);
882
+ if (embedded.method !== "roots/list" && embedded.params === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key}' of kind '${embedded.method}' without params`);
883
+ if (require_src.missingClientCapabilities(required, declared) !== void 0) return legacyShimFailure(method, `Cannot request input '${key}' (${embedded.method}): the client on this 2025-era connection did not declare the required capability${declared === void 0 ? " (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)" : ""}`);
884
+ coerced.push([key, embedded]);
885
+ }
886
+ const roundAbort = require_src.linkedRoundAbort(outerSignal);
887
+ try {
888
+ const legOptions = {
889
+ relatedRequestId: ctx.mcpReq.id,
890
+ timeout: roundTimeoutMs,
891
+ resetTimeoutOnProgress: true,
892
+ onprogress: () => {},
893
+ signal: roundAbort.signal
894
+ };
895
+ const fulfilled = await Promise.all(coerced.map(async ([key, embedded]) => {
896
+ try {
897
+ return [key, await this._dispatchLeg(embedded, legOptions)];
898
+ } catch (error) {
899
+ roundAbort.abort(error);
900
+ throw error;
901
+ }
902
+ }));
903
+ responses = Object.fromEntries(fulfilled);
904
+ } catch (error) {
905
+ if (outerSignal.aborted) throw error;
906
+ return legacyShimFailure(method, `Fulfilling input required by '${method}' failed: ${error instanceof Error ? error.message : String(error)}`);
907
+ } finally {
908
+ roundAbort.dispose();
909
+ }
910
+ } else await require_src.sleep(require_src.REQUEST_STATE_ONLY_LEG_PACING_MS, outerSignal);
911
+ let ctxNext = {
912
+ ...ctx,
913
+ mcpReq: {
914
+ ...ctx.mcpReq,
915
+ inputResponses: responses,
916
+ droppedInputResponseKeys: void 0,
917
+ requestState: require_src.requestStateAccessor(requestState)
918
+ }
919
+ };
920
+ if (requestState !== void 0) {
921
+ const decoded = await this._host.verifyRequestState(requestState, ctxNext, method);
922
+ if (decoded !== void 0) ctxNext = require_src.withRequestStateValue(ctxNext, decoded);
923
+ }
924
+ const next = await handler(request, ctxNext);
925
+ if (!require_src.isInputRequiredResult(next)) return next;
926
+ current = next;
927
+ }
928
+ }
929
+ /** Routes one embedded request through the host's existing 2025-era senders (gate already ran). */
930
+ async _dispatchLeg(embedded, options) {
931
+ switch (embedded.method) {
932
+ case "elicitation/create": {
933
+ let params = embedded.params;
934
+ if (params.mode === "url" && params.elicitationId === void 0) params = {
935
+ ...params,
936
+ elicitationId: syntheticElicitationId()
937
+ };
938
+ return await this._host.sendElicitation(params, options);
939
+ }
940
+ case "sampling/createMessage": return await this._host.sendSampling(embedded.params, options);
941
+ case "roots/list": return await this._host.listRoots(embedded.params, options);
942
+ }
943
+ }
944
+ };
945
+
946
+ //#endregion
947
+ //#region src/server/server.ts
948
+ /**
949
+ * The request methods whose 2026-07-28 result vocabulary includes
950
+ * `input_required` (the multi round-trip methods). Returning an
951
+ * input-required result from any other handler is a server bug.
952
+ */
953
+ const INPUT_REQUIRED_CAPABLE_METHODS = new Set([
954
+ "tools/call",
955
+ "prompts/get",
956
+ "resources/read"
957
+ ]);
958
+ let writeClientIdentity;
959
+ let installDiscoverHandler;
960
+ let readServerIdentity;
961
+ /**
962
+ * Package-internal: backfills the connection-scoped client-identity fields of a
963
+ * per-request server instance from the request's validated `_meta` envelope, so the
964
+ * (deprecated) {@linkcode Server.getClientCapabilities} / {@linkcode Server.getClientVersion}
965
+ * accessors keep answering on instances that never see an `initialize` handshake.
966
+ * Not public API.
967
+ */
968
+ function seedClientIdentityFromEnvelope(server, identity) {
969
+ writeClientIdentity(server, identity);
970
+ }
971
+ /**
972
+ * Package-internal: installs the modern-only `server/discover` handler on an instance
973
+ * the HTTP entry has marked as serving the 2026-07-28 era, and makes sure the modern
974
+ * revisions the entry serves appear in the instance's supported-versions list (so the
975
+ * discover advertisement and version-mismatch errors name them). Idempotent.
976
+ * Hand-constructed instances are unaffected: nothing else calls this, so they keep
977
+ * answering `-32601` unless their own supported-versions list opts into a modern
978
+ * revision. Not public API.
979
+ */
980
+ function installModernOnlyHandlers(server, servedModernVersions) {
981
+ installDiscoverHandler(server, servedModernVersions);
982
+ }
983
+ /**
984
+ * Package-internal: the instance's implementation identity, for the serving
985
+ * entries to stamp onto entry-built results (the `subscriptions/listen`
986
+ * graceful-close result — built outside the encode seam, but the spec's
987
+ * `SubscriptionsListenResultMetaObject` extends `ResultMetaObject`, so it carries
988
+ * the serverInfo SHOULD like every other result). Not public API.
989
+ */
990
+ function serverIdentityOf(server) {
991
+ return readServerIdentity(server);
992
+ }
993
+ /**
994
+ * An MCP server on top of a pluggable transport.
995
+ *
996
+ * This server will automatically respond to the initialization flow as initiated from the client.
997
+ *
998
+ * @deprecated Use {@linkcode server/mcp.McpServer | McpServer} instead for the high-level API. Only use `Server` for advanced use cases.
999
+ */
1000
+ var Server = class extends require_src.Protocol {
1001
+ _clientCapabilities;
1002
+ _clientVersion;
1003
+ static {
1004
+ writeClientIdentity = (server, identity) => {
1005
+ if (identity.clientCapabilities !== void 0) server._clientCapabilities = identity.clientCapabilities;
1006
+ if (identity.clientInfo !== void 0) server._clientVersion = identity.clientInfo;
1007
+ };
1008
+ installDiscoverHandler = (server, servedModernVersions) => {
1009
+ const missing = servedModernVersions.filter((version) => !server._supportedProtocolVersions.includes(version));
1010
+ if (missing.length > 0) server._supportedProtocolVersions = [...server._supportedProtocolVersions, ...missing];
1011
+ server.setRequestHandler("server/discover", () => server._ondiscover());
1012
+ };
1013
+ readServerIdentity = (server) => server._serverInfo;
1014
+ }
1015
+ _capabilities;
1016
+ _instructions;
1017
+ _jsonSchemaValidator;
1018
+ _cacheHints;
1019
+ _requestStateVerify;
1020
+ _inputRequiredServing;
1021
+ _legacyShim;
1022
+ /** Lazily-built legacy shim; the loop lives in legacyInputRequiredShim.ts behind a narrow host contract. */
1023
+ _legacyInputRequiredShim() {
1024
+ return this._legacyShim ??= new LegacyInputRequiredShim({
1025
+ maxRounds: this._inputRequiredServing.maxRounds,
1026
+ roundTimeoutMs: this._inputRequiredServing.roundTimeoutMs,
1027
+ resolvedClientCapabilities: (ctx) => this._inputRequestCapabilityView(ctx),
1028
+ verifyRequestState: (state, ctx, method) => this._verifyRequestState(state, ctx, method),
1029
+ sendElicitation: (params, options) => this._sendElicitationLeg(params, options, { validateAcceptedContent: false }),
1030
+ sendSampling: (params, options) => this.createMessage(params, options),
1031
+ listRoots: (params, options) => this.listRoots(params, options)
1032
+ });
1033
+ }
1034
+ /**
1035
+ * Callback for when initialization has fully completed (i.e., the client has sent an `notifications/initialized` notification).
1036
+ */
1037
+ oninitialized;
1038
+ /**
1039
+ * Initializes this server with the given name and version information.
1040
+ */
1041
+ constructor(_serverInfo, options) {
1042
+ super(options);
1043
+ this._serverInfo = _serverInfo;
1044
+ this._capabilities = options?.capabilities ? { ...options.capabilities } : {};
1045
+ this._instructions = options?.instructions;
1046
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new _modelcontextprotocol_server__shims.DefaultJsonSchemaValidator();
1047
+ this._requestStateVerify = options?.requestState?.verify;
1048
+ this._inputRequiredServing = resolveLegacyShimOptions(options?.inputRequired);
1049
+ if (options?.cacheHints !== void 0) {
1050
+ for (const [operation, hint] of Object.entries(options.cacheHints)) if (hint !== void 0) require_src.assertValidCacheHint(hint, `cacheHints['${operation}']`);
1051
+ this._cacheHints = options.cacheHints;
1052
+ }
1053
+ this.setRequestHandler("initialize", (request) => this._oninitialize(request));
1054
+ this.setNotificationHandler("notifications/initialized", () => this.oninitialized?.());
1055
+ if (require_src.modernProtocolVersions(this._supportedProtocolVersions).length > 0) this.setRequestHandler("server/discover", () => this._ondiscover());
1056
+ if (this._capabilities.logging) this._registerLoggingHandler();
1057
+ }
1058
+ /** Attaches to the given transport; rejects while this instance is connected to another one. */
1059
+ async connect(transport) {
1060
+ if (this.transport !== void 0) throw new require_src.SdkError(require_src.SdkErrorCode.AlreadyConnected, "Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");
1061
+ await super.connect(transport);
1062
+ }
1063
+ /**
1064
+ * Registers the built-in `logging/setLevel` request handler.
1065
+ *
1066
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1067
+ * Remains functional during the deprecation window (at least twelve months).
1068
+ * Migrate to stderr logging (STDIO servers) or OpenTelemetry.
1069
+ */
1070
+ _registerLoggingHandler() {
1071
+ this.setRequestHandler("logging/setLevel", async (request, ctx) => {
1072
+ const transportSessionId = ctx.sessionId || ctx.http?.req?.headers.get("mcp-session-id") || void 0;
1073
+ const { level } = request.params;
1074
+ const parseResult = require_src.parseSchema(_modelcontextprotocol_core_internal.LoggingLevelSchema, level);
1075
+ if (parseResult.success) this._loggingLevels.set(transportSessionId, parseResult.data);
1076
+ return {};
1077
+ });
1078
+ }
1079
+ buildContext(ctx, transportInfo) {
1080
+ const hasHttpInfo = ctx.http || transportInfo?.request || transportInfo?.closeSSEStream || transportInfo?.closeStandaloneSSEStream;
1081
+ return {
1082
+ ...ctx,
1083
+ mcpReq: {
1084
+ ...ctx.mcpReq,
1085
+ log: (level, data, logger) => {
1086
+ if (!this._capabilities.logging) return Promise.resolve();
1087
+ let threshold;
1088
+ if (this._servedModernEra()) {
1089
+ threshold = ctx.mcpReq.envelope?.[_modelcontextprotocol_core_internal.LOG_LEVEL_META_KEY];
1090
+ if (threshold === void 0) return Promise.resolve();
1091
+ } else threshold = this._loggingLevels.get(ctx.sessionId) ?? this._loggingLevels.get(void 0);
1092
+ if (threshold !== void 0 && this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(threshold)) return Promise.resolve();
1093
+ return ctx.mcpReq.notify({
1094
+ method: "notifications/message",
1095
+ params: {
1096
+ level,
1097
+ data,
1098
+ logger
1099
+ }
1100
+ });
1101
+ },
1102
+ elicitInput: (params, options) => this.elicitInput(params, options),
1103
+ requestSampling: (params, options) => this.createMessage(params, options)
1104
+ },
1105
+ http: hasHttpInfo ? {
1106
+ ...ctx.http,
1107
+ req: transportInfo?.request,
1108
+ closeSSE: transportInfo?.closeSSEStream,
1109
+ closeStandaloneSSE: transportInfo?.closeStandaloneSSEStream
1110
+ } : void 0
1111
+ };
1112
+ }
1113
+ _loggingLevels = /* @__PURE__ */ new Map();
1114
+ LOG_LEVEL_SEVERITY = new Map(_modelcontextprotocol_core_internal.LoggingLevelSchema.options.map((level, index) => [level, index]));
1115
+ isMessageIgnored = (level, sessionId) => {
1116
+ const currentLevel = this._loggingLevels.get(sessionId);
1117
+ return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
1118
+ };
1119
+ /**
1120
+ * Registers new capabilities. This can only be called before connecting to a transport.
1121
+ *
1122
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
1123
+ */
1124
+ registerCapabilities(capabilities) {
1125
+ if (this.transport) throw new require_src.SdkError(require_src.SdkErrorCode.AlreadyConnected, "Cannot register capabilities after connecting to transport");
1126
+ const hadLogging = !!this._capabilities.logging;
1127
+ this._capabilities = require_src.mergeCapabilities(this._capabilities, capabilities);
1128
+ if (!hadLogging && this._capabilities.logging) this._registerLoggingHandler();
1129
+ }
1130
+ /**
1131
+ * Enforces server-side validation for `tools/call` results regardless of how the
1132
+ * handler was registered, attaches the configured per-operation cache hint
1133
+ * (when one exists) so the 2026-07-28 encode seam can fill `ttlMs`/`cacheScope`
1134
+ * for results that do not provide their own, and owns the multi-round-trip
1135
+ * seam: on the methods whose 2026-07-28 result vocabulary includes
1136
+ * `input_required` (`tools/call`, `prompts/get`, `resources/read`) an
1137
+ * input-required return skips result-schema validation and is checked
1138
+ * against the served era, the at-least-one rule, and the request's own
1139
+ * declared client capabilities; on every other method an input-required
1140
+ * return is a server bug and fails loudly. The hint rides a symbol-keyed
1141
+ * property that is never serialized, so 2025-era responses are unaffected.
1142
+ */
1143
+ _wrapHandler(method, handler) {
1144
+ if (method !== "tools/call") {
1145
+ const cacheHint = this._cacheHints?.[method];
1146
+ const isInputRequiredCapable = INPUT_REQUIRED_CAPABLE_METHODS.has(method);
1147
+ if (cacheHint === void 0 && !isInputRequiredCapable) return async (request, ctx) => {
1148
+ const result = await handler(request, ctx);
1149
+ if (require_src.isInputRequiredResult(result)) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);
1150
+ return result;
1151
+ };
1152
+ return async (request, ctx) => {
1153
+ const result = isInputRequiredCapable ? await this._invokeInputRequiredCapableHandler(method, handler, request, ctx) : await handler(request, ctx);
1154
+ if (require_src.isInputRequiredResult(result)) {
1155
+ if (!isInputRequiredCapable) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);
1156
+ return result;
1157
+ }
1158
+ return cacheHint === void 0 ? result : require_src.attachCacheHintFallback(result, cacheHint);
1159
+ };
1160
+ }
1161
+ return async (request, ctx) => {
1162
+ const codec = require_src.codecForVersion(this._negotiatedProtocolVersion);
1163
+ const validatedRequest = codec.validateRequest("tools/call", request);
1164
+ if (!validatedRequest.ok) throw new require_src.ProtocolError(validatedRequest.reason === "not-in-era" ? require_src.ProtocolErrorCode.InternalError : require_src.ProtocolErrorCode.InvalidParams, validatedRequest.reason === "not-in-era" ? "No wire schema for tools/call in the resolved era" : `Invalid tools/call request: ${validatedRequest.message}`);
1165
+ const result = await this._invokeInputRequiredCapableHandler("tools/call", handler, request, ctx);
1166
+ if (require_src.isInputRequiredResult(result)) return result;
1167
+ const normalizedResult = require_src.normalizeContentlessToolResult(result);
1168
+ const validationResult = codec.validateResult("tools/call", normalizedResult);
1169
+ if (!validationResult.ok) throw new require_src.ProtocolError(validationResult.reason === "not-in-era" ? require_src.ProtocolErrorCode.InternalError : require_src.ProtocolErrorCode.InvalidParams, validationResult.reason === "not-in-era" ? "No wire schema for tools/call in the resolved era" : `Invalid tools/call result: ${validationResult.message}`);
1170
+ return validationResult.value;
1171
+ };
1172
+ }
1173
+ /**
1174
+ * Whether this instance is bound to a 2026-07-28-or-later protocol
1175
+ * revision. Era is instance state — a serving entry (`createMcpHandler`,
1176
+ * `serveStdio`) marks the instance modern at construction; a 2025-era
1177
+ * `initialize` handshake binds it legacy. The multi-round-trip seam reads
1178
+ * this directly: there is no per-request era consult.
1179
+ */
1180
+ _servedModernEra() {
1181
+ return this._negotiatedProtocolVersion !== void 0 && require_src.isModernProtocolVersion(this._negotiatedProtocolVersion);
1182
+ }
1183
+ /**
1184
+ * Invokes a handler for one of the multi-round-trip methods and applies
1185
+ * the input-required seam:
1186
+ *
1187
+ * - a `UrlElicitationRequiredError` (or any 2025-style server→client
1188
+ * request idiom) escaping the handler on a request served on the
1189
+ * 2026-07-28 era fails LOUDLY with a clear steer to
1190
+ * `inputRequired.elicitUrl(...)` — the `-32042` error never reaches the
1191
+ * 2026-07-28 wire and the throw is not silently converted. Requests
1192
+ * served on the 2025 era keep today's `-32042` behavior byte-exact (the
1193
+ * error is rethrown unchanged).
1194
+ * - an input-required RETURN toward a 2026-07-28 request must satisfy
1195
+ * the at-least-one rule, and every embedded request must be covered by
1196
+ * the capabilities declared on the request's envelope (violations
1197
+ * answer the typed `-32021` error). Toward a 2025-era request the
1198
+ * return is fulfilled by the default-on legacy shim, whose own gate
1199
+ * consults the initialize-declared capabilities and surfaces
1200
+ * violations per family; `inputRequired.legacyShim: false` restores
1201
+ * the pre-shim loud failure.
1202
+ */
1203
+ async _invokeInputRequiredCapableHandler(method, handler, request, ctx) {
1204
+ const servedModern = this._servedModernEra();
1205
+ const rawRequestState = ctx.mcpReq.requestState();
1206
+ if (rawRequestState !== void 0 && typeof rawRequestState !== "string") throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "Invalid or expired requestState", { reason: "invalid_request_state" });
1207
+ let ctxForHandler = ctx;
1208
+ if (typeof rawRequestState === "string") {
1209
+ const decoded = await this._verifyRequestState(rawRequestState, ctx, method);
1210
+ if (decoded !== void 0) ctxForHandler = require_src.withRequestStateValue(ctx, decoded);
1211
+ }
1212
+ let result;
1213
+ try {
1214
+ result = await handler(request, ctxForHandler);
1215
+ } catch (error) {
1216
+ if (error instanceof require_src.ProtocolError && error.code === require_src.ProtocolErrorCode.UrlElicitationRequired) {
1217
+ if (!servedModern) throw error;
1218
+ throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`);
1219
+ }
1220
+ throw error;
1221
+ }
1222
+ if (!require_src.isInputRequiredResult(result)) return result;
1223
+ if (!servedModern) {
1224
+ if (!this._inputRequiredServing.legacyShim) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion ?? _modelcontextprotocol_core_internal.LATEST_PROTOCOL_VERSION}, which has no input_required vocabulary`);
1225
+ return await this._legacyInputRequiredShim().fulfill(method, handler, request, ctxForHandler, result);
1226
+ }
1227
+ const inputRequests = result.inputRequests;
1228
+ const hasInputRequests = inputRequests != null && Object.keys(inputRequests).length > 0;
1229
+ const hasRequestState = typeof result.requestState === "string";
1230
+ if (!hasInputRequests && !hasRequestState) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);
1231
+ if (hasInputRequests) {
1232
+ const declared = this._inputRequestCapabilityView(ctx);
1233
+ for (const [key, entry] of Object.entries(inputRequests)) {
1234
+ const { embedded, required } = coerceEmbeddedInputRequest(method, key, entry);
1235
+ const missing = require_src.missingClientCapabilities(required, declared);
1236
+ if (missing !== void 0) throw new require_src.MissingRequiredClientCapabilityError({ requiredCapabilities: missing }, `Cannot request input '${key}' (${embedded.method}): the request's client capabilities do not declare the required capability`);
1237
+ }
1238
+ }
1239
+ return result;
1240
+ }
1241
+ /**
1242
+ * Runs the configured `requestState.verify` hook and returns its
1243
+ * resolved value (`undefined` when unconfigured or the hook returns
1244
+ * nothing). Deny-on-error: any hook failure answers the frozen `-32602`;
1245
+ * the reason goes to `onerror` only.
1246
+ */
1247
+ async _verifyRequestState(state, ctx, method) {
1248
+ if (this._requestStateVerify === void 0) return;
1249
+ try {
1250
+ return await this._requestStateVerify(state, ctx);
1251
+ } catch (error) {
1252
+ this.onerror?.(/* @__PURE__ */ new Error(`requestState verification rejected ${method}: ${error instanceof Error ? error.message : String(error)}`));
1253
+ throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "Invalid or expired requestState", { reason: "invalid_request_state" });
1254
+ }
1255
+ }
1256
+ /**
1257
+ * The per-request resolved client-capabilities view: the request's own
1258
+ * `_meta` envelope on the 2026 era; the `initialize`-declared state on a
1259
+ * 2025-era connection. Per-request instances that never saw an
1260
+ * initialize (stateless legacy) hold nothing, so gates refuse there.
1261
+ */
1262
+ _inputRequestCapabilityView(ctx) {
1263
+ return this._servedModernEra() ? ctx.mcpReq.envelope?.[_modelcontextprotocol_core_internal.CLIENT_CAPABILITIES_META_KEY] : this._clientCapabilities;
1264
+ }
1265
+ /**
1266
+ * Guard for the push-style server→client request APIs ({@linkcode createMessage},
1267
+ * {@linkcode elicitInput}, {@linkcode listRoots}, {@linkcode ping}) on a
1268
+ * modern-era instance: the 2026-07-28 revision has no server→client request
1269
+ * channel, so the call fails before any wire traffic with a typed error
1270
+ * whose message steers to `inputRequired(...)`. The base era gate would
1271
+ * also reject it; this guard runs first to carry the steer.
1272
+ */
1273
+ _assertPushApiInServedEra(method) {
1274
+ if (this._servedModernEra()) throw new require_src.SdkError(require_src.SdkErrorCode.MethodNotSupportedByProtocolVersion, `Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${method}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`, {
1275
+ method,
1276
+ era: "2026-07-28"
1277
+ });
1278
+ }
1279
+ assertCapabilityForMethod(method) {
1280
+ switch (method) {
1281
+ case "sampling/createMessage":
1282
+ if (!this._clientCapabilities?.sampling) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support sampling (required for ${method})`);
1283
+ break;
1284
+ case "elicitation/create":
1285
+ if (!this._clientCapabilities?.elicitation) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support elicitation (required for ${method})`);
1286
+ break;
1287
+ case "roots/list":
1288
+ if (!this._clientCapabilities?.roots) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support listing roots (required for ${method})`);
1289
+ break;
1290
+ case "ping": break;
1291
+ }
1292
+ }
1293
+ assertNotificationCapability(method) {
1294
+ switch (method) {
1295
+ case "notifications/message":
1296
+ if (!this._capabilities.logging) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support logging (required for ${method})`);
1297
+ break;
1298
+ case "notifications/resources/updated":
1299
+ case "notifications/resources/list_changed":
1300
+ if (!this._capabilities.resources) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support notifying about resources (required for ${method})`);
1301
+ break;
1302
+ case "notifications/tools/list_changed":
1303
+ if (!this._capabilities.tools) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support notifying of tool list changes (required for ${method})`);
1304
+ break;
1305
+ case "notifications/prompts/list_changed":
1306
+ if (!this._capabilities.prompts) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support notifying of prompt list changes (required for ${method})`);
1307
+ break;
1308
+ case "notifications/elicitation/complete":
1309
+ if (!this._clientCapabilities?.elicitation?.url) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support URL elicitation (required for ${method})`);
1310
+ break;
1311
+ case "notifications/cancelled": break;
1312
+ case "notifications/progress": break;
1313
+ }
1314
+ }
1315
+ assertRequestHandlerCapability(method) {
1316
+ switch (method) {
1317
+ case "completion/complete":
1318
+ if (!this._capabilities.completions) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support completions (required for ${method})`);
1319
+ break;
1320
+ case "logging/setLevel":
1321
+ if (!this._capabilities.logging) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support logging (required for ${method})`);
1322
+ break;
1323
+ case "prompts/get":
1324
+ case "prompts/list":
1325
+ if (!this._capabilities.prompts) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support prompts (required for ${method})`);
1326
+ break;
1327
+ case "resources/list":
1328
+ case "resources/templates/list":
1329
+ case "resources/read":
1330
+ if (!this._capabilities.resources) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support resources (required for ${method})`);
1331
+ break;
1332
+ case "tools/call":
1333
+ case "tools/list":
1334
+ if (!this._capabilities.tools) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support tools (required for ${method})`);
1335
+ break;
1336
+ case "ping":
1337
+ case "initialize": break;
1338
+ }
1339
+ }
1340
+ async _oninitialize(request) {
1341
+ const requestedVersion = request.params.protocolVersion;
1342
+ this._clientCapabilities = request.params.capabilities;
1343
+ this._clientVersion = request.params.clientInfo;
1344
+ const legacyVersions = require_src.legacyProtocolVersions(this._supportedProtocolVersions);
1345
+ const protocolVersion = legacyVersions.includes(requestedVersion) ? requestedVersion : legacyVersions[0] ?? _modelcontextprotocol_core_internal.LATEST_PROTOCOL_VERSION;
1346
+ this._negotiatedProtocolVersion = protocolVersion;
1347
+ this.transport?.setProtocolVersion?.(protocolVersion);
1348
+ return {
1349
+ protocolVersion,
1350
+ capabilities: this.getCapabilities(),
1351
+ serverInfo: this._serverInfo,
1352
+ ...this._instructions && { instructions: this._instructions }
1353
+ };
1354
+ }
1355
+ /**
1356
+ * Answers `server/discover` (protocol revision 2026-07-28). `supportedVersions`
1357
+ * lists only modern revisions (2025-era versions are negotiated via `initialize`);
1358
+ * the capabilities are advertised as-is, listChanged/subscribe bits included
1359
+ * (see {@linkcode discoverAdvertisedCapabilities}).
1360
+ */
1361
+ _ondiscover() {
1362
+ return {
1363
+ supportedVersions: require_src.modernProtocolVersions(this._supportedProtocolVersions),
1364
+ capabilities: discoverAdvertisedCapabilities(this.getCapabilities()),
1365
+ ...this._instructions && { instructions: this._instructions }
1366
+ };
1367
+ }
1368
+ /**
1369
+ * The identity the 2026-era encode seam stamps into every outbound
1370
+ * result's `_meta` under `io.modelcontextprotocol/serverInfo` (spec PR
1371
+ * #3002: servers SHOULD identify themselves on every response).
1372
+ */
1373
+ _outboundServerInfo() {
1374
+ return this._serverInfo;
1375
+ }
1376
+ /**
1377
+ * After initialization has completed, this will be populated with the client's reported capabilities.
1378
+ *
1379
+ * @deprecated Read client identity from the per-request handler context instead: on
1380
+ * 2026-07-28 (per-request envelope) requests `ctx.mcpReq.envelope` carries the client's
1381
+ * declared capabilities, while on 2025-era connections this accessor keeps returning the
1382
+ * `initialize`-scoped value. The accessor remains functional — instances serving the
1383
+ * 2026-07-28 era are backfilled per request from the validated envelope.
1384
+ */
1385
+ getClientCapabilities() {
1386
+ return this._clientCapabilities;
1387
+ }
1388
+ /**
1389
+ * After initialization has completed, this will be populated with information about the client's name and version.
1390
+ *
1391
+ * @deprecated Read client identity from the per-request handler context instead: on
1392
+ * 2026-07-28 (per-request envelope) requests `ctx.mcpReq.envelope` carries the client's
1393
+ * name and version, while on 2025-era connections this accessor keeps returning the
1394
+ * `initialize`-scoped value. The accessor remains functional — instances serving the
1395
+ * 2026-07-28 era are backfilled per request from the validated envelope.
1396
+ */
1397
+ getClientVersion() {
1398
+ return this._clientVersion;
1399
+ }
1400
+ /**
1401
+ * After initialization has completed, this will be populated with the protocol version negotiated
1402
+ * with the client (the version the server responded with during the initialize handshake), or
1403
+ * `undefined` before initialization.
1404
+ *
1405
+ * @deprecated Read the protocol revision from the per-request handler context instead: on
1406
+ * 2026-07-28 (per-request envelope) requests `ctx.mcpReq.envelope` names the revision the
1407
+ * request was sent for, while on 2025-era connections this accessor keeps returning the
1408
+ * `initialize`-negotiated version. The accessor remains functional — instances serving the
1409
+ * 2026-07-28 era report that revision.
1410
+ */
1411
+ getNegotiatedProtocolVersion() {
1412
+ return this._negotiatedProtocolVersion;
1413
+ }
1414
+ /**
1415
+ * Project a `tools/call` result through this instance's negotiated wire
1416
+ * codec — the era-agnostic SEP-2106 §4.3 TextContent auto-append, plus on
1417
+ * the 2025 era the `{result:…}` wrap when `structuredContent` is a
1418
+ * non-object value or the advertised `outputSchema` had a non-object root.
1419
+ * Identity for object-shaped `structuredContent` on the 2026 era.
1420
+ *
1421
+ * `McpServer`'s built-in `tools/call` handler routes through this method.
1422
+ * Low-level `setRequestHandler('tools/call', …)` authors call it
1423
+ * themselves so the projection lives in one place (the codec) and the
1424
+ * server-side handler stays era-blind.
1425
+ *
1426
+ * This is the only codec function exposed on `Server` — the full
1427
+ * `WireCodec` is intentionally not part of the public surface.
1428
+ */
1429
+ projectCallToolResult(result, advertisedOutputSchema) {
1430
+ return this._wireCodec().projectCallToolResult(result, advertisedOutputSchema);
1431
+ }
1432
+ /**
1433
+ * Returns the current server capabilities.
1434
+ */
1435
+ getCapabilities() {
1436
+ return this._capabilities;
1437
+ }
1438
+ /**
1439
+ * Sends a `ping` request to the connected client.
1440
+ *
1441
+ * @deprecated The 2026-07-28 protocol removed ping; it throws on a 2026-07-28-era instance.
1442
+ * If your factory serves both eras, this only works on the legacy path.
1443
+ */
1444
+ async ping() {
1445
+ this._assertPushApiInServedEra("ping");
1446
+ return this.request({ method: "ping" });
1447
+ }
1448
+ async createMessage(params, options) {
1449
+ this._assertPushApiInServedEra("sampling/createMessage");
1450
+ if ((params.tools || params.toolChoice) && !this._clientCapabilities?.sampling?.tools) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support sampling tools capability.");
1451
+ if (params.messages.length > 0) {
1452
+ const lastMessage = params.messages.at(-1);
1453
+ const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
1454
+ const hasToolResults = lastContent.some((c) => c.type === "tool_result");
1455
+ const previousMessage = params.messages.length > 1 ? params.messages.at(-2) : void 0;
1456
+ const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
1457
+ const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
1458
+ if (hasToolResults) {
1459
+ if (lastContent.some((c) => c.type !== "tool_result")) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "The last message must contain only tool_result content if any is present");
1460
+ if (!hasPreviousToolUse) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "tool_result blocks are not matching any tool_use from the previous message");
1461
+ }
1462
+ if (hasPreviousToolUse) {
1463
+ const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
1464
+ const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
1465
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "ids of tool_result blocks and tool_use blocks from previous message do not match");
1466
+ }
1467
+ }
1468
+ const hasTools = Boolean(params.tools || params.toolChoice);
1469
+ const wide = await this.request({
1470
+ method: "sampling/createMessage",
1471
+ params
1472
+ }, options);
1473
+ const outcome = this._wireCodec().samplingResultVariant(hasTools, wide);
1474
+ if (!outcome.ok) throw new require_src.SdkError(require_src.SdkErrorCode.InvalidResult, `Invalid sampling/createMessage result: ${outcome.reason === "invalid" ? outcome.message : outcome.reason}`);
1475
+ return outcome.value;
1476
+ }
1477
+ /**
1478
+ * Creates an elicitation request for the given parameters.
1479
+ * For backwards compatibility, `mode` may be omitted for form requests and will default to `"form"`.
1480
+ * @param params The parameters for the elicitation request.
1481
+ * @param options Optional request options.
1482
+ * @returns The result of the elicitation request.
1483
+ *
1484
+ * @deprecated Throws on a 2026-07-28-era request — use {@link index.inputRequired | inputRequired} (multi-round-trip)
1485
+ * instead. The 2025 push-style server-to-client request model is replaced by input_required
1486
+ * results in the 2026-07-28 protocol. If your factory serves both eras, this only works on the
1487
+ * legacy path.
1488
+ */
1489
+ async elicitInput(params, options) {
1490
+ this._assertPushApiInServedEra("elicitation/create");
1491
+ switch (params.mode ?? "form") {
1492
+ case "url":
1493
+ if (!this._clientCapabilities?.elicitation?.url) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support url elicitation.");
1494
+ break;
1495
+ case "form":
1496
+ if (!this._clientCapabilities?.elicitation?.form) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support form elicitation.");
1497
+ break;
1498
+ }
1499
+ return this._sendElicitationLeg(params, options);
1500
+ }
1501
+ /**
1502
+ * The capability-check-free core of {@linkcode elicitInput}. The shim
1503
+ * uses it because its gate differs from the public checks: a bare
1504
+ * `elicitation: {}` counts as form support (the pre-mode rule), and
1505
+ * accepted content passes through unvalidated for parity with the
1506
+ * modern client driver (handlers validate via the schema-aware
1507
+ * `acceptedContent` overload and can re-ask).
1508
+ */
1509
+ async _sendElicitationLeg(params, options, behavior) {
1510
+ const mode = params.mode ?? "form";
1511
+ const validateAcceptedContent = behavior?.validateAcceptedContent ?? true;
1512
+ switch (mode) {
1513
+ case "url": {
1514
+ const urlParams = params;
1515
+ return this.request({
1516
+ method: "elicitation/create",
1517
+ params: urlParams
1518
+ }, options);
1519
+ }
1520
+ case "form": {
1521
+ const formParams = params.mode === "form" ? params : {
1522
+ ...params,
1523
+ mode: "form"
1524
+ };
1525
+ const result = await this.request({
1526
+ method: "elicitation/create",
1527
+ params: formParams
1528
+ }, options);
1529
+ if (validateAcceptedContent && result.action === "accept" && result.content && formParams.requestedSchema) try {
1530
+ const validationResult = this._jsonSchemaValidator.getValidator(formParams.requestedSchema)(result.content);
1531
+ if (!validationResult.valid) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
1532
+ } catch (error) {
1533
+ if (error instanceof require_src.ProtocolError) throw error;
1534
+ throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Error validating elicitation response: ${error instanceof Error ? error.message : String(error)}`);
1535
+ }
1536
+ return result;
1537
+ }
1538
+ }
1539
+ }
1540
+ /**
1541
+ * Creates a reusable callback that, when invoked, will send a `notifications/elicitation/complete`
1542
+ * notification for the specified elicitation ID.
1543
+ *
1544
+ * The notification (and the `elicitationId` it references) exists only on protocol revision
1545
+ * 2025-11-25 — the 2026-07-28 revision removed both. On a connection negotiated at 2026-07-28 the
1546
+ * returned callback rejects with a typed local error before anything reaches the transport
1547
+ * (the method is not part of that revision's wire registry).
1548
+ *
1549
+ * @param elicitationId The ID of the elicitation to mark as complete.
1550
+ * @param options Optional notification options. Useful when the completion notification should be related to a prior request.
1551
+ * @returns A function that emits the completion notification when awaited.
1552
+ */
1553
+ createElicitationCompletionNotifier(elicitationId, options) {
1554
+ if (!this._clientCapabilities?.elicitation?.url) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support URL elicitation (required for notifications/elicitation/complete)");
1555
+ return () => this.notification({
1556
+ method: "notifications/elicitation/complete",
1557
+ params: { elicitationId }
1558
+ }, options);
1559
+ }
1560
+ /**
1561
+ * Requests the list of roots from the client.
1562
+ *
1563
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1564
+ * Throws on a 2026-07-28-era request — use {@link index.inputRequired | inputRequired} (multi-round-trip) instead,
1565
+ * or migrate to passing paths via tool parameters, resource URIs, or configuration. The 2025
1566
+ * push-style server-to-client request model is replaced by input_required results in the
1567
+ * 2026-07-28 protocol. If your factory serves both eras, this only works on the legacy path.
1568
+ */
1569
+ async listRoots(params, options) {
1570
+ this._assertPushApiInServedEra("roots/list");
1571
+ return this.request({
1572
+ method: "roots/list",
1573
+ params
1574
+ }, options);
1575
+ }
1576
+ /**
1577
+ * Sends a logging message to the client, if connected.
1578
+ * Note: You only need to send the parameters object, not the entire JSON-RPC message.
1579
+ * @see {@linkcode LoggingMessageNotification}
1580
+ * @param params
1581
+ * @param sessionId Optional for stateless transports and backward compatibility.
1582
+ *
1583
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1584
+ * Remains functional during the deprecation window (at least twelve months).
1585
+ * Migrate to stderr logging (STDIO servers) or OpenTelemetry.
1586
+ */
1587
+ async sendLoggingMessage(params, sessionId) {
1588
+ if (this._capabilities.logging && !this.isMessageIgnored(params.level, sessionId)) return this.notification({
1589
+ method: "notifications/message",
1590
+ params
1591
+ });
1592
+ }
1593
+ async sendResourceUpdated(params) {
1594
+ return this.notification({
1595
+ method: "notifications/resources/updated",
1596
+ params
1597
+ });
1598
+ }
1599
+ async sendResourceListChanged() {
1600
+ return this.notification({ method: "notifications/resources/list_changed" });
1601
+ }
1602
+ async sendToolListChanged() {
1603
+ return this.notification({ method: "notifications/tools/list_changed" });
1604
+ }
1605
+ async sendPromptListChanged() {
1606
+ return this.notification({ method: "notifications/prompts/list_changed" });
1607
+ }
1608
+ };
1609
+ /**
1610
+ * The capability set a server advertises on `server/discover`. Pure — never
1611
+ * mutates the input; the legacy `initialize` advertisement is untouched.
1612
+ *
1613
+ * The serving entries serve `subscriptions/listen` themselves, so the
1614
+ * `listChanged` and `resources.subscribe` capability bits are advertised
1615
+ * as-is: a modern-era client uses them to decide which notification types to
1616
+ * request on its listen filter.
1617
+ */
1618
+ function discoverAdvertisedCapabilities(capabilities) {
1619
+ return { ...capabilities };
1620
+ }
1621
+
1622
+ //#endregion
1623
+ //#region src/server/mcp.ts
1624
+ function toolInputElementCount(value, max) {
1625
+ let count = 0;
1626
+ const stack = [value];
1627
+ while (stack.length > 0) {
1628
+ const node = stack.pop();
1629
+ if (node === null || typeof node !== "object") continue;
1630
+ if (Array.isArray(node)) for (const child of node) {
1631
+ if (++count > max) return count;
1632
+ if (child !== null && typeof child === "object") stack.push(child);
1633
+ }
1634
+ else for (const key in node) {
1635
+ if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
1636
+ if (++count > max) return count;
1637
+ const child = node[key];
1638
+ if (child !== null && typeof child === "object") stack.push(child);
1639
+ }
1640
+ }
1641
+ return count;
1642
+ }
1643
+ function resolveMaxToolInputElements(value) {
1644
+ if (value === void 0 || value === Infinity) return void 0;
1645
+ if (typeof value !== "number" || Number.isNaN(value) || value < 1) throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
1646
+ return value;
1647
+ }
1648
+ /**
1649
+ * High-level MCP server that provides a simpler API for working with resources, tools, and prompts.
1650
+ * For advanced usage (like sending notifications or setting custom request handlers), use the underlying
1651
+ * {@linkcode Server} instance available via the {@linkcode McpServer.server | server} property.
1652
+ *
1653
+ * @example
1654
+ * ```ts source="./mcp.examples.ts#McpServer_basicUsage"
1655
+ * const server = new McpServer({
1656
+ * name: 'my-server',
1657
+ * version: '1.0.0'
1658
+ * });
1659
+ * ```
1660
+ */
1661
+ var McpServer = class {
1662
+ /**
1663
+ * The underlying {@linkcode Server} instance, useful for advanced operations like sending notifications.
1664
+ */
1665
+ server;
1666
+ _maxToolInputElements;
1667
+ _registeredResources = {};
1668
+ _registeredResourceTemplates = {};
1669
+ _registeredTools = {};
1670
+ _registeredPrompts = {};
1671
+ /** Per-tool JSON-converted `inputSchema`, filled on first use by `toolInputSchemaJson()`. */
1672
+ _toolInputSchemaJson = {};
1673
+ /**
1674
+ * The JSON-serialized `inputSchema` of a registered tool, or `undefined`
1675
+ * when no such tool is registered. Used by the HTTP entry's pre-dispatch
1676
+ * SEP-2243 `Mcp-Param-*` validation step (which needs the same JSON Schema
1677
+ * `tools/list` would emit, before dispatch reaches the handler).
1678
+ *
1679
+ * @internal
1680
+ */
1681
+ toolInputSchemaJson(name) {
1682
+ const tool = this._registeredTools[name];
1683
+ if (tool === void 0 || !tool.enabled) return void 0;
1684
+ if (Object.hasOwn(this._toolInputSchemaJson, name)) return this._toolInputSchemaJson[name];
1685
+ if (tool.inputSchema === void 0) return EMPTY_OBJECT_JSON_SCHEMA;
1686
+ try {
1687
+ const json = require_src.standardSchemaToJsonSchema(tool.inputSchema, "input");
1688
+ this._toolInputSchemaJson[name] = json;
1689
+ return json;
1690
+ } catch {
1691
+ return;
1692
+ }
1693
+ }
1694
+ constructor(serverInfo, options) {
1695
+ this.server = new Server(serverInfo, options);
1696
+ this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
1697
+ if (options?.capabilities?.tools) this.setToolRequestHandlers();
1698
+ if (options?.capabilities?.resources) this.setResourceRequestHandlers();
1699
+ if (options?.capabilities?.prompts) this.setPromptRequestHandlers();
1700
+ }
1701
+ /**
1702
+ * Attaches to the given transport, starts it, and starts listening for messages.
1703
+ *
1704
+ * The `server` object assumes ownership of the {@linkcode Transport}, replacing any callbacks that have already been set, and expects that it is the only user of the {@linkcode Transport} instance going forward.
1705
+ *
1706
+ * @example
1707
+ * ```ts source="./mcp.examples.ts#McpServer_connect_stdio"
1708
+ * const server = new McpServer({ name: 'my-server', version: '1.0.0' });
1709
+ * const transport = new StdioServerTransport();
1710
+ * await server.connect(transport);
1711
+ * ```
1712
+ */
1713
+ async connect(transport) {
1714
+ if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
1715
+ return await this.server.connect(transport);
1716
+ }
1717
+ /**
1718
+ * Closes the connection.
1719
+ */
1720
+ async close() {
1721
+ await this.server.close();
1722
+ }
1723
+ /** @internal */
1724
+ resolveScopeChallenge = (context) => {
1725
+ switch (context.request.method) {
1726
+ case "tools/call": {
1727
+ const toolName = context.request.params?.name;
1728
+ if (typeof toolName !== "string") return;
1729
+ const tool = this._registeredTools[toolName];
1730
+ if (tool === void 0 || !tool.enabled) return;
1731
+ return tool.scopeChallenge?.(context);
1732
+ }
1733
+ case "resources/read": {
1734
+ const resourceUri = context.request.params?.uri;
1735
+ if (typeof resourceUri !== "string") return;
1736
+ let uri;
1737
+ try {
1738
+ uri = new URL(resourceUri);
1739
+ } catch {
1740
+ return;
1741
+ }
1742
+ const resource = this._registeredResources[uri.toString()];
1743
+ if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
1744
+ for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
1745
+ return;
1746
+ }
1747
+ case "prompts/get": {
1748
+ const promptName = context.request.params?.name;
1749
+ if (typeof promptName !== "string") return;
1750
+ const prompt = this._registeredPrompts[promptName];
1751
+ if (prompt === void 0 || !prompt.enabled) return;
1752
+ return prompt.scopeChallenge?.(context);
1753
+ }
1754
+ default: return;
1755
+ }
1756
+ };
1757
+ _toolHandlersInitialized = false;
1758
+ setToolRequestHandlers() {
1759
+ if (this._toolHandlersInitialized) return;
1760
+ this.server.assertCanSetRequestHandler("tools/list");
1761
+ this.server.assertCanSetRequestHandler("tools/call");
1762
+ this.server.registerCapabilities({ tools: { listChanged: this.server.getCapabilities().tools?.listChanged ?? true } });
1763
+ this.server.setRequestHandler("tools/list", () => ({ tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
1764
+ const toolDefinition = {
1765
+ name,
1766
+ title: tool.title,
1767
+ description: tool.description,
1768
+ inputSchema: tool.inputSchema ? convertListedInputSchema(name, tool.inputSchema) : EMPTY_OBJECT_JSON_SCHEMA,
1769
+ annotations: tool.annotations,
1770
+ icons: tool.icons,
1771
+ execution: tool.execution,
1772
+ _meta: tool._meta
1773
+ };
1774
+ if (tool.outputSchema) toolDefinition.outputSchema = require_src.standardSchemaToJsonSchema(tool.outputSchema, "output");
1775
+ return toolDefinition;
1776
+ }) }));
1777
+ this.server.setRequestHandler("tools/call", async (request, ctx) => {
1778
+ const tool = this._registeredTools[request.params.name];
1779
+ if (!tool) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
1780
+ if (!tool.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
1781
+ try {
1782
+ const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
1783
+ const result = await this.executeToolHandler(tool, args, ctx);
1784
+ await this.validateToolOutput(tool, result, request.params.name);
1785
+ if (require_src.isInputRequiredResult(result)) return result;
1786
+ return this.server.projectCallToolResult(result, tool.outputSchemaJson);
1787
+ } catch (error) {
1788
+ if (error instanceof require_src.ProtocolError && error.code === require_src.ProtocolErrorCode.UrlElicitationRequired) throw error;
1789
+ return this.createToolError(error instanceof Error ? error.message : String(error));
1790
+ }
1791
+ });
1792
+ this._toolHandlersInitialized = true;
1793
+ }
1794
+ /**
1795
+ * Creates a tool error result.
1796
+ *
1797
+ * @param errorMessage - The error message.
1798
+ * @returns The tool error result.
1799
+ */
1800
+ createToolError(errorMessage) {
1801
+ return {
1802
+ content: [{
1803
+ type: "text",
1804
+ text: errorMessage
1805
+ }],
1806
+ isError: true
1807
+ };
1808
+ }
1809
+ /**
1810
+ * Validates tool input arguments against the tool's input schema.
1811
+ */
1812
+ async validateToolInput(tool, args, toolName) {
1813
+ if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
1814
+ if (!tool.inputSchema) return;
1815
+ const parseResult = await require_src.validateStandardSchema(tool.inputSchema, args ?? {});
1816
+ if (!parseResult.success) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${parseResult.error}`);
1817
+ return parseResult.data;
1818
+ }
1819
+ /**
1820
+ * Validates tool output against the tool's output schema.
1821
+ */
1822
+ async validateToolOutput(tool, result, toolName) {
1823
+ if (!tool.outputSchema) return;
1824
+ if (require_src.isInputRequiredResult(result)) return;
1825
+ if (result.isError) return;
1826
+ if (result.structuredContent === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
1827
+ const parseResult = await require_src.validateStandardSchema(tool.outputSchema, result.structuredContent);
1828
+ if (!parseResult.success) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${parseResult.error}`);
1829
+ }
1830
+ /**
1831
+ * Executes a tool handler.
1832
+ */
1833
+ async executeToolHandler(tool, args, ctx) {
1834
+ return tool.executor(args, ctx);
1835
+ }
1836
+ _completionHandlerInitialized = false;
1837
+ setCompletionRequestHandler() {
1838
+ if (this._completionHandlerInitialized) return;
1839
+ this.server.assertCanSetRequestHandler("completion/complete");
1840
+ this.server.registerCapabilities({ completions: {} });
1841
+ this.server.setRequestHandler("completion/complete", async (request) => {
1842
+ switch (request.params.ref.type) {
1843
+ case "ref/prompt":
1844
+ require_src.assertCompleteRequestPrompt(request);
1845
+ return this.handlePromptCompletion(request, request.params.ref);
1846
+ case "ref/resource":
1847
+ require_src.assertCompleteRequestResourceTemplate(request);
1848
+ return this.handleResourceCompletion(request, request.params.ref);
1849
+ default: throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Invalid completion reference: ${request.params.ref}`);
1850
+ }
1851
+ });
1852
+ this._completionHandlerInitialized = true;
1853
+ }
1854
+ async handlePromptCompletion(request, ref) {
1855
+ const prompt = this._registeredPrompts[ref.name];
1856
+ if (!prompt) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
1857
+ if (!prompt.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
1858
+ if (!prompt.argsSchema) return EMPTY_COMPLETION_RESULT;
1859
+ const field = unwrapOptionalSchema(getSchemaShape(prompt.argsSchema)?.[request.params.argument.name]);
1860
+ if (!isCompletable(field)) return EMPTY_COMPLETION_RESULT;
1861
+ const completer = getCompleter(field);
1862
+ if (!completer) return EMPTY_COMPLETION_RESULT;
1863
+ return createCompletionResult(await completer(request.params.argument.value, request.params.context));
1864
+ }
1865
+ async handleResourceCompletion(request, ref) {
1866
+ const template = Object.values(this._registeredResourceTemplates).find((t) => t.resourceTemplate.uriTemplate.toString() === ref.uri);
1867
+ if (!template) {
1868
+ if (this._registeredResources[ref.uri]) return EMPTY_COMPLETION_RESULT;
1869
+ throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource template ${request.params.ref.uri} not found`);
1870
+ }
1871
+ const completer = template.resourceTemplate.completeCallback(request.params.argument.name);
1872
+ if (!completer) return EMPTY_COMPLETION_RESULT;
1873
+ return createCompletionResult(await completer(request.params.argument.value, request.params.context));
1874
+ }
1875
+ _resourceHandlersInitialized = false;
1876
+ setResourceRequestHandlers() {
1877
+ if (this._resourceHandlersInitialized) return;
1878
+ this.server.assertCanSetRequestHandler("resources/list");
1879
+ this.server.assertCanSetRequestHandler("resources/templates/list");
1880
+ this.server.assertCanSetRequestHandler("resources/read");
1881
+ this.server.registerCapabilities({ resources: { listChanged: this.server.getCapabilities().resources?.listChanged ?? true } });
1882
+ this.server.setRequestHandler("resources/list", async (_request, ctx) => {
1883
+ const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
1884
+ uri,
1885
+ name: resource.name,
1886
+ ...resource.metadata
1887
+ }));
1888
+ const templateResources = [];
1889
+ for (const template of Object.values(this._registeredResourceTemplates)) {
1890
+ if (!template.resourceTemplate.listCallback) continue;
1891
+ const result = await template.resourceTemplate.listCallback(ctx);
1892
+ for (const resource of result.resources) templateResources.push({
1893
+ ...template.metadata,
1894
+ ...resource
1895
+ });
1896
+ }
1897
+ return { resources: [...resources, ...templateResources] };
1898
+ });
1899
+ this.server.setRequestHandler("resources/templates/list", async () => {
1900
+ return { resourceTemplates: Object.entries(this._registeredResourceTemplates).map(([name, template]) => ({
1901
+ name,
1902
+ uriTemplate: template.resourceTemplate.uriTemplate.toString(),
1903
+ ...template.metadata
1904
+ })) };
1905
+ });
1906
+ this.server.setRequestHandler("resources/read", async (request, ctx) => {
1907
+ let uri;
1908
+ try {
1909
+ uri = new URL(request.params.uri);
1910
+ } catch {
1911
+ throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource URI ${request.params.uri} is invalid`, {
1912
+ uri: request.params.uri,
1913
+ reason: "invalid_uri"
1914
+ });
1915
+ }
1916
+ const resource = this._registeredResources[uri.toString()];
1917
+ if (resource) {
1918
+ if (!resource.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource ${uri} disabled`);
1919
+ return require_src.attachCacheHintFallback(await resource.readCallback(uri, ctx), resource.cacheHint);
1920
+ }
1921
+ for (const template of Object.values(this._registeredResourceTemplates)) {
1922
+ const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
1923
+ if (variables) {
1924
+ if (!template.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
1925
+ return require_src.attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
1926
+ }
1927
+ }
1928
+ throw new require_src.ResourceNotFoundError(request.params.uri);
1929
+ });
1930
+ this._resourceHandlersInitialized = true;
1931
+ }
1932
+ _promptHandlersInitialized = false;
1933
+ setPromptRequestHandlers() {
1934
+ if (this._promptHandlersInitialized) return;
1935
+ this.server.assertCanSetRequestHandler("prompts/list");
1936
+ this.server.assertCanSetRequestHandler("prompts/get");
1937
+ this.server.registerCapabilities({ prompts: { listChanged: this.server.getCapabilities().prompts?.listChanged ?? true } });
1938
+ this.server.setRequestHandler("prompts/list", () => ({ prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
1939
+ return {
1940
+ name,
1941
+ title: prompt.title,
1942
+ description: prompt.description,
1943
+ arguments: prompt.argsSchema ? require_src.promptArgumentsFromStandardSchema(prompt.argsSchema) : void 0,
1944
+ icons: prompt.icons,
1945
+ _meta: prompt._meta
1946
+ };
1947
+ }) }));
1948
+ this.server.setRequestHandler("prompts/get", async (request, ctx) => {
1949
+ const prompt = this._registeredPrompts[request.params.name];
1950
+ if (!prompt) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
1951
+ if (!prompt.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
1952
+ return prompt.handler(request.params.arguments, ctx);
1953
+ });
1954
+ this._promptHandlersInitialized = true;
1955
+ }
1956
+ registerResource(name, uriOrTemplate, config, readCallback) {
1957
+ const { cacheHint, scopeChallenge, ...resourceMetadata } = config;
1958
+ const metadata = resourceMetadata;
1959
+ if (cacheHint !== void 0) require_src.assertValidCacheHint(cacheHint, `resource ${name}`);
1960
+ if (typeof uriOrTemplate === "string") {
1961
+ if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
1962
+ const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
1963
+ if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
1964
+ this.setResourceRequestHandlers();
1965
+ this.sendResourceListChanged();
1966
+ return registeredResource;
1967
+ } else {
1968
+ if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
1969
+ const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
1970
+ if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
1971
+ this.setResourceRequestHandlers();
1972
+ this.sendResourceListChanged();
1973
+ return registeredResourceTemplate;
1974
+ }
1975
+ }
1976
+ _createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
1977
+ const registeredResource = {
1978
+ name,
1979
+ title,
1980
+ metadata,
1981
+ readCallback,
1982
+ scopeChallenge,
1983
+ enabled: true,
1984
+ disable: () => registeredResource.update({ enabled: false }),
1985
+ enable: () => registeredResource.update({ enabled: true }),
1986
+ remove: () => registeredResource.update({ uri: null }),
1987
+ update: (updates) => {
1988
+ if (updates.uri !== void 0 && updates.uri !== uri) {
1989
+ delete this._registeredResources[uri];
1990
+ if (updates.uri) this._registeredResources[updates.uri] = registeredResource;
1991
+ }
1992
+ if (updates.name !== void 0) registeredResource.name = updates.name;
1993
+ if (updates.title !== void 0) registeredResource.title = updates.title;
1994
+ if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
1995
+ if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
1996
+ if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
1997
+ if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
1998
+ this.sendResourceListChanged();
1999
+ }
2000
+ };
2001
+ this._registeredResources[uri] = registeredResource;
2002
+ return registeredResource;
2003
+ }
2004
+ _createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
2005
+ const registeredResourceTemplate = {
2006
+ resourceTemplate: template,
2007
+ title,
2008
+ metadata,
2009
+ readCallback,
2010
+ scopeChallenge,
2011
+ enabled: true,
2012
+ disable: () => registeredResourceTemplate.update({ enabled: false }),
2013
+ enable: () => registeredResourceTemplate.update({ enabled: true }),
2014
+ remove: () => registeredResourceTemplate.update({ name: null }),
2015
+ update: (updates) => {
2016
+ if (updates.name !== void 0 && updates.name !== name) {
2017
+ delete this._registeredResourceTemplates[name];
2018
+ if (updates.name) this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
2019
+ }
2020
+ if (updates.title !== void 0) registeredResourceTemplate.title = updates.title;
2021
+ if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
2022
+ if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
2023
+ if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
2024
+ if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
2025
+ if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
2026
+ this.sendResourceListChanged();
2027
+ }
2028
+ };
2029
+ this._registeredResourceTemplates[name] = registeredResourceTemplate;
2030
+ const variableNames = template.uriTemplate.variableNames;
2031
+ if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
2032
+ return registeredResourceTemplate;
2033
+ }
2034
+ _createRegisteredPrompt(name, title, description, argsSchema, callback, icons, scopeChallenge, _meta) {
2035
+ let currentArgsSchema = argsSchema;
2036
+ let currentCallback = callback;
2037
+ const registeredPrompt = {
2038
+ title,
2039
+ description,
2040
+ argsSchema,
2041
+ icons,
2042
+ scopeChallenge,
2043
+ _meta,
2044
+ handler: createPromptHandler(name, argsSchema, callback),
2045
+ enabled: true,
2046
+ disable: () => registeredPrompt.update({ enabled: false }),
2047
+ enable: () => registeredPrompt.update({ enabled: true }),
2048
+ remove: () => registeredPrompt.update({ name: null }),
2049
+ update: (updates) => {
2050
+ if (updates.name !== void 0 && updates.name !== name) {
2051
+ delete this._registeredPrompts[name];
2052
+ if (updates.name) this._registeredPrompts[updates.name] = registeredPrompt;
2053
+ }
2054
+ if (updates.title !== void 0) registeredPrompt.title = updates.title;
2055
+ if (updates.description !== void 0) registeredPrompt.description = updates.description;
2056
+ if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
2057
+ if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
2058
+ if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
2059
+ let needsHandlerRegen = false;
2060
+ if (updates.argsSchema !== void 0) {
2061
+ registeredPrompt.argsSchema = updates.argsSchema;
2062
+ currentArgsSchema = updates.argsSchema;
2063
+ needsHandlerRegen = true;
2064
+ }
2065
+ if (updates.callback !== void 0) {
2066
+ currentCallback = updates.callback;
2067
+ needsHandlerRegen = true;
2068
+ }
2069
+ if (needsHandlerRegen) registeredPrompt.handler = createPromptHandler(name, currentArgsSchema, currentCallback);
2070
+ if (updates.enabled !== void 0) registeredPrompt.enabled = updates.enabled;
2071
+ this.sendPromptListChanged();
2072
+ }
2073
+ };
2074
+ this._registeredPrompts[name] = registeredPrompt;
2075
+ if (argsSchema) {
2076
+ const shape = getSchemaShape(argsSchema);
2077
+ if (shape) {
2078
+ if (Object.values(shape).some((field) => {
2079
+ return isCompletable(unwrapOptionalSchema(field));
2080
+ })) this.setCompletionRequestHandler();
2081
+ }
2082
+ }
2083
+ return registeredPrompt;
2084
+ }
2085
+ _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
2086
+ require_src.validateAndWarnToolName(name);
2087
+ let currentHandler = handler;
2088
+ let outputSchemaJson;
2089
+ const registeredTool = {
2090
+ title,
2091
+ description,
2092
+ inputSchema,
2093
+ outputSchema,
2094
+ get outputSchemaJson() {
2095
+ return outputSchemaJson ??= convertOutputSchemaJson(registeredTool.outputSchema);
2096
+ },
2097
+ set outputSchemaJson(value) {
2098
+ outputSchemaJson = value;
2099
+ },
2100
+ annotations,
2101
+ icons,
2102
+ execution,
2103
+ scopeChallenge,
2104
+ _meta,
2105
+ handler,
2106
+ executor: createToolExecutor(inputSchema, handler),
2107
+ enabled: true,
2108
+ disable: () => registeredTool.update({ enabled: false }),
2109
+ enable: () => registeredTool.update({ enabled: true }),
2110
+ remove: () => registeredTool.update({ name: null }),
2111
+ update: (updates) => {
2112
+ if (updates.name !== void 0 && updates.name !== name) {
2113
+ if (typeof updates.name === "string") require_src.validateAndWarnToolName(updates.name);
2114
+ delete this._registeredTools[name];
2115
+ delete this._toolInputSchemaJson[name];
2116
+ if (updates.name) {
2117
+ delete this._toolInputSchemaJson[updates.name];
2118
+ this._registeredTools[updates.name] = registeredTool;
2119
+ name = updates.name;
2120
+ }
2121
+ }
2122
+ if (updates.title !== void 0) registeredTool.title = updates.title;
2123
+ if (updates.description !== void 0) registeredTool.description = updates.description;
2124
+ let needsExecutorRegen = false;
2125
+ if (updates.paramsSchema !== void 0) {
2126
+ registeredTool.inputSchema = updates.paramsSchema;
2127
+ delete this._toolInputSchemaJson[name];
2128
+ needsExecutorRegen = true;
2129
+ }
2130
+ if (updates.callback !== void 0) {
2131
+ registeredTool.handler = updates.callback;
2132
+ currentHandler = updates.callback;
2133
+ needsExecutorRegen = true;
2134
+ }
2135
+ if (needsExecutorRegen) registeredTool.executor = createToolExecutor(registeredTool.inputSchema, currentHandler);
2136
+ if (updates.outputSchema !== void 0) {
2137
+ registeredTool.outputSchema = updates.outputSchema;
2138
+ registeredTool.outputSchemaJson = convertOutputSchemaJson(updates.outputSchema);
2139
+ }
2140
+ if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
2141
+ if (updates.icons !== void 0) registeredTool.icons = updates.icons;
2142
+ if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
2143
+ if (updates._meta !== void 0) registeredTool._meta = updates._meta;
2144
+ if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
2145
+ this.sendToolListChanged();
2146
+ }
2147
+ };
2148
+ this._registeredTools[name] = registeredTool;
2149
+ this.setToolRequestHandlers();
2150
+ this.sendToolListChanged();
2151
+ return registeredTool;
2152
+ }
2153
+ registerTool(name, config, cb) {
2154
+ if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
2155
+ const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config;
2156
+ return this._createRegisteredTool(name, title, description, require_src.normalizeRawShapeSchema(inputSchema), require_src.normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
2157
+ }
2158
+ registerPrompt(name, config, cb) {
2159
+ if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
2160
+ const { title, description, argsSchema, icons, scopeChallenge, _meta } = config;
2161
+ const registeredPrompt = this._createRegisteredPrompt(name, title, description, require_src.normalizeRawShapeSchema(argsSchema), cb, icons, scopeChallenge, _meta);
2162
+ this.setPromptRequestHandlers();
2163
+ this.sendPromptListChanged();
2164
+ return registeredPrompt;
2165
+ }
2166
+ /**
2167
+ * Checks if the server is connected to a transport.
2168
+ * @returns `true` if the server is connected
2169
+ */
2170
+ isConnected() {
2171
+ return this.server.transport !== void 0;
2172
+ }
2173
+ /**
2174
+ * Sends a logging message to the client, if connected.
2175
+ * Note: You only need to send the parameters object, not the entire JSON-RPC message.
2176
+ * @see {@linkcode LoggingMessageNotification}
2177
+ * @param params
2178
+ * @param sessionId Optional for stateless transports and backward compatibility.
2179
+ *
2180
+ * @example
2181
+ * ```ts source="./mcp.examples.ts#McpServer_sendLoggingMessage_basic"
2182
+ * await server.sendLoggingMessage({
2183
+ * level: 'info',
2184
+ * data: 'Processing complete'
2185
+ * });
2186
+ * ```
2187
+ *
2188
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2189
+ * Remains functional during the deprecation window (at least twelve months).
2190
+ * Migrate to stderr logging (STDIO servers) or OpenTelemetry.
2191
+ */
2192
+ async sendLoggingMessage(params, sessionId) {
2193
+ return this.server.sendLoggingMessage(params, sessionId);
2194
+ }
2195
+ /**
2196
+ * Sends a resource list changed event to the client, if connected.
2197
+ */
2198
+ sendResourceListChanged() {
2199
+ if (this.isConnected()) this.server.sendResourceListChanged();
2200
+ }
2201
+ /**
2202
+ * Sends a tool list changed event to the client, if connected.
2203
+ */
2204
+ sendToolListChanged() {
2205
+ if (this.isConnected()) this.server.sendToolListChanged();
2206
+ }
2207
+ /**
2208
+ * Sends a prompt list changed event to the client, if connected.
2209
+ */
2210
+ sendPromptListChanged() {
2211
+ if (this.isConnected()) this.server.sendPromptListChanged();
2212
+ }
2213
+ };
2214
+ /**
2215
+ * A resource template combines a URI pattern with optional functionality to enumerate
2216
+ * all resources matching that pattern.
2217
+ */
2218
+ var ResourceTemplate = class {
2219
+ _uriTemplate;
2220
+ constructor(uriTemplate, _callbacks) {
2221
+ this._callbacks = _callbacks;
2222
+ this._uriTemplate = typeof uriTemplate === "string" ? new require_src.UriTemplate(uriTemplate) : uriTemplate;
2223
+ }
2224
+ /**
2225
+ * Gets the URI template pattern.
2226
+ */
2227
+ get uriTemplate() {
2228
+ return this._uriTemplate;
2229
+ }
2230
+ /**
2231
+ * Gets the list callback, if one was provided.
2232
+ */
2233
+ get listCallback() {
2234
+ return this._callbacks.list;
2235
+ }
2236
+ /**
2237
+ * Gets the callback for completing a specific URI template variable, if one was provided.
2238
+ */
2239
+ completeCallback(variable) {
2240
+ return this._callbacks.complete?.[variable];
2241
+ }
2242
+ };
2243
+ /**
2244
+ * Creates an executor that invokes the handler with the appropriate arguments.
2245
+ * When `inputSchema` is defined, the handler is called with `(args, ctx)`.
2246
+ * When `inputSchema` is undefined, the handler is called with just `(ctx)`.
2247
+ */
2248
+ function createToolExecutor(inputSchema, handler) {
2249
+ if (inputSchema) {
2250
+ const callback$1 = handler;
2251
+ return async (args, ctx) => callback$1(args, ctx);
2252
+ }
2253
+ const callback = handler;
2254
+ return async (_args, ctx) => callback(ctx);
2255
+ }
2256
+ const EMPTY_OBJECT_JSON_SCHEMA = {
2257
+ type: "object",
2258
+ properties: {}
2259
+ };
2260
+ /** Converts a tool's `inputSchema` for `tools/list` and warns on an invalid SEP-2243 `x-mcp-header` declaration. */
2261
+ function convertListedInputSchema(name, inputSchema) {
2262
+ const json = require_src.standardSchemaToJsonSchema(inputSchema, "input");
2263
+ const scan = require_src.scanXMcpHeaderDeclarations(json);
2264
+ if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
2265
+ return json;
2266
+ }
2267
+ /**
2268
+ * Convert a registered `outputSchema` to JSON Schema, memoised on {@link RegisteredTool.outputSchemaJson}
2269
+ * so `tools/call` passes the SAME advertised schema to the wire codec's `projectCallToolResult` that
2270
+ * `tools/list` emits (and that the 2025 codec's `encodeResult('tools/list', …)` may wrap). A conversion
2271
+ * failure yields `undefined` so the failure surfaces where it always has (`tools/list`).
2272
+ */
2273
+ function convertOutputSchemaJson(outputSchema) {
2274
+ if (outputSchema === void 0) return void 0;
2275
+ try {
2276
+ return require_src.standardSchemaToJsonSchema(outputSchema, "output");
2277
+ } catch {
2278
+ return;
2279
+ }
2280
+ }
2281
+ /**
2282
+ * Creates a type-safe prompt handler that captures the schema and callback in a closure.
2283
+ * This eliminates the need for type assertions at the call site.
2284
+ */
2285
+ function createPromptHandler(name, argsSchema, callback) {
2286
+ if (argsSchema) {
2287
+ const typedCallback = callback;
2288
+ return async (args, ctx) => {
2289
+ const parseResult = await require_src.validateStandardSchema(argsSchema, args ?? {});
2290
+ if (!parseResult.success) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Invalid arguments for prompt ${name}: ${parseResult.error}`);
2291
+ return typedCallback(parseResult.data, ctx);
2292
+ };
2293
+ } else {
2294
+ const typedCallback = callback;
2295
+ return async (_args, ctx) => {
2296
+ return typedCallback(ctx);
2297
+ };
2298
+ }
2299
+ }
2300
+ function createCompletionResult(suggestions) {
2301
+ return { completion: {
2302
+ values: suggestions.map(String).slice(0, 100),
2303
+ total: suggestions.length,
2304
+ hasMore: suggestions.length > 100
2305
+ } };
2306
+ }
2307
+ const EMPTY_COMPLETION_RESULT = { completion: {
2308
+ values: [],
2309
+ hasMore: false
2310
+ } };
2311
+ /** @internal Gets the shape of a Zod object schema */
2312
+ function getSchemaShape(schema) {
2313
+ const candidate = schema;
2314
+ if (candidate.shape && typeof candidate.shape === "object") return candidate.shape;
2315
+ }
2316
+ /** @internal Checks if a Zod schema is optional */
2317
+ function isOptionalSchema(schema) {
2318
+ return schema?.type === "optional";
2319
+ }
2320
+ /** @internal Unwraps an optional Zod schema */
2321
+ function unwrapOptionalSchema(schema) {
2322
+ if (!isOptionalSchema(schema)) return schema;
2323
+ return schema.def?.innerType ?? schema;
2324
+ }
2325
+
2326
+ //#endregion
2327
+ Object.defineProperty(exports, 'DEFAULT_MAX_SUBSCRIPTIONS', {
2328
+ enumerable: true,
2329
+ get: function () {
2330
+ return DEFAULT_MAX_SUBSCRIPTIONS;
2331
+ }
2332
+ });
2333
+ Object.defineProperty(exports, 'DEFAULT_SSE_KEEP_ALIVE_MS', {
2334
+ enumerable: true,
2335
+ get: function () {
2336
+ return DEFAULT_SSE_KEEP_ALIVE_MS;
2337
+ }
2338
+ });
2339
+ Object.defineProperty(exports, 'InMemoryServerEventBus', {
2340
+ enumerable: true,
2341
+ get: function () {
2342
+ return InMemoryServerEventBus;
2343
+ }
2344
+ });
2345
+ Object.defineProperty(exports, 'McpServer', {
2346
+ enumerable: true,
2347
+ get: function () {
2348
+ return McpServer;
2349
+ }
2350
+ });
2351
+ Object.defineProperty(exports, 'ResourceTemplate', {
2352
+ enumerable: true,
2353
+ get: function () {
2354
+ return ResourceTemplate;
2355
+ }
2356
+ });
2357
+ Object.defineProperty(exports, 'Server', {
2358
+ enumerable: true,
2359
+ get: function () {
2360
+ return Server;
2361
+ }
2362
+ });
2363
+ Object.defineProperty(exports, 'StdioListenRouter', {
2364
+ enumerable: true,
2365
+ get: function () {
2366
+ return StdioListenRouter;
2367
+ }
2368
+ });
2369
+ Object.defineProperty(exports, 'armSseKeepAlive', {
2370
+ enumerable: true,
2371
+ get: function () {
2372
+ return armSseKeepAlive;
2373
+ }
2374
+ });
2375
+ Object.defineProperty(exports, 'bearerAuthChallengeResponse', {
2376
+ enumerable: true,
2377
+ get: function () {
2378
+ return bearerAuthChallengeResponse;
2379
+ }
2380
+ });
2381
+ Object.defineProperty(exports, 'buildOAuthProtectedResourceMetadata', {
2382
+ enumerable: true,
2383
+ get: function () {
2384
+ return buildOAuthProtectedResourceMetadata;
2385
+ }
2386
+ });
2387
+ Object.defineProperty(exports, 'completable', {
2388
+ enumerable: true,
2389
+ get: function () {
2390
+ return completable;
2391
+ }
2392
+ });
2393
+ Object.defineProperty(exports, 'createListenRouter', {
2394
+ enumerable: true,
2395
+ get: function () {
2396
+ return createListenRouter;
2397
+ }
2398
+ });
2399
+ Object.defineProperty(exports, 'createScopeChallengeResponse', {
2400
+ enumerable: true,
2401
+ get: function () {
2402
+ return createScopeChallengeResponse;
2403
+ }
2404
+ });
2405
+ Object.defineProperty(exports, 'createServerNotifier', {
2406
+ enumerable: true,
2407
+ get: function () {
2408
+ return createServerNotifier;
2409
+ }
2410
+ });
2411
+ Object.defineProperty(exports, 'findScopeChallenge', {
2412
+ enumerable: true,
2413
+ get: function () {
2414
+ return findScopeChallenge;
2415
+ }
2416
+ });
2417
+ Object.defineProperty(exports, 'getOAuthProtectedResourceMetadataUrl', {
2418
+ enumerable: true,
2419
+ get: function () {
2420
+ return getOAuthProtectedResourceMetadataUrl;
2421
+ }
2422
+ });
2423
+ Object.defineProperty(exports, 'installModernOnlyHandlers', {
2424
+ enumerable: true,
2425
+ get: function () {
2426
+ return installModernOnlyHandlers;
2427
+ }
2428
+ });
2429
+ Object.defineProperty(exports, 'isCompletable', {
2430
+ enumerable: true,
2431
+ get: function () {
2432
+ return isCompletable;
2433
+ }
2434
+ });
2435
+ Object.defineProperty(exports, 'oauthMetadataResponse', {
2436
+ enumerable: true,
2437
+ get: function () {
2438
+ return oauthMetadataResponse;
2439
+ }
2440
+ });
2441
+ Object.defineProperty(exports, 'requireBearerAuth', {
2442
+ enumerable: true,
2443
+ get: function () {
2444
+ return requireBearerAuth;
2445
+ }
2446
+ });
2447
+ Object.defineProperty(exports, 'requireScopes', {
2448
+ enumerable: true,
2449
+ get: function () {
2450
+ return requireScopes;
2451
+ }
2452
+ });
2453
+ Object.defineProperty(exports, 'scopeChallengeResourceMetadataUrl', {
2454
+ enumerable: true,
2455
+ get: function () {
2456
+ return scopeChallengeResourceMetadataUrl;
2457
+ }
2458
+ });
2459
+ Object.defineProperty(exports, 'seedClientIdentityFromEnvelope', {
2460
+ enumerable: true,
2461
+ get: function () {
2462
+ return seedClientIdentityFromEnvelope;
2463
+ }
2464
+ });
2465
+ Object.defineProperty(exports, 'serverIdentityOf', {
2466
+ enumerable: true,
2467
+ get: function () {
2468
+ return serverIdentityOf;
2469
+ }
2470
+ });
2471
+ Object.defineProperty(exports, 'verifyBearerToken', {
2472
+ enumerable: true,
2473
+ get: function () {
2474
+ return verifyBearerToken;
2475
+ }
2476
+ });
2477
+ //# sourceMappingURL=mcp-BumlNux0.cjs.map