@cyanheads/mcp-ts-core 0.11.5 → 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 (357) 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/dist/cli/init.js +1 -1
  7. package/dist/cli/init.js.map +1 -1
  8. package/dist/config/index.d.ts +0 -18
  9. package/dist/config/index.d.ts.map +1 -1
  10. package/dist/config/index.js +0 -25
  11. package/dist/config/index.js.map +1 -1
  12. package/dist/core/app.d.ts +5 -7
  13. package/dist/core/app.d.ts.map +1 -1
  14. package/dist/core/app.js +18 -27
  15. package/dist/core/app.js.map +1 -1
  16. package/dist/core/context.d.ts +90 -57
  17. package/dist/core/context.d.ts.map +1 -1
  18. package/dist/core/context.js +32 -33
  19. package/dist/core/context.js.map +1 -1
  20. package/dist/core/gcPressure.d.ts.map +1 -1
  21. package/dist/core/gcPressure.js +3 -4
  22. package/dist/core/gcPressure.js.map +1 -1
  23. package/dist/core/index.d.ts +6 -7
  24. package/dist/core/index.d.ts.map +1 -1
  25. package/dist/core/index.js +10 -2
  26. package/dist/core/index.js.map +1 -1
  27. package/dist/core/serverManifest.d.ts +1 -3
  28. package/dist/core/serverManifest.d.ts.map +1 -1
  29. package/dist/core/serverManifest.js +9 -4
  30. package/dist/core/serverManifest.js.map +1 -1
  31. package/dist/core/worker.d.ts.map +1 -1
  32. package/dist/core/worker.js +32 -35
  33. package/dist/core/worker.js.map +1 -1
  34. package/dist/logs/combined.log +10 -22
  35. package/dist/logs/error.log +6 -18
  36. package/dist/mcp-server/inputRequired.d.ts +52 -0
  37. package/dist/mcp-server/inputRequired.d.ts.map +1 -0
  38. package/dist/mcp-server/inputRequired.js +76 -0
  39. package/dist/mcp-server/inputRequired.js.map +1 -0
  40. package/dist/mcp-server/notifications.d.ts +33 -31
  41. package/dist/mcp-server/notifications.d.ts.map +1 -1
  42. package/dist/mcp-server/notifications.js +34 -26
  43. package/dist/mcp-server/notifications.js.map +1 -1
  44. package/dist/mcp-server/prompts/prompt-registration.d.ts +2 -2
  45. package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
  46. package/dist/mcp-server/prompts/prompt-registration.js +15 -5
  47. package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
  48. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +1 -1
  49. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -1
  50. package/dist/mcp-server/resources/resource-registration.d.ts +3 -3
  51. package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
  52. package/dist/mcp-server/resources/resource-registration.js +8 -15
  53. package/dist/mcp-server/resources/resource-registration.js.map +1 -1
  54. package/dist/mcp-server/resources/resourceSubscriptions.d.ts +45 -0
  55. package/dist/mcp-server/resources/resourceSubscriptions.d.ts.map +1 -0
  56. package/dist/mcp-server/resources/resourceSubscriptions.js +51 -0
  57. package/dist/mcp-server/resources/resourceSubscriptions.js.map +1 -0
  58. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +3 -5
  59. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -1
  60. package/dist/mcp-server/resources/utils/resourceDefinition.js +1 -1
  61. package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -1
  62. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +8 -15
  63. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
  64. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +21 -22
  65. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
  66. package/dist/mcp-server/server.d.ts +12 -21
  67. package/dist/mcp-server/server.d.ts.map +1 -1
  68. package/dist/mcp-server/server.js +38 -28
  69. package/dist/mcp-server/server.js.map +1 -1
  70. package/dist/mcp-server/tools/tool-registration.d.ts +11 -33
  71. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
  72. package/dist/mcp-server/tools/tool-registration.js +17 -243
  73. package/dist/mcp-server/tools/tool-registration.js.map +1 -1
  74. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +1 -3
  75. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
  76. package/dist/mcp-server/tools/utils/toolDefinition.js +48 -1
  77. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
  78. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +46 -20
  79. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
  80. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +131 -25
  81. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
  82. package/dist/mcp-server/transports/ITransport.d.ts +2 -2
  83. package/dist/mcp-server/transports/ITransport.d.ts.map +1 -1
  84. package/dist/mcp-server/transports/auth/authFactory.js +1 -1
  85. package/dist/mcp-server/transports/auth/authFactory.js.map +1 -1
  86. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +1 -1
  87. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -1
  88. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -1
  89. package/dist/mcp-server/transports/auth/lib/authUtils.js +5 -13
  90. package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -1
  91. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +5 -11
  92. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -1
  93. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -1
  94. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +9 -22
  95. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -1
  96. package/dist/mcp-server/transports/heartbeat.d.ts.map +1 -1
  97. package/dist/mcp-server/transports/heartbeat.js +4 -8
  98. package/dist/mcp-server/transports/heartbeat.js.map +1 -1
  99. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -1
  100. package/dist/mcp-server/transports/http/httpErrorHandler.js +6 -24
  101. package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
  102. package/dist/mcp-server/transports/http/httpServer.d.ts +3 -3
  103. package/dist/mcp-server/transports/http/httpServer.d.ts.map +1 -1
  104. package/dist/mcp-server/transports/http/httpServer.js +15 -32
  105. package/dist/mcp-server/transports/http/httpServer.js.map +1 -1
  106. package/dist/mcp-server/transports/http/httpTransport.d.ts +25 -8
  107. package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
  108. package/dist/mcp-server/transports/http/httpTransport.js +156 -373
  109. package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
  110. package/dist/mcp-server/transports/http/landing-page/assets/styles.d.ts.map +1 -1
  111. package/dist/mcp-server/transports/http/landing-page/assets/styles.js +0 -1
  112. package/dist/mcp-server/transports/http/landing-page/assets/styles.js.map +1 -1
  113. package/dist/mcp-server/transports/http/landing-page/handler.d.ts.map +1 -1
  114. package/dist/mcp-server/transports/http/landing-page/handler.js +4 -8
  115. package/dist/mcp-server/transports/http/landing-page/handler.js.map +1 -1
  116. package/dist/mcp-server/transports/http/landing-page/sections/tools.js +0 -2
  117. package/dist/mcp-server/transports/http/landing-page/sections/tools.js.map +1 -1
  118. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -1
  119. package/dist/mcp-server/transports/http/protectedResourceMetadata.js +2 -6
  120. package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -1
  121. package/dist/mcp-server/transports/http/robotsTxt.js +2 -2
  122. package/dist/mcp-server/transports/http/robotsTxt.js.map +1 -1
  123. package/dist/mcp-server/transports/http/serverCard.d.ts.map +1 -1
  124. package/dist/mcp-server/transports/http/serverCard.js +2 -6
  125. package/dist/mcp-server/transports/http/serverCard.js.map +1 -1
  126. package/dist/mcp-server/transports/http/sessionStore.d.ts +46 -66
  127. package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -1
  128. package/dist/mcp-server/transports/http/sessionStore.js +140 -238
  129. package/dist/mcp-server/transports/http/sessionStore.js.map +1 -1
  130. package/dist/mcp-server/transports/manager.d.ts +12 -4
  131. package/dist/mcp-server/transports/manager.d.ts.map +1 -1
  132. package/dist/mcp-server/transports/manager.js +35 -33
  133. package/dist/mcp-server/transports/manager.js.map +1 -1
  134. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +24 -31
  135. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -1
  136. package/dist/mcp-server/transports/stdio/stdioTransport.js +23 -38
  137. package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -1
  138. package/dist/mcp-server/types.d.ts +25 -0
  139. package/dist/mcp-server/types.d.ts.map +1 -0
  140. package/dist/mcp-server/types.js +10 -0
  141. package/dist/mcp-server/types.js.map +1 -0
  142. package/dist/services/canvas/core/CanvasInstance.d.ts +2 -2
  143. package/dist/services/canvas/core/CanvasInstance.d.ts.map +1 -1
  144. package/dist/services/canvas/core/CanvasInstance.js.map +1 -1
  145. package/dist/services/canvas/core/CanvasRegistry.d.ts +4 -4
  146. package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
  147. package/dist/services/canvas/core/CanvasRegistry.js +8 -18
  148. package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
  149. package/dist/services/canvas/core/DataCanvas.d.ts +5 -5
  150. package/dist/services/canvas/core/DataCanvas.d.ts.map +1 -1
  151. package/dist/services/canvas/core/DataCanvas.js +2 -3
  152. package/dist/services/canvas/core/DataCanvas.js.map +1 -1
  153. package/dist/services/canvas/core/IDataCanvasProvider.d.ts +11 -11
  154. package/dist/services/canvas/core/IDataCanvasProvider.d.ts.map +1 -1
  155. package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts +11 -11
  156. package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
  157. package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +4 -10
  158. package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
  159. package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -1
  160. package/dist/services/llm/providers/openrouter.provider.js +2 -5
  161. package/dist/services/llm/providers/openrouter.provider.js.map +1 -1
  162. package/dist/services/mirror/core/defineMirror.js +1 -1
  163. package/dist/services/mirror/core/defineMirror.js.map +1 -1
  164. package/dist/services/mirror/types.d.ts +5 -5
  165. package/dist/services/mirror/types.d.ts.map +1 -1
  166. package/dist/services/speech/providers/elevenlabs.provider.js +1 -1
  167. package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -1
  168. package/dist/services/speech/providers/whisper.provider.js +1 -1
  169. package/dist/services/speech/providers/whisper.provider.js.map +1 -1
  170. package/dist/storage/core/StorageService.d.ts +1 -1
  171. package/dist/storage/core/StorageService.d.ts.map +1 -1
  172. package/dist/storage/core/StorageService.js +12 -20
  173. package/dist/storage/core/StorageService.js.map +1 -1
  174. package/dist/storage/core/storageFactory.d.ts.map +1 -1
  175. package/dist/storage/core/storageFactory.js.map +1 -1
  176. package/dist/storage/core/storageValidation.d.ts +1 -1
  177. package/dist/storage/core/storageValidation.d.ts.map +1 -1
  178. package/dist/storage/core/storageValidation.js +2 -2
  179. package/dist/storage/core/storageValidation.js.map +1 -1
  180. package/dist/storage/providers/cloudflare/d1Provider.d.ts +1 -1
  181. package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -1
  182. package/dist/storage/providers/cloudflare/d1Provider.js +4 -12
  183. package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -1
  184. package/dist/storage/providers/cloudflare/kvProvider.d.ts +1 -1
  185. package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -1
  186. package/dist/storage/providers/cloudflare/kvProvider.js +3 -8
  187. package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -1
  188. package/dist/storage/providers/cloudflare/r2Provider.d.ts +1 -1
  189. package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -1
  190. package/dist/storage/providers/cloudflare/r2Provider.js +3 -8
  191. package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -1
  192. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +1 -1
  193. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
  194. package/dist/storage/providers/inMemory/inMemoryProvider.js +2 -4
  195. package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
  196. package/dist/testing/index.d.ts +35 -12
  197. package/dist/testing/index.d.ts.map +1 -1
  198. package/dist/testing/index.js +53 -38
  199. package/dist/testing/index.js.map +1 -1
  200. package/dist/testing/vitest.d.ts +1 -1
  201. package/dist/testing/vitest.d.ts.map +1 -1
  202. package/dist/types-global/errors.d.ts +28 -15
  203. package/dist/types-global/errors.d.ts.map +1 -1
  204. package/dist/types-global/errors.js +8 -1
  205. package/dist/types-global/errors.js.map +1 -1
  206. package/dist/utils/formatting/diffFormatter.d.ts +5 -5
  207. package/dist/utils/formatting/diffFormatter.d.ts.map +1 -1
  208. package/dist/utils/formatting/diffFormatter.js +7 -20
  209. package/dist/utils/formatting/diffFormatter.js.map +1 -1
  210. package/dist/utils/formatting/tableFormatter.d.ts +3 -3
  211. package/dist/utils/formatting/tableFormatter.d.ts.map +1 -1
  212. package/dist/utils/formatting/tableFormatter.js +6 -17
  213. package/dist/utils/formatting/tableFormatter.js.map +1 -1
  214. package/dist/utils/formatting/treeFormatter.d.ts +3 -3
  215. package/dist/utils/formatting/treeFormatter.d.ts.map +1 -1
  216. package/dist/utils/formatting/treeFormatter.js +5 -18
  217. package/dist/utils/formatting/treeFormatter.js.map +1 -1
  218. package/dist/utils/index.d.ts +4 -2
  219. package/dist/utils/index.d.ts.map +1 -1
  220. package/dist/utils/index.js +2 -2
  221. package/dist/utils/index.js.map +1 -1
  222. package/dist/utils/internal/error-handler/errorHandler.d.ts +1 -1
  223. package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
  224. package/dist/utils/internal/error-handler/errorHandler.js +23 -11
  225. package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
  226. package/dist/utils/internal/error-handler/types.d.ts +10 -13
  227. package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
  228. package/dist/utils/internal/logger.d.ts +3 -3
  229. package/dist/utils/internal/logger.d.ts.map +1 -1
  230. package/dist/utils/internal/logger.js +11 -5
  231. package/dist/utils/internal/logger.js.map +1 -1
  232. package/dist/utils/internal/performance.d.ts +1 -1
  233. package/dist/utils/internal/performance.d.ts.map +1 -1
  234. package/dist/utils/internal/performance.js +57 -13
  235. package/dist/utils/internal/performance.js.map +1 -1
  236. package/dist/utils/internal/requestContext.d.ts +79 -55
  237. package/dist/utils/internal/requestContext.d.ts.map +1 -1
  238. package/dist/utils/internal/requestContext.js +77 -32
  239. package/dist/utils/internal/requestContext.js.map +1 -1
  240. package/dist/utils/metrics/tokenCounter.d.ts +3 -3
  241. package/dist/utils/metrics/tokenCounter.d.ts.map +1 -1
  242. package/dist/utils/metrics/tokenCounter.js.map +1 -1
  243. package/dist/utils/network/fetchWithTimeout.d.ts +2 -2
  244. package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
  245. package/dist/utils/network/fetchWithTimeout.js +8 -24
  246. package/dist/utils/network/fetchWithTimeout.js.map +1 -1
  247. package/dist/utils/network/retry.d.ts +2 -2
  248. package/dist/utils/network/retry.d.ts.map +1 -1
  249. package/dist/utils/overflow/outlineOnOverflow.d.ts +1 -1
  250. package/dist/utils/overflow/outlineOnOverflow.d.ts.map +1 -1
  251. package/dist/utils/pagination/pagination.d.ts +3 -3
  252. package/dist/utils/pagination/pagination.d.ts.map +1 -1
  253. package/dist/utils/pagination/pagination.js +3 -3
  254. package/dist/utils/pagination/pagination.js.map +1 -1
  255. package/dist/utils/parsing/csvParser.d.ts +2 -2
  256. package/dist/utils/parsing/csvParser.d.ts.map +1 -1
  257. package/dist/utils/parsing/csvParser.js +4 -8
  258. package/dist/utils/parsing/csvParser.js.map +1 -1
  259. package/dist/utils/parsing/dateParser.d.ts +3 -3
  260. package/dist/utils/parsing/dateParser.d.ts.map +1 -1
  261. package/dist/utils/parsing/dateParser.js +3 -2
  262. package/dist/utils/parsing/dateParser.js.map +1 -1
  263. package/dist/utils/parsing/frontmatterParser.d.ts +2 -2
  264. package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -1
  265. package/dist/utils/parsing/frontmatterParser.js +7 -10
  266. package/dist/utils/parsing/frontmatterParser.js.map +1 -1
  267. package/dist/utils/parsing/htmlExtractor.d.ts +2 -2
  268. package/dist/utils/parsing/htmlExtractor.d.ts.map +1 -1
  269. package/dist/utils/parsing/htmlExtractor.js +6 -11
  270. package/dist/utils/parsing/htmlExtractor.js.map +1 -1
  271. package/dist/utils/parsing/jsonParser.d.ts +2 -2
  272. package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
  273. package/dist/utils/parsing/jsonParser.js +4 -8
  274. package/dist/utils/parsing/jsonParser.js.map +1 -1
  275. package/dist/utils/parsing/pdfParser.d.ts +10 -10
  276. package/dist/utils/parsing/pdfParser.d.ts.map +1 -1
  277. package/dist/utils/parsing/pdfParser.js +26 -89
  278. package/dist/utils/parsing/pdfParser.js.map +1 -1
  279. package/dist/utils/parsing/xmlParser.d.ts +2 -2
  280. package/dist/utils/parsing/xmlParser.d.ts.map +1 -1
  281. package/dist/utils/parsing/xmlParser.js +4 -8
  282. package/dist/utils/parsing/xmlParser.js.map +1 -1
  283. package/dist/utils/parsing/yamlParser.d.ts +2 -2
  284. package/dist/utils/parsing/yamlParser.d.ts.map +1 -1
  285. package/dist/utils/parsing/yamlParser.js +4 -8
  286. package/dist/utils/parsing/yamlParser.js.map +1 -1
  287. package/dist/utils/scheduling/scheduler.d.ts.map +1 -1
  288. package/dist/utils/scheduling/scheduler.js +5 -6
  289. package/dist/utils/scheduling/scheduler.js.map +1 -1
  290. package/dist/utils/security/rateLimiter.d.ts +2 -2
  291. package/dist/utils/security/rateLimiter.d.ts.map +1 -1
  292. package/dist/utils/security/rateLimiter.js +1 -1
  293. package/dist/utils/security/rateLimiter.js.map +1 -1
  294. package/dist/utils/telemetry/attributes.d.ts +23 -7
  295. package/dist/utils/telemetry/attributes.d.ts.map +1 -1
  296. package/dist/utils/telemetry/attributes.js +23 -10
  297. package/dist/utils/telemetry/attributes.js.map +1 -1
  298. package/dist/utils/telemetry/trace.d.ts +3 -3
  299. package/dist/utils/telemetry/trace.d.ts.map +1 -1
  300. package/dist/utils/telemetry/trace.js +4 -2
  301. package/dist/utils/telemetry/trace.js.map +1 -1
  302. package/package.json +22 -26
  303. package/scripts/lint-mcp.ts +1 -3
  304. package/scripts/lint-packaging.ts +1 -1
  305. package/skills/add-service/SKILL.md +2 -2
  306. package/skills/add-test/SKILL.md +42 -20
  307. package/skills/add-tool/SKILL.md +68 -19
  308. package/skills/api-config/SKILL.md +1 -11
  309. package/skills/api-context/SKILL.md +175 -111
  310. package/skills/api-linter/SKILL.md +2 -2
  311. package/skills/api-telemetry/SKILL.md +8 -12
  312. package/skills/api-testing/SKILL.md +53 -52
  313. package/skills/code-simplifier/SKILL.md +2 -2
  314. package/skills/design-mcp-server/SKILL.md +31 -17
  315. package/skills/field-test/SKILL.md +4 -2
  316. package/skills/polish-docs-meta/SKILL.md +1 -1
  317. package/skills/polish-docs-meta/references/agent-protocol.md +2 -2
  318. package/skills/polish-docs-meta/references/readme.md +1 -1
  319. package/skills/release-and-publish/SKILL.md +3 -1
  320. package/skills/report-issue-framework/SKILL.md +2 -2
  321. package/skills/report-issue-local/SKILL.md +2 -2
  322. package/skills/security-pass/SKILL.md +16 -14
  323. package/templates/AGENTS.md +6 -6
  324. package/templates/CLAUDE.md +6 -6
  325. package/templates/tests/resources/echo.resource.test.ts +16 -9
  326. package/dist/mcp-server/elicitation.d.ts +0 -64
  327. package/dist/mcp-server/elicitation.d.ts.map +0 -1
  328. package/dist/mcp-server/elicitation.js +0 -81
  329. package/dist/mcp-server/elicitation.js.map +0 -1
  330. package/dist/mcp-server/protocolSession.d.ts +0 -34
  331. package/dist/mcp-server/protocolSession.d.ts.map +0 -1
  332. package/dist/mcp-server/protocolSession.js +0 -13
  333. package/dist/mcp-server/protocolSession.js.map +0 -1
  334. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts +0 -53
  335. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts.map +0 -1
  336. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js +0 -65
  337. package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js.map +0 -1
  338. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +0 -70
  339. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +0 -1
  340. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +0 -130
  341. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +0 -1
  342. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +0 -109
  343. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +0 -1
  344. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +0 -209
  345. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +0 -1
  346. package/dist/mcp-server/tasks/core/taskManager.d.ts +0 -91
  347. package/dist/mcp-server/tasks/core/taskManager.d.ts.map +0 -1
  348. package/dist/mcp-server/tasks/core/taskManager.js +0 -210
  349. package/dist/mcp-server/tasks/core/taskManager.js.map +0 -1
  350. package/dist/mcp-server/tasks/core/taskTypes.d.ts +0 -18
  351. package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +0 -1
  352. package/dist/mcp-server/tasks/core/taskTypes.js +0 -20
  353. package/dist/mcp-server/tasks/core/taskTypes.js.map +0 -1
  354. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +0 -101
  355. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +0 -1
  356. package/dist/mcp-server/tasks/utils/taskToolDefinition.js +0 -14
  357. package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +0 -1
@@ -36,9 +36,13 @@ export interface AuthContext {
36
36
  /**
37
37
  * Core context object associated with a single request or operation.
38
38
  *
39
- * Every handler invocation receives a `RequestContext` (wrapped in `Context`).
40
- * It is the authoritative source for log correlation (`requestId`, `traceId`,
41
- * `spanId`), multi-tenancy isolation (`tenantId`), and auth (`auth`).
39
+ * The one canonical request-shape type. Handler-facing `Context` extends it, so
40
+ * a handler's `ctx` is accepted anywhere a `RequestContext` is — services,
41
+ * storage, the logger — with no slice helper and no index-signature gymnastics.
42
+ *
43
+ * Closed by design: a misspelled canonical field (`tenatId`) is a type error
44
+ * rather than a silently-ignored key. Operation-specific data goes in
45
+ * {@link RequestContext.extra}, the one place that is explicitly an open bag.
42
46
  *
43
47
  * Optional fields (`traceId`, `spanId`) are injected automatically when an
44
48
  * OpenTelemetry active span exists at context-creation time.
@@ -55,12 +59,33 @@ export interface RequestContext {
55
59
  * `undefined` when the request is unauthenticated or auth mode is `none`.
56
60
  */
57
61
  auth?: AuthContext | undefined;
62
+ /**
63
+ * Operation-specific correlation data — tool name, resource URI, retry
64
+ * attempt, whatever the call site wants carried alongside the canonical
65
+ * fields. Flattened into every log line written with this context, so the
66
+ * emitted shape is the same as the pre-0.12 open-bag spread.
67
+ *
68
+ * Add to it with {@link withExtra} rather than by hand: that merges into any
69
+ * value a parent context already carried instead of replacing it.
70
+ */
71
+ extra?: Readonly<Record<string, unknown>> | undefined;
72
+ /**
73
+ * Human-readable label for the operation this context belongs to. Set from
74
+ * `createRequestContext({ operation })` and read by the storage layer's
75
+ * tenant assertion and the network helpers' error reporting.
76
+ */
77
+ operation?: string | undefined;
58
78
  /**
59
79
  * Unique identifier for this request, used to correlate log entries across
60
80
  * service boundaries. Inherited from a parent context when provided;
61
81
  * otherwise generated by {@link generateRequestContextId}.
62
82
  */
63
83
  requestId: string;
84
+ /**
85
+ * MCP session identifier, when the request carries a durable session.
86
+ * `undefined` for stdio and for stateless HTTP.
87
+ */
88
+ sessionId?: string | undefined;
64
89
  /**
65
90
  * OpenTelemetry span ID from the active span at context-creation time.
66
91
  * `undefined` when no active span exists.
@@ -69,7 +94,7 @@ export interface RequestContext {
69
94
  /**
70
95
  * Tenant identifier used for multi-tenancy data isolation.
71
96
  * Resolved in priority order: `additionalContext.tenantId` →
72
- * rest params → `parentContext.tenantId` → AsyncLocalStorage auth store.
97
+ * `tenantId` param → `parentContext.tenantId` → AsyncLocalStorage auth store.
73
98
  */
74
99
  tenantId?: string | undefined;
75
100
  /**
@@ -81,47 +106,49 @@ export interface RequestContext {
81
106
  * `undefined` when no active span exists.
82
107
  */
83
108
  traceId?: string | undefined;
84
- /**
85
- * Additional arbitrary key-value pairs for operation-specific context.
86
- * Consumers must type-check before accessing extended properties.
87
- *
88
- * Note: optional fields above are typed `?: T | undefined` (not just `?: T`)
89
- * so the handler-facing `Context` — which carries strict-optional fields
90
- * under `exactOptionalPropertyTypes` — is structurally assignable to
91
- * {@link RequestContextLike} (the closed canonical-field projection used by
92
- * service-layer signatures). `RequestContext` itself remains the open
93
- * "context bag" that the logger and `createRequestContext` build by spread.
94
- */
95
- [key: string]: unknown;
96
109
  }
97
110
  /**
98
- * Closed, canonical-field projection of {@link RequestContext} for service
99
- * signatures. The handler-facing `Context` carries strict-optional fields with
100
- * `| undefined` and lacks the `[key: string]: unknown` index signature, so it
101
- * is not assignable to `RequestContext` itself; this projection is what both
102
- * `Context` and `RequestContext` are structurally assignable to.
103
- *
104
- * Service and canvas method signatures accept `RequestContextLike` instead of
105
- * `RequestContext` so consumers can pass the handler `ctx` directly without a
106
- * slice helper. Internal context construction (`createRequestContext`,
107
- * `enriched` log dispatch) still produces `RequestContext`, preserving the
108
- * open-bag spread pattern.
111
+ * @deprecated Use {@link RequestContext}. It was the closed projection that
112
+ * existed only because `RequestContext` carried an index signature; now that
113
+ * the index signature is gone, `RequestContext` *is* the closed projection.
114
+ * Kept as an alias for one minor.
109
115
  */
110
- export type RequestContextLike = {
111
- auth?: AuthContext | undefined;
112
- requestId: string;
113
- spanId?: string | undefined;
114
- tenantId?: string | undefined;
115
- timestamp: string;
116
- traceId?: string | undefined;
117
- };
116
+ export type RequestContextLike = RequestContext;
117
+ /**
118
+ * Projects any context-shaped object down to the {@link RequestContext}
119
+ * contract, dropping every key the type does not declare.
120
+ *
121
+ * TypeScript cannot enforce this at the call site: excess-property checking
122
+ * applies to object *literals*, not to a variable, so a handler `ctx` — which
123
+ * carries live request machinery (`log`, `signal`, `state`) and, after a
124
+ * multi-round-trip round, the user-entered content in `inputs.responses` —
125
+ * satisfies a `RequestContext` parameter and arrives whole. Anything that
126
+ * serializes a caller-supplied context onto a wire or into a log must project
127
+ * first, or that payload rides along.
128
+ *
129
+ * Allowlist, not denylist: a field added to a handler context later is dropped
130
+ * by default rather than silently published.
131
+ */
132
+ export declare function toCanonicalContext(context: Readonly<Record<string, unknown>>): RequestContext;
133
+ /**
134
+ * Returns a copy of `context` with `fields` merged into its {@link
135
+ * RequestContext.extra} bag.
136
+ *
137
+ * Replaces the `{ ...context, someField }` spread the open-bag type used to
138
+ * allow. Merging rather than replacing means a child call site can add its own
139
+ * correlation data without dropping what a parent already attached.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * logger.warning('Retrying upstream call', withExtra(ctx, { attempt, url }));
144
+ * ```
145
+ */
146
+ export declare function withExtra(context: RequestContext, fields: Readonly<Record<string, unknown>>): RequestContext;
118
147
  /**
119
148
  * Parameters accepted by {@link requestContextService.createRequestContext}.
120
149
  *
121
- * Named fields (`parentContext`, `additionalContext`, `operation`) receive
122
- * special handling. All other properties are spread directly onto the resulting
123
- * {@link RequestContext} as-is, allowing ad-hoc context extension without
124
- * modifying this interface.
150
+ * Closed, like the context it builds. Operation-specific keys go in
151
+ * `additionalContext`, which lands on {@link RequestContext.extra}.
125
152
  *
126
153
  * @example
127
154
  * ```typescript
@@ -134,25 +161,23 @@ export type RequestContextLike = {
134
161
  */
135
162
  export interface CreateRequestContextParams {
136
163
  /**
137
- * Key-value pairs merged into the context after `parentContext` properties
138
- * but before `requestId`/`timestamp` are pinned. Takes precedence over
139
- * `parentContext` for overlapping keys. `requestId` and `timestamp` keys in
140
- * `additionalContext` are silently stripped to prevent overwrites.
164
+ * Operation-specific key-value pairs, merged into the new context's
165
+ * {@link RequestContext.extra} on top of whatever the parent carried.
141
166
  */
142
- additionalContext?: Record<string, unknown>;
167
+ additionalContext?: Readonly<Record<string, unknown>> | undefined;
143
168
  /**
144
169
  * Human-readable label for the operation creating this context.
145
170
  * Written onto the context as `context.operation` when provided.
146
171
  */
147
- operation?: string;
172
+ operation?: string | undefined;
148
173
  /**
149
174
  * Parent context whose properties are inherited as the base. When
150
175
  * `parentContext.requestId` is a non-empty string it is reused as-is,
151
176
  * preserving the same request ID across a call chain.
152
177
  */
153
- parentContext?: Record<string, unknown> | RequestContext | undefined;
154
- /** Any additional key-value pairs spread directly onto the resulting context. */
155
- [key: string]: unknown;
178
+ parentContext?: Partial<RequestContext> | undefined;
179
+ /** Explicit tenant, ranked below `additionalContext.tenantId`. */
180
+ tenantId?: string | undefined;
156
181
  }
157
182
  /**
158
183
  * Service for creating and enriching {@link RequestContext} instances.
@@ -182,12 +207,11 @@ export declare const requestContextService: {
182
207
  * Merge order (later entries win, except `requestId`/`timestamp` which are
183
208
  * always generated fresh or inherited):
184
209
  * 1. `parentContext` properties (base)
185
- * 2. Remaining spread params (everything in `params` except named fields)
186
- * 3. `additionalContext` properties (`requestId`/`timestamp` stripped)
187
- * 4. Resolved `requestId` and `timestamp` (canonical, never overwritten)
188
- * 5. Resolved `tenantId` (see priority order in {@link RequestContext.tenantId})
189
- * 6. `operation` (written as `context.operation` when provided)
190
- * 7. OTel `traceId`/`spanId` from the active span (when present)
210
+ * 2. Resolved `requestId` and `timestamp` (canonical, never overwritten)
211
+ * 3. `extra` — the parent's bag with `additionalContext` merged over it
212
+ * 4. Resolved `tenantId` (see priority order in {@link RequestContext.tenantId})
213
+ * 5. `operation` (written as `context.operation` when provided)
214
+ * 6. OTel `traceId`/`spanId` from the active span (when present)
191
215
  *
192
216
  * @param params - Context creation parameters. Defaults to `{}`.
193
217
  * @returns A fully constructed `RequestContext`.
@@ -228,6 +252,6 @@ export declare const requestContextService: {
228
252
  * // context now includes: { requestId, timestamp, tenantId, auth: {...}, ... }
229
253
  * ```
230
254
  */
231
- withAuthInfo(authInfo: AuthInfo, parentContext?: Record<string, unknown> | RequestContext): RequestContext;
255
+ withAuthInfo(authInfo: AuthInfo, parentContext?: Partial<RequestContext>): RequestContext;
232
256
  };
233
257
  //# sourceMappingURL=requestContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.d.ts","sourceRoot":"","sources":["../../../src/utils/internal/requestContext.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAc9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,2HAA2H;IAC3H,GAAG,EAAE,MAAM,CAAC;IACZ,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IAEtE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAA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AgB,SAAS,CACvB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,cAAc,CAEhB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAElE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEpD,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AA6HD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB;IA1IhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;kCAC0B,0BAA0B,GAAQ,cAAc;IAmD7E;;;;;;;;;;;;;;;;;;;;;OAqBG;2BACoB,QAAQ,kBAAkB,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc;CAoCzB,CAAC"}
@@ -10,7 +10,7 @@
10
10
  * - `requestId` is inherited from a parent context when provided, otherwise a
11
11
  * new unique ID is generated via {@link generateRequestContextId}.
12
12
  * - `tenantId` is resolved with the following priority (highest to lowest):
13
- * `additionalContext.tenantId` → spread rest params → `parentContext.tenantId`
13
+ * `additionalContext.tenantId` → the `tenantId` param → `parentContext.tenantId`
14
14
  * → AsyncLocalStorage auth store (`authContext`).
15
15
  * - OpenTelemetry `traceId` and `spanId` are automatically injected from the
16
16
  * active span when one exists.
@@ -33,6 +33,61 @@ function toAuthContext(info) {
33
33
  ...(info.token && { token: info.token }),
34
34
  };
35
35
  }
36
+ /**
37
+ * The complete key set of {@link RequestContext}. The type is closed, so this
38
+ * list is its runtime mirror — used by {@link toCanonicalContext} to project a
39
+ * wider object back down to the contract.
40
+ */
41
+ const CANONICAL_CONTEXT_KEYS = [
42
+ 'auth',
43
+ 'extra',
44
+ 'operation',
45
+ 'requestId',
46
+ 'sessionId',
47
+ 'spanId',
48
+ 'tenantId',
49
+ 'timestamp',
50
+ 'traceId',
51
+ ];
52
+ /**
53
+ * Projects any context-shaped object down to the {@link RequestContext}
54
+ * contract, dropping every key the type does not declare.
55
+ *
56
+ * TypeScript cannot enforce this at the call site: excess-property checking
57
+ * applies to object *literals*, not to a variable, so a handler `ctx` — which
58
+ * carries live request machinery (`log`, `signal`, `state`) and, after a
59
+ * multi-round-trip round, the user-entered content in `inputs.responses` —
60
+ * satisfies a `RequestContext` parameter and arrives whole. Anything that
61
+ * serializes a caller-supplied context onto a wire or into a log must project
62
+ * first, or that payload rides along.
63
+ *
64
+ * Allowlist, not denylist: a field added to a handler context later is dropped
65
+ * by default rather than silently published.
66
+ */
67
+ export function toCanonicalContext(context) {
68
+ const projected = {};
69
+ for (const key of CANONICAL_CONTEXT_KEYS) {
70
+ if (context[key] !== undefined)
71
+ projected[key] = context[key];
72
+ }
73
+ return projected;
74
+ }
75
+ /**
76
+ * Returns a copy of `context` with `fields` merged into its {@link
77
+ * RequestContext.extra} bag.
78
+ *
79
+ * Replaces the `{ ...context, someField }` spread the open-bag type used to
80
+ * allow. Merging rather than replacing means a child call site can add its own
81
+ * correlation data without dropping what a parent already attached.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * logger.warning('Retrying upstream call', withExtra(ctx, { attempt, url }));
86
+ * ```
87
+ */
88
+ export function withExtra(context, fields) {
89
+ return { ...context, extra: { ...context.extra, ...fields } };
90
+ }
36
91
  /**
37
92
  * Singleton-like service object for managing request context operations.
38
93
  * @private
@@ -45,12 +100,11 @@ const requestContextServiceInstance = {
45
100
  * Merge order (later entries win, except `requestId`/`timestamp` which are
46
101
  * always generated fresh or inherited):
47
102
  * 1. `parentContext` properties (base)
48
- * 2. Remaining spread params (everything in `params` except named fields)
49
- * 3. `additionalContext` properties (`requestId`/`timestamp` stripped)
50
- * 4. Resolved `requestId` and `timestamp` (canonical, never overwritten)
51
- * 5. Resolved `tenantId` (see priority order in {@link RequestContext.tenantId})
52
- * 6. `operation` (written as `context.operation` when provided)
53
- * 7. OTel `traceId`/`spanId` from the active span (when present)
103
+ * 2. Resolved `requestId` and `timestamp` (canonical, never overwritten)
104
+ * 3. `extra` — the parent's bag with `additionalContext` merged over it
105
+ * 4. Resolved `tenantId` (see priority order in {@link RequestContext.tenantId})
106
+ * 5. `operation` (written as `context.operation` when provided)
107
+ * 6. OTel `traceId`/`spanId` from the active span (when present)
54
108
  *
55
109
  * @param params - Context creation parameters. Defaults to `{}`.
56
110
  * @returns A fully constructed `RequestContext`.
@@ -69,8 +123,7 @@ const requestContextServiceInstance = {
69
123
  * ```
70
124
  */
71
125
  createRequestContext(params = {}) {
72
- const { parentContext, additionalContext, operation, ...rest } = params;
73
- const inheritedContext = parentContext && typeof parentContext === 'object' ? { ...parentContext } : {};
126
+ const { parentContext, additionalContext, operation, tenantId } = params;
74
127
  const authStore = alsAuthContext.getStore();
75
128
  const tenantIdFromAuth = authStore?.authInfo?.tenantId;
76
129
  // Bridge auth info from ALS into the context so ctx.auth is populated
@@ -78,25 +131,22 @@ const requestContextServiceInstance = {
78
131
  const authFromStore = authStore?.authInfo
79
132
  ? toAuthContext(authStore.authInfo)
80
133
  : undefined;
81
- const requestId = typeof inheritedContext.requestId === 'string' && inheritedContext.requestId
82
- ? inheritedContext.requestId
134
+ const requestId = parentContext?.requestId
135
+ ? parentContext.requestId
83
136
  : generateRequestContextId();
84
137
  const timestamp = new Date().toISOString();
85
- const extractTenantId = (obj) => obj != null && typeof obj.tenantId === 'string' ? obj.tenantId : undefined;
86
- const resolvedTenantId = extractTenantId(additionalContext) ??
87
- extractTenantId(rest) ??
88
- extractTenantId(inheritedContext) ??
89
- tenantIdFromAuth;
90
- // Strip system fields from additionalContext to prevent overwriting requestId/timestamp
91
- const { requestId: _r, timestamp: _t, ...safeAdditional } = additionalContext && typeof additionalContext === 'object' ? additionalContext : {};
138
+ const additionalTenantId = typeof additionalContext?.tenantId === 'string' ? additionalContext.tenantId : undefined;
139
+ const resolvedTenantId = additionalTenantId ?? tenantId ?? parentContext?.tenantId ?? tenantIdFromAuth;
140
+ const extra = parentContext?.extra || additionalContext
141
+ ? { ...parentContext?.extra, ...additionalContext }
142
+ : undefined;
92
143
  const context = {
93
- ...inheritedContext,
94
- ...rest, // Spread any other properties from the params object
95
- ...safeAdditional,
144
+ ...parentContext,
96
145
  requestId,
97
146
  timestamp,
147
+ ...(extra && { extra }),
98
148
  ...(resolvedTenantId ? { tenantId: resolvedTenantId } : {}),
99
- ...(operation && typeof operation === 'string' ? { operation } : {}),
149
+ ...(operation ? { operation } : {}),
100
150
  ...(authFromStore && { auth: authFromStore }),
101
151
  };
102
152
  // --- OpenTelemetry Integration ---
@@ -134,17 +184,12 @@ const requestContextServiceInstance = {
134
184
  * ```
135
185
  */
136
186
  withAuthInfo(authInfo, parentContext) {
137
- // Inherit the operation from parentContext when provided, so callers that
138
- // already established an operation name (e.g. 'AutoTaskHandler') keep it.
139
- const parentOp = parentContext && typeof parentContext.operation === 'string'
140
- ? parentContext.operation
141
- : undefined;
142
187
  const baseContext = this.createRequestContext({
143
- operation: parentOp ?? 'withAuthInfo',
144
- parentContext,
145
- additionalContext: {
146
- tenantId: authInfo.tenantId,
147
- },
188
+ // Inherit the operation from parentContext when provided, so callers that
189
+ // already established an operation name keep it.
190
+ operation: parentContext?.operation ?? 'withAuthInfo',
191
+ ...(parentContext && { parentContext }),
192
+ ...(authInfo.tenantId && { tenantId: authInfo.tenantId }),
148
193
  });
149
194
  return {
150
195
  ...baseContext,
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.js","sourceRoot":"","sources":["../../../src/utils/internal/requestContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,o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AAC;YACnC,GAAG,CAAC,aAAa,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;SAC9C,CAAC;QAEF,oCAAoC;QACpC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACzC,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;YAC/D,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;YAC7C,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;gBACtC,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;YACtC,CAAC;QACH,CAAC;QACD,wCAAwC;QAExC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,CAAC,QAAkB,EAAE,aAAuC;QACtE,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC;YAC5C,0EAA0E;YAC1E,iDAAiD;YACjD,SAAS,EAAE,aAAa,EAAE,SAAS,IAAI,cAAc;YACrD,GAAG,CAAC,aAAa,IAAI,EAAE,aAAa,EAAE,CAAC;YACvC,GAAG,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;SAC1D,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,WAAW;YACd,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC;SAC9B,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,6BAA6B,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { RequestContext, RequestContextLike } from '../../utils/internal/requestContext.js';
1
+ import type { RequestContext } from '../../utils/internal/requestContext.js';
2
2
  /**
3
3
  * Minimal chat message shape used for token counting, intentionally provider-agnostic.
4
4
  * Covers the common subset of OpenAI-style chat message fields without depending on
@@ -65,7 +65,7 @@ export interface ModelHeuristics {
65
65
  * const tokens = await countTokens('Hello, world!');
66
66
  * // Returns approximately 4 (13 chars / 4 charsPerToken, rounded up)
67
67
  */
68
- export declare function countTokens(text: string, context?: RequestContextLike | RequestContext, model?: string): Promise<number>;
68
+ export declare function countTokens(text: string, context?: RequestContext, model?: string): Promise<number>;
69
69
  /**
70
70
  * Estimates the total number of tokens for an array of chat messages using the same
71
71
  * heuristics as OpenAI's token-counting cookbook for gpt-4o-family models.
@@ -93,5 +93,5 @@ export declare function countTokens(text: string, context?: RequestContextLike |
93
93
  * { role: 'assistant', content: 'It is 4.' },
94
94
  * ]);
95
95
  */
96
- export declare function countChatTokens(messages: ReadonlyArray<ChatMessage>, context?: RequestContextLike | RequestContext, model?: string): Promise<number>;
96
+ export declare function countChatTokens(messages: ReadonlyArray<ChatMessage>, context?: RequestContext, model?: string): Promise<number>;
97
97
  //# sourceMappingURL=tokenCounter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokenCounter.d.ts","sourceRoot":"","sources":["../../../src/utils/metrics/tokenCounter.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7F;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IACtF,+FAA+F;IAC/F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,E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CAAC,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QAED,MAAM,IAAI,CAAC,CAAC,WAAW,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC,EACD;QACE,SAAS,EAAE,iBAAiB;QAC5B,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC;QAC3B,KAAK,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE;QACxC,SAAS,EAAE,gBAAgB,CAAC,aAAa;KAC1C,CACF,CAAC;AACJ,CAAC;AACD,wEAAwE;AACxE,4EAA4E"}
@@ -1,4 +1,4 @@
1
- import type { RequestContext, RequestContextLike } from '../../utils/internal/requestContext.js';
1
+ import { type RequestContext } from '../../utils/internal/requestContext.js';
2
2
  /** Eagerly creates the HTTP client duration histogram so the series exists from startup. */
3
3
  export declare function initHttpClientMetrics(): void;
4
4
  /**
@@ -152,5 +152,5 @@ export interface FetchWithTimeoutOptions extends Omit<RequestInit, 'signal'> {
152
152
  * );
153
153
  * ```
154
154
  */
155
- export declare function fetchWithTimeout(url: string | URL, timeoutMs: number, context: RequestContextLike | RequestContext, options?: FetchWithTimeoutOptions): Promise<Response>;
155
+ export declare function fetchWithTimeout(url: string | URL, timeoutMs: number, context: RequestContext, options?: FetchWithTimeoutOptions): Promise<Response>;
156
156
  //# sourceMappingURL=fetchWithTimeout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchWithTimeout.d.ts","sourceRoot":"","sources":["../../../src/utils/network/fetchWithTimeout.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AA8C7F,4FAA4F;AAC5F,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AA2BD;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC1E;;;;;;;;;OASG;IAC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AsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAwPnB"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { JsonRpcErrorCode, McpError, serviceUnavailable, timeout, validationError, } from '../../types-global/errors.js';
7
7
  import { logger } from '../../utils/internal/logger.js';
8
+ import { withExtra } from '../../utils/internal/requestContext.js';
8
9
  import { runtimeCaps } from '../../utils/internal/runtime.js';
9
10
  import { httpStatusToErrorCode } from '../../utils/network/httpError.js';
10
11
  import { readBoundedResponseText } from '../../utils/network/responseBody.js';
@@ -25,15 +26,6 @@ const ERROR_BODY_SCAN_LIMIT = 16_384;
25
26
  * exactly this set, so these responses are returned untouched.
26
27
  */
27
28
  const NULL_BODY_STATUS = new Set([204, 205, 304]);
28
- /**
29
- * Reads the optional `operation` label off a context argument. It is an ad-hoc
30
- * field of the `RequestContext` bag, absent from both `RequestContextLike` and
31
- * the handler-facing `Context`.
32
- */
33
- function contextOperation(context) {
34
- const operation = context.operation;
35
- return typeof operation === 'string' ? operation : undefined;
36
- }
37
29
  let clientDurationHistogram;
38
30
  function getHttpClientMetrics() {
39
31
  clientDurationHistogram ??= createHistogram('http.client.request.duration', 'Duration of outbound HTTP requests', 's');
@@ -477,23 +469,17 @@ export async function fetchWithTimeout(url, timeoutMs, context, options) {
477
469
  let deadlineFollowsBody = false;
478
470
  const errorIdentity = {
479
471
  requestId: context.requestId,
480
- operation: contextOperation(context),
472
+ operation: context.operation,
481
473
  };
482
474
  const timeoutFailure = () => {
483
- logger.error(`${operationDescription} timed out after ${timeoutMs}ms.`, {
484
- ...context,
485
- errorSource: 'FetchTimeout',
486
- });
475
+ logger.error(`${operationDescription} timed out after ${timeoutMs}ms.`, withExtra(context, { errorSource: 'FetchTimeout' }));
487
476
  return timeout(`${operationDescription} timed out.`, {
488
477
  ...errorIdentity,
489
478
  errorSource: 'FetchTimeout',
490
479
  });
491
480
  };
492
481
  const abortedFailure = () => {
493
- logger.info(`${operationDescription} aborted by caller.`, {
494
- ...context,
495
- errorSource: 'FetchAborted',
496
- });
482
+ logger.info(`${operationDescription} aborted by caller.`, withExtra(context, { errorSource: 'FetchAborted' }));
497
483
  return new McpError(JsonRpcErrorCode.InternalError, `${operationDescription} was aborted.`, {
498
484
  ...errorIdentity,
499
485
  errorSource: 'FetchAborted',
@@ -536,13 +522,12 @@ export async function fetchWithTimeout(url, timeoutMs, context, options) {
536
522
  // Callers that treat a status as expected (e.g. 404 → empty result) get a
537
523
  // debug line instead of error; the thrown McpError below is unchanged.
538
524
  const logMessage = `Fetch failed for ${redactUrl(currentUrl)} with status ${response.status}.`;
539
- const logPayload = {
540
- ...context,
525
+ const logPayload = withExtra(context, {
541
526
  statusCode: response.status,
542
527
  statusText: response.statusText,
543
528
  responseBody,
544
529
  errorSource: 'FetchHttpError',
545
- };
530
+ });
546
531
  if (expectedStatuses?.includes(response.status)) {
547
532
  logger.debug(logMessage, logPayload);
548
533
  }
@@ -614,11 +599,10 @@ export async function fetchWithTimeout(url, timeoutMs, context, options) {
614
599
  throw abortedFailure();
615
600
  }
616
601
  const errorMessage = error instanceof Error ? error.message : String(error);
617
- logger.error(`Network error during ${operationDescription}: ${errorMessage}`, {
618
- ...context,
602
+ logger.error(`Network error during ${operationDescription}: ${errorMessage}`, withExtra(context, {
619
603
  originalErrorName: error instanceof Error ? error.name : 'UnknownError',
620
604
  errorSource: 'FetchNetworkError',
621
- });
605
+ }));
622
606
  if (error instanceof McpError) {
623
607
  throw error;
624
608
  }