@cyanheads/mcp-ts-core 0.1.0-beta.12

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 (485) hide show
  1. package/CLAUDE.md +583 -0
  2. package/LICENSE +201 -0
  3. package/README.md +287 -0
  4. package/biome.json +103 -0
  5. package/dist/app.d.ts +82 -0
  6. package/dist/app.d.ts.map +1 -0
  7. package/dist/app.js +222 -0
  8. package/dist/app.js.map +1 -0
  9. package/dist/cli/init.d.ts +8 -0
  10. package/dist/cli/init.d.ts.map +1 -0
  11. package/dist/cli/init.js +161 -0
  12. package/dist/cli/init.js.map +1 -0
  13. package/dist/config/index.d.ts +349 -0
  14. package/dist/config/index.d.ts.map +1 -0
  15. package/dist/config/index.js +464 -0
  16. package/dist/config/index.js.map +1 -0
  17. package/dist/context.d.ts +119 -0
  18. package/dist/context.d.ts.map +1 -0
  19. package/dist/context.js +144 -0
  20. package/dist/context.js.map +1 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +9 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/mcp-server/prompts/prompt-registration.d.ts +33 -0
  26. package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -0
  27. package/dist/mcp-server/prompts/prompt-registration.js +91 -0
  28. package/dist/mcp-server/prompts/prompt-registration.js.map +1 -0
  29. package/dist/mcp-server/prompts/utils/newPromptDefinition.d.ts +49 -0
  30. package/dist/mcp-server/prompts/utils/newPromptDefinition.d.ts.map +1 -0
  31. package/dist/mcp-server/prompts/utils/newPromptDefinition.js +39 -0
  32. package/dist/mcp-server/prompts/utils/newPromptDefinition.js.map +1 -0
  33. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +37 -0
  34. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -0
  35. package/dist/mcp-server/prompts/utils/promptDefinition.js +2 -0
  36. package/dist/mcp-server/prompts/utils/promptDefinition.js.map +1 -0
  37. package/dist/mcp-server/resources/resource-registration.d.ts +27 -0
  38. package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -0
  39. package/dist/mcp-server/resources/resource-registration.js +85 -0
  40. package/dist/mcp-server/resources/resource-registration.js.map +1 -0
  41. package/dist/mcp-server/resources/utils/newResourceDefinition.d.ts +84 -0
  42. package/dist/mcp-server/resources/utils/newResourceDefinition.d.ts.map +1 -0
  43. package/dist/mcp-server/resources/utils/newResourceDefinition.js +40 -0
  44. package/dist/mcp-server/resources/utils/newResourceDefinition.js.map +1 -0
  45. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.d.ts +32 -0
  46. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.d.ts.map +1 -0
  47. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.js +103 -0
  48. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.js.map +1 -0
  49. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +94 -0
  50. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -0
  51. package/dist/mcp-server/resources/utils/resourceDefinition.js +2 -0
  52. package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -0
  53. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +14 -0
  54. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -0
  55. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +111 -0
  56. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -0
  57. package/dist/mcp-server/roots/roots-registration.d.ts +22 -0
  58. package/dist/mcp-server/roots/roots-registration.d.ts.map +1 -0
  59. package/dist/mcp-server/roots/roots-registration.js +25 -0
  60. package/dist/mcp-server/roots/roots-registration.js.map +1 -0
  61. package/dist/mcp-server/server.d.ts +34 -0
  62. package/dist/mcp-server/server.d.ts.map +1 -0
  63. package/dist/mcp-server/server.js +62 -0
  64. package/dist/mcp-server/server.js.map +1 -0
  65. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +42 -0
  66. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +1 -0
  67. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +70 -0
  68. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +1 -0
  69. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +109 -0
  70. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +1 -0
  71. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +209 -0
  72. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +1 -0
  73. package/dist/mcp-server/tasks/core/taskManager.d.ts +103 -0
  74. package/dist/mcp-server/tasks/core/taskManager.d.ts.map +1 -0
  75. package/dist/mcp-server/tasks/core/taskManager.js +144 -0
  76. package/dist/mcp-server/tasks/core/taskManager.js.map +1 -0
  77. package/dist/mcp-server/tasks/core/taskTypes.d.ts +11 -0
  78. package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +1 -0
  79. package/dist/mcp-server/tasks/core/taskTypes.js +13 -0
  80. package/dist/mcp-server/tasks/core/taskTypes.js.map +1 -0
  81. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +108 -0
  82. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +1 -0
  83. package/dist/mcp-server/tasks/utils/taskToolDefinition.js +14 -0
  84. package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +1 -0
  85. package/dist/mcp-server/tools/tool-registration.d.ts +49 -0
  86. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -0
  87. package/dist/mcp-server/tools/tool-registration.js +269 -0
  88. package/dist/mcp-server/tools/tool-registration.js.map +1 -0
  89. package/dist/mcp-server/tools/utils/newToolDefinition.d.ts +73 -0
  90. package/dist/mcp-server/tools/utils/newToolDefinition.d.ts.map +1 -0
  91. package/dist/mcp-server/tools/utils/newToolDefinition.js +45 -0
  92. package/dist/mcp-server/tools/utils/newToolDefinition.js.map +1 -0
  93. package/dist/mcp-server/tools/utils/newToolHandlerFactory.d.ts +33 -0
  94. package/dist/mcp-server/tools/utils/newToolHandlerFactory.d.ts.map +1 -0
  95. package/dist/mcp-server/tools/utils/newToolHandlerFactory.js +107 -0
  96. package/dist/mcp-server/tools/utils/newToolHandlerFactory.js.map +1 -0
  97. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +118 -0
  98. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -0
  99. package/dist/mcp-server/tools/utils/toolDefinition.js +2 -0
  100. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -0
  101. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +34 -0
  102. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -0
  103. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +68 -0
  104. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -0
  105. package/dist/mcp-server/transports/ITransport.d.ts +15 -0
  106. package/dist/mcp-server/transports/ITransport.d.ts.map +1 -0
  107. package/dist/mcp-server/transports/ITransport.js +2 -0
  108. package/dist/mcp-server/transports/ITransport.js.map +1 -0
  109. package/dist/mcp-server/transports/auth/authFactory.d.ts +11 -0
  110. package/dist/mcp-server/transports/auth/authFactory.d.ts.map +1 -0
  111. package/dist/mcp-server/transports/auth/authFactory.js +43 -0
  112. package/dist/mcp-server/transports/auth/authFactory.js.map +1 -0
  113. package/dist/mcp-server/transports/auth/authMiddleware.d.ts +24 -0
  114. package/dist/mcp-server/transports/auth/authMiddleware.d.ts.map +1 -0
  115. package/dist/mcp-server/transports/auth/authMiddleware.js +69 -0
  116. package/dist/mcp-server/transports/auth/authMiddleware.js.map +1 -0
  117. package/dist/mcp-server/transports/auth/lib/authContext.d.ts +34 -0
  118. package/dist/mcp-server/transports/auth/lib/authContext.d.ts.map +1 -0
  119. package/dist/mcp-server/transports/auth/lib/authContext.js +25 -0
  120. package/dist/mcp-server/transports/auth/lib/authContext.js.map +1 -0
  121. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +19 -0
  122. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -0
  123. package/dist/mcp-server/transports/auth/lib/authTypes.js +2 -0
  124. package/dist/mcp-server/transports/auth/lib/authTypes.js.map +1 -0
  125. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts +18 -0
  126. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -0
  127. package/dist/mcp-server/transports/auth/lib/authUtils.js +64 -0
  128. package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -0
  129. package/dist/mcp-server/transports/auth/lib/checkScopes.d.ts +25 -0
  130. package/dist/mcp-server/transports/auth/lib/checkScopes.d.ts.map +1 -0
  131. package/dist/mcp-server/transports/auth/lib/checkScopes.js +34 -0
  132. package/dist/mcp-server/transports/auth/lib/checkScopes.js.map +1 -0
  133. package/dist/mcp-server/transports/auth/lib/claimParser.d.ts +34 -0
  134. package/dist/mcp-server/transports/auth/lib/claimParser.d.ts.map +1 -0
  135. package/dist/mcp-server/transports/auth/lib/claimParser.js +58 -0
  136. package/dist/mcp-server/transports/auth/lib/claimParser.js.map +1 -0
  137. package/dist/mcp-server/transports/auth/lib/withAuth.d.ts +25 -0
  138. package/dist/mcp-server/transports/auth/lib/withAuth.d.ts.map +1 -0
  139. package/dist/mcp-server/transports/auth/lib/withAuth.js +30 -0
  140. package/dist/mcp-server/transports/auth/lib/withAuth.js.map +1 -0
  141. package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts +18 -0
  142. package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts.map +1 -0
  143. package/dist/mcp-server/transports/auth/strategies/authStrategy.js +2 -0
  144. package/dist/mcp-server/transports/auth/strategies/authStrategy.js.map +1 -0
  145. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts +14 -0
  146. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts.map +1 -0
  147. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +86 -0
  148. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -0
  149. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts +14 -0
  150. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -0
  151. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +113 -0
  152. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -0
  153. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts +25 -0
  154. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -0
  155. package/dist/mcp-server/transports/http/httpErrorHandler.js +112 -0
  156. package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -0
  157. package/dist/mcp-server/transports/http/httpTransport.d.ts +47 -0
  158. package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -0
  159. package/dist/mcp-server/transports/http/httpTransport.js +396 -0
  160. package/dist/mcp-server/transports/http/httpTransport.js.map +1 -0
  161. package/dist/mcp-server/transports/http/httpTypes.d.ts +17 -0
  162. package/dist/mcp-server/transports/http/httpTypes.d.ts.map +1 -0
  163. package/dist/mcp-server/transports/http/httpTypes.js +2 -0
  164. package/dist/mcp-server/transports/http/httpTypes.js.map +1 -0
  165. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts +21 -0
  166. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -0
  167. package/dist/mcp-server/transports/http/protectedResourceMetadata.js +44 -0
  168. package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -0
  169. package/dist/mcp-server/transports/http/sessionIdUtils.d.ts +33 -0
  170. package/dist/mcp-server/transports/http/sessionIdUtils.d.ts.map +1 -0
  171. package/dist/mcp-server/transports/http/sessionIdUtils.js +54 -0
  172. package/dist/mcp-server/transports/http/sessionIdUtils.js.map +1 -0
  173. package/dist/mcp-server/transports/http/sessionStore.d.ts +87 -0
  174. package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -0
  175. package/dist/mcp-server/transports/http/sessionStore.js +209 -0
  176. package/dist/mcp-server/transports/http/sessionStore.js.map +1 -0
  177. package/dist/mcp-server/transports/manager.d.ts +22 -0
  178. package/dist/mcp-server/transports/manager.d.ts.map +1 -0
  179. package/dist/mcp-server/transports/manager.js +62 -0
  180. package/dist/mcp-server/transports/manager.js.map +1 -0
  181. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +44 -0
  182. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -0
  183. package/dist/mcp-server/transports/stdio/stdioTransport.js +63 -0
  184. package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -0
  185. package/dist/services/graph/core/GraphService.d.ts +205 -0
  186. package/dist/services/graph/core/GraphService.d.ts.map +1 -0
  187. package/dist/services/graph/core/GraphService.js +231 -0
  188. package/dist/services/graph/core/GraphService.js.map +1 -0
  189. package/dist/services/graph/core/IGraphProvider.d.ts +295 -0
  190. package/dist/services/graph/core/IGraphProvider.d.ts.map +1 -0
  191. package/dist/services/graph/core/IGraphProvider.js +8 -0
  192. package/dist/services/graph/core/IGraphProvider.js.map +1 -0
  193. package/dist/services/graph/types.d.ts +107 -0
  194. package/dist/services/graph/types.d.ts.map +1 -0
  195. package/dist/services/graph/types.js +8 -0
  196. package/dist/services/graph/types.js.map +1 -0
  197. package/dist/services/llm/core/ILlmProvider.d.ts +86 -0
  198. package/dist/services/llm/core/ILlmProvider.d.ts.map +1 -0
  199. package/dist/services/llm/core/ILlmProvider.js +2 -0
  200. package/dist/services/llm/core/ILlmProvider.js.map +1 -0
  201. package/dist/services/llm/providers/openrouter.provider.d.ts +187 -0
  202. package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -0
  203. package/dist/services/llm/providers/openrouter.provider.js +302 -0
  204. package/dist/services/llm/providers/openrouter.provider.js.map +1 -0
  205. package/dist/services/llm/types.d.ts +16 -0
  206. package/dist/services/llm/types.d.ts.map +1 -0
  207. package/dist/services/llm/types.js +9 -0
  208. package/dist/services/llm/types.js.map +1 -0
  209. package/dist/services/speech/core/ISpeechProvider.d.ts +92 -0
  210. package/dist/services/speech/core/ISpeechProvider.d.ts.map +1 -0
  211. package/dist/services/speech/core/ISpeechProvider.js +34 -0
  212. package/dist/services/speech/core/ISpeechProvider.js.map +1 -0
  213. package/dist/services/speech/core/SpeechService.d.ts +87 -0
  214. package/dist/services/speech/core/SpeechService.d.ts.map +1 -0
  215. package/dist/services/speech/core/SpeechService.js +135 -0
  216. package/dist/services/speech/core/SpeechService.js.map +1 -0
  217. package/dist/services/speech/providers/elevenlabs.provider.d.ts +77 -0
  218. package/dist/services/speech/providers/elevenlabs.provider.d.ts.map +1 -0
  219. package/dist/services/speech/providers/elevenlabs.provider.js +199 -0
  220. package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -0
  221. package/dist/services/speech/providers/whisper.provider.d.ts +94 -0
  222. package/dist/services/speech/providers/whisper.provider.d.ts.map +1 -0
  223. package/dist/services/speech/providers/whisper.provider.js +240 -0
  224. package/dist/services/speech/providers/whisper.provider.js.map +1 -0
  225. package/dist/services/speech/types.d.ts +173 -0
  226. package/dist/services/speech/types.d.ts.map +1 -0
  227. package/dist/services/speech/types.js +8 -0
  228. package/dist/services/speech/types.js.map +1 -0
  229. package/dist/storage/core/IStorageProvider.d.ts +159 -0
  230. package/dist/storage/core/IStorageProvider.d.ts.map +1 -0
  231. package/dist/storage/core/IStorageProvider.js +2 -0
  232. package/dist/storage/core/IStorageProvider.js.map +1 -0
  233. package/dist/storage/core/StorageService.d.ts +22 -0
  234. package/dist/storage/core/StorageService.d.ts.map +1 -0
  235. package/dist/storage/core/StorageService.js +151 -0
  236. package/dist/storage/core/StorageService.js.map +1 -0
  237. package/dist/storage/core/storageFactory.d.ts +66 -0
  238. package/dist/storage/core/storageFactory.d.ts.map +1 -0
  239. package/dist/storage/core/storageFactory.js +122 -0
  240. package/dist/storage/core/storageFactory.js.map +1 -0
  241. package/dist/storage/core/storageValidation.d.ts +77 -0
  242. package/dist/storage/core/storageValidation.d.ts.map +1 -0
  243. package/dist/storage/core/storageValidation.js +303 -0
  244. package/dist/storage/core/storageValidation.js.map +1 -0
  245. package/dist/storage/providers/cloudflare/d1Provider.d.ts +94 -0
  246. package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -0
  247. package/dist/storage/providers/cloudflare/d1Provider.js +347 -0
  248. package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -0
  249. package/dist/storage/providers/cloudflare/kvProvider.d.ts +21 -0
  250. package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -0
  251. package/dist/storage/providers/cloudflare/kvProvider.js +183 -0
  252. package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -0
  253. package/dist/storage/providers/cloudflare/r2Provider.d.ts +28 -0
  254. package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -0
  255. package/dist/storage/providers/cloudflare/r2Provider.js +222 -0
  256. package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -0
  257. package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts +20 -0
  258. package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts.map +1 -0
  259. package/dist/storage/providers/fileSystem/fileSystemProvider.js +282 -0
  260. package/dist/storage/providers/fileSystem/fileSystemProvider.js.map +1 -0
  261. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +21 -0
  262. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -0
  263. package/dist/storage/providers/inMemory/inMemoryProvider.js +139 -0
  264. package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -0
  265. package/dist/storage/providers/supabase/supabase.types.d.ts +49 -0
  266. package/dist/storage/providers/supabase/supabase.types.d.ts.map +1 -0
  267. package/dist/storage/providers/supabase/supabase.types.js +8 -0
  268. package/dist/storage/providers/supabase/supabase.types.js.map +1 -0
  269. package/dist/storage/providers/supabase/supabaseProvider.d.ts +24 -0
  270. package/dist/storage/providers/supabase/supabaseProvider.d.ts.map +1 -0
  271. package/dist/storage/providers/supabase/supabaseProvider.js +209 -0
  272. package/dist/storage/providers/supabase/supabaseProvider.js.map +1 -0
  273. package/dist/testing/index.d.ts +53 -0
  274. package/dist/testing/index.d.ts.map +1 -0
  275. package/dist/testing/index.js +132 -0
  276. package/dist/testing/index.js.map +1 -0
  277. package/dist/types-global/errors.d.ts +83 -0
  278. package/dist/types-global/errors.d.ts.map +1 -0
  279. package/dist/types-global/errors.js +113 -0
  280. package/dist/types-global/errors.js.map +1 -0
  281. package/dist/utils/formatting/diffFormatter.d.ts +227 -0
  282. package/dist/utils/formatting/diffFormatter.d.ts.map +1 -0
  283. package/dist/utils/formatting/diffFormatter.js +369 -0
  284. package/dist/utils/formatting/diffFormatter.js.map +1 -0
  285. package/dist/utils/formatting/index.d.ts +9 -0
  286. package/dist/utils/formatting/index.d.ts.map +1 -0
  287. package/dist/utils/formatting/index.js +9 -0
  288. package/dist/utils/formatting/index.js.map +1 -0
  289. package/dist/utils/formatting/markdownBuilder.d.ts +543 -0
  290. package/dist/utils/formatting/markdownBuilder.d.ts.map +1 -0
  291. package/dist/utils/formatting/markdownBuilder.js +674 -0
  292. package/dist/utils/formatting/markdownBuilder.js.map +1 -0
  293. package/dist/utils/formatting/tableFormatter.d.ts +261 -0
  294. package/dist/utils/formatting/tableFormatter.d.ts.map +1 -0
  295. package/dist/utils/formatting/tableFormatter.js +456 -0
  296. package/dist/utils/formatting/tableFormatter.js.map +1 -0
  297. package/dist/utils/formatting/treeFormatter.d.ts +344 -0
  298. package/dist/utils/formatting/treeFormatter.d.ts.map +1 -0
  299. package/dist/utils/formatting/treeFormatter.js +400 -0
  300. package/dist/utils/formatting/treeFormatter.js.map +1 -0
  301. package/dist/utils/internal/encoding.d.ts +42 -0
  302. package/dist/utils/internal/encoding.d.ts.map +1 -0
  303. package/dist/utils/internal/encoding.js +87 -0
  304. package/dist/utils/internal/encoding.js.map +1 -0
  305. package/dist/utils/internal/error-handler/errorHandler.d.ts +140 -0
  306. package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -0
  307. package/dist/utils/internal/error-handler/errorHandler.js +318 -0
  308. package/dist/utils/internal/error-handler/errorHandler.js.map +1 -0
  309. package/dist/utils/internal/error-handler/helpers.d.ts +98 -0
  310. package/dist/utils/internal/error-handler/helpers.d.ts.map +1 -0
  311. package/dist/utils/internal/error-handler/helpers.js +214 -0
  312. package/dist/utils/internal/error-handler/helpers.js.map +1 -0
  313. package/dist/utils/internal/error-handler/mappings.d.ts +85 -0
  314. package/dist/utils/internal/error-handler/mappings.d.ts.map +1 -0
  315. package/dist/utils/internal/error-handler/mappings.js +234 -0
  316. package/dist/utils/internal/error-handler/mappings.js.map +1 -0
  317. package/dist/utils/internal/error-handler/types.d.ts +160 -0
  318. package/dist/utils/internal/error-handler/types.d.ts.map +1 -0
  319. package/dist/utils/internal/error-handler/types.js +6 -0
  320. package/dist/utils/internal/error-handler/types.js.map +1 -0
  321. package/dist/utils/internal/health.d.ts +60 -0
  322. package/dist/utils/internal/health.d.ts.map +1 -0
  323. package/dist/utils/internal/health.js +46 -0
  324. package/dist/utils/internal/health.js.map +1 -0
  325. package/dist/utils/internal/logger.d.ts +300 -0
  326. package/dist/utils/internal/logger.d.ts.map +1 -0
  327. package/dist/utils/internal/logger.js +573 -0
  328. package/dist/utils/internal/logger.js.map +1 -0
  329. package/dist/utils/internal/performance.d.ts +78 -0
  330. package/dist/utils/internal/performance.d.ts.map +1 -0
  331. package/dist/utils/internal/performance.js +227 -0
  332. package/dist/utils/internal/performance.js.map +1 -0
  333. package/dist/utils/internal/requestContext.d.ts +200 -0
  334. package/dist/utils/internal/requestContext.d.ts.map +1 -0
  335. package/dist/utils/internal/requestContext.js +163 -0
  336. package/dist/utils/internal/requestContext.js.map +1 -0
  337. package/dist/utils/internal/runtime.d.ts +49 -0
  338. package/dist/utils/internal/runtime.d.ts.map +1 -0
  339. package/dist/utils/internal/runtime.js +90 -0
  340. package/dist/utils/internal/runtime.js.map +1 -0
  341. package/dist/utils/internal/startupBanner.d.ts +23 -0
  342. package/dist/utils/internal/startupBanner.d.ts.map +1 -0
  343. package/dist/utils/internal/startupBanner.js +34 -0
  344. package/dist/utils/internal/startupBanner.js.map +1 -0
  345. package/dist/utils/metrics/tokenCounter.d.ts +97 -0
  346. package/dist/utils/metrics/tokenCounter.d.ts.map +1 -0
  347. package/dist/utils/metrics/tokenCounter.js +162 -0
  348. package/dist/utils/metrics/tokenCounter.js.map +1 -0
  349. package/dist/utils/network/fetchWithTimeout.d.ts +91 -0
  350. package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -0
  351. package/dist/utils/network/fetchWithTimeout.js +305 -0
  352. package/dist/utils/network/fetchWithTimeout.js.map +1 -0
  353. package/dist/utils/pagination/pagination.d.ts +157 -0
  354. package/dist/utils/pagination/pagination.d.ts.map +1 -0
  355. package/dist/utils/pagination/pagination.js +191 -0
  356. package/dist/utils/pagination/pagination.js.map +1 -0
  357. package/dist/utils/parsing/csvParser.d.ts +84 -0
  358. package/dist/utils/parsing/csvParser.d.ts.map +1 -0
  359. package/dist/utils/parsing/csvParser.js +132 -0
  360. package/dist/utils/parsing/csvParser.js.map +1 -0
  361. package/dist/utils/parsing/dateParser.d.ts +103 -0
  362. package/dist/utils/parsing/dateParser.d.ts.map +1 -0
  363. package/dist/utils/parsing/dateParser.js +142 -0
  364. package/dist/utils/parsing/dateParser.js.map +1 -0
  365. package/dist/utils/parsing/frontmatterParser.d.ts +91 -0
  366. package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -0
  367. package/dist/utils/parsing/frontmatterParser.js +163 -0
  368. package/dist/utils/parsing/frontmatterParser.js.map +1 -0
  369. package/dist/utils/parsing/index.d.ts +15 -0
  370. package/dist/utils/parsing/index.d.ts.map +1 -0
  371. package/dist/utils/parsing/index.js +15 -0
  372. package/dist/utils/parsing/index.js.map +1 -0
  373. package/dist/utils/parsing/jsonParser.d.ts +115 -0
  374. package/dist/utils/parsing/jsonParser.d.ts.map +1 -0
  375. package/dist/utils/parsing/jsonParser.js +177 -0
  376. package/dist/utils/parsing/jsonParser.js.map +1 -0
  377. package/dist/utils/parsing/pdfParser.d.ts +563 -0
  378. package/dist/utils/parsing/pdfParser.d.ts.map +1 -0
  379. package/dist/utils/parsing/pdfParser.js +775 -0
  380. package/dist/utils/parsing/pdfParser.js.map +1 -0
  381. package/dist/utils/parsing/thinkBlock.d.ts +31 -0
  382. package/dist/utils/parsing/thinkBlock.d.ts.map +1 -0
  383. package/dist/utils/parsing/thinkBlock.js +31 -0
  384. package/dist/utils/parsing/thinkBlock.js.map +1 -0
  385. package/dist/utils/parsing/xmlParser.d.ts +69 -0
  386. package/dist/utils/parsing/xmlParser.d.ts.map +1 -0
  387. package/dist/utils/parsing/xmlParser.js +140 -0
  388. package/dist/utils/parsing/xmlParser.js.map +1 -0
  389. package/dist/utils/parsing/yamlParser.d.ts +64 -0
  390. package/dist/utils/parsing/yamlParser.d.ts.map +1 -0
  391. package/dist/utils/parsing/yamlParser.js +129 -0
  392. package/dist/utils/parsing/yamlParser.js.map +1 -0
  393. package/dist/utils/scheduling/scheduler.d.ts +174 -0
  394. package/dist/utils/scheduling/scheduler.d.ts.map +1 -0
  395. package/dist/utils/scheduling/scheduler.js +248 -0
  396. package/dist/utils/scheduling/scheduler.js.map +1 -0
  397. package/dist/utils/security/idGenerator.d.ts +189 -0
  398. package/dist/utils/security/idGenerator.d.ts.map +1 -0
  399. package/dist/utils/security/idGenerator.js +301 -0
  400. package/dist/utils/security/idGenerator.js.map +1 -0
  401. package/dist/utils/security/index.d.ts +8 -0
  402. package/dist/utils/security/index.d.ts.map +1 -0
  403. package/dist/utils/security/index.js +8 -0
  404. package/dist/utils/security/index.js.map +1 -0
  405. package/dist/utils/security/rateLimiter.d.ts +171 -0
  406. package/dist/utils/security/rateLimiter.d.ts.map +1 -0
  407. package/dist/utils/security/rateLimiter.js +294 -0
  408. package/dist/utils/security/rateLimiter.js.map +1 -0
  409. package/dist/utils/security/sanitization.d.ts +430 -0
  410. package/dist/utils/security/sanitization.d.ts.map +1 -0
  411. package/dist/utils/security/sanitization.js +759 -0
  412. package/dist/utils/security/sanitization.js.map +1 -0
  413. package/dist/utils/telemetry/index.d.ts +12 -0
  414. package/dist/utils/telemetry/index.d.ts.map +1 -0
  415. package/dist/utils/telemetry/index.js +12 -0
  416. package/dist/utils/telemetry/index.js.map +1 -0
  417. package/dist/utils/telemetry/instrumentation.d.ts +62 -0
  418. package/dist/utils/telemetry/instrumentation.d.ts.map +1 -0
  419. package/dist/utils/telemetry/instrumentation.js +223 -0
  420. package/dist/utils/telemetry/instrumentation.js.map +1 -0
  421. package/dist/utils/telemetry/metrics.d.ts +170 -0
  422. package/dist/utils/telemetry/metrics.d.ts.map +1 -0
  423. package/dist/utils/telemetry/metrics.js +205 -0
  424. package/dist/utils/telemetry/metrics.js.map +1 -0
  425. package/dist/utils/telemetry/semconv.d.ts +147 -0
  426. package/dist/utils/telemetry/semconv.d.ts.map +1 -0
  427. package/dist/utils/telemetry/semconv.js +159 -0
  428. package/dist/utils/telemetry/semconv.js.map +1 -0
  429. package/dist/utils/telemetry/trace.d.ts +141 -0
  430. package/dist/utils/telemetry/trace.d.ts.map +1 -0
  431. package/dist/utils/telemetry/trace.js +193 -0
  432. package/dist/utils/telemetry/trace.js.map +1 -0
  433. package/dist/utils/types/guards.d.ts +209 -0
  434. package/dist/utils/types/guards.d.ts.map +1 -0
  435. package/dist/utils/types/guards.js +229 -0
  436. package/dist/utils/types/guards.js.map +1 -0
  437. package/dist/utils/types/index.d.ts +6 -0
  438. package/dist/utils/types/index.d.ts.map +1 -0
  439. package/dist/utils/types/index.js +6 -0
  440. package/dist/utils/types/index.js.map +1 -0
  441. package/dist/worker.d.ts +59 -0
  442. package/dist/worker.d.ts.map +1 -0
  443. package/dist/worker.js +216 -0
  444. package/dist/worker.js.map +1 -0
  445. package/package.json +377 -0
  446. package/skills/README.md +38 -0
  447. package/skills/add-export/SKILL.md +49 -0
  448. package/skills/add-prompt/SKILL.md +97 -0
  449. package/skills/add-provider/SKILL.md +53 -0
  450. package/skills/add-resource/SKILL.md +107 -0
  451. package/skills/add-service/SKILL.md +113 -0
  452. package/skills/add-tool/SKILL.md +110 -0
  453. package/skills/api-auth/SKILL.md +173 -0
  454. package/skills/api-config/SKILL.md +68 -0
  455. package/skills/api-context/SKILL.md +321 -0
  456. package/skills/api-errors/SKILL.md +146 -0
  457. package/skills/api-services/SKILL.md +24 -0
  458. package/skills/api-services/references/graph.md +124 -0
  459. package/skills/api-services/references/llm.md +46 -0
  460. package/skills/api-services/references/speech.md +72 -0
  461. package/skills/api-testing/SKILL.md +263 -0
  462. package/skills/api-utils/SKILL.md +106 -0
  463. package/skills/api-utils/references/formatting.md +237 -0
  464. package/skills/api-utils/references/parsing.md +263 -0
  465. package/skills/api-utils/references/security.md +226 -0
  466. package/skills/api-workers/SKILL.md +165 -0
  467. package/skills/devcheck/SKILL.md +31 -0
  468. package/skills/maintenance/SKILL.md +52 -0
  469. package/skills/migrate-mcp-ts-template/SKILL.md +131 -0
  470. package/skills/release/SKILL.md +67 -0
  471. package/skills/setup/SKILL.md +89 -0
  472. package/skills/walkthrough-init/SKILL.md +50 -0
  473. package/templates/.env.example +17 -0
  474. package/templates/AGENTS.md +113 -0
  475. package/templates/CLAUDE.md +113 -0
  476. package/templates/_tsconfig.json +33 -0
  477. package/templates/biome.template.json +43 -0
  478. package/templates/package.json +26 -0
  479. package/templates/src/index.ts +16 -0
  480. package/templates/src/mcp-server/prompts/definitions/echo.prompt.ts +19 -0
  481. package/templates/src/mcp-server/resources/definitions/echo.resource.ts +30 -0
  482. package/templates/src/mcp-server/tools/definitions/echo.tool.ts +24 -0
  483. package/templates/vitest.config.ts +12 -0
  484. package/tsconfig.base.json +44 -0
  485. package/vitest.config.base.ts +38 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @fileoverview Defines a unified Hono middleware for authentication.
3
+ * This middleware is strategy-agnostic. It extracts a Bearer token,
4
+ * delegates verification to the provided authentication strategy, and
5
+ * populates the async-local storage context with the resulting auth info.
6
+ *
7
+ * Errors from the strategy propagate directly to the Hono global error
8
+ * handler ({@link httpErrorHandler}), which handles OTel recording, logging,
9
+ * and JSON-RPC response formatting.
10
+ * @module src/mcp-server/transports/auth/authMiddleware
11
+ */
12
+ import type { HttpBindings } from '@hono/node-server';
13
+ import type { MiddlewareHandler } from 'hono';
14
+ import type { AuthStrategy } from '../../../mcp-server/transports/auth/strategies/authStrategy.js';
15
+ /**
16
+ * Creates a Hono middleware function that enforces authentication using a given strategy.
17
+ *
18
+ * @param strategy - An instance of a class that implements the `AuthStrategy` interface.
19
+ * @returns A Hono middleware function.
20
+ */
21
+ export declare function createAuthMiddleware(strategy: AuthStrategy): MiddlewareHandler<{
22
+ Bindings: HttpBindings;
23
+ }>;
24
+ //# sourceMappingURL=authMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/auth/authMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAW,iBAAiB,EAAQ,MAAM,MAAM,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yDAAyD,CAAC;AAK5F;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,GACrB,iBAAiB,CAAC;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,CAwD/C"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @fileoverview Defines a unified Hono middleware for authentication.
3
+ * This middleware is strategy-agnostic. It extracts a Bearer token,
4
+ * delegates verification to the provided authentication strategy, and
5
+ * populates the async-local storage context with the resulting auth info.
6
+ *
7
+ * Errors from the strategy propagate directly to the Hono global error
8
+ * handler ({@link httpErrorHandler}), which handles OTel recording, logging,
9
+ * and JSON-RPC response formatting.
10
+ * @module src/mcp-server/transports/auth/authMiddleware
11
+ */
12
+ import { trace } from '@opentelemetry/api';
13
+ import { authContext } from '../../../mcp-server/transports/auth/lib/authContext.js';
14
+ import { JsonRpcErrorCode, McpError } from '../../../types-global/errors.js';
15
+ import { logger } from '../../../utils/internal/logger.js';
16
+ import { requestContextService } from '../../../utils/internal/requestContext.js';
17
+ /**
18
+ * Creates a Hono middleware function that enforces authentication using a given strategy.
19
+ *
20
+ * @param strategy - An instance of a class that implements the `AuthStrategy` interface.
21
+ * @returns A Hono middleware function.
22
+ */
23
+ export function createAuthMiddleware(strategy) {
24
+ return async function authMiddleware(c, next) {
25
+ const context = requestContextService.createRequestContext({
26
+ operation: 'authMiddleware',
27
+ additionalContext: {
28
+ method: c.req.method,
29
+ path: c.req.path,
30
+ },
31
+ });
32
+ logger.debug('Initiating authentication check.', context);
33
+ const authHeader = c.req.header('Authorization');
34
+ if (!authHeader?.startsWith('Bearer ')) {
35
+ logger.warning('Authorization header missing or invalid.', context);
36
+ throw new McpError(JsonRpcErrorCode.Unauthorized, 'Missing or invalid Authorization header. Bearer scheme required.');
37
+ }
38
+ const token = authHeader.substring(7);
39
+ if (!token) {
40
+ logger.warning('Bearer token is missing from Authorization header.', context);
41
+ throw new McpError(JsonRpcErrorCode.Unauthorized, 'Authentication token is missing.');
42
+ }
43
+ logger.debug('Extracted Bearer token, proceeding to verification.', context);
44
+ // Strategy.verify() throws McpError on failure — errors propagate to httpErrorHandler.
45
+ const authInfo = await strategy.verify(token);
46
+ const authLogContext = {
47
+ ...context,
48
+ ...(authInfo.tenantId ? { tenantId: authInfo.tenantId } : {}),
49
+ clientId: authInfo.clientId,
50
+ subject: authInfo.subject,
51
+ scopes: authInfo.scopes,
52
+ };
53
+ logger.info('Authentication successful. Auth context populated.', authLogContext);
54
+ // Add authentication context to OpenTelemetry span for distributed tracing
55
+ const activeSpan = trace.getActiveSpan();
56
+ if (activeSpan) {
57
+ activeSpan.setAttributes({
58
+ 'auth.client_id': authInfo.clientId,
59
+ 'auth.tenant_id': authInfo.tenantId ?? 'none',
60
+ 'auth.scopes': authInfo.scopes.join(','),
61
+ 'auth.subject': authInfo.subject ?? 'unknown',
62
+ 'auth.method': 'bearer',
63
+ });
64
+ }
65
+ // Run the next middleware in the chain within the populated auth context.
66
+ await authContext.run({ authInfo }, next);
67
+ };
68
+ }
69
+ //# sourceMappingURL=authMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authMiddleware.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/auth/authMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAsB;IAEtB,OAAO,KAAK,UAAU,cAAc,CAAC,CAAsC,EAAE,IAAU;QACrF,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,gBAAgB;YAC3B,iBAAiB,EAAE;gBACjB,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM;gBACpB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI;aACjB;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC;QAE1D,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACvC,MAAM,CAAC,OAAO,CAAC,0CAA0C,EAAE,OAAO,CAAC,CAAC;YACpE,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,YAAY,EAC7B,kEAAkE,CACnE,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,CAAC,OAAO,CAAC,oDAAoD,EAAE,OAAO,CAAC,CAAC;YAC9E,MAAM,IAAI,QAAQ,CAAC,gBAAgB,CAAC,YAAY,EAAE,kCAAkC,CAAC,CAAC;QACxF,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,qDAAqD,EAAE,OAAO,CAAC,CAAC;QAE7E,uFAAuF;QACvF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE9C,MAAM,cAAc,GAAG;YACrB,GAAG,OAAO;YACV,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,oDAAoD,EAAE,cAAc,CAAC,CAAC;QAElF,2EAA2E;QAC3E,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACzC,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,aAAa,CAAC;gBACvB,gBAAgB,EAAE,QAAQ,CAAC,QAAQ;gBACnC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,IAAI,MAAM;gBAC7C,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;gBACxC,cAAc,EAAE,QAAQ,CAAC,OAAO,IAAI,SAAS;gBAC7C,aAAa,EAAE,QAAQ;aACxB,CAAC,CAAC;QACL,CAAC;QAED,0EAA0E;QAC1E,MAAM,WAAW,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Defines the AsyncLocalStorage context for authentication information.
3
+ * This module provides a mechanism to store and retrieve authentication details
4
+ * (like scopes and client ID) across asynchronous operations, making it available
5
+ * from the middleware layer down to the tool and resource handlers without
6
+ * drilling props.
7
+ *
8
+ * @module src/mcp-server/transports/auth/core/authContext
9
+ */
10
+ import { AsyncLocalStorage } from 'node:async_hooks';
11
+ import type { AuthInfo } from './authTypes.js';
12
+ /**
13
+ * Defines the structure of the store used within the AsyncLocalStorage.
14
+ * It holds the authentication information for the current request context.
15
+ */
16
+ interface AuthStore {
17
+ authInfo: AuthInfo;
18
+ }
19
+ /**
20
+ * An instance of AsyncLocalStorage to hold the authentication context (`AuthStore`).
21
+ * This allows `authInfo` to be accessible throughout the async call chain of a request
22
+ * after being set in the authentication middleware.
23
+ *
24
+ * @example
25
+ * // In middleware:
26
+ * await authContext.run({ authInfo }, next);
27
+ *
28
+ * // In a deeper handler:
29
+ * const store = authContext.getStore();
30
+ * const scopes = store?.authInfo.scopes;
31
+ */
32
+ export declare const authContext: AsyncLocalStorage<AuthStore>;
33
+ export {};
34
+ //# sourceMappingURL=authContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authContext.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/authContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,UAAU,SAAS;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,8BAAqC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @fileoverview Defines the AsyncLocalStorage context for authentication information.
3
+ * This module provides a mechanism to store and retrieve authentication details
4
+ * (like scopes and client ID) across asynchronous operations, making it available
5
+ * from the middleware layer down to the tool and resource handlers without
6
+ * drilling props.
7
+ *
8
+ * @module src/mcp-server/transports/auth/core/authContext
9
+ */
10
+ import { AsyncLocalStorage } from 'node:async_hooks';
11
+ /**
12
+ * An instance of AsyncLocalStorage to hold the authentication context (`AuthStore`).
13
+ * This allows `authInfo` to be accessible throughout the async call chain of a request
14
+ * after being set in the authentication middleware.
15
+ *
16
+ * @example
17
+ * // In middleware:
18
+ * await authContext.run({ authInfo }, next);
19
+ *
20
+ * // In a deeper handler:
21
+ * const store = authContext.getStore();
22
+ * const scopes = store?.authInfo.scopes;
23
+ */
24
+ export const authContext = new AsyncLocalStorage();
25
+ //# sourceMappingURL=authContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authContext.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/authContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAa,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @fileoverview Shared types for authentication middleware.
3
+ * @module src/mcp-server/transports/auth/lib/authTypes
4
+ */
5
+ import type { AuthInfo as SdkAuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
6
+ /**
7
+ * Extends the SDK's base AuthInfo with common optional JWT claims
8
+ * not part of the core MCP auth contract.
9
+ *
10
+ * - `subject` — JWT `sub` claim (end-user or service identity)
11
+ * - `tenantId` — JWT `tid` claim (Azure AD / custom multi-tenant)
12
+ */
13
+ export type AuthInfo = SdkAuthInfo & {
14
+ /** JWT `sub` claim — the authenticated subject (user or service). */
15
+ subject?: string;
16
+ /** JWT `tid` claim — tenant identifier for multi-tenant deployments. */
17
+ tenantId?: string;
18
+ };
19
+ //# sourceMappingURL=authTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authTypes.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/authTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG;IACnC,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=authTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authTypes.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/authTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @fileoverview Provides utility functions for authorization, specifically for
3
+ * checking token scopes against required permissions for a given operation.
4
+ * @module src/mcp-server/transports/auth/core/authUtils
5
+ */
6
+ import { type RequestContext } from '../../../../utils/internal/requestContext.js';
7
+ /**
8
+ * Checks if the current authentication context contains all the specified scopes.
9
+ * When auth is disabled (`MCP_AUTH_MODE=none`), scope checks are skipped.
10
+ * When auth is enabled and the auth context is missing, fails closed with Unauthorized.
11
+ *
12
+ * @param requiredScopes - An array of scope strings that are mandatory for the operation.
13
+ * @param parentContext - Optional parent request context for trace correlation.
14
+ * @throws {McpError} Throws `Unauthorized` if auth is enabled but no auth context exists.
15
+ * @throws {McpError} Throws `Forbidden` if auth is active and required scopes are missing.
16
+ */
17
+ export declare function withRequiredScopes(requiredScopes: string[], parentContext?: RequestContext): void;
18
+ //# sourceMappingURL=authUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authUtils.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/authUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,oCAAoC,CAAC;AAEhG;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI,CA8DjG"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @fileoverview Provides utility functions for authorization, specifically for
3
+ * checking token scopes against required permissions for a given operation.
4
+ * @module src/mcp-server/transports/auth/core/authUtils
5
+ */
6
+ import { config } from '../../../../config/index.js';
7
+ import { authContext } from '../../../../mcp-server/transports/auth/lib/authContext.js';
8
+ import { JsonRpcErrorCode, McpError } from '../../../../types-global/errors.js';
9
+ import { logger } from '../../../../utils/internal/logger.js';
10
+ import { requestContextService } from '../../../../utils/internal/requestContext.js';
11
+ /**
12
+ * Checks if the current authentication context contains all the specified scopes.
13
+ * When auth is disabled (`MCP_AUTH_MODE=none`), scope checks are skipped.
14
+ * When auth is enabled and the auth context is missing, fails closed with Unauthorized.
15
+ *
16
+ * @param requiredScopes - An array of scope strings that are mandatory for the operation.
17
+ * @param parentContext - Optional parent request context for trace correlation.
18
+ * @throws {McpError} Throws `Unauthorized` if auth is enabled but no auth context exists.
19
+ * @throws {McpError} Throws `Forbidden` if auth is active and required scopes are missing.
20
+ */
21
+ export function withRequiredScopes(requiredScopes, parentContext) {
22
+ const initialContext = parentContext
23
+ ? {
24
+ ...parentContext,
25
+ operation: 'withRequiredScopesCheck',
26
+ requiredScopes,
27
+ }
28
+ : requestContextService.createRequestContext({
29
+ operation: 'withRequiredScopesCheck',
30
+ additionalContext: { requiredScopes },
31
+ });
32
+ // Explicitly check if auth is disabled — only skip scope checks when intentionally off.
33
+ if (config.mcpAuthMode === 'none') {
34
+ logger.debug('Auth disabled (MCP_AUTH_MODE=none), skipping scope check.', initialContext);
35
+ return;
36
+ }
37
+ const store = authContext.getStore();
38
+ // Auth is enabled but no context exists — fail closed.
39
+ if (!store || !store.authInfo) {
40
+ logger.warning('Auth enabled but no authentication context found. Denying request.', initialContext);
41
+ throw new McpError(JsonRpcErrorCode.Unauthorized, 'Authentication required but no auth context was established.', initialContext);
42
+ }
43
+ logger.debug('Performing scope authorization check.', initialContext);
44
+ const { scopes: grantedScopes, clientId, subject } = store.authInfo;
45
+ const grantedScopeSet = new Set(grantedScopes);
46
+ const missingScopes = requiredScopes.filter((scope) => !grantedScopeSet.has(scope));
47
+ const finalContext = {
48
+ ...initialContext,
49
+ grantedScopes,
50
+ clientId,
51
+ subject,
52
+ };
53
+ if (missingScopes.length > 0) {
54
+ // Log full details server-side (grantedScopes, clientId, subject stay in logs)
55
+ logger.warning('Authorization failed: Missing required scopes.', {
56
+ ...finalContext,
57
+ missingScopes,
58
+ });
59
+ // Only surface non-sensitive info in the client-facing error
60
+ throw new McpError(JsonRpcErrorCode.Forbidden, `Insufficient permissions. Missing required scopes: ${missingScopes.join(', ')}`, { requiredScopes, missingScopes });
61
+ }
62
+ logger.debug('Scope authorization successful.', finalContext);
63
+ }
64
+ //# sourceMappingURL=authUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authUtils.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/authUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAuB,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAEhG;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,cAAwB,EAAE,aAA8B;IACzF,MAAM,cAAc,GAAG,aAAa;QAClC,CAAC,CAAC;YACE,GAAG,aAAa;YAChB,SAAS,EAAE,yBAAyB;YACpC,cAAc;SACf;QACH,CAAC,CAAC,qBAAqB,CAAC,oBAAoB,CAAC;YACzC,SAAS,EAAE,yBAAyB;YACpC,iBAAiB,EAAE,EAAE,cAAc,EAAE;SACtC,CAAC,CAAC;IAEP,wFAAwF;IACxF,IAAI,MAAM,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,2DAA2D,EAAE,cAAc,CAAC,CAAC;QAC1F,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IAErC,uDAAuD;IACvD,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,CACZ,oEAAoE,EACpE,cAAc,CACf,CAAC;QACF,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,YAAY,EAC7B,8DAA8D,EAC9D,cAAc,CACf,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,cAAc,CAAC,CAAC;IAEtE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IACpE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;IAE/C,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,MAAM,YAAY,GAAG;QACnB,GAAG,cAAc;QACjB,aAAa;QACb,QAAQ;QACR,OAAO;KACR,CAAC;IAEF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,+EAA+E;QAC/E,MAAM,CAAC,OAAO,CAAC,gDAAgD,EAAE;YAC/D,GAAG,YAAY;YACf,aAAa;SACd,CAAC,CAAC;QACH,6DAA6D;QAC7D,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,SAAS,EAC1B,sDAAsD,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAChF,EAAE,cAAc,EAAE,aAAa,EAAE,CAClC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,YAAY,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @fileoverview Public API for dynamic scope checking in new-style handlers.
3
+ * Use when auth scopes depend on runtime input (e.g., `team:${input.teamId}:write`).
4
+ * For static scopes, prefer the `auth` property on the tool/resource definition.
5
+ * @module src/mcp-server/transports/auth/lib/checkScopes
6
+ */
7
+ import type { Context } from '../../../../context.js';
8
+ /**
9
+ * Checks that the current request has the required auth scopes.
10
+ * Throws `McpError(Forbidden)` if scopes are insufficient.
11
+ * No-ops when auth is disabled (`MCP_AUTH_MODE=none`).
12
+ * Throws `Unauthorized` when auth is enabled but no auth context exists.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { checkScopes } from '@cyanheads/mcp-ts-core/auth';
17
+ *
18
+ * handler: async (input, ctx) => {
19
+ * checkScopes(ctx, [`team:${input.teamId}:write`]);
20
+ * // ...
21
+ * },
22
+ * ```
23
+ */
24
+ export declare function checkScopes(ctx: Context, requiredScopes: string[]): void;
25
+ //# sourceMappingURL=checkScopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkScopes.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/checkScopes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,CASxE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Public API for dynamic scope checking in new-style handlers.
3
+ * Use when auth scopes depend on runtime input (e.g., `team:${input.teamId}:write`).
4
+ * For static scopes, prefer the `auth` property on the tool/resource definition.
5
+ * @module src/mcp-server/transports/auth/lib/checkScopes
6
+ */
7
+ import { withRequiredScopes } from '../../../../mcp-server/transports/auth/lib/authUtils.js';
8
+ /**
9
+ * Checks that the current request has the required auth scopes.
10
+ * Throws `McpError(Forbidden)` if scopes are insufficient.
11
+ * No-ops when auth is disabled (`MCP_AUTH_MODE=none`).
12
+ * Throws `Unauthorized` when auth is enabled but no auth context exists.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { checkScopes } from '@cyanheads/mcp-ts-core/auth';
17
+ *
18
+ * handler: async (input, ctx) => {
19
+ * checkScopes(ctx, [`team:${input.teamId}:write`]);
20
+ * // ...
21
+ * },
22
+ * ```
23
+ */
24
+ export function checkScopes(ctx, requiredScopes) {
25
+ withRequiredScopes(requiredScopes, {
26
+ requestId: ctx.requestId,
27
+ timestamp: ctx.timestamp,
28
+ operation: 'checkScopes',
29
+ ...(ctx.tenantId ? { tenantId: ctx.tenantId } : {}),
30
+ ...(ctx.traceId ? { traceId: ctx.traceId } : {}),
31
+ ...(ctx.spanId ? { spanId: ctx.spanId } : {}),
32
+ });
33
+ }
34
+ //# sourceMappingURL=checkScopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkScopes.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/checkScopes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAEnF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY,EAAE,cAAwB;IAChE,kBAAkB,CAAC,cAAc,EAAE;QACjC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,aAAa;QACxB,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Shared JWT claim parsing and AuthInfo construction.
3
+ * Extracts and validates standard claims (clientId, scopes, subject, tenantId, expiresAt)
4
+ * from a decoded JWT payload, producing a fully-formed AuthInfo object.
5
+ * Used by both JWT and OAuth strategies to ensure consistent claim handling.
6
+ * @module src/mcp-server/transports/auth/lib/claimParser
7
+ */
8
+ import type { JWTPayload } from 'jose';
9
+ import type { AuthInfo } from '../../../../mcp-server/transports/auth/lib/authTypes.js';
10
+ /**
11
+ * Builds an {@link AuthInfo} from a raw token string and decoded JWT payload.
12
+ *
13
+ * Claim resolution order:
14
+ * - **clientId**: `cid` (Okta) → `client_id` (OAuth 2.1 standard)
15
+ * - **scopes**: `scp` (Okta, array) → `scope` (standard, space-delimited string)
16
+ * - **subject**: `sub` (standard)
17
+ * - **tenantId**: `tid` (Azure AD / custom)
18
+ * - **expiresAt**: `exp` (standard, seconds since epoch)
19
+ *
20
+ * @throws {McpError} `Unauthorized` if `clientId` or `scopes` are missing/empty.
21
+ */
22
+ export declare function buildAuthInfoFromClaims(token: string, payload: JWTPayload): AuthInfo;
23
+ /**
24
+ * Handles errors thrown by `jose` verification functions.
25
+ * Rethrows {@link McpError} instances as-is and wraps other errors
26
+ * (e.g. `JWTExpired`, `JWSSignatureVerificationFailed`) in an
27
+ * `Unauthorized` McpError.
28
+ *
29
+ * @param error - The caught error from a jose verify call.
30
+ * @param fallbackMessage - Message used when the error is not a recognized jose type.
31
+ * @throws Always throws — either the original McpError or a new Unauthorized McpError.
32
+ */
33
+ export declare function handleJoseVerifyError(error: unknown, fallbackMessage: string): never;
34
+ //# sourceMappingURL=claimParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claimParser.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/claimParser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAG9E;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,QAAQ,CAqCpF;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,GAAG,KAAK,CAOpF"}
@@ -0,0 +1,58 @@
1
+ import { JsonRpcErrorCode, McpError } from '../../../../types-global/errors.js';
2
+ /**
3
+ * Builds an {@link AuthInfo} from a raw token string and decoded JWT payload.
4
+ *
5
+ * Claim resolution order:
6
+ * - **clientId**: `cid` (Okta) → `client_id` (OAuth 2.1 standard)
7
+ * - **scopes**: `scp` (Okta, array) → `scope` (standard, space-delimited string)
8
+ * - **subject**: `sub` (standard)
9
+ * - **tenantId**: `tid` (Azure AD / custom)
10
+ * - **expiresAt**: `exp` (standard, seconds since epoch)
11
+ *
12
+ * @throws {McpError} `Unauthorized` if `clientId` or `scopes` are missing/empty.
13
+ */
14
+ export function buildAuthInfoFromClaims(token, payload) {
15
+ const clientId = typeof payload.cid === 'string'
16
+ ? payload.cid
17
+ : typeof payload.client_id === 'string'
18
+ ? payload.client_id
19
+ : undefined;
20
+ if (!clientId) {
21
+ throw new McpError(JsonRpcErrorCode.Unauthorized, "Invalid token: missing 'cid' or 'client_id' claim.");
22
+ }
23
+ let scopes = [];
24
+ if (Array.isArray(payload.scp) && payload.scp.every((s) => typeof s === 'string')) {
25
+ scopes = payload.scp;
26
+ }
27
+ else if (typeof payload.scope === 'string' && payload.scope.trim()) {
28
+ scopes = payload.scope.split(' ').filter(Boolean);
29
+ }
30
+ if (scopes.length === 0) {
31
+ throw new McpError(JsonRpcErrorCode.Unauthorized, 'Token must contain valid, non-empty scopes.');
32
+ }
33
+ return {
34
+ token,
35
+ clientId,
36
+ scopes,
37
+ ...(typeof payload.sub === 'string' && { subject: payload.sub }),
38
+ ...(typeof payload.tid === 'string' && { tenantId: payload.tid }),
39
+ ...(typeof payload.exp === 'number' && { expiresAt: payload.exp }),
40
+ };
41
+ }
42
+ /**
43
+ * Handles errors thrown by `jose` verification functions.
44
+ * Rethrows {@link McpError} instances as-is and wraps other errors
45
+ * (e.g. `JWTExpired`, `JWSSignatureVerificationFailed`) in an
46
+ * `Unauthorized` McpError.
47
+ *
48
+ * @param error - The caught error from a jose verify call.
49
+ * @param fallbackMessage - Message used when the error is not a recognized jose type.
50
+ * @throws Always throws — either the original McpError or a new Unauthorized McpError.
51
+ */
52
+ export function handleJoseVerifyError(error, fallbackMessage) {
53
+ if (error instanceof McpError)
54
+ throw error;
55
+ const message = error instanceof Error && error.name === 'JWTExpired' ? 'Token has expired.' : fallbackMessage;
56
+ throw new McpError(JsonRpcErrorCode.Unauthorized, message);
57
+ }
58
+ //# sourceMappingURL=claimParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claimParser.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/claimParser.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa,EAAE,OAAmB;IACxE,MAAM,QAAQ,GACZ,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;QAC7B,CAAC,CAAC,OAAO,CAAC,GAAG;QACb,CAAC,CAAC,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS;YACnB,CAAC,CAAC,SAAS,CAAC;IAElB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,YAAY,EAC7B,oDAAoD,CACrD,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,GAAa,EAAE,CAAC;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;QAClF,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IACvB,CAAC;SAAM,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACrE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,YAAY,EAC7B,6CAA6C,CAC9C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,QAAQ;QACR,MAAM;QACN,GAAG,CAAC,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QAChE,GAAG,CAAC,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QACjE,GAAG,CAAC,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc,EAAE,eAAuB;IAC3E,IAAI,KAAK,YAAY,QAAQ;QAAE,MAAM,KAAK,CAAC;IAE3C,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC;IAEjG,MAAM,IAAI,QAAQ,CAAC,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @fileoverview Higher-order functions for declarative, scope-based authorization.
3
+ * @module src/mcp-server/transports/auth/lib/withAuth
4
+ */
5
+ import type { SdkContext } from '../../../../mcp-server/tools/utils/toolDefinition.js';
6
+ import type { RequestContext } from '../../../../utils/internal/requestContext.js';
7
+ /**
8
+ * A higher-order function that wraps a **tool's** logic function with a
9
+ * scope-based authorization check.
10
+ *
11
+ * @param {string[]} requiredScopes An array of scopes required to execute the logic.
12
+ * @param {Function} logicFn The core tool logic function to execute if authorization succeeds.
13
+ * @returns A new async function that performs the auth check before executing the logic.
14
+ */
15
+ export declare function withToolAuth<TInput, TOutput>(requiredScopes: string[], logicFn: (input: TInput, context: RequestContext, sdkContext: SdkContext) => TOutput | Promise<TOutput>): (input: TInput, context: RequestContext, sdkContext: SdkContext) => Promise<TOutput>;
16
+ /**
17
+ * A higher-order function that wraps a **resource's** logic function with a
18
+ * scope-based authorization check.
19
+ *
20
+ * @param {string[]} requiredScopes An array of scopes required to execute the logic.
21
+ * @param {Function} logicFn The core resource logic function to execute if authorization succeeds.
22
+ * @returns A new async function that performs the auth check before executing the logic.
23
+ */
24
+ export declare function withResourceAuth<TUri, TParams, TOutput>(requiredScopes: string[], logicFn: (uri: TUri, params: TParams, context: RequestContext) => TOutput | Promise<TOutput>): (uri: TUri, params: TParams, context: RequestContext) => Promise<TOutput>;
25
+ //# sourceMappingURL=withAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withAuth.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/withAuth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAC1C,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,CACP,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,UAAU,KACnB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC9B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAStF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EACrD,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC3F,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAK3E"}
@@ -0,0 +1,30 @@
1
+ import { withRequiredScopes } from '../../../../mcp-server/transports/auth/lib/authUtils.js';
2
+ /**
3
+ * A higher-order function that wraps a **tool's** logic function with a
4
+ * scope-based authorization check.
5
+ *
6
+ * @param {string[]} requiredScopes An array of scopes required to execute the logic.
7
+ * @param {Function} logicFn The core tool logic function to execute if authorization succeeds.
8
+ * @returns A new async function that performs the auth check before executing the logic.
9
+ */
10
+ export function withToolAuth(requiredScopes, logicFn) {
11
+ return async (input, context, sdkContext) => {
12
+ withRequiredScopes(requiredScopes, context);
13
+ return await logicFn(input, context, sdkContext);
14
+ };
15
+ }
16
+ /**
17
+ * A higher-order function that wraps a **resource's** logic function with a
18
+ * scope-based authorization check.
19
+ *
20
+ * @param {string[]} requiredScopes An array of scopes required to execute the logic.
21
+ * @param {Function} logicFn The core resource logic function to execute if authorization succeeds.
22
+ * @returns A new async function that performs the auth check before executing the logic.
23
+ */
24
+ export function withResourceAuth(requiredScopes, logicFn) {
25
+ return async (uri, params, context) => {
26
+ withRequiredScopes(requiredScopes, context);
27
+ return await logicFn(uri, params, context);
28
+ };
29
+ }
30
+ //# sourceMappingURL=withAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withAuth.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/lib/withAuth.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAGnF;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,cAAwB,EACxB,OAI+B;IAE/B,OAAO,KAAK,EACV,KAAa,EACb,OAAuB,EACvB,UAAsB,EACJ,EAAE;QACpB,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,cAAwB,EACxB,OAA4F;IAE5F,OAAO,KAAK,EAAE,GAAS,EAAE,MAAe,EAAE,OAAuB,EAAoB,EAAE;QACrF,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @fileoverview Defines the interface for all authentication strategies.
3
+ * This interface establishes a contract for verifying authentication tokens,
4
+ * ensuring that any authentication method (JWT, OAuth, etc.) can be used
5
+ * interchangeably by the core authentication middleware.
6
+ * @module src/mcp-server/transports/auth/strategies/AuthStrategy
7
+ */
8
+ import type { AuthInfo } from '../../../../mcp-server/transports/auth/lib/authTypes.js';
9
+ export interface AuthStrategy {
10
+ /**
11
+ * Verifies an authentication token.
12
+ * @param token The raw token string extracted from the request.
13
+ * @returns A promise that resolves with the AuthInfo on successful verification.
14
+ * @throws {McpError} if the token is invalid, expired, or fails verification for any reason.
15
+ */
16
+ verify(token: string): Promise<AuthInfo>;
17
+ }
18
+ //# sourceMappingURL=authStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authStrategy.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/authStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAE9E,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=authStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authStrategy.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/authStrategy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { config as ConfigType } from '../../../../config/index.js';
2
+ import type { AuthInfo } from '../../../../mcp-server/transports/auth/lib/authTypes.js';
3
+ import type { AuthStrategy } from '../../../../mcp-server/transports/auth/strategies/authStrategy.js';
4
+ import type { logger as LoggerType } from '../../../../utils/internal/logger.js';
5
+ export declare class JwtStrategy implements AuthStrategy {
6
+ private config;
7
+ private logger;
8
+ private readonly secretKey;
9
+ private readonly devMcpClientId;
10
+ private readonly devMcpScopes;
11
+ constructor(config: typeof ConfigType, logger: typeof LoggerType);
12
+ verify(token: string): Promise<AuthInfo>;
13
+ }
14
+ //# sourceMappingURL=jwtStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwtStrategy.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/jwtStrategy.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAK9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yDAAyD,CAAC;AAE5F,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGvE,qBAAa,WAAY,YAAW,YAAY;IAM5C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IANhB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAW;gBAG9B,MAAM,EAAE,OAAO,UAAU,EACzB,MAAM,EAAE,OAAO,UAAU;IAiC7B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CA8C/C"}