@cyanheads/mcp-ts-core 0.11.4 → 0.12.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 (366) hide show
  1. package/AGENTS.md +28 -24
  2. package/CLAUDE.md +28 -24
  3. package/README.md +10 -10
  4. package/biome.json +1 -1
  5. package/changelog/0.11.x/0.11.5.md +28 -0
  6. package/changelog/0.12.x/0.12.0.md +96 -0
  7. package/changelog/template.md +55 -16
  8. package/dist/cli/init.js +1 -1
  9. package/dist/cli/init.js.map +1 -1
  10. package/dist/config/index.d.ts +0 -18
  11. package/dist/config/index.d.ts.map +1 -1
  12. package/dist/config/index.js +0 -25
  13. package/dist/config/index.js.map +1 -1
  14. package/dist/core/app.d.ts +5 -7
  15. package/dist/core/app.d.ts.map +1 -1
  16. package/dist/core/app.js +18 -27
  17. package/dist/core/app.js.map +1 -1
  18. package/dist/core/context.d.ts +90 -57
  19. package/dist/core/context.d.ts.map +1 -1
  20. package/dist/core/context.js +32 -33
  21. package/dist/core/context.js.map +1 -1
  22. package/dist/core/gcPressure.d.ts.map +1 -1
  23. package/dist/core/gcPressure.js +3 -4
  24. package/dist/core/gcPressure.js.map +1 -1
  25. package/dist/core/index.d.ts +6 -7
  26. package/dist/core/index.d.ts.map +1 -1
  27. package/dist/core/index.js +10 -2
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/core/serverManifest.d.ts +1 -3
  30. package/dist/core/serverManifest.d.ts.map +1 -1
  31. package/dist/core/serverManifest.js +9 -4
  32. package/dist/core/serverManifest.js.map +1 -1
  33. package/dist/core/worker.d.ts.map +1 -1
  34. package/dist/core/worker.js +32 -35
  35. package/dist/core/worker.js.map +1 -1
  36. package/dist/logs/combined.log +10 -0
  37. package/dist/logs/error.log +6 -0
  38. package/dist/logs/interactions.log +0 -0
  39. package/dist/mcp-server/inputRequired.d.ts +52 -0
  40. package/dist/mcp-server/inputRequired.d.ts.map +1 -0
  41. package/dist/mcp-server/inputRequired.js +76 -0
  42. package/dist/mcp-server/inputRequired.js.map +1 -0
  43. package/dist/mcp-server/notifications.d.ts +33 -31
  44. package/dist/mcp-server/notifications.d.ts.map +1 -1
  45. package/dist/mcp-server/notifications.js +34 -26
  46. package/dist/mcp-server/notifications.js.map +1 -1
  47. package/dist/mcp-server/prompts/prompt-registration.d.ts +2 -2
  48. package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
  49. package/dist/mcp-server/prompts/prompt-registration.js +15 -5
  50. package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
  51. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +1 -1
  52. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -1
  53. package/dist/mcp-server/resources/resource-registration.d.ts +3 -3
  54. package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
  55. package/dist/mcp-server/resources/resource-registration.js +8 -15
  56. package/dist/mcp-server/resources/resource-registration.js.map +1 -1
  57. package/dist/mcp-server/resources/resourceSubscriptions.d.ts +45 -0
  58. package/dist/mcp-server/resources/resourceSubscriptions.d.ts.map +1 -0
  59. package/dist/mcp-server/resources/resourceSubscriptions.js +51 -0
  60. package/dist/mcp-server/resources/resourceSubscriptions.js.map +1 -0
  61. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +3 -5
  62. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -1
  63. package/dist/mcp-server/resources/utils/resourceDefinition.js +1 -1
  64. package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -1
  65. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +8 -15
  66. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
  67. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +21 -22
  68. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
  69. package/dist/mcp-server/server.d.ts +12 -21
  70. package/dist/mcp-server/server.d.ts.map +1 -1
  71. package/dist/mcp-server/server.js +38 -28
  72. package/dist/mcp-server/server.js.map +1 -1
  73. package/dist/mcp-server/tools/tool-registration.d.ts +11 -33
  74. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
  75. package/dist/mcp-server/tools/tool-registration.js +17 -243
  76. package/dist/mcp-server/tools/tool-registration.js.map +1 -1
  77. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +1 -3
  78. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
  79. package/dist/mcp-server/tools/utils/toolDefinition.js +48 -1
  80. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
  81. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +46 -20
  82. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
  83. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +131 -25
  84. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
  85. package/dist/mcp-server/transports/ITransport.d.ts +2 -2
  86. package/dist/mcp-server/transports/ITransport.d.ts.map +1 -1
  87. package/dist/mcp-server/transports/auth/authFactory.js +1 -1
  88. package/dist/mcp-server/transports/auth/authFactory.js.map +1 -1
  89. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +1 -1
  90. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -1
  91. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -1
  92. package/dist/mcp-server/transports/auth/lib/authUtils.js +5 -13
  93. package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -1
  94. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +5 -11
  95. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -1
  96. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -1
  97. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +9 -22
  98. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -1
  99. package/dist/mcp-server/transports/heartbeat.d.ts.map +1 -1
  100. package/dist/mcp-server/transports/heartbeat.js +4 -8
  101. package/dist/mcp-server/transports/heartbeat.js.map +1 -1
  102. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -1
  103. package/dist/mcp-server/transports/http/httpErrorHandler.js +6 -24
  104. package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
  105. package/dist/mcp-server/transports/http/httpServer.d.ts +3 -3
  106. package/dist/mcp-server/transports/http/httpServer.d.ts.map +1 -1
  107. package/dist/mcp-server/transports/http/httpServer.js +15 -32
  108. package/dist/mcp-server/transports/http/httpServer.js.map +1 -1
  109. package/dist/mcp-server/transports/http/httpTransport.d.ts +25 -8
  110. package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
  111. package/dist/mcp-server/transports/http/httpTransport.js +156 -310
  112. package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
  113. package/dist/mcp-server/transports/http/landing-page/assets/styles.d.ts.map +1 -1
  114. package/dist/mcp-server/transports/http/landing-page/assets/styles.js +0 -1
  115. package/dist/mcp-server/transports/http/landing-page/assets/styles.js.map +1 -1
  116. package/dist/mcp-server/transports/http/landing-page/handler.d.ts.map +1 -1
  117. package/dist/mcp-server/transports/http/landing-page/handler.js +4 -8
  118. package/dist/mcp-server/transports/http/landing-page/handler.js.map +1 -1
  119. package/dist/mcp-server/transports/http/landing-page/sections/tools.js +0 -2
  120. package/dist/mcp-server/transports/http/landing-page/sections/tools.js.map +1 -1
  121. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -1
  122. package/dist/mcp-server/transports/http/protectedResourceMetadata.js +2 -6
  123. package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -1
  124. package/dist/mcp-server/transports/http/robotsTxt.js +2 -2
  125. package/dist/mcp-server/transports/http/robotsTxt.js.map +1 -1
  126. package/dist/mcp-server/transports/http/serverCard.d.ts.map +1 -1
  127. package/dist/mcp-server/transports/http/serverCard.js +2 -6
  128. package/dist/mcp-server/transports/http/serverCard.js.map +1 -1
  129. package/dist/mcp-server/transports/http/sessionStore.d.ts +48 -45
  130. package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -1
  131. package/dist/mcp-server/transports/http/sessionStore.js +141 -185
  132. package/dist/mcp-server/transports/http/sessionStore.js.map +1 -1
  133. package/dist/mcp-server/transports/manager.d.ts +12 -4
  134. package/dist/mcp-server/transports/manager.d.ts.map +1 -1
  135. package/dist/mcp-server/transports/manager.js +35 -33
  136. package/dist/mcp-server/transports/manager.js.map +1 -1
  137. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +24 -31
  138. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -1
  139. package/dist/mcp-server/transports/stdio/stdioTransport.js +23 -38
  140. package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -1
  141. package/dist/mcp-server/types.d.ts +25 -0
  142. package/dist/mcp-server/types.d.ts.map +1 -0
  143. package/dist/mcp-server/types.js +10 -0
  144. package/dist/mcp-server/types.js.map +1 -0
  145. package/dist/services/canvas/core/CanvasInstance.d.ts +2 -2
  146. package/dist/services/canvas/core/CanvasInstance.d.ts.map +1 -1
  147. package/dist/services/canvas/core/CanvasInstance.js.map +1 -1
  148. package/dist/services/canvas/core/CanvasRegistry.d.ts +4 -4
  149. package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
  150. package/dist/services/canvas/core/CanvasRegistry.js +8 -18
  151. package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
  152. package/dist/services/canvas/core/DataCanvas.d.ts +5 -5
  153. package/dist/services/canvas/core/DataCanvas.d.ts.map +1 -1
  154. package/dist/services/canvas/core/DataCanvas.js +2 -3
  155. package/dist/services/canvas/core/DataCanvas.js.map +1 -1
  156. package/dist/services/canvas/core/IDataCanvasProvider.d.ts +11 -11
  157. package/dist/services/canvas/core/IDataCanvasProvider.d.ts.map +1 -1
  158. package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts +11 -11
  159. package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
  160. package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +4 -10
  161. package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
  162. package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -1
  163. package/dist/services/llm/providers/openrouter.provider.js +2 -5
  164. package/dist/services/llm/providers/openrouter.provider.js.map +1 -1
  165. package/dist/services/mirror/core/defineMirror.js +1 -1
  166. package/dist/services/mirror/core/defineMirror.js.map +1 -1
  167. package/dist/services/mirror/types.d.ts +5 -5
  168. package/dist/services/mirror/types.d.ts.map +1 -1
  169. package/dist/services/speech/providers/elevenlabs.provider.js +1 -1
  170. package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -1
  171. package/dist/services/speech/providers/whisper.provider.js +1 -1
  172. package/dist/services/speech/providers/whisper.provider.js.map +1 -1
  173. package/dist/storage/core/StorageService.d.ts +1 -1
  174. package/dist/storage/core/StorageService.d.ts.map +1 -1
  175. package/dist/storage/core/StorageService.js +12 -20
  176. package/dist/storage/core/StorageService.js.map +1 -1
  177. package/dist/storage/core/storageFactory.d.ts.map +1 -1
  178. package/dist/storage/core/storageFactory.js.map +1 -1
  179. package/dist/storage/core/storageValidation.d.ts +1 -1
  180. package/dist/storage/core/storageValidation.d.ts.map +1 -1
  181. package/dist/storage/core/storageValidation.js +2 -2
  182. package/dist/storage/core/storageValidation.js.map +1 -1
  183. package/dist/storage/providers/cloudflare/d1Provider.d.ts +1 -1
  184. package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -1
  185. package/dist/storage/providers/cloudflare/d1Provider.js +4 -12
  186. package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -1
  187. package/dist/storage/providers/cloudflare/kvProvider.d.ts +1 -1
  188. package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -1
  189. package/dist/storage/providers/cloudflare/kvProvider.js +3 -8
  190. package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -1
  191. package/dist/storage/providers/cloudflare/r2Provider.d.ts +1 -1
  192. package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -1
  193. package/dist/storage/providers/cloudflare/r2Provider.js +3 -8
  194. package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -1
  195. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +1 -1
  196. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
  197. package/dist/storage/providers/inMemory/inMemoryProvider.js +2 -4
  198. package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
  199. package/dist/testing/index.d.ts +35 -12
  200. package/dist/testing/index.d.ts.map +1 -1
  201. package/dist/testing/index.js +53 -38
  202. package/dist/testing/index.js.map +1 -1
  203. package/dist/testing/vitest.d.ts +1 -1
  204. package/dist/testing/vitest.d.ts.map +1 -1
  205. package/dist/types-global/errors.d.ts +28 -15
  206. package/dist/types-global/errors.d.ts.map +1 -1
  207. package/dist/types-global/errors.js +8 -1
  208. package/dist/types-global/errors.js.map +1 -1
  209. package/dist/utils/formatting/diffFormatter.d.ts +5 -5
  210. package/dist/utils/formatting/diffFormatter.d.ts.map +1 -1
  211. package/dist/utils/formatting/diffFormatter.js +7 -20
  212. package/dist/utils/formatting/diffFormatter.js.map +1 -1
  213. package/dist/utils/formatting/tableFormatter.d.ts +3 -3
  214. package/dist/utils/formatting/tableFormatter.d.ts.map +1 -1
  215. package/dist/utils/formatting/tableFormatter.js +6 -17
  216. package/dist/utils/formatting/tableFormatter.js.map +1 -1
  217. package/dist/utils/formatting/treeFormatter.d.ts +3 -3
  218. package/dist/utils/formatting/treeFormatter.d.ts.map +1 -1
  219. package/dist/utils/formatting/treeFormatter.js +5 -18
  220. package/dist/utils/formatting/treeFormatter.js.map +1 -1
  221. package/dist/utils/index.d.ts +4 -2
  222. package/dist/utils/index.d.ts.map +1 -1
  223. package/dist/utils/index.js +2 -2
  224. package/dist/utils/index.js.map +1 -1
  225. package/dist/utils/internal/error-handler/errorHandler.d.ts +1 -1
  226. package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
  227. package/dist/utils/internal/error-handler/errorHandler.js +23 -11
  228. package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
  229. package/dist/utils/internal/error-handler/types.d.ts +10 -13
  230. package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
  231. package/dist/utils/internal/logger.d.ts +3 -3
  232. package/dist/utils/internal/logger.d.ts.map +1 -1
  233. package/dist/utils/internal/logger.js +11 -5
  234. package/dist/utils/internal/logger.js.map +1 -1
  235. package/dist/utils/internal/performance.d.ts +1 -1
  236. package/dist/utils/internal/performance.d.ts.map +1 -1
  237. package/dist/utils/internal/performance.js +57 -13
  238. package/dist/utils/internal/performance.js.map +1 -1
  239. package/dist/utils/internal/requestContext.d.ts +79 -55
  240. package/dist/utils/internal/requestContext.d.ts.map +1 -1
  241. package/dist/utils/internal/requestContext.js +77 -32
  242. package/dist/utils/internal/requestContext.js.map +1 -1
  243. package/dist/utils/metrics/tokenCounter.d.ts +3 -3
  244. package/dist/utils/metrics/tokenCounter.d.ts.map +1 -1
  245. package/dist/utils/metrics/tokenCounter.js.map +1 -1
  246. package/dist/utils/network/fetchWithTimeout.d.ts +2 -2
  247. package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
  248. package/dist/utils/network/fetchWithTimeout.js +8 -24
  249. package/dist/utils/network/fetchWithTimeout.js.map +1 -1
  250. package/dist/utils/network/retry.d.ts +2 -2
  251. package/dist/utils/network/retry.d.ts.map +1 -1
  252. package/dist/utils/overflow/outlineOnOverflow.d.ts +1 -1
  253. package/dist/utils/overflow/outlineOnOverflow.d.ts.map +1 -1
  254. package/dist/utils/pagination/pagination.d.ts +3 -3
  255. package/dist/utils/pagination/pagination.d.ts.map +1 -1
  256. package/dist/utils/pagination/pagination.js +3 -3
  257. package/dist/utils/pagination/pagination.js.map +1 -1
  258. package/dist/utils/parsing/csvParser.d.ts +2 -2
  259. package/dist/utils/parsing/csvParser.d.ts.map +1 -1
  260. package/dist/utils/parsing/csvParser.js +4 -8
  261. package/dist/utils/parsing/csvParser.js.map +1 -1
  262. package/dist/utils/parsing/dateParser.d.ts +3 -3
  263. package/dist/utils/parsing/dateParser.d.ts.map +1 -1
  264. package/dist/utils/parsing/dateParser.js +3 -2
  265. package/dist/utils/parsing/dateParser.js.map +1 -1
  266. package/dist/utils/parsing/frontmatterParser.d.ts +2 -2
  267. package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -1
  268. package/dist/utils/parsing/frontmatterParser.js +7 -10
  269. package/dist/utils/parsing/frontmatterParser.js.map +1 -1
  270. package/dist/utils/parsing/htmlExtractor.d.ts +2 -2
  271. package/dist/utils/parsing/htmlExtractor.d.ts.map +1 -1
  272. package/dist/utils/parsing/htmlExtractor.js +6 -11
  273. package/dist/utils/parsing/htmlExtractor.js.map +1 -1
  274. package/dist/utils/parsing/jsonParser.d.ts +2 -2
  275. package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
  276. package/dist/utils/parsing/jsonParser.js +4 -8
  277. package/dist/utils/parsing/jsonParser.js.map +1 -1
  278. package/dist/utils/parsing/pdfParser.d.ts +10 -10
  279. package/dist/utils/parsing/pdfParser.d.ts.map +1 -1
  280. package/dist/utils/parsing/pdfParser.js +26 -89
  281. package/dist/utils/parsing/pdfParser.js.map +1 -1
  282. package/dist/utils/parsing/xmlParser.d.ts +2 -2
  283. package/dist/utils/parsing/xmlParser.d.ts.map +1 -1
  284. package/dist/utils/parsing/xmlParser.js +4 -8
  285. package/dist/utils/parsing/xmlParser.js.map +1 -1
  286. package/dist/utils/parsing/yamlParser.d.ts +2 -2
  287. package/dist/utils/parsing/yamlParser.d.ts.map +1 -1
  288. package/dist/utils/parsing/yamlParser.js +4 -8
  289. package/dist/utils/parsing/yamlParser.js.map +1 -1
  290. package/dist/utils/scheduling/scheduler.d.ts.map +1 -1
  291. package/dist/utils/scheduling/scheduler.js +5 -6
  292. package/dist/utils/scheduling/scheduler.js.map +1 -1
  293. package/dist/utils/security/rateLimiter.d.ts +2 -2
  294. package/dist/utils/security/rateLimiter.d.ts.map +1 -1
  295. package/dist/utils/security/rateLimiter.js +1 -1
  296. package/dist/utils/security/rateLimiter.js.map +1 -1
  297. package/dist/utils/telemetry/attributes.d.ts +23 -7
  298. package/dist/utils/telemetry/attributes.d.ts.map +1 -1
  299. package/dist/utils/telemetry/attributes.js +23 -10
  300. package/dist/utils/telemetry/attributes.js.map +1 -1
  301. package/dist/utils/telemetry/trace.d.ts +3 -3
  302. package/dist/utils/telemetry/trace.d.ts.map +1 -1
  303. package/dist/utils/telemetry/trace.js +4 -2
  304. package/dist/utils/telemetry/trace.js.map +1 -1
  305. package/package.json +22 -26
  306. package/scripts/lint-mcp.ts +1 -3
  307. package/scripts/lint-packaging.ts +1 -1
  308. package/skills/add-service/SKILL.md +2 -2
  309. package/skills/add-test/SKILL.md +42 -20
  310. package/skills/add-tool/SKILL.md +68 -19
  311. package/skills/api-canvas/SKILL.md +2 -2
  312. package/skills/api-config/SKILL.md +1 -11
  313. package/skills/api-context/SKILL.md +175 -111
  314. package/skills/api-linter/SKILL.md +2 -2
  315. package/skills/api-telemetry/SKILL.md +8 -12
  316. package/skills/api-testing/SKILL.md +53 -52
  317. package/skills/code-simplifier/SKILL.md +2 -2
  318. package/skills/design-mcp-server/SKILL.md +34 -18
  319. package/skills/field-test/SKILL.md +4 -2
  320. package/skills/git-wrapup/SKILL.md +3 -3
  321. package/skills/polish-docs-meta/SKILL.md +1 -1
  322. package/skills/polish-docs-meta/references/agent-protocol.md +2 -2
  323. package/skills/polish-docs-meta/references/readme.md +1 -1
  324. package/skills/release-and-publish/SKILL.md +3 -1
  325. package/skills/report-issue-framework/SKILL.md +2 -2
  326. package/skills/report-issue-local/SKILL.md +2 -2
  327. package/skills/security-pass/SKILL.md +16 -14
  328. package/templates/.github/CODE_OF_CONDUCT.md +28 -0
  329. package/templates/.github/CONTRIBUTING.md +50 -0
  330. package/templates/.github/SECURITY.md +24 -0
  331. package/templates/AGENTS.md +6 -6
  332. package/templates/CLAUDE.md +6 -6
  333. package/templates/changelog/template.md +55 -16
  334. package/templates/tests/resources/echo.resource.test.ts +16 -9
  335. package/dist/mcp-server/elicitation.d.ts +0 -64
  336. package/dist/mcp-server/elicitation.d.ts.map +0 -1
  337. package/dist/mcp-server/elicitation.js +0 -81
  338. package/dist/mcp-server/elicitation.js.map +0 -1
  339. package/dist/mcp-server/protocolSession.d.ts +0 -34
  340. package/dist/mcp-server/protocolSession.d.ts.map +0 -1
  341. package/dist/mcp-server/protocolSession.js +0 -13
  342. package/dist/mcp-server/protocolSession.js.map +0 -1
  343. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts +0 -53
  344. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts.map +0 -1
  345. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js +0 -65
  346. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js.map +0 -1
  347. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +0 -70
  348. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +0 -1
  349. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +0 -130
  350. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +0 -1
  351. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +0 -109
  352. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +0 -1
  353. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +0 -209
  354. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +0 -1
  355. package/dist/mcp-server/tasks/core/taskManager.d.ts +0 -91
  356. package/dist/mcp-server/tasks/core/taskManager.d.ts.map +0 -1
  357. package/dist/mcp-server/tasks/core/taskManager.js +0 -210
  358. package/dist/mcp-server/tasks/core/taskManager.js.map +0 -1
  359. package/dist/mcp-server/tasks/core/taskTypes.d.ts +0 -18
  360. package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +0 -1
  361. package/dist/mcp-server/tasks/core/taskTypes.js +0 -20
  362. package/dist/mcp-server/tasks/core/taskTypes.js.map +0 -1
  363. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +0 -101
  364. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +0 -1
  365. package/dist/mcp-server/tasks/utils/taskToolDefinition.js +0 -14
  366. package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +0 -1
@@ -1,28 +1,28 @@
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).
12
14
  *
13
15
  * @module src/mcp-server/notifications
14
16
  */
15
- import type { ServerNotification } from '@modelcontextprotocol/sdk/types.js';
17
+ import type { ServerNotification } from '@modelcontextprotocol/server';
16
18
  /**
17
- * The minimal shape we need off the SDK's `RequestHandlerExtra`. Typed with an
18
- * optional `sendNotification` (the SDK declares it required) so the runtime
19
- * presence check below is type-meaningful — mirroring how `wrapElicit` narrows
20
- * against a loose capability interface rather than the full extra. A non-request
21
- * scope (some test harnesses pass a bare `Request`) has no sender, and we fall
22
- * back to the server-level notifiers there.
19
+ * The slice of `ctx.mcpReq` these notifiers need. Typed with an optional
20
+ * `notify` so the runtime presence check is type-meaningful — a background or
21
+ * test scope may pass a stand-in without one, and callers fall back to the
22
+ * server-level notifiers there.
23
23
  */
24
24
  interface NotificationSender {
25
- sendNotification?: (notification: ServerNotification) => Promise<void>;
25
+ notify?: (notification: ServerNotification) => Promise<void>;
26
26
  }
27
27
  /** The four list-changed / resource-updated closures attached to a handler `ctx`. */
28
28
  export interface RequestScopedNotifiers {
@@ -31,25 +31,27 @@ export interface RequestScopedNotifiers {
31
31
  notifyResourceUpdated: (uri: string) => void;
32
32
  notifyToolListChanged: () => void;
33
33
  }
34
+ /** Per-connection subscription state consulted before a resource-updated emit. */
35
+ export interface ResourceSubscriptions {
36
+ /** True when the connected client subscribed to this exact URI. */
37
+ has: (uri: string) => boolean;
38
+ }
34
39
  /**
35
- * Builds notifier closures bound to a single request's `extra.sendNotification`.
36
- * The SDK stamps `relatedRequestId` onto these sends, so `@hono/mcp` routes them
37
- * to that request's SSE response stream — the delivery path the server-level
38
- * `server.send*ListChanged()` calls miss under the per-request McpServer model,
39
- * where they drop silently (#135).
40
+ * Builds notifier closures bound to a single request's `ctx.mcpReq.notify`.
40
41
  *
41
- * Returns `undefined` when the supplied extra exposes no sender; callers fall
42
- * back to the server-level notifiers in that case.
42
+ * Returns `undefined` when the supplied request scope exposes no sender;
43
+ * callers fall back to the server-level notifiers in that case.
43
44
  *
44
- * Fire-and-forget by contract (`() => void`): the underlying `sendNotification`
45
- * promise is not awaited — a notification that can't flush (client already gone,
46
- * response not upgraded to SSE) must not fail the handler. A flush failure is
47
- * logged at debug rather than swallowed silently.
45
+ * Fire-and-forget by contract (`() => void`): the underlying promise is not
46
+ * awaited — a notification that can't flush (client already gone, response not
47
+ * upgraded to SSE) must not fail the handler. A flush failure is logged at
48
+ * debug rather than swallowed silently.
48
49
  *
49
- * Handler-time only. A background task (auto-task handler, cron) has no request
50
- * scope; those paths keep the server-level notifiers, which deliver on stdio but
51
- * not under HTTP — the residual gap a session-scoped notification bus would close.
50
+ * @param mcpReq - The request scope from the SDK's `ServerContext`.
51
+ * @param subscriptions - Per-connection `resources/subscribe` registry. When
52
+ * supplied, `notifyResourceUpdated` emits only for subscribed URIs; when
53
+ * omitted (no subscription tracking available) every URI is emitted.
52
54
  */
53
- export declare function buildRequestScopedNotifiers(extra: NotificationSender): RequestScopedNotifiers | undefined;
55
+ export declare function buildRequestScopedNotifiers(mcpReq: NotificationSender, subscriptions?: ResourceSubscriptions): RequestScopedNotifiers | undefined;
54
56
  export {};
55
57
  //# sourceMappingURL=notifications.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/mcp-server/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E;;;;;;;GAOG;AACH,UAAU,kBAAkB;IAC1B,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAED,qFAAqF;AACrF,MAAM,WAAW,sBAAsB;IACrC,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,kBAAkB,GACxB,sBAAsB,GAAG,SAAS,CAmBpC"}
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/mcp-server/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIvE;;;;;GAKG;AACH,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED,qFAAqF;AACrF,MAAM,WAAW,sBAAsB;IACrC,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC;AAED,kFAAkF;AAClF,MAAM,WAAW,qBAAqB;IACpC,mEAAmE;IACnE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,kBAAkB,EAC1B,aAAa,CAAC,EAAE,qBAAqB,GACpC,sBAAsB,GAAG,SAAS,CA2BpC"}
@@ -1,41 +1,40 @@
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).
12
14
  *
13
15
  * @module src/mcp-server/notifications
14
16
  */
15
17
  import { logger } from '../utils/internal/logger.js';
16
18
  /**
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).
19
+ * Builds notifier closures bound to a single request's `ctx.mcpReq.notify`.
22
20
  *
23
- * Returns `undefined` when the supplied extra exposes no sender; callers fall
24
- * back to the server-level notifiers in that case.
21
+ * Returns `undefined` when the supplied request scope exposes no sender;
22
+ * callers fall back to the server-level notifiers in that case.
25
23
  *
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.
24
+ * Fire-and-forget by contract (`() => void`): the underlying promise is not
25
+ * awaited — a notification that can't flush (client already gone, response not
26
+ * upgraded to SSE) must not fail the handler. A flush failure is logged at
27
+ * debug rather than swallowed silently.
30
28
  *
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.
29
+ * @param mcpReq - The request scope from the SDK's `ServerContext`.
30
+ * @param subscriptions - Per-connection `resources/subscribe` registry. When
31
+ * supplied, `notifyResourceUpdated` emits only for subscribed URIs; when
32
+ * omitted (no subscription tracking available) every URI is emitted.
34
33
  */
35
- export function buildRequestScopedNotifiers(extra) {
36
- if (typeof extra.sendNotification !== 'function')
34
+ export function buildRequestScopedNotifiers(mcpReq, subscriptions) {
35
+ if (typeof mcpReq.notify !== 'function')
37
36
  return;
38
- const send = extra.sendNotification.bind(extra);
37
+ const send = mcpReq.notify.bind(mcpReq);
39
38
  const emit = (notification) => {
40
39
  void send(notification).catch((error) => {
41
40
  logger.debug(`Notification ${notification.method} not delivered: ${error instanceof Error ? error.message : String(error)}`);
@@ -45,7 +44,16 @@ export function buildRequestScopedNotifiers(extra) {
45
44
  notifyToolListChanged: () => emit({ method: 'notifications/tools/list_changed' }),
46
45
  notifyResourceListChanged: () => emit({ method: 'notifications/resources/list_changed' }),
47
46
  notifyPromptListChanged: () => emit({ method: 'notifications/prompts/list_changed' }),
48
- notifyResourceUpdated: (uri) => emit({ method: 'notifications/resources/updated', params: { uri } }),
47
+ notifyResourceUpdated: (uri) => {
48
+ // Spec: `notifications/resources/updated` SHOULD only be sent for a URI
49
+ // the client subscribed to. Emitting to a client that never subscribed is
50
+ // noise it has no handler for.
51
+ if (subscriptions && !subscriptions.has(uri)) {
52
+ logger.debug(`Resource update for ${uri} not sent: no active subscription.`);
53
+ return;
54
+ }
55
+ emit({ method: 'notifications/resources/updated', params: { uri } });
56
+ },
49
57
  };
50
58
  }
51
59
  //# 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,KAA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C,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,MAAM,EAAE,kCAAkC,EAAE,CAAC;QACjF,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,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,gDAAgD,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAM3E,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,IAAI,CAAC,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,CAAC,CAAC;QAEjF,sEAAsE;QACtE,wEAAwE;QACxE,6CAA6C;QAC5C,MAAoD,CAAC,wBAAwB,EAAE,CAAC;QAEjF,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,UAAU,CAAC,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC;IAC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C,IAAI,EAAE,EAC1C,aAAa,CACd,CAAC;oBACF,OAAO,EAAE,QAAQ,EAAE,CAAC;gBACtB,CAAC;gBAAC,OAAO,KAAc,EAAE,CAAC;oBACxB,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;wBAC9C,SAAS,EAAE,UAAU,SAAS,CAAC,IAAI,EAAE;wBACrC,OAAO;qBACR,CAAC,CAAC;oBACH,MAAM,OAAO,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;0BA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AO,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"}
@@ -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,C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AC,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,mBAAmB,GAAG,gBAAgB,CAAC,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 } 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): 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,EAAE,KAAK,SAAS,EAAoB,MAAM,8BAA8B,CAAC;AAEhF,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,GACpC,OAAO,CAAC,IAAI,CAAC,CA2Bf;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) {
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,18 @@ 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 }),
44
38
  };
45
39
  const context = requestContextService.createRequestContext({
46
40
  operation: 'ResourceRegistry.registerAll',
47
41
  });
48
42
  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();
43
+ // `resources/list` and `resources/read` are installed by the SDK from the
44
+ // declared `resources` capability, so a server with no resources still
45
+ // answers `resources/list` with an empty array rather than `-32601`.
53
46
  for (const resourceDef of this.resourceDefs) {
54
47
  await this.registerResource(server, resourceDef, notifiers);
55
48
  }
@@ -88,10 +81,10 @@ export class ResourceRegistry {
88
81
  list: def.list,
89
82
  ...(def.complete && { complete: def.complete }),
90
83
  });
91
- server.resource(resourceName, template, metadata, handler);
84
+ server.registerResource(resourceName, template, metadata, handler);
92
85
  }
93
86
  else {
94
- server.resource(resourceName, def.uriTemplate, metadata, (uri, extra) => handler(uri, {}, extra));
87
+ server.registerResource(resourceName, def.uriTemplate, metadata, (uri, ctx) => handler(uri, {}, ctx));
95
88
  }
96
89
  logger.debug(`Resource '${resourceName}' registered successfully.`, registrationContext);
97
90
  }, {
@@ -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,SA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AAC;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"}
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,8BAA8B,CAAC;AAIhF,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;QAErC,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;Y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,GAAG,EAAE,GAAG,EAAE,EAAE,CAC5E,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CACtB,CAAC;YACJ,CAAC;YAED,MAAM,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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AA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,MAAM,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,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;;;;;;;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"}
@@ -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"}