@cyanheads/mcp-ts-core 0.11.5 → 0.12.1

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 (389) hide show
  1. package/AGENTS.md +27 -23
  2. package/CLAUDE.md +27 -23
  3. package/README.md +10 -10
  4. package/biome.json +1 -1
  5. package/changelog/0.12.x/0.12.0.md +96 -0
  6. package/changelog/0.12.x/0.12.1.md +26 -0
  7. package/dist/cli/init.js +1 -1
  8. package/dist/cli/init.js.map +1 -1
  9. package/dist/config/index.d.ts +9 -18
  10. package/dist/config/index.d.ts.map +1 -1
  11. package/dist/config/index.js +21 -28
  12. package/dist/config/index.js.map +1 -1
  13. package/dist/core/app.d.ts +27 -7
  14. package/dist/core/app.d.ts.map +1 -1
  15. package/dist/core/app.js +28 -28
  16. package/dist/core/app.js.map +1 -1
  17. package/dist/core/context.d.ts +90 -57
  18. package/dist/core/context.d.ts.map +1 -1
  19. package/dist/core/context.js +32 -33
  20. package/dist/core/context.js.map +1 -1
  21. package/dist/core/gcPressure.d.ts.map +1 -1
  22. package/dist/core/gcPressure.js +3 -4
  23. package/dist/core/gcPressure.js.map +1 -1
  24. package/dist/core/index.d.ts +6 -7
  25. package/dist/core/index.d.ts.map +1 -1
  26. package/dist/core/index.js +10 -2
  27. package/dist/core/index.js.map +1 -1
  28. package/dist/core/serverManifest.d.ts +6 -4
  29. package/dist/core/serverManifest.d.ts.map +1 -1
  30. package/dist/core/serverManifest.js +37 -14
  31. package/dist/core/serverManifest.js.map +1 -1
  32. package/dist/core/worker.d.ts.map +1 -1
  33. package/dist/core/worker.js +34 -37
  34. package/dist/core/worker.js.map +1 -1
  35. package/dist/linter/rules/enrichment-rules.d.ts.map +1 -1
  36. package/dist/linter/rules/enrichment-rules.js +5 -2
  37. package/dist/linter/rules/enrichment-rules.js.map +1 -1
  38. package/dist/linter/rules/portability-rules.d.ts +4 -2
  39. package/dist/linter/rules/portability-rules.d.ts.map +1 -1
  40. package/dist/linter/rules/portability-rules.js +33 -4
  41. package/dist/linter/rules/portability-rules.js.map +1 -1
  42. package/dist/linter/rules/schema-rules.d.ts +10 -3
  43. package/dist/linter/rules/schema-rules.d.ts.map +1 -1
  44. package/dist/linter/rules/schema-rules.js +52 -25
  45. package/dist/linter/rules/schema-rules.js.map +1 -1
  46. package/dist/linter/rules/tool-rules.d.ts.map +1 -1
  47. package/dist/linter/rules/tool-rules.js +5 -2
  48. package/dist/linter/rules/tool-rules.js.map +1 -1
  49. package/dist/linter/types.d.ts +2 -1
  50. package/dist/linter/types.d.ts.map +1 -1
  51. package/dist/logs/combined.log +10 -22
  52. package/dist/logs/error.log +6 -18
  53. package/dist/mcp-server/inputRequired.d.ts +52 -0
  54. package/dist/mcp-server/inputRequired.d.ts.map +1 -0
  55. package/dist/mcp-server/inputRequired.js +76 -0
  56. package/dist/mcp-server/inputRequired.js.map +1 -0
  57. package/dist/mcp-server/notifications.d.ts +103 -34
  58. package/dist/mcp-server/notifications.d.ts.map +1 -1
  59. package/dist/mcp-server/notifications.js +104 -29
  60. package/dist/mcp-server/notifications.js.map +1 -1
  61. package/dist/mcp-server/prompts/prompt-registration.d.ts +2 -2
  62. package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
  63. package/dist/mcp-server/prompts/prompt-registration.js +15 -5
  64. package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
  65. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +1 -1
  66. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -1
  67. package/dist/mcp-server/resources/resource-registration.d.ts +3 -3
  68. package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
  69. package/dist/mcp-server/resources/resource-registration.js +9 -15
  70. package/dist/mcp-server/resources/resource-registration.js.map +1 -1
  71. package/dist/mcp-server/resources/resourceSubscriptions.d.ts +45 -0
  72. package/dist/mcp-server/resources/resourceSubscriptions.d.ts.map +1 -0
  73. package/dist/mcp-server/resources/resourceSubscriptions.js +51 -0
  74. package/dist/mcp-server/resources/resourceSubscriptions.js.map +1 -0
  75. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +3 -5
  76. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -1
  77. package/dist/mcp-server/resources/utils/resourceDefinition.js +1 -1
  78. package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -1
  79. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +18 -17
  80. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
  81. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +39 -39
  82. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
  83. package/dist/mcp-server/server.d.ts +20 -21
  84. package/dist/mcp-server/server.d.ts.map +1 -1
  85. package/dist/mcp-server/server.js +42 -28
  86. package/dist/mcp-server/server.js.map +1 -1
  87. package/dist/mcp-server/tools/tool-registration.d.ts +11 -33
  88. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
  89. package/dist/mcp-server/tools/tool-registration.js +18 -243
  90. package/dist/mcp-server/tools/tool-registration.js.map +1 -1
  91. package/dist/mcp-server/tools/utils/schemaShape.d.ts +27 -0
  92. package/dist/mcp-server/tools/utils/schemaShape.d.ts.map +1 -0
  93. package/dist/mcp-server/tools/utils/schemaShape.js +43 -0
  94. package/dist/mcp-server/tools/utils/schemaShape.js.map +1 -0
  95. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +28 -8
  96. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
  97. package/dist/mcp-server/tools/utils/toolDefinition.js +63 -1
  98. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
  99. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +54 -20
  100. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
  101. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +156 -44
  102. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
  103. package/dist/mcp-server/transports/ITransport.d.ts +2 -2
  104. package/dist/mcp-server/transports/ITransport.d.ts.map +1 -1
  105. package/dist/mcp-server/transports/auth/authFactory.js +1 -1
  106. package/dist/mcp-server/transports/auth/authFactory.js.map +1 -1
  107. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +1 -1
  108. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -1
  109. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -1
  110. package/dist/mcp-server/transports/auth/lib/authUtils.js +5 -13
  111. package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -1
  112. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +5 -11
  113. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -1
  114. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -1
  115. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +9 -22
  116. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -1
  117. package/dist/mcp-server/transports/heartbeat.d.ts.map +1 -1
  118. package/dist/mcp-server/transports/heartbeat.js +4 -8
  119. package/dist/mcp-server/transports/heartbeat.js.map +1 -1
  120. package/dist/mcp-server/transports/http/eventStore.d.ts +57 -0
  121. package/dist/mcp-server/transports/http/eventStore.d.ts.map +1 -0
  122. package/dist/mcp-server/transports/http/eventStore.js +114 -0
  123. package/dist/mcp-server/transports/http/eventStore.js.map +1 -0
  124. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -1
  125. package/dist/mcp-server/transports/http/httpErrorHandler.js +6 -24
  126. package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
  127. package/dist/mcp-server/transports/http/httpServer.d.ts +4 -3
  128. package/dist/mcp-server/transports/http/httpServer.d.ts.map +1 -1
  129. package/dist/mcp-server/transports/http/httpServer.js +16 -33
  130. package/dist/mcp-server/transports/http/httpServer.js.map +1 -1
  131. package/dist/mcp-server/transports/http/httpTransport.d.ts +30 -8
  132. package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
  133. package/dist/mcp-server/transports/http/httpTransport.js +180 -374
  134. package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
  135. package/dist/mcp-server/transports/http/landing-page/assets/styles.d.ts.map +1 -1
  136. package/dist/mcp-server/transports/http/landing-page/assets/styles.js +0 -1
  137. package/dist/mcp-server/transports/http/landing-page/assets/styles.js.map +1 -1
  138. package/dist/mcp-server/transports/http/landing-page/handler.d.ts.map +1 -1
  139. package/dist/mcp-server/transports/http/landing-page/handler.js +4 -8
  140. package/dist/mcp-server/transports/http/landing-page/handler.js.map +1 -1
  141. package/dist/mcp-server/transports/http/landing-page/sections/tools.js +22 -4
  142. package/dist/mcp-server/transports/http/landing-page/sections/tools.js.map +1 -1
  143. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -1
  144. package/dist/mcp-server/transports/http/protectedResourceMetadata.js +2 -6
  145. package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -1
  146. package/dist/mcp-server/transports/http/robotsTxt.js +2 -2
  147. package/dist/mcp-server/transports/http/robotsTxt.js.map +1 -1
  148. package/dist/mcp-server/transports/http/serverCard.d.ts.map +1 -1
  149. package/dist/mcp-server/transports/http/serverCard.js +2 -6
  150. package/dist/mcp-server/transports/http/serverCard.js.map +1 -1
  151. package/dist/mcp-server/transports/http/sessionStore.d.ts +46 -66
  152. package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -1
  153. package/dist/mcp-server/transports/http/sessionStore.js +140 -238
  154. package/dist/mcp-server/transports/http/sessionStore.js.map +1 -1
  155. package/dist/mcp-server/transports/manager.d.ts +21 -4
  156. package/dist/mcp-server/transports/manager.d.ts.map +1 -1
  157. package/dist/mcp-server/transports/manager.js +40 -34
  158. package/dist/mcp-server/transports/manager.js.map +1 -1
  159. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +24 -31
  160. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -1
  161. package/dist/mcp-server/transports/stdio/stdioTransport.js +23 -38
  162. package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -1
  163. package/dist/mcp-server/types.d.ts +25 -0
  164. package/dist/mcp-server/types.d.ts.map +1 -0
  165. package/dist/mcp-server/types.js +10 -0
  166. package/dist/mcp-server/types.js.map +1 -0
  167. package/dist/services/canvas/core/CanvasInstance.d.ts +2 -2
  168. package/dist/services/canvas/core/CanvasInstance.d.ts.map +1 -1
  169. package/dist/services/canvas/core/CanvasInstance.js.map +1 -1
  170. package/dist/services/canvas/core/CanvasRegistry.d.ts +4 -4
  171. package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
  172. package/dist/services/canvas/core/CanvasRegistry.js +8 -18
  173. package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
  174. package/dist/services/canvas/core/DataCanvas.d.ts +5 -5
  175. package/dist/services/canvas/core/DataCanvas.d.ts.map +1 -1
  176. package/dist/services/canvas/core/DataCanvas.js +2 -3
  177. package/dist/services/canvas/core/DataCanvas.js.map +1 -1
  178. package/dist/services/canvas/core/IDataCanvasProvider.d.ts +11 -11
  179. package/dist/services/canvas/core/IDataCanvasProvider.d.ts.map +1 -1
  180. package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts +11 -11
  181. package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
  182. package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +4 -10
  183. package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
  184. package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -1
  185. package/dist/services/llm/providers/openrouter.provider.js +2 -5
  186. package/dist/services/llm/providers/openrouter.provider.js.map +1 -1
  187. package/dist/services/mirror/core/defineMirror.js +1 -1
  188. package/dist/services/mirror/core/defineMirror.js.map +1 -1
  189. package/dist/services/mirror/types.d.ts +5 -5
  190. package/dist/services/mirror/types.d.ts.map +1 -1
  191. package/dist/services/speech/providers/elevenlabs.provider.js +1 -1
  192. package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -1
  193. package/dist/services/speech/providers/whisper.provider.js +1 -1
  194. package/dist/services/speech/providers/whisper.provider.js.map +1 -1
  195. package/dist/storage/core/StorageService.d.ts +1 -1
  196. package/dist/storage/core/StorageService.d.ts.map +1 -1
  197. package/dist/storage/core/StorageService.js +12 -20
  198. package/dist/storage/core/StorageService.js.map +1 -1
  199. package/dist/storage/core/storageFactory.d.ts.map +1 -1
  200. package/dist/storage/core/storageFactory.js.map +1 -1
  201. package/dist/storage/core/storageValidation.d.ts +1 -1
  202. package/dist/storage/core/storageValidation.d.ts.map +1 -1
  203. package/dist/storage/core/storageValidation.js +2 -2
  204. package/dist/storage/core/storageValidation.js.map +1 -1
  205. package/dist/storage/providers/cloudflare/d1Provider.d.ts +1 -1
  206. package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -1
  207. package/dist/storage/providers/cloudflare/d1Provider.js +4 -12
  208. package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -1
  209. package/dist/storage/providers/cloudflare/kvProvider.d.ts +1 -1
  210. package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -1
  211. package/dist/storage/providers/cloudflare/kvProvider.js +3 -8
  212. package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -1
  213. package/dist/storage/providers/cloudflare/r2Provider.d.ts +1 -1
  214. package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -1
  215. package/dist/storage/providers/cloudflare/r2Provider.js +3 -8
  216. package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -1
  217. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +1 -1
  218. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
  219. package/dist/storage/providers/inMemory/inMemoryProvider.js +2 -4
  220. package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
  221. package/dist/testing/fuzz.d.ts +7 -4
  222. package/dist/testing/fuzz.d.ts.map +1 -1
  223. package/dist/testing/fuzz.js +13 -5
  224. package/dist/testing/fuzz.js.map +1 -1
  225. package/dist/testing/index.d.ts +35 -12
  226. package/dist/testing/index.d.ts.map +1 -1
  227. package/dist/testing/index.js +53 -38
  228. package/dist/testing/index.js.map +1 -1
  229. package/dist/testing/vitest.d.ts +1 -1
  230. package/dist/testing/vitest.d.ts.map +1 -1
  231. package/dist/types-global/errors.d.ts +28 -15
  232. package/dist/types-global/errors.d.ts.map +1 -1
  233. package/dist/types-global/errors.js +8 -1
  234. package/dist/types-global/errors.js.map +1 -1
  235. package/dist/utils/formatting/diffFormatter.d.ts +5 -5
  236. package/dist/utils/formatting/diffFormatter.d.ts.map +1 -1
  237. package/dist/utils/formatting/diffFormatter.js +7 -20
  238. package/dist/utils/formatting/diffFormatter.js.map +1 -1
  239. package/dist/utils/formatting/tableFormatter.d.ts +3 -3
  240. package/dist/utils/formatting/tableFormatter.d.ts.map +1 -1
  241. package/dist/utils/formatting/tableFormatter.js +6 -17
  242. package/dist/utils/formatting/tableFormatter.js.map +1 -1
  243. package/dist/utils/formatting/treeFormatter.d.ts +3 -3
  244. package/dist/utils/formatting/treeFormatter.d.ts.map +1 -1
  245. package/dist/utils/formatting/treeFormatter.js +5 -18
  246. package/dist/utils/formatting/treeFormatter.js.map +1 -1
  247. package/dist/utils/index.d.ts +4 -2
  248. package/dist/utils/index.d.ts.map +1 -1
  249. package/dist/utils/index.js +2 -2
  250. package/dist/utils/index.js.map +1 -1
  251. package/dist/utils/internal/error-handler/errorHandler.d.ts +1 -1
  252. package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
  253. package/dist/utils/internal/error-handler/errorHandler.js +23 -11
  254. package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
  255. package/dist/utils/internal/error-handler/types.d.ts +10 -13
  256. package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
  257. package/dist/utils/internal/logger.d.ts +3 -3
  258. package/dist/utils/internal/logger.d.ts.map +1 -1
  259. package/dist/utils/internal/logger.js +11 -5
  260. package/dist/utils/internal/logger.js.map +1 -1
  261. package/dist/utils/internal/performance.d.ts +13 -5
  262. package/dist/utils/internal/performance.d.ts.map +1 -1
  263. package/dist/utils/internal/performance.js +76 -17
  264. package/dist/utils/internal/performance.js.map +1 -1
  265. package/dist/utils/internal/requestContext.d.ts +92 -55
  266. package/dist/utils/internal/requestContext.d.ts.map +1 -1
  267. package/dist/utils/internal/requestContext.js +120 -40
  268. package/dist/utils/internal/requestContext.js.map +1 -1
  269. package/dist/utils/metrics/tokenCounter.d.ts +3 -3
  270. package/dist/utils/metrics/tokenCounter.d.ts.map +1 -1
  271. package/dist/utils/metrics/tokenCounter.js.map +1 -1
  272. package/dist/utils/network/fetchWithTimeout.d.ts +2 -2
  273. package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
  274. package/dist/utils/network/fetchWithTimeout.js +8 -24
  275. package/dist/utils/network/fetchWithTimeout.js.map +1 -1
  276. package/dist/utils/network/retry.d.ts +2 -2
  277. package/dist/utils/network/retry.d.ts.map +1 -1
  278. package/dist/utils/overflow/outlineOnOverflow.d.ts +1 -1
  279. package/dist/utils/overflow/outlineOnOverflow.d.ts.map +1 -1
  280. package/dist/utils/pagination/pagination.d.ts +3 -3
  281. package/dist/utils/pagination/pagination.d.ts.map +1 -1
  282. package/dist/utils/pagination/pagination.js +3 -3
  283. package/dist/utils/pagination/pagination.js.map +1 -1
  284. package/dist/utils/parsing/csvParser.d.ts +2 -2
  285. package/dist/utils/parsing/csvParser.d.ts.map +1 -1
  286. package/dist/utils/parsing/csvParser.js +4 -8
  287. package/dist/utils/parsing/csvParser.js.map +1 -1
  288. package/dist/utils/parsing/dateParser.d.ts +3 -3
  289. package/dist/utils/parsing/dateParser.d.ts.map +1 -1
  290. package/dist/utils/parsing/dateParser.js +3 -2
  291. package/dist/utils/parsing/dateParser.js.map +1 -1
  292. package/dist/utils/parsing/frontmatterParser.d.ts +2 -2
  293. package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -1
  294. package/dist/utils/parsing/frontmatterParser.js +7 -10
  295. package/dist/utils/parsing/frontmatterParser.js.map +1 -1
  296. package/dist/utils/parsing/htmlExtractor.d.ts +2 -2
  297. package/dist/utils/parsing/htmlExtractor.d.ts.map +1 -1
  298. package/dist/utils/parsing/htmlExtractor.js +6 -11
  299. package/dist/utils/parsing/htmlExtractor.js.map +1 -1
  300. package/dist/utils/parsing/jsonParser.d.ts +2 -2
  301. package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
  302. package/dist/utils/parsing/jsonParser.js +4 -8
  303. package/dist/utils/parsing/jsonParser.js.map +1 -1
  304. package/dist/utils/parsing/pdfParser.d.ts +10 -10
  305. package/dist/utils/parsing/pdfParser.d.ts.map +1 -1
  306. package/dist/utils/parsing/pdfParser.js +26 -89
  307. package/dist/utils/parsing/pdfParser.js.map +1 -1
  308. package/dist/utils/parsing/xmlParser.d.ts +2 -2
  309. package/dist/utils/parsing/xmlParser.d.ts.map +1 -1
  310. package/dist/utils/parsing/xmlParser.js +4 -8
  311. package/dist/utils/parsing/xmlParser.js.map +1 -1
  312. package/dist/utils/parsing/yamlParser.d.ts +2 -2
  313. package/dist/utils/parsing/yamlParser.d.ts.map +1 -1
  314. package/dist/utils/parsing/yamlParser.js +4 -8
  315. package/dist/utils/parsing/yamlParser.js.map +1 -1
  316. package/dist/utils/scheduling/scheduler.d.ts.map +1 -1
  317. package/dist/utils/scheduling/scheduler.js +5 -6
  318. package/dist/utils/scheduling/scheduler.js.map +1 -1
  319. package/dist/utils/security/rateLimiter.d.ts +2 -2
  320. package/dist/utils/security/rateLimiter.d.ts.map +1 -1
  321. package/dist/utils/security/rateLimiter.js +1 -1
  322. package/dist/utils/security/rateLimiter.js.map +1 -1
  323. package/dist/utils/telemetry/attributes.d.ts +23 -7
  324. package/dist/utils/telemetry/attributes.d.ts.map +1 -1
  325. package/dist/utils/telemetry/attributes.js +23 -10
  326. package/dist/utils/telemetry/attributes.js.map +1 -1
  327. package/dist/utils/telemetry/trace.d.ts +3 -3
  328. package/dist/utils/telemetry/trace.d.ts.map +1 -1
  329. package/dist/utils/telemetry/trace.js +4 -2
  330. package/dist/utils/telemetry/trace.js.map +1 -1
  331. package/package.json +22 -26
  332. package/scripts/lint-mcp.ts +1 -3
  333. package/scripts/lint-packaging.ts +1 -1
  334. package/skills/add-service/SKILL.md +2 -2
  335. package/skills/add-test/SKILL.md +42 -20
  336. package/skills/add-tool/SKILL.md +103 -19
  337. package/skills/api-config/SKILL.md +4 -11
  338. package/skills/api-context/SKILL.md +216 -120
  339. package/skills/api-linter/SKILL.md +16 -3
  340. package/skills/api-telemetry/SKILL.md +10 -12
  341. package/skills/api-testing/SKILL.md +53 -52
  342. package/skills/api-workers/SKILL.md +9 -1
  343. package/skills/code-simplifier/SKILL.md +2 -2
  344. package/skills/design-mcp-server/SKILL.md +31 -17
  345. package/skills/field-test/SKILL.md +4 -2
  346. package/skills/polish-docs-meta/SKILL.md +1 -1
  347. package/skills/polish-docs-meta/references/agent-protocol.md +2 -2
  348. package/skills/polish-docs-meta/references/readme.md +1 -1
  349. package/skills/release-and-publish/SKILL.md +3 -1
  350. package/skills/report-issue-framework/SKILL.md +2 -2
  351. package/skills/report-issue-local/SKILL.md +2 -2
  352. package/skills/security-pass/SKILL.md +16 -14
  353. package/skills/tool-defs-analysis/SKILL.md +15 -5
  354. package/templates/.env.example +4 -0
  355. package/templates/AGENTS.md +6 -6
  356. package/templates/CLAUDE.md +6 -6
  357. package/templates/tests/resources/echo.resource.test.ts +16 -9
  358. package/dist/mcp-server/elicitation.d.ts +0 -64
  359. package/dist/mcp-server/elicitation.d.ts.map +0 -1
  360. package/dist/mcp-server/elicitation.js +0 -81
  361. package/dist/mcp-server/elicitation.js.map +0 -1
  362. package/dist/mcp-server/protocolSession.d.ts +0 -34
  363. package/dist/mcp-server/protocolSession.d.ts.map +0 -1
  364. package/dist/mcp-server/protocolSession.js +0 -13
  365. package/dist/mcp-server/protocolSession.js.map +0 -1
  366. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts +0 -53
  367. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts.map +0 -1
  368. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js +0 -65
  369. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js.map +0 -1
  370. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +0 -70
  371. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +0 -1
  372. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +0 -130
  373. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +0 -1
  374. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +0 -109
  375. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +0 -1
  376. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +0 -209
  377. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +0 -1
  378. package/dist/mcp-server/tasks/core/taskManager.d.ts +0 -91
  379. package/dist/mcp-server/tasks/core/taskManager.d.ts.map +0 -1
  380. package/dist/mcp-server/tasks/core/taskManager.js +0 -210
  381. package/dist/mcp-server/tasks/core/taskManager.js.map +0 -1
  382. package/dist/mcp-server/tasks/core/taskTypes.d.ts +0 -18
  383. package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +0 -1
  384. package/dist/mcp-server/tasks/core/taskTypes.js +0 -20
  385. package/dist/mcp-server/tasks/core/taskTypes.js.map +0 -1
  386. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +0 -101
  387. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +0 -1
  388. package/dist/mcp-server/tasks/utils/taskToolDefinition.js +0 -14
  389. package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +0 -1
@@ -1,41 +1,107 @@
1
1
  /**
2
2
  * @fileoverview Request-scoped list-changed / resource-updated notifiers.
3
3
  *
4
- * Under the per-request `McpServer` model (HTTP and Workers,
5
- * GHSA-345p-7cg4-v4c7), the server-level `server.send*ListChanged()` path emits
6
- * a notification with no `relatedRequestId`. `@hono/mcp` then looks for the
7
- * standalone GET SSE stream — which lives on a *different* transport instance —
8
- * and, finding none on the POST transport, drops the notification silently
9
- * (#135). The fix is to route handler-time notifications through the request's
10
- * own `extra.sendNotification`, which stamps `relatedRequestId` so the
11
- * notification reaches that request's SSE response stream.
4
+ * Notifications fired from inside a handler are sent through the request's own
5
+ * `ctx.mcpReq.notify`, which stamps `relatedRequestId` so the message lands on
6
+ * that request's own response stream. The server-level `send*ListChanged()`
7
+ * path targets the standalone GET SSE stream instead, which does not exist
8
+ * under per-request serving (`createMcpHandler`'s modern leg and its stateless
9
+ * legacy fallback both build one instance per request) — notifications sent
10
+ * that way drop silently (#135).
11
+ *
12
+ * `notifications/resources/updated` is subscription-scoped: it is emitted only
13
+ * for URIs the client actually subscribed to via `resources/subscribe` (#354).
14
+ *
15
+ * That request-scoped path is the **2025-era** one. On 2026-07-28 delivery
16
+ * belongs to the client's `subscriptions/listen` stream, so a modern instance
17
+ * publishes to the handler's event bus instead — see {@link buildBusNotifiers}
18
+ * (#193).
12
19
  *
13
20
  * @module src/mcp-server/notifications
14
21
  */
15
22
  import { logger } from '../utils/internal/logger.js';
16
23
  /**
17
- * Builds notifier closures bound to a single request's `extra.sendNotification`.
18
- * The SDK stamps `relatedRequestId` onto these sends, so `@hono/mcp` routes them
19
- * to that request's SSE response stream — the delivery path the server-level
20
- * `server.send*ListChanged()` calls miss under the per-request McpServer model,
21
- * where they drop silently (#135).
22
- *
23
- * Returns `undefined` when the supplied extra exposes no sender; callers fall
24
- * back to the server-level notifiers in that case.
25
- *
26
- * Fire-and-forget by contract (`() => void`): the underlying `sendNotification`
27
- * promise is not awaited — a notification that can't flush (client already gone,
28
- * response not upgraded to SSE) must not fail the handler. A flush failure is
29
- * logged at debug rather than swallowed silently.
30
- *
31
- * Handler-time only. A background task (auto-task handler, cron) has no request
32
- * scope; those paths keep the server-level notifiers, which deliver on stdio but
33
- * not under HTTP — the residual gap a session-scoped notification bus would close.
24
+ * Picks the delivery path a handler's `ctx.notify*` should take, era-ordered.
25
+ *
26
+ * A modern instance publishes to the listen bus, where the SDK applies the
27
+ * client's subscription filter and an out-of-request emit still reaches open
28
+ * streams (#193). A legacy instance sends through the request's own scope so
29
+ * the message carries `relatedRequestId` (#135). The server-level closures are
30
+ * the fallback for scopes with no sender at all — stdio and test harnesses.
31
+ *
32
+ * Both handler factories route through here so the ordering is one decision
33
+ * rather than two copies that can drift apart.
34
+ */
35
+ export function selectNotifiers(sources, mcpReq) {
36
+ return ((sources.bus ? buildBusNotifiers(sources.bus) : undefined) ??
37
+ buildRequestScopedNotifiers(mcpReq ?? {}, sources.subscriptions) ??
38
+ sources);
39
+ }
40
+ /**
41
+ * A {@link ServerNotifier} over an arbitrary {@link ServerEventBus}.
42
+ *
43
+ * `createMcpHandler` returns one bound to its own bus, but the framework builds
44
+ * the bus first — before any transport exists — so `setup()` can capture a
45
+ * publish handle that stays valid once serving starts. The names mirror the
46
+ * wire methods.
47
+ */
48
+ export function notifierFor(bus) {
49
+ return {
50
+ toolsChanged: () => bus.publish({ kind: 'tools_list_changed' }),
51
+ promptsChanged: () => bus.publish({ kind: 'prompts_list_changed' }),
52
+ resourcesChanged: () => bus.publish({ kind: 'resources_list_changed' }),
53
+ resourceUpdated: (uri) => bus.publish({ kind: 'resource_updated', uri }),
54
+ };
55
+ }
56
+ /**
57
+ * Builds notifier closures that publish onto the modern era's
58
+ * `subscriptions/listen` bus.
59
+ *
60
+ * On protocol revision 2026-07-28 a client opts into notification types by
61
+ * opening a `subscriptions/listen` stream, and the spec is explicit that a
62
+ * server MUST NOT send types the client has not requested. That filter lives in
63
+ * the SDK's listen router, which only sees what reaches the bus — so a modern
64
+ * handler firing through its own request scope bypasses it and delivers to
65
+ * clients that opened no stream at all.
66
+ *
67
+ * Publishing is also what makes *out-of-request* emission work: the bus is not
68
+ * request-scoped, so a background emitter reaches every open stream rather than
69
+ * dropping into a closed exchange.
70
+ *
71
+ * No subscription registry is consulted here — including for
72
+ * `resources/updated`. Per-URI routing is the listen filter's
73
+ * `resourceSubscriptions` field, which the SDK applies on publish; the
74
+ * `resources/subscribe` registry is the 2025-era mechanism and does not exist
75
+ * on this era.
76
+ */
77
+ export function buildBusNotifiers(notify) {
78
+ return {
79
+ notifyToolListChanged: () => notify.toolsChanged(),
80
+ notifyResourceListChanged: () => notify.resourcesChanged(),
81
+ notifyPromptListChanged: () => notify.promptsChanged(),
82
+ notifyResourceUpdated: (uri) => notify.resourceUpdated(uri),
83
+ };
84
+ }
85
+ /**
86
+ * Builds notifier closures bound to a single request's `ctx.mcpReq.notify`.
87
+ *
88
+ * Returns `undefined` when the supplied request scope exposes no sender;
89
+ * callers fall back to the server-level notifiers in that case.
90
+ *
91
+ * Fire-and-forget by contract (`() => void`): the underlying promise is not
92
+ * awaited — a notification that can't flush (client already gone, response not
93
+ * upgraded to SSE) must not fail the handler. A flush failure is logged at
94
+ * debug rather than swallowed silently.
95
+ *
96
+ * @param mcpReq - The request scope from the SDK's `ServerContext`.
97
+ * @param subscriptions - Per-connection `resources/subscribe` registry. When
98
+ * supplied, `notifyResourceUpdated` emits only for subscribed URIs; when
99
+ * omitted (no subscription tracking available) every URI is emitted.
34
100
  */
35
- export function buildRequestScopedNotifiers(extra) {
36
- if (typeof extra.sendNotification !== 'function')
101
+ export function buildRequestScopedNotifiers(mcpReq, subscriptions) {
102
+ if (typeof mcpReq.notify !== 'function')
37
103
  return;
38
- const send = extra.sendNotification.bind(extra);
104
+ const send = mcpReq.notify.bind(mcpReq);
39
105
  const emit = (notification) => {
40
106
  void send(notification).catch((error) => {
41
107
  logger.debug(`Notification ${notification.method} not delivered: ${error instanceof Error ? error.message : String(error)}`);
@@ -45,7 +111,16 @@ export function buildRequestScopedNotifiers(extra) {
45
111
  notifyToolListChanged: () => emit({ method: 'notifications/tools/list_changed' }),
46
112
  notifyResourceListChanged: () => emit({ method: 'notifications/resources/list_changed' }),
47
113
  notifyPromptListChanged: () => emit({ method: 'notifications/prompts/list_changed' }),
48
- notifyResourceUpdated: (uri) => emit({ method: 'notifications/resources/updated', params: { uri } }),
114
+ notifyResourceUpdated: (uri) => {
115
+ // Spec: `notifications/resources/updated` SHOULD only be sent for a URI
116
+ // the client subscribed to. Emitting to a client that never subscribed is
117
+ // noise it has no handler for.
118
+ if (subscriptions && !subscriptions.has(uri)) {
119
+ logger.debug(`Resource update for ${uri} not sent: no active subscription.`);
120
+ return;
121
+ }
122
+ emit({ method: 'notifications/resources/updated', params: { uri } });
123
+ },
49
124
  };
50
125
  }
51
126
  //# sourceMappingURL=notifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/mcp-server/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAsBpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAyB;IAEzB,IAAI,OAAO,KAAK,CAAC,gBAAgB,KAAK,UAAU;QAAE,OAAO;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,CAAC,YAAgC,EAAQ,EAAE;QACtD,KAAK,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC/C,MAAM,CAAC,KAAK,CACV,gBAAgB,YAAY,CAAC,MAAM,mBACjC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO;QACL,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE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E,MAAM,EAAE,sCAAsC,EAAE,CAAC;QACzF,uBAAuB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,oCAAoC,EAAE,CAAC;QACrF,qBAAqB,EAAE,CAAC,GAAW,EAAE,EAAE;YACrC,wEAAwE;YACxE,0EAA0E;YAC1E,+BAA+B;YAC/B,IAAI,aAAa,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC7C,MAAM,CAAC,KAAK,CAAC,uBAAuB,GAAG,oCAAoC,CAAC,CAAC;gBAC7E,OAAO;YACT,CAAC;YACD,IAAI,CAAC,EAAE,MAAM,EAAE,iCAAiC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -2,10 +2,10 @@
2
2
  * @fileoverview Service for registering MCP prompts on a server instance.
3
3
  *
4
4
  * MCP Prompts Specification:
5
- * @see {@link https://modelcontextprotocol.io/specification/2025-06-18/basic/prompts | MCP Prompts}
5
+ * @see {@link https://modelcontextprotocol.io/specification/2026-07-28/server/prompts | MCP Prompts}
6
6
  * @module src/mcp-server/prompts/prompt-registration
7
7
  */
8
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
8
+ import type { McpServer } from '@modelcontextprotocol/server';
9
9
  import type { AnyPromptDefinition } from '../../mcp-server/prompts/utils/promptDefinition.js';
10
10
  import type { logger as defaultLogger } from '../../utils/internal/logger.js';
11
11
  export declare class PromptRegistry {
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAG1F,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQ1E,qBAAa,cAAc;IAKvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IALhB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,OAAO,aAAa,EAClC;IAEJ;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBlD;IAED,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;YAUV,cAAc;CAsD7B"}
1
+ {"version":3,"file":"prompt-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAwC,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAG1F,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI1E,qBAAa,cAAc;IAKvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IALhB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,OAAO,aAAa,EAClC;IAEJ;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlD;IAED,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;YAUV,cAAc;CAgE7B"}
@@ -1,3 +1,4 @@
1
+ import { isInputRequiredSignal } from '../../mcp-server/inputRequired.js';
1
2
  import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
2
3
  import { ErrorHandler } from '../../utils/internal/error-handler/errorHandler.js';
3
4
  import { measurePromptGeneration } from '../../utils/internal/performance.js';
@@ -20,10 +21,9 @@ export class PromptRegistry {
20
21
  operation: 'PromptRegistry.registerAll',
21
22
  });
22
23
  this.logger.debug(`Registering ${this.promptDefs.length} prompt(s)...`, context);
23
- // The SDK only initializes prompts/list + prompts/get handlers when a
24
- // prompt is first registered. Initialize them up front so empty servers
25
- // still expose truthful MCP prompt behavior.
26
- server.setPromptRequestHandlers();
24
+ // `prompts/list` and `prompts/get` are installed by the SDK from the
25
+ // declared `prompts` capability, so a server with no prompts still answers
26
+ // `prompts/list` with an empty array rather than `-32601`.
27
27
  for (const promptDef of this.promptDefs) {
28
28
  await this.registerPrompt(server, promptDef, context);
29
29
  }
@@ -44,8 +44,13 @@ export class PromptRegistry {
44
44
  server.registerPrompt(promptDef.name, {
45
45
  ...(promptDef.title && { title: promptDef.title }),
46
46
  description: promptDef.description,
47
+ // The ZodObject itself, not `.shape`: the raw-shape overload
48
+ // rebuilds a fresh non-strict object (dropping `.strict()` and any
49
+ // object-level refinement), and requiredness is derived from the
50
+ // emitted JSON Schema, so a `.default()`ed argument correctly
51
+ // advertises as optional (#258).
47
52
  ...(promptDef.args && {
48
- argsSchema: promptDef.args.shape,
53
+ argsSchema: promptDef.args,
49
54
  }),
50
55
  }, async (args) => {
51
56
  try {
@@ -54,6 +59,11 @@ export class PromptRegistry {
54
59
  return { messages };
55
60
  }
56
61
  catch (error) {
62
+ // `ctx.requestInput(...)` is protocol control flow, not a failure
63
+ // — `prompts/get` honors `input_required` on the 2026-07-28
64
+ // revision.
65
+ if (isInputRequiredSignal(error))
66
+ return error.result;
57
67
  const handled = ErrorHandler.handleError(error, {
58
68
  operation: `prompt:${promptDef.name}`,
59
69
  context,
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM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O,YAAY,QAAQ;wBAC/B,CAAC,CAAC,OAAO;wBACT,CAAC,CAAC,IAAI,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC,CACF,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,SAAS,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC,EACD;YACE,SAAS,EAAE,qBAAqB,SAAS,CAAC,IAAI,EAAE;YAChD,OAAO;YACP,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"prompt-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,OAAO,cAAc;IAKf,UAAU;IACV,MAAM;IALhB,sEAAsE;IACrD,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAErD,YACU,UAAiC,EACjC,MAA4B;0BAD5B,UAAU;sBACV,MAAM;IACb,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAAiB;QACjC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAE7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,4BAA4B;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,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YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -6,7 +6,7 @@
6
6
  * @see {@link https://modelcontextprotocol.io/specification/2025-06-18/basic/prompts | MCP Prompts}
7
7
  * @module src/mcp-server/prompts/utils/promptDefinition
8
8
  */
9
- import type { PromptMessage } from '@modelcontextprotocol/sdk/types.js';
9
+ import type { PromptMessage } from '@modelcontextprotocol/server';
10
10
  import type { ZodObject, ZodRawShape, z } from 'zod';
11
11
  /**
12
12
  * Represents the complete, self-contained definition of an MCP prompt.
@@ -1 +1 @@
1
- {"version":3,"file":"promptDefinition.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/prompts/utils/promptDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,SAAS;IAC5F;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,KAAK,SAAS,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAChF,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAChD,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,kFAAkF;AAClF,MAAM,MAAM,mBA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SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,CAAC;AAMvF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,KAAK,SAAS,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,SAAS,EACjF,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAC7C,gBAAgB,CAAC,KAAK,CAAC,CAEzB"}
@@ -2,8 +2,8 @@
2
2
  * @fileoverview Encapsulates the registration of all resource definitions with an McpServer.
3
3
  * @module src/mcp-server/resources/resource-registration
4
4
  */
5
- import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { ProtocolSessionHooks } from '../../mcp-server/protocolSession.js';
5
+ import { type McpServer, type ServerNotifier } from '@modelcontextprotocol/server';
6
+ import type { ResourceSubscriptions } from '../../mcp-server/notifications.js';
7
7
  import type { AnyResourceDefinition } from '../../mcp-server/resources/utils/resourceDefinition.js';
8
8
  import { type ResourceHandlerFactoryServices } from '../../mcp-server/resources/utils/resourceHandlerFactory.js';
9
9
  export declare class ResourceRegistry {
@@ -15,7 +15,7 @@ export declare class ResourceRegistry {
15
15
  /**
16
16
  * Registers all resolved resource definitions with the provided McpServer instance.
17
17
  */
18
- registerAll(server: McpServer, protocolSession?: ProtocolSessionHooks): Promise<void>;
18
+ registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier): Promise<void>;
19
19
  /** Throws at startup if a resource with the same name was already registered. */
20
20
  private assertUniqueName;
21
21
  private registerResource;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAE3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAEL,KAAK,8BAA8B,EAEpC,MAAM,wDAAwD,CAAC;AAchE,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,QAAQ;IALlB,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,YAAY,EAAE,qBAAqB,EAAE,EACrC,QAAQ,EAAE,8BAA8B,EAC9C;IAEJ;;OAEG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,eAAe,CAAC,EAAE,oBAAoB,GACrC,OAAO,CAAC,IAAI,CAAC,CAoCf;IAED,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;YAUV,gBAAgB;CAqD/B"}
1
+ {"version":3,"file":"resource-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAEL,KAAK,8BAA8B,EAEpC,MAAM,wDAAwD,CAAC;AAUhE,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,QAAQ;IALlB,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,YAAY,EAAE,qBAAqB,EAAE,EACrC,QAAQ,EAAE,8BAA8B,EAC9C;IAEJ;;OAEG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CA4Bf;IAED,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;YAUV,gBAAgB;CAqD/B"}
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Encapsulates the registration of all resource definitions with an McpServer.
3
3
  * @module src/mcp-server/resources/resource-registration
4
4
  */
5
- import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import { ResourceTemplate, } from '@modelcontextprotocol/server';
6
6
  import { createResourceHandler, } from '../../mcp-server/resources/utils/resourceHandlerFactory.js';
7
7
  import { JsonRpcErrorCode } from '../../types-global/errors.js';
8
8
  import { ErrorHandler } from '../../utils/internal/error-handler/errorHandler.js';
@@ -23,7 +23,7 @@ export class ResourceRegistry {
23
23
  /**
24
24
  * Registers all resolved resource definitions with the provided McpServer instance.
25
25
  */
26
- async registerAll(server, protocolSession) {
26
+ async registerAll(server, subscriptions, bus) {
27
27
  this.registeredNames.clear();
28
28
  // Per-server notifier closures targeting `server.send*ListChanged()`. Bound
29
29
  // once per registerAll() call — never mutated on a shared services object
@@ -31,25 +31,19 @@ export class ResourceRegistry {
31
31
  // factory prefers request-scoped notifiers (#135) and falls back to these
32
32
  // only when a request has no notification sender.
33
33
  const notifiers = {
34
- elicitInput: (params) => server.server.elicitInput(params),
35
- getClientCapabilities: () => protocolSession?.clientCapabilities ?? server.server.getClientCapabilities(),
36
34
  notifyPromptListChanged: () => server.sendPromptListChanged(),
37
35
  notifyResourceListChanged: () => server.sendResourceListChanged(),
38
- notifyResourceUpdated: (uri) => server.server.sendResourceUpdated({ uri }),
39
36
  notifyToolListChanged: () => server.sendToolListChanged(),
40
- requestScopedElicitation: protocolSession !== undefined,
41
- ...(protocolSession?.registerRequest && {
42
- registerRequest: protocolSession.registerRequest,
43
- }),
37
+ ...(subscriptions && { subscriptions }),
38
+ ...(bus && { bus }),
44
39
  };
45
40
  const context = requestContextService.createRequestContext({
46
41
  operation: 'ResourceRegistry.registerAll',
47
42
  });
48
43
  logger.debug(`Registering ${this.resourceDefs.length} resource(s)...`, context);
49
- // The SDK only initializes resources/list + resources/read handlers when a
50
- // resource is first registered. Initialize them up front so empty servers
51
- // still expose truthful MCP resource behavior.
52
- server.setResourceRequestHandlers();
44
+ // `resources/list` and `resources/read` are installed by the SDK from the
45
+ // declared `resources` capability, so a server with no resources still
46
+ // answers `resources/list` with an empty array rather than `-32601`.
53
47
  for (const resourceDef of this.resourceDefs) {
54
48
  await this.registerResource(server, resourceDef, notifiers);
55
49
  }
@@ -88,10 +82,10 @@ export class ResourceRegistry {
88
82
  list: def.list,
89
83
  ...(def.complete && { complete: def.complete }),
90
84
  });
91
- server.resource(resourceName, template, metadata, handler);
85
+ server.registerResource(resourceName, template, metadata, handler);
92
86
  }
93
87
  else {
94
- server.resource(resourceName, def.uriTemplate, metadata, (uri, extra) => handler(uri, {}, extra));
88
+ server.registerResource(resourceName, def.uriTemplate, metadata, (uri, ctx) => handler(uri, {}, ctx));
95
89
  }
96
90
  logger.debug(`Resource '${resourceName}' registered successfully.`, registrationContext);
97
91
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"resource-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAkB,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAI3F,OAAO,EACL,qBAAqB,GAGtB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAM3E,SAAS,uBAAuB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,gBAAgB;IAKjB,YAAY;IACZ,QAAQ;IALlB,wEAAwE;IACvD,eAAe,GAAG,IAAI,GA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F"}
1
+ {"version":3,"file":"resource-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EACL,qBAAqB,GAGtB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,SAAS,uBAAuB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,gBAAgB;IAKjB,YAAY;IACZ,QAAQ;IALlB,wEAAwE;IACvD,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAErD,YACU,YAAqC,EACrC,QAAwC;4BADxC,YAAY;wBACZ,QAAQ;IACf,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,WAAW,CACtB,MAAiB,EACjB,aAAqC,EACrC,GAAoB;QAEpB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAE7B,4EAA4E;QAC5E,0EAA0E;QAC1E,0EAA0E;QAC1E,0EAA0E;QAC1E,kDAAkD;QAClD,MAAM,SAAS,GAA6B;YAC1C,uBAAuB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,qBAAqB,EAAE;YAC7D,yBAAyB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,EAAE;YACjE,qBAAqB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,EAAE;YACzD,GAAG,CAAC,aAAa,IAAI,EAAE,aAAa,EAAE,CAAC;YACvC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC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AAM,CAAC,KAAK,CAAC,aAAa,YAAY,4BAA4B,EAAE,mBAAmB,CAAC,CAAC;QAC3F,CAAC,EACD;YACE,SAAS,EAAE,uBAAuB,YAAY,EAAE;YAChD,OAAO,EAAE,mBAAmB;YAC5B,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @fileoverview Per-connection `resources/subscribe` registry.
3
+ *
4
+ * The framework advertises `resources: { subscribe: true }`, and a declared
5
+ * capability is a promise: `resources/subscribe` and `resources/unsubscribe`
6
+ * must resolve, and `notifications/resources/updated` must only reach clients
7
+ * that actually subscribed to the URI (#354).
8
+ *
9
+ * This is the **2025-era** mechanism, and it is installed only on instances
10
+ * serving that era. The 2026-07-28 revision has no `resources/subscribe` RPC —
11
+ * a client opts in through `subscriptions/listen`'s `resourceSubscriptions`
12
+ * filter, and the SDK's listen router owns delivery. Handing a modern instance
13
+ * this registry would leave it permanently empty and silently drop every
14
+ * `ctx.notifyResourceUpdated(uri)`, so `createMcpServerInstance` passes none
15
+ * and the notifiers emit unconditionally there.
16
+ *
17
+ * Scope is the `McpServer` instance, which is also the connection: a persistent
18
+ * instance per session on the sessionful legacy arm, one per request under
19
+ * per-request serving. On the per-request arm a subscription cannot outlive the
20
+ * request that created it, so a handler-time `ctx.notifyResourceUpdated(uri)`
21
+ * only delivers when the same exchange subscribed first.
22
+ *
23
+ * @see {@link https://modelcontextprotocol.io/specification/2026-07-28/server/resources | MCP Resources}
24
+ * @module src/mcp-server/resources/resourceSubscriptions
25
+ */
26
+ import type { McpServer } from '@modelcontextprotocol/server';
27
+ import type { ResourceSubscriptions } from '../../mcp-server/notifications.js';
28
+ /**
29
+ * Read-only view of one connection's subscription set. The set is mutated only
30
+ * by the `resources/subscribe` / `resources/unsubscribe` handlers installed
31
+ * alongside it.
32
+ */
33
+ export interface ResourceSubscriptionRegistry extends ResourceSubscriptions {
34
+ readonly size: number;
35
+ }
36
+ /**
37
+ * Installs `resources/subscribe` / `resources/unsubscribe` on a server instance
38
+ * and returns the registry the notifiers read.
39
+ *
40
+ * Both handlers are idempotent and never fail: re-subscribing is a no-op, and
41
+ * unsubscribing from a URI that was never subscribed succeeds (the spec
42
+ * defines no error for it, and clients tear down optimistically).
43
+ */
44
+ export declare function installResourceSubscriptions(server: McpServer): ResourceSubscriptionRegistry;
45
+ //# sourceMappingURL=resourceSubscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceSubscriptions.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resourceSubscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;GAIG;AACH,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,GAAG,4BAA4B,CAmB5F"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @fileoverview Per-connection `resources/subscribe` registry.
3
+ *
4
+ * The framework advertises `resources: { subscribe: true }`, and a declared
5
+ * capability is a promise: `resources/subscribe` and `resources/unsubscribe`
6
+ * must resolve, and `notifications/resources/updated` must only reach clients
7
+ * that actually subscribed to the URI (#354).
8
+ *
9
+ * This is the **2025-era** mechanism, and it is installed only on instances
10
+ * serving that era. The 2026-07-28 revision has no `resources/subscribe` RPC —
11
+ * a client opts in through `subscriptions/listen`'s `resourceSubscriptions`
12
+ * filter, and the SDK's listen router owns delivery. Handing a modern instance
13
+ * this registry would leave it permanently empty and silently drop every
14
+ * `ctx.notifyResourceUpdated(uri)`, so `createMcpServerInstance` passes none
15
+ * and the notifiers emit unconditionally there.
16
+ *
17
+ * Scope is the `McpServer` instance, which is also the connection: a persistent
18
+ * instance per session on the sessionful legacy arm, one per request under
19
+ * per-request serving. On the per-request arm a subscription cannot outlive the
20
+ * request that created it, so a handler-time `ctx.notifyResourceUpdated(uri)`
21
+ * only delivers when the same exchange subscribed first.
22
+ *
23
+ * @see {@link https://modelcontextprotocol.io/specification/2026-07-28/server/resources | MCP Resources}
24
+ * @module src/mcp-server/resources/resourceSubscriptions
25
+ */
26
+ /**
27
+ * Installs `resources/subscribe` / `resources/unsubscribe` on a server instance
28
+ * and returns the registry the notifiers read.
29
+ *
30
+ * Both handlers are idempotent and never fail: re-subscribing is a no-op, and
31
+ * unsubscribing from a URI that was never subscribed succeeds (the spec
32
+ * defines no error for it, and clients tear down optimistically).
33
+ */
34
+ export function installResourceSubscriptions(server) {
35
+ const subscribed = new Set();
36
+ server.server.setRequestHandler('resources/subscribe', (request) => {
37
+ subscribed.add(request.params.uri);
38
+ return {};
39
+ });
40
+ server.server.setRequestHandler('resources/unsubscribe', (request) => {
41
+ subscribed.delete(request.params.uri);
42
+ return {};
43
+ });
44
+ return {
45
+ has: (uri) => subscribed.has(uri),
46
+ get size() {
47
+ return subscribed.size;
48
+ },
49
+ };
50
+ }
51
+ //# sourceMappingURL=resourceSubscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceSubscriptions.js","sourceRoot":"","sources":["../../../src/mcp-server/resources/resourceSubscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAeH;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAiB;IAC5D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE;QACjE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,uBAAuB,EAAE,CAAC,OAAO,EAAE,EAAE;QACnE,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;QACjC,IAAI,IAAI;YACN,OAAO,UAAU,CAAC,IAAI,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -3,12 +3,10 @@
3
3
  * Handler receives `(params, ctx)` — URI is available on `ctx.uri`.
4
4
  *
5
5
  * MCP Resources Specification:
6
- * @see {@link https://modelcontextprotocol.io/specification/2025-06-18/basic/resources | MCP Resources}
6
+ * @see {@link https://modelcontextprotocol.io/specification/2026-07-28/server/resources | MCP Resources}
7
7
  * @module src/mcp-server/resources/utils/resourceDefinition
8
8
  */
9
- import type { CompleteResourceTemplateCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
10
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
11
- import type { ListResourcesResult, ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
9
+ import type { CompleteResourceTemplateCallback, ListResourcesResult, ReadResourceResult, ServerContext } from '@modelcontextprotocol/server';
12
10
  import type { ZodObject, ZodRawShape, z } from 'zod';
13
11
  import type { HandlerContext, ReasonOf } from '../../../core/context.js';
14
12
  import type { ErrorContract } from '../../../types-global/errors.js';
@@ -25,7 +23,7 @@ export interface ResourceAnnotations {
25
23
  priority?: number;
26
24
  }
27
25
  /** Extra context provided to list() handlers. */
28
- export type ListExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
26
+ export type ListExtra = ServerContext;
29
27
  /**
30
28
  * Represents a complete, self-contained definition of an MCP resource.
31
29
  * Handler receives `(params, ctx)` — URI is available on `ctx.uri`.
@@ -1 +1 @@
1
- {"version":3,"file":"resourceDefinition.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IACpC,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,EAC/D,OAAO,SAAS,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,SAAS,EAC9D,OAAO,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,GAAG,SAAS;IAEhE;;;;;;;;;;;;;;;;;;OAkBG;IACH,KA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AAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CACpD,SAAS,CAAC,WAAW,CAAC,EACtB,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,EAClC,SAAS,aAAa,EAAE,GAAG,SAAS,CACrC,CAAC;AAMF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CACtB,OAAO,SAAS,SAAS,CAAC,WAAW,CAAC,EACtC,OAAO,SAAS,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,SAAS,EAC9D,KAAK,CAAC,OAAO,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,GAAG,SAAS,EAEtE,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,GAC1E,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAE/C"}
1
+ {"version":3,"file":"resourceDefinition.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,m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C,GAAG,SAAS,GAAG,SAAS,EAC9D,KAAK,CAAC,OAAO,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,GAAG,SAAS,EAEtE,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,GAC1E,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAE/C"}
@@ -3,7 +3,7 @@
3
3
  * Handler receives `(params, ctx)` — URI is available on `ctx.uri`.
4
4
  *
5
5
  * MCP Resources Specification:
6
- * @see {@link https://modelcontextprotocol.io/specification/2025-06-18/basic/resources | MCP Resources}
6
+ * @see {@link https://modelcontextprotocol.io/specification/2026-07-28/server/resources | MCP Resources}
7
7
  * @module src/mcp-server/resources/utils/resourceDefinition
8
8
  */
9
9
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"resourceDefinition.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAyIH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CAKtB,WAAmB,EACnB,OAA2E;IAE3E,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"resourceDefinition.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuIH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CAKtB,WAAmB,EACnB,OAA2E;IAE3E,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -3,15 +3,11 @@
3
3
  * Constructs Context (with `uri`), checks inline auth, validates params, formats response.
4
4
  * @module src/mcp-server/resources/utils/resourceHandlerFactory
5
5
  */
6
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
7
- import type { Variables } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';
8
- import type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
9
- import { type ElicitationNotifiers } from '../../../mcp-server/elicitation.js';
10
- import type { ProtocolRequestRegistration } from '../../../mcp-server/protocolSession.js';
6
+ import type { InputRequiredResult, ReadResourceResult, ServerContext, ServerNotifier, Variables } from '@modelcontextprotocol/server';
7
+ import { type ResourceSubscriptions } from '../../../mcp-server/notifications.js';
11
8
  import type { AnyResourceDefinition } from '../../../mcp-server/resources/utils/resourceDefinition.js';
12
9
  import type { StorageService } from '../../../storage/core/StorageService.js';
13
10
  import type { Logger } from '../../../utils/internal/logger.js';
14
- type SdkExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
15
11
  /** Services required by the handler factory to construct Context. */
16
12
  export interface ResourceHandlerFactoryServices {
17
13
  /**
@@ -26,25 +22,31 @@ export interface ResourceHandlerFactoryServices {
26
22
  }
27
23
  /**
28
24
  * Per-server notifier closures bound at registration time, targeting
29
- * `server.send*ListChanged()` and `server.server.elicitInput(...)`.
25
+ * `server.send*ListChanged()`.
30
26
  *
31
27
  * Split from {@link ResourceHandlerFactoryServices} so each per-request
32
28
  * McpServer gets its own notifier closures — preventing a concurrent
33
29
  * registerAll() from overwriting an in-flight handler's notifier target.
34
30
  *
35
- * The resource handler factory prefers request-scoped notifiers
36
- * ({@link buildRequestScopedNotifiers}, #135) and uses these only as a fallback
37
- * when the SDK extra exposes no sender (e.g. a non-request test scope).
38
- *
39
- * The elicitation fields come from {@link ElicitationNotifiers}.
31
+ * The resource handler factory picks a delivery path per era via
32
+ * {@link selectNotifiers}, and uses these closures only as a fallback for
33
+ * scopes with neither a bus nor a request sender (stdio, test harnesses).
40
34
  */
41
- export interface ResourceHandlerNotifiers extends ElicitationNotifiers {
35
+ export interface ResourceHandlerNotifiers {
36
+ /**
37
+ * Publish facade for the modern era's `subscriptions/listen` bus, supplied
38
+ * only for `modern` instances. Takes precedence over the request-scoped path:
39
+ * on 2026-07-28 the client opts into notification types through its listen
40
+ * stream, and only what reaches the bus is filtered against that opt-in
41
+ * (#193).
42
+ */
43
+ bus?: ServerNotifier;
42
44
  notifyPromptListChanged?: () => void;
43
45
  notifyResourceListChanged?: () => void;
44
46
  notifyResourceUpdated?: (uri: string) => void;
45
47
  notifyToolListChanged?: () => void;
46
- /** Registers this handler invocation for session-scoped HTTP cancellation. */
47
- registerRequest?: (requestId: SdkExtra['requestId']) => ProtocolRequestRegistration;
48
+ /** Per-connection `resources/subscribe` registry (#354). Legacy era only. */
49
+ subscriptions?: ResourceSubscriptions;
48
50
  }
49
51
  /**
50
52
  * Creates an MCP resource read handler from a resource definition.
@@ -58,6 +60,5 @@ export interface ResourceHandlerNotifiers extends ElicitationNotifiers {
58
60
  * - Formats response via `format` or JSON default
59
61
  * - Catches errors and re-throws for the SDK
60
62
  */
61
- export declare function createResourceHandler(def: AnyResourceDefinition, services: ResourceHandlerFactoryServices, notifiers: ResourceHandlerNotifiers): (uri: URL, variables: Variables, extra: SdkExtra) => Promise<ReadResourceResult>;
62
- export {};
63
+ export declare function createResourceHandler(def: AnyResourceDefinition, services: ResourceHandlerFactoryServices, notifiers: ResourceHandlerNotifiers): (uri: URL, variables: Variables, ctx: ServerContext) => Promise<ReadResourceResult | InputRequiredResult>;
63
64
  //# sourceMappingURL=resourceHandlerFactory.d.ts.map