@1mcp/agent 0.24.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (509) hide show
  1. package/README.md +31 -478
  2. package/build/{services → application/services}/configReloadService.d.ts +1 -1
  3. package/build/application/services/configReloadService.d.ts.map +1 -0
  4. package/build/{services → application/services}/configReloadService.js +8 -8
  5. package/build/application/services/configReloadService.js.map +1 -0
  6. package/build/{services → application/services}/healthService.d.ts +1 -1
  7. package/build/application/services/healthService.d.ts.map +1 -0
  8. package/build/{services → application/services}/healthService.js +6 -6
  9. package/build/application/services/healthService.js.map +1 -0
  10. package/build/{services → application/services}/tokenEstimationService.d.ts +1 -1
  11. package/build/application/services/tokenEstimationService.d.ts.map +1 -0
  12. package/build/{services → application/services}/tokenEstimationService.js +1 -1
  13. package/build/application/services/tokenEstimationService.js.map +1 -0
  14. package/build/auth/sdkOAuthClientProvider.d.ts +1 -1
  15. package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -1
  16. package/build/auth/sdkOAuthClientProvider.js +2 -2
  17. package/build/auth/sdkOAuthClientProvider.js.map +1 -1
  18. package/build/auth/sdkOAuthServerProvider.d.ts +3 -3
  19. package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -1
  20. package/build/auth/sdkOAuthServerProvider.js +4 -4
  21. package/build/auth/sdkOAuthServerProvider.js.map +1 -1
  22. package/build/auth/sessionTypes.d.ts.map +1 -1
  23. package/build/auth/sessionTypes.js +0 -1
  24. package/build/auth/sessionTypes.js.map +1 -1
  25. package/build/auth/storage/authCodeRepository.d.ts +1 -1
  26. package/build/auth/storage/authCodeRepository.d.ts.map +1 -1
  27. package/build/auth/storage/authCodeRepository.js +1 -1
  28. package/build/auth/storage/authCodeRepository.js.map +1 -1
  29. package/build/auth/storage/authRequestRepository.d.ts +1 -1
  30. package/build/auth/storage/authRequestRepository.d.ts.map +1 -1
  31. package/build/auth/storage/authRequestRepository.js +1 -1
  32. package/build/auth/storage/authRequestRepository.js.map +1 -1
  33. package/build/auth/storage/clientDataRepository.d.ts +1 -1
  34. package/build/auth/storage/clientDataRepository.d.ts.map +1 -1
  35. package/build/auth/storage/clientDataRepository.js +1 -1
  36. package/build/auth/storage/clientDataRepository.js.map +1 -1
  37. package/build/auth/storage/clientSessionRepository.d.ts +1 -1
  38. package/build/auth/storage/clientSessionRepository.d.ts.map +1 -1
  39. package/build/auth/storage/clientSessionRepository.js +1 -1
  40. package/build/auth/storage/clientSessionRepository.js.map +1 -1
  41. package/build/auth/storage/fileStorageService.d.ts +1 -1
  42. package/build/auth/storage/fileStorageService.d.ts.map +1 -1
  43. package/build/auth/storage/fileStorageService.js +1 -1
  44. package/build/auth/storage/fileStorageService.js.map +1 -1
  45. package/build/auth/storage/oauthStorageService.d.ts +1 -1
  46. package/build/auth/storage/oauthStorageService.d.ts.map +1 -1
  47. package/build/auth/storage/oauthStorageService.js +4 -4
  48. package/build/auth/storage/oauthStorageService.js.map +1 -1
  49. package/build/auth/storage/sessionRepository.d.ts +1 -1
  50. package/build/auth/storage/sessionRepository.d.ts.map +1 -1
  51. package/build/auth/storage/sessionRepository.js +1 -1
  52. package/build/auth/storage/sessionRepository.js.map +1 -1
  53. package/build/commands/app/backups.d.ts +1 -1
  54. package/build/commands/app/backups.d.ts.map +1 -1
  55. package/build/commands/app/backups.js +2 -2
  56. package/build/commands/app/backups.js.map +1 -1
  57. package/build/commands/app/consolidate.d.ts +1 -1
  58. package/build/commands/app/consolidate.d.ts.map +1 -1
  59. package/build/commands/app/consolidate.js +9 -9
  60. package/build/commands/app/consolidate.js.map +1 -1
  61. package/build/commands/app/discover.d.ts +1 -1
  62. package/build/commands/app/discover.d.ts.map +1 -1
  63. package/build/commands/app/discover.js +2 -2
  64. package/build/commands/app/discover.js.map +1 -1
  65. package/build/commands/app/index.d.ts.map +1 -1
  66. package/build/commands/app/index.js +3 -3
  67. package/build/commands/app/index.js.map +1 -1
  68. package/build/commands/app/list.d.ts +1 -1
  69. package/build/commands/app/list.d.ts.map +1 -1
  70. package/build/commands/app/list.js +1 -1
  71. package/build/commands/app/list.js.map +1 -1
  72. package/build/commands/app/restore.d.ts +1 -1
  73. package/build/commands/app/restore.d.ts.map +1 -1
  74. package/build/commands/app/restore.js +2 -2
  75. package/build/commands/app/restore.js.map +1 -1
  76. package/build/commands/app/status.d.ts +1 -1
  77. package/build/commands/app/status.d.ts.map +1 -1
  78. package/build/commands/app/status.js +3 -3
  79. package/build/commands/app/status.js.map +1 -1
  80. package/build/commands/mcp/add.d.ts +1 -1
  81. package/build/commands/mcp/add.d.ts.map +1 -1
  82. package/build/commands/mcp/add.js +2 -2
  83. package/build/commands/mcp/add.js.map +1 -1
  84. package/build/commands/mcp/enable.d.ts +1 -1
  85. package/build/commands/mcp/enable.d.ts.map +1 -1
  86. package/build/commands/mcp/enable.js +1 -1
  87. package/build/commands/mcp/enable.js.map +1 -1
  88. package/build/commands/mcp/index.d.ts.map +1 -1
  89. package/build/commands/mcp/index.js +5 -5
  90. package/build/commands/mcp/index.js.map +1 -1
  91. package/build/commands/mcp/list.d.ts +1 -1
  92. package/build/commands/mcp/list.d.ts.map +1 -1
  93. package/build/commands/mcp/list.js +3 -3
  94. package/build/commands/mcp/list.js.map +1 -1
  95. package/build/commands/mcp/remove.d.ts +1 -1
  96. package/build/commands/mcp/remove.d.ts.map +1 -1
  97. package/build/commands/mcp/remove.js +1 -1
  98. package/build/commands/mcp/remove.js.map +1 -1
  99. package/build/commands/mcp/status.d.ts +1 -1
  100. package/build/commands/mcp/status.d.ts.map +1 -1
  101. package/build/commands/mcp/status.js +2 -2
  102. package/build/commands/mcp/status.js.map +1 -1
  103. package/build/commands/mcp/tokens.d.ts +1 -1
  104. package/build/commands/mcp/tokens.d.ts.map +1 -1
  105. package/build/commands/mcp/tokens.js +7 -7
  106. package/build/commands/mcp/tokens.js.map +1 -1
  107. package/build/commands/mcp/update.d.ts +1 -1
  108. package/build/commands/mcp/update.d.ts.map +1 -1
  109. package/build/commands/mcp/update.js +2 -2
  110. package/build/commands/mcp/update.js.map +1 -1
  111. package/build/commands/mcp/utils/configUtils.d.ts.map +1 -1
  112. package/build/commands/mcp/utils/configUtils.js +1 -1
  113. package/build/commands/mcp/utils/configUtils.js.map +1 -1
  114. package/build/commands/mcp/utils/connectionHelper.d.ts +1 -1
  115. package/build/commands/mcp/utils/connectionHelper.d.ts.map +1 -1
  116. package/build/commands/mcp/utils/connectionHelper.js +1 -1
  117. package/build/commands/mcp/utils/connectionHelper.js.map +1 -1
  118. package/build/commands/mcp/utils/validation.d.ts.map +1 -1
  119. package/build/commands/preset/create.d.ts +1 -1
  120. package/build/commands/preset/create.d.ts.map +1 -1
  121. package/build/commands/preset/create.js +4 -4
  122. package/build/commands/preset/create.js.map +1 -1
  123. package/build/commands/preset/delete.d.ts +1 -1
  124. package/build/commands/preset/delete.d.ts.map +1 -1
  125. package/build/commands/preset/delete.js +2 -2
  126. package/build/commands/preset/delete.js.map +1 -1
  127. package/build/commands/preset/edit.d.ts +1 -1
  128. package/build/commands/preset/edit.d.ts.map +1 -1
  129. package/build/commands/preset/edit.js +4 -3
  130. package/build/commands/preset/edit.js.map +1 -1
  131. package/build/commands/preset/index.d.ts.map +1 -1
  132. package/build/commands/preset/index.js +4 -4
  133. package/build/commands/preset/index.js.map +1 -1
  134. package/build/commands/preset/interactive.d.ts.map +1 -1
  135. package/build/commands/preset/interactive.js +3 -3
  136. package/build/commands/preset/interactive.js.map +1 -1
  137. package/build/commands/preset/list.d.ts +1 -1
  138. package/build/commands/preset/list.d.ts.map +1 -1
  139. package/build/commands/preset/list.js +2 -2
  140. package/build/commands/preset/list.js.map +1 -1
  141. package/build/commands/preset/show.d.ts +1 -1
  142. package/build/commands/preset/show.d.ts.map +1 -1
  143. package/build/commands/preset/show.js +3 -3
  144. package/build/commands/preset/show.js.map +1 -1
  145. package/build/commands/preset/test.d.ts +1 -1
  146. package/build/commands/preset/test.d.ts.map +1 -1
  147. package/build/commands/preset/test.js +2 -2
  148. package/build/commands/preset/test.js.map +1 -1
  149. package/build/commands/preset/url.d.ts +1 -1
  150. package/build/commands/preset/url.d.ts.map +1 -1
  151. package/build/commands/preset/url.js +3 -3
  152. package/build/commands/preset/url.js.map +1 -1
  153. package/build/commands/proxy/index.d.ts +1 -1
  154. package/build/commands/proxy/index.d.ts.map +1 -1
  155. package/build/commands/proxy/index.js +1 -1
  156. package/build/commands/proxy/index.js.map +1 -1
  157. package/build/commands/proxy/proxy.d.ts.map +1 -1
  158. package/build/commands/proxy/proxy.js +2 -2
  159. package/build/commands/proxy/proxy.js.map +1 -1
  160. package/build/commands/serve/index.d.ts.map +1 -1
  161. package/build/commands/serve/index.js +2 -2
  162. package/build/commands/serve/index.js.map +1 -1
  163. package/build/commands/serve/serve.d.ts.map +1 -1
  164. package/build/commands/serve/serve.js +31 -19
  165. package/build/commands/serve/serve.js.map +1 -1
  166. package/build/commands/shared/configUtils.d.ts +71 -0
  167. package/build/commands/shared/configUtils.d.ts.map +1 -0
  168. package/build/commands/shared/configUtils.js +304 -0
  169. package/build/commands/shared/configUtils.js.map +1 -0
  170. package/build/commands/shared/connectionHelper.d.ts +29 -0
  171. package/build/commands/shared/connectionHelper.d.ts.map +1 -0
  172. package/build/commands/shared/connectionHelper.js +162 -0
  173. package/build/commands/shared/connectionHelper.js.map +1 -0
  174. package/build/commands/shared/validation.d.ts +33 -0
  175. package/build/commands/shared/validation.d.ts.map +1 -0
  176. package/build/commands/shared/validation.js +235 -0
  177. package/build/commands/shared/validation.js.map +1 -0
  178. package/build/config/configContext.js.map +1 -1
  179. package/build/config/envProcessor.d.ts.map +1 -0
  180. package/build/config/envProcessor.js.map +1 -0
  181. package/build/config/mcpConfigManager.d.ts.map +1 -1
  182. package/build/config/mcpConfigManager.js +3 -3
  183. package/build/config/mcpConfigManager.js.map +1 -1
  184. package/build/config/projectConfigLoader.d.ts.map +1 -0
  185. package/build/{utils → config}/projectConfigLoader.js +2 -2
  186. package/build/config/projectConfigLoader.js.map +1 -0
  187. package/build/config/projectConfigTypes.d.ts.map +1 -0
  188. package/build/config/projectConfigTypes.js.map +1 -0
  189. package/build/constants/api.d.ts +14 -0
  190. package/build/constants/api.d.ts.map +1 -0
  191. package/build/constants/api.js +17 -0
  192. package/build/constants/api.js.map +1 -0
  193. package/build/constants/auth.d.ts +65 -0
  194. package/build/constants/auth.d.ts.map +1 -0
  195. package/build/constants/auth.js +73 -0
  196. package/build/constants/auth.js.map +1 -0
  197. package/build/constants/index.d.ts +9 -0
  198. package/build/constants/index.d.ts.map +1 -0
  199. package/build/constants/index.js +10 -0
  200. package/build/constants/index.js.map +1 -0
  201. package/build/constants/mcp.d.ts +12 -0
  202. package/build/constants/mcp.d.ts.map +1 -0
  203. package/build/constants/mcp.js +31 -0
  204. package/build/constants/mcp.js.map +1 -0
  205. package/build/constants/paths.d.ts +35 -0
  206. package/build/constants/paths.d.ts.map +1 -0
  207. package/build/constants/paths.js +66 -0
  208. package/build/constants/paths.js.map +1 -0
  209. package/build/constants.d.ts +3 -114
  210. package/build/constants.d.ts.map +1 -1
  211. package/build/constants.js +4 -174
  212. package/build/constants.js.map +1 -1
  213. package/build/core/capabilities/asyncLoadingOrchestrator.d.ts +4 -4
  214. package/build/core/capabilities/asyncLoadingOrchestrator.d.ts.map +1 -1
  215. package/build/core/capabilities/asyncLoadingOrchestrator.js +3 -3
  216. package/build/core/capabilities/asyncLoadingOrchestrator.js.map +1 -1
  217. package/build/core/capabilities/capabilityAggregator.d.ts +2 -2
  218. package/build/core/capabilities/capabilityAggregator.d.ts.map +1 -1
  219. package/build/core/capabilities/capabilityAggregator.js +1 -1
  220. package/build/core/capabilities/capabilityAggregator.js.map +1 -1
  221. package/build/core/capabilities/capabilityManager.d.ts +1 -1
  222. package/build/core/capabilities/capabilityManager.d.ts.map +1 -1
  223. package/build/core/capabilities/capabilityManager.js +2 -2
  224. package/build/core/capabilities/capabilityManager.js.map +1 -1
  225. package/build/core/client/clientManager.d.ts +2 -2
  226. package/build/core/client/clientManager.d.ts.map +1 -1
  227. package/build/core/client/clientManager.js +15 -9
  228. package/build/core/client/clientManager.js.map +1 -1
  229. package/build/{utils → core/filtering}/clientFiltering.d.ts +2 -2
  230. package/build/core/filtering/clientFiltering.d.ts.map +1 -0
  231. package/build/{utils → core/filtering}/clientFiltering.js +3 -3
  232. package/build/core/filtering/clientFiltering.js.map +1 -0
  233. package/build/core/filtering/filteringService.d.ts +3 -3
  234. package/build/core/filtering/filteringService.d.ts.map +1 -1
  235. package/build/core/filtering/filteringService.js +4 -4
  236. package/build/core/filtering/filteringService.js.map +1 -1
  237. package/build/core/instructions/instructionAggregator.d.ts +1 -1
  238. package/build/core/instructions/instructionAggregator.d.ts.map +1 -1
  239. package/build/core/instructions/instructionAggregator.js +3 -3
  240. package/build/core/instructions/instructionAggregator.js.map +1 -1
  241. package/build/core/loading/loadingStateTracker.d.ts.map +1 -1
  242. package/build/core/loading/loadingStateTracker.js.map +1 -1
  243. package/build/core/loading/mcpLoadingManager.d.ts +2 -2
  244. package/build/core/loading/mcpLoadingManager.d.ts.map +1 -1
  245. package/build/core/loading/mcpLoadingManager.js +1 -1
  246. package/build/core/loading/mcpLoadingManager.js.map +1 -1
  247. package/build/core/notifications/notificationManager.d.ts +2 -2
  248. package/build/core/notifications/notificationManager.d.ts.map +1 -1
  249. package/build/core/notifications/notificationManager.js +1 -1
  250. package/build/core/notifications/notificationManager.js.map +1 -1
  251. package/build/{handlers → core/protocol}/notificationHandlers.d.ts +1 -1
  252. package/build/core/protocol/notificationHandlers.d.ts.map +1 -0
  253. package/build/{handlers → core/protocol}/notificationHandlers.js +4 -4
  254. package/build/core/protocol/notificationHandlers.js.map +1 -0
  255. package/build/{handlers → core/protocol}/requestHandlers.d.ts +1 -1
  256. package/build/core/protocol/requestHandlers.d.ts.map +1 -0
  257. package/build/{handlers → core/protocol}/requestHandlers.js +38 -26
  258. package/build/core/protocol/requestHandlers.js.map +1 -0
  259. package/build/core/server/agentConfig.js.map +1 -1
  260. package/build/core/server/pidFileManager.d.ts.map +1 -0
  261. package/build/{utils → core/server}/pidFileManager.js +1 -1
  262. package/build/core/server/pidFileManager.js.map +1 -0
  263. package/build/core/server/serverManager.d.ts +3 -3
  264. package/build/core/server/serverManager.d.ts.map +1 -1
  265. package/build/core/server/serverManager.js +5 -5
  266. package/build/core/server/serverManager.js.map +1 -1
  267. package/build/core/types/client.d.ts +1 -1
  268. package/build/core/types/client.d.ts.map +1 -1
  269. package/build/core/types/client.js.map +1 -1
  270. package/build/core/types/server.d.ts +3 -3
  271. package/build/core/types/server.d.ts.map +1 -1
  272. package/build/core/types/server.js.map +1 -1
  273. package/build/core/types/transport.d.ts +2 -2
  274. package/build/core/types/transport.d.ts.map +1 -1
  275. package/build/core/types/transport.js.map +1 -1
  276. package/build/domains/backup/backupManager.d.ts.map +1 -0
  277. package/build/{utils → domains/backup}/backupManager.js +3 -3
  278. package/build/domains/backup/backupManager.js.map +1 -0
  279. package/build/domains/discovery/appDiscovery.d.ts.map +1 -0
  280. package/build/{utils → domains/discovery}/appDiscovery.js +2 -2
  281. package/build/domains/discovery/appDiscovery.js.map +1 -0
  282. package/build/domains/discovery/appPresets.d.ts.map +1 -0
  283. package/build/{utils → domains/discovery}/appPresets.js +1 -1
  284. package/build/domains/discovery/appPresets.js.map +1 -0
  285. package/build/{utils → domains/preset/manager}/presetManager.d.ts +1 -1
  286. package/build/domains/preset/manager/presetManager.d.ts.map +1 -0
  287. package/build/{utils → domains/preset/manager}/presetManager.js +8 -8
  288. package/build/domains/preset/manager/presetManager.js.map +1 -0
  289. package/build/{utils → domains/preset/parsers}/tagQueryEvaluator.d.ts +1 -1
  290. package/build/domains/preset/parsers/tagQueryEvaluator.d.ts.map +1 -0
  291. package/build/{utils → domains/preset/parsers}/tagQueryEvaluator.js +0 -4
  292. package/build/domains/preset/parsers/tagQueryEvaluator.js.map +1 -0
  293. package/build/{utils → domains/preset/parsers}/tagQueryParser.d.ts +1 -1
  294. package/build/domains/preset/parsers/tagQueryParser.d.ts.map +1 -0
  295. package/build/{utils → domains/preset/parsers}/tagQueryParser.js +0 -4
  296. package/build/domains/preset/parsers/tagQueryParser.js.map +1 -0
  297. package/build/domains/preset/services/presetErrorHandler.d.ts.map +1 -0
  298. package/build/{utils → domains/preset/services}/presetErrorHandler.js +1 -1
  299. package/build/domains/preset/services/presetErrorHandler.js.map +1 -0
  300. package/build/domains/preset/services/presetNotificationService.d.ts.map +1 -0
  301. package/build/{utils → domains/preset/services}/presetNotificationService.js +1 -1
  302. package/build/domains/preset/services/presetNotificationService.js.map +1 -0
  303. package/build/domains/preset/services/presetServerChangeDetector.d.ts.map +1 -0
  304. package/build/domains/preset/services/presetServerChangeDetector.js.map +1 -0
  305. package/build/domains/preset/types/presetTypes.d.ts.map +1 -0
  306. package/build/domains/preset/types/presetTypes.js.map +1 -0
  307. package/build/index.d.ts.map +1 -1
  308. package/build/index.js +5 -5
  309. package/build/index.js.map +1 -1
  310. package/build/logger/configureGlobalLogger.d.ts.map +1 -0
  311. package/build/{utils → logger}/configureGlobalLogger.js +0 -4
  312. package/build/logger/configureGlobalLogger.js.map +1 -0
  313. package/build/logger/logger.d.ts.map +1 -1
  314. package/build/logger/logger.js +13 -1
  315. package/build/logger/logger.js.map +1 -1
  316. package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -1
  317. package/build/logger/mcpLoggingEnhancer.js.map +1 -1
  318. package/build/server.d.ts +2 -2
  319. package/build/server.d.ts.map +1 -1
  320. package/build/server.js +9 -9
  321. package/build/server.js.map +1 -1
  322. package/build/transport/http/middlewares/errorHandler.d.ts.map +1 -1
  323. package/build/transport/http/middlewares/errorHandler.js.map +1 -1
  324. package/build/transport/http/middlewares/httpRequestLogger.d.ts +1 -1
  325. package/build/transport/http/middlewares/httpRequestLogger.d.ts.map +1 -1
  326. package/build/transport/http/middlewares/httpRequestLogger.js +1 -1
  327. package/build/transport/http/middlewares/httpRequestLogger.js.map +1 -1
  328. package/build/transport/http/middlewares/mcpAvailabilityMiddleware.d.ts +1 -1
  329. package/build/transport/http/middlewares/mcpAvailabilityMiddleware.d.ts.map +1 -1
  330. package/build/transport/http/middlewares/mcpAvailabilityMiddleware.js +3 -3
  331. package/build/transport/http/middlewares/mcpAvailabilityMiddleware.js.map +1 -1
  332. package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +3 -3
  333. package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -1
  334. package/build/transport/http/middlewares/scopeAuthMiddleware.js +3 -3
  335. package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -1
  336. package/build/transport/http/middlewares/securityMiddleware.d.ts +1 -1
  337. package/build/transport/http/middlewares/securityMiddleware.d.ts.map +1 -1
  338. package/build/transport/http/middlewares/securityMiddleware.js +1 -1
  339. package/build/transport/http/middlewares/securityMiddleware.js.map +1 -1
  340. package/build/transport/http/middlewares/tagsExtractor.d.ts +1 -1
  341. package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -1
  342. package/build/transport/http/middlewares/tagsExtractor.js +3 -3
  343. package/build/transport/http/middlewares/tagsExtractor.js.map +1 -1
  344. package/build/transport/http/routes/healthRoutes.d.ts +1 -1
  345. package/build/transport/http/routes/healthRoutes.d.ts.map +1 -1
  346. package/build/transport/http/routes/healthRoutes.js +3 -3
  347. package/build/transport/http/routes/healthRoutes.js.map +1 -1
  348. package/build/transport/http/routes/oauthRoutes.d.ts +1 -1
  349. package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
  350. package/build/transport/http/routes/oauthRoutes.js +10 -10
  351. package/build/transport/http/routes/oauthRoutes.js.map +1 -1
  352. package/build/transport/http/routes/sseRoutes.d.ts +2 -2
  353. package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
  354. package/build/transport/http/routes/sseRoutes.js +4 -4
  355. package/build/transport/http/routes/sseRoutes.js.map +1 -1
  356. package/build/transport/http/routes/streamableHttpRoutes.d.ts +2 -2
  357. package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
  358. package/build/transport/http/routes/streamableHttpRoutes.js +3 -3
  359. package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
  360. package/build/transport/http/server.d.ts +2 -2
  361. package/build/transport/http/server.d.ts.map +1 -1
  362. package/build/transport/http/server.js +13 -13
  363. package/build/transport/http/server.js.map +1 -1
  364. package/build/transport/restartableStdioTransport.d.ts +2 -2
  365. package/build/transport/restartableStdioTransport.d.ts.map +1 -1
  366. package/build/transport/restartableStdioTransport.js.map +1 -1
  367. package/build/transport/stdioProxyTransport.d.ts.map +1 -1
  368. package/build/transport/stdioProxyTransport.js +9 -2
  369. package/build/transport/stdioProxyTransport.js.map +1 -1
  370. package/build/transport/transportFactory.d.ts.map +1 -1
  371. package/build/transport/transportFactory.js +11 -8
  372. package/build/transport/transportFactory.js.map +1 -1
  373. package/build/utils/core/errorHandling.d.ts.map +1 -0
  374. package/build/utils/{errorHandling.js → core/errorHandling.js} +1 -1
  375. package/build/utils/core/errorHandling.js.map +1 -0
  376. package/build/utils/core/errorTypes.d.ts.map +1 -0
  377. package/build/utils/core/errorTypes.js.map +1 -0
  378. package/build/utils/{operationExecution.d.ts → core/operationExecution.d.ts} +1 -1
  379. package/build/utils/core/operationExecution.d.ts.map +1 -0
  380. package/build/utils/{operationExecution.js → core/operationExecution.js} +1 -1
  381. package/build/utils/core/operationExecution.js.map +1 -0
  382. package/build/utils/{parsing.d.ts → core/parsing.d.ts} +8 -0
  383. package/build/utils/core/parsing.d.ts.map +1 -0
  384. package/build/utils/{parsing.js → core/parsing.js} +19 -0
  385. package/build/utils/core/parsing.js.map +1 -0
  386. package/build/utils/core/timeoutUtils.d.ts +18 -0
  387. package/build/utils/core/timeoutUtils.d.ts.map +1 -0
  388. package/build/utils/core/timeoutUtils.js +21 -0
  389. package/build/utils/core/timeoutUtils.js.map +1 -0
  390. package/build/utils/{interactiveSelector.d.ts → ui/interactiveSelector.d.ts} +1 -1
  391. package/build/utils/ui/interactiveSelector.d.ts.map +1 -0
  392. package/build/utils/{interactiveSelector.js → ui/interactiveSelector.js} +4 -4
  393. package/build/utils/ui/interactiveSelector.js.map +1 -0
  394. package/build/utils/ui/logo.d.ts +17 -0
  395. package/build/utils/ui/logo.d.ts.map +1 -0
  396. package/build/utils/ui/logo.js +108 -0
  397. package/build/utils/ui/logo.js.map +1 -0
  398. package/build/utils/{pagination.d.ts → ui/pagination.d.ts} +2 -2
  399. package/build/utils/ui/pagination.d.ts.map +1 -0
  400. package/build/utils/{pagination.js → ui/pagination.js} +7 -6
  401. package/build/utils/ui/pagination.js.map +1 -0
  402. package/build/utils/ui/urlGenerator.d.ts.map +1 -0
  403. package/build/utils/{urlGenerator.js → ui/urlGenerator.js} +3 -3
  404. package/build/utils/ui/urlGenerator.js.map +1 -0
  405. package/build/utils/validation/sanitization.d.ts.map +1 -0
  406. package/build/utils/validation/sanitization.js.map +1 -0
  407. package/build/utils/validation/scopeValidation.d.ts.map +1 -0
  408. package/build/utils/{scopeValidation.js → validation/scopeValidation.js} +1 -1
  409. package/build/utils/validation/scopeValidation.js.map +1 -0
  410. package/build/utils/validation/urlDetection.d.ts.map +1 -0
  411. package/build/utils/{urlDetection.js → validation/urlDetection.js} +3 -3
  412. package/build/utils/validation/urlDetection.js.map +1 -0
  413. package/build/utils/validation/validationHelpers.d.ts.map +1 -0
  414. package/build/utils/{validationHelpers.js → validation/validationHelpers.js} +1 -1
  415. package/build/utils/validation/validationHelpers.js.map +1 -0
  416. package/package.json +7 -3
  417. package/build/handlers/notificationHandlers.d.ts.map +0 -1
  418. package/build/handlers/notificationHandlers.js.map +0 -1
  419. package/build/handlers/requestHandlers.d.ts.map +0 -1
  420. package/build/handlers/requestHandlers.js.map +0 -1
  421. package/build/services/configReloadService.d.ts.map +0 -1
  422. package/build/services/configReloadService.js.map +0 -1
  423. package/build/services/healthService.d.ts.map +0 -1
  424. package/build/services/healthService.js.map +0 -1
  425. package/build/services/tokenEstimationService.d.ts.map +0 -1
  426. package/build/services/tokenEstimationService.js.map +0 -1
  427. package/build/utils/appDiscovery.d.ts.map +0 -1
  428. package/build/utils/appDiscovery.js.map +0 -1
  429. package/build/utils/appPresets.d.ts.map +0 -1
  430. package/build/utils/appPresets.js.map +0 -1
  431. package/build/utils/backupManager.d.ts.map +0 -1
  432. package/build/utils/backupManager.js.map +0 -1
  433. package/build/utils/clientFiltering.d.ts.map +0 -1
  434. package/build/utils/clientFiltering.js.map +0 -1
  435. package/build/utils/configureGlobalLogger.d.ts.map +0 -1
  436. package/build/utils/configureGlobalLogger.js.map +0 -1
  437. package/build/utils/envProcessor.d.ts.map +0 -1
  438. package/build/utils/envProcessor.js.map +0 -1
  439. package/build/utils/errorHandling.d.ts.map +0 -1
  440. package/build/utils/errorHandling.js.map +0 -1
  441. package/build/utils/errorTypes.d.ts.map +0 -1
  442. package/build/utils/errorTypes.js.map +0 -1
  443. package/build/utils/interactiveSelector.d.ts.map +0 -1
  444. package/build/utils/interactiveSelector.js.map +0 -1
  445. package/build/utils/logo.d.ts +0 -8
  446. package/build/utils/logo.d.ts.map +0 -1
  447. package/build/utils/logo.js +0 -26
  448. package/build/utils/logo.js.map +0 -1
  449. package/build/utils/operationExecution.d.ts.map +0 -1
  450. package/build/utils/operationExecution.js.map +0 -1
  451. package/build/utils/pagination.d.ts.map +0 -1
  452. package/build/utils/pagination.js.map +0 -1
  453. package/build/utils/parsing.d.ts.map +0 -1
  454. package/build/utils/parsing.js.map +0 -1
  455. package/build/utils/pidFileManager.d.ts.map +0 -1
  456. package/build/utils/pidFileManager.js.map +0 -1
  457. package/build/utils/presetErrorHandler.d.ts.map +0 -1
  458. package/build/utils/presetErrorHandler.js.map +0 -1
  459. package/build/utils/presetManager.d.ts.map +0 -1
  460. package/build/utils/presetManager.js.map +0 -1
  461. package/build/utils/presetNotificationService.d.ts.map +0 -1
  462. package/build/utils/presetNotificationService.js.map +0 -1
  463. package/build/utils/presetServerChangeDetector.d.ts.map +0 -1
  464. package/build/utils/presetServerChangeDetector.js.map +0 -1
  465. package/build/utils/presetTypes.d.ts.map +0 -1
  466. package/build/utils/presetTypes.js.map +0 -1
  467. package/build/utils/projectConfigLoader.d.ts.map +0 -1
  468. package/build/utils/projectConfigLoader.js.map +0 -1
  469. package/build/utils/projectConfigTypes.d.ts.map +0 -1
  470. package/build/utils/projectConfigTypes.js.map +0 -1
  471. package/build/utils/sanitization.d.ts.map +0 -1
  472. package/build/utils/sanitization.js.map +0 -1
  473. package/build/utils/scopeValidation.d.ts.map +0 -1
  474. package/build/utils/scopeValidation.js.map +0 -1
  475. package/build/utils/tagQueryEvaluator.d.ts.map +0 -1
  476. package/build/utils/tagQueryEvaluator.js.map +0 -1
  477. package/build/utils/tagQueryParser.d.ts.map +0 -1
  478. package/build/utils/tagQueryParser.js.map +0 -1
  479. package/build/utils/urlDetection.d.ts.map +0 -1
  480. package/build/utils/urlDetection.js.map +0 -1
  481. package/build/utils/urlGenerator.d.ts.map +0 -1
  482. package/build/utils/urlGenerator.js.map +0 -1
  483. package/build/utils/validationHelpers.d.ts.map +0 -1
  484. package/build/utils/validationHelpers.js.map +0 -1
  485. /package/build/{utils → config}/envProcessor.d.ts +0 -0
  486. /package/build/{utils → config}/envProcessor.js +0 -0
  487. /package/build/{utils → config}/projectConfigLoader.d.ts +0 -0
  488. /package/build/{utils → config}/projectConfigTypes.d.ts +0 -0
  489. /package/build/{utils → config}/projectConfigTypes.js +0 -0
  490. /package/build/{utils → core/server}/pidFileManager.d.ts +0 -0
  491. /package/build/{utils → domains/backup}/backupManager.d.ts +0 -0
  492. /package/build/{utils → domains/discovery}/appDiscovery.d.ts +0 -0
  493. /package/build/{utils → domains/discovery}/appPresets.d.ts +0 -0
  494. /package/build/{utils → domains/preset/services}/presetErrorHandler.d.ts +0 -0
  495. /package/build/{utils → domains/preset/services}/presetNotificationService.d.ts +0 -0
  496. /package/build/{utils → domains/preset/services}/presetServerChangeDetector.d.ts +0 -0
  497. /package/build/{utils → domains/preset/services}/presetServerChangeDetector.js +0 -0
  498. /package/build/{utils → domains/preset/types}/presetTypes.d.ts +0 -0
  499. /package/build/{utils → domains/preset/types}/presetTypes.js +0 -0
  500. /package/build/{utils → logger}/configureGlobalLogger.d.ts +0 -0
  501. /package/build/utils/{errorHandling.d.ts → core/errorHandling.d.ts} +0 -0
  502. /package/build/utils/{errorTypes.d.ts → core/errorTypes.d.ts} +0 -0
  503. /package/build/utils/{errorTypes.js → core/errorTypes.js} +0 -0
  504. /package/build/utils/{urlGenerator.d.ts → ui/urlGenerator.d.ts} +0 -0
  505. /package/build/utils/{sanitization.d.ts → validation/sanitization.d.ts} +0 -0
  506. /package/build/utils/{sanitization.js → validation/sanitization.js} +0 -0
  507. /package/build/utils/{scopeValidation.d.ts → validation/scopeValidation.d.ts} +0 -0
  508. /package/build/utils/{urlDetection.d.ts → validation/urlDetection.d.ts} +0 -0
  509. /package/build/utils/{validationHelpers.d.ts → validation/validationHelpers.d.ts} +0 -0
@@ -0,0 +1,71 @@
1
+ import { MCPServerParams } from '../../core/types/index.js';
2
+ /**
3
+ * Configuration file utilities for server management commands
4
+ */
5
+ /**
6
+ * Initialize the configuration context with CLI options
7
+ * This should be called at the beginning of each command
8
+ */
9
+ export declare function initializeConfigContext(configPath?: string, configDir?: string): void;
10
+ export interface ServerConfig {
11
+ mcpServers: Record<string, MCPServerParams>;
12
+ }
13
+ /**
14
+ * Load the MCP configuration from a file
15
+ * Uses ConfigContext to resolve the appropriate config file path
16
+ */
17
+ export declare function loadConfig(configPath?: string): ServerConfig;
18
+ /**
19
+ * Save the MCP configuration to a file
20
+ * Uses ConfigContext to resolve the appropriate config file path
21
+ */
22
+ export declare function saveConfig(config: ServerConfig): void;
23
+ /**
24
+ * Check if a server exists in the configuration
25
+ */
26
+ export declare function serverExists(serverName: string): boolean;
27
+ /**
28
+ * Get a specific server configuration
29
+ */
30
+ export declare function getServer(serverName: string): MCPServerParams | null;
31
+ /**
32
+ * Add or update a server in the configuration
33
+ */
34
+ export declare function setServer(serverName: string, serverConfig: MCPServerParams): void;
35
+ /**
36
+ * Remove a server from the configuration
37
+ */
38
+ export declare function removeServer(serverName: string): boolean;
39
+ /**
40
+ * Get all servers in the configuration
41
+ */
42
+ export declare function getAllServers(): Record<string, MCPServerParams>;
43
+ /**
44
+ * Parse environment variables from key=value format
45
+ */
46
+ export declare function parseEnvVars(envArray?: string[]): Record<string, string>;
47
+ /**
48
+ * Parse headers from key=value format
49
+ */
50
+ export declare function parseHeaders(headersArray?: string[]): Record<string, string>;
51
+ /**
52
+ * Parse tags from comma-separated string
53
+ */
54
+ export declare function parseTags(tagsString?: string): string[];
55
+ /**
56
+ * Validate configuration file path
57
+ */
58
+ export declare function validateConfigPath(configPath?: string): string;
59
+ /**
60
+ * Create a backup of the configuration file
61
+ */
62
+ export declare function backupConfig(): string;
63
+ /**
64
+ * Validate server configuration against schema
65
+ */
66
+ export declare function validateServerConfig(serverConfig: MCPServerParams): void;
67
+ /**
68
+ * Reload MCP config manager after configuration changes
69
+ */
70
+ export declare function reloadMcpConfig(): void;
71
+ //# sourceMappingURL=configUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configUtils.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/configUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAUrF;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAuB5D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAkBrD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAOxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAOpE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,GAAG,IAAI,CAiBjF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAcxD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAO/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwB5E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CASvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAuB9D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAarC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,eAAe,GAAG,IAAI,CAkDxE;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAYtC"}
@@ -0,0 +1,304 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import ConfigContext from '../../config/configContext.js';
4
+ import { McpConfigManager } from '../../config/mcpConfigManager.js';
5
+ import logger from '../../logger/logger.js';
6
+ /**
7
+ * Configuration file utilities for server management commands
8
+ */
9
+ /**
10
+ * Initialize the configuration context with CLI options
11
+ * This should be called at the beginning of each command
12
+ */
13
+ export function initializeConfigContext(configPath, configDir) {
14
+ const configContext = ConfigContext.getInstance();
15
+ if (configPath) {
16
+ configContext.setConfigPath(configPath);
17
+ }
18
+ else if (configDir) {
19
+ configContext.setConfigDir(configDir);
20
+ }
21
+ else {
22
+ configContext.reset(); // Use defaults
23
+ }
24
+ }
25
+ /**
26
+ * Load the MCP configuration from a file
27
+ * Uses ConfigContext to resolve the appropriate config file path
28
+ */
29
+ export function loadConfig(configPath) {
30
+ const configContext = ConfigContext.getInstance();
31
+ const filePath = configPath || configContext.getResolvedConfigPath();
32
+ try {
33
+ if (!fs.existsSync(filePath)) {
34
+ throw new Error(`Configuration file not found: ${filePath}`);
35
+ }
36
+ const configData = JSON.parse(fs.readFileSync(filePath, 'utf8'));
37
+ // Ensure mcpServers exists
38
+ if (!configData.mcpServers) {
39
+ configData.mcpServers = {};
40
+ }
41
+ return configData;
42
+ }
43
+ catch (error) {
44
+ if (error instanceof SyntaxError) {
45
+ throw new Error(`Invalid JSON in configuration file: ${filePath}`);
46
+ }
47
+ throw error;
48
+ }
49
+ }
50
+ /**
51
+ * Save the MCP configuration to a file
52
+ * Uses ConfigContext to resolve the appropriate config file path
53
+ */
54
+ export function saveConfig(config) {
55
+ const configContext = ConfigContext.getInstance();
56
+ const filePath = configContext.getResolvedConfigPath();
57
+ try {
58
+ // Ensure directory exists
59
+ const fileDir = path.dirname(filePath);
60
+ if (!fs.existsSync(fileDir)) {
61
+ fs.mkdirSync(fileDir, { recursive: true });
62
+ }
63
+ // Write configuration with pretty formatting
64
+ fs.writeFileSync(filePath, JSON.stringify(config, null, 2));
65
+ logger.info(`Configuration saved to: ${filePath}`);
66
+ }
67
+ catch (error) {
68
+ throw new Error(`Failed to save configuration to ${filePath}: ${error}`);
69
+ }
70
+ }
71
+ /**
72
+ * Check if a server exists in the configuration
73
+ */
74
+ export function serverExists(serverName) {
75
+ try {
76
+ const config = loadConfig();
77
+ return serverName in config.mcpServers;
78
+ }
79
+ catch (_error) {
80
+ return false;
81
+ }
82
+ }
83
+ /**
84
+ * Get a specific server configuration
85
+ */
86
+ export function getServer(serverName) {
87
+ try {
88
+ const config = loadConfig();
89
+ return config.mcpServers[serverName] || null;
90
+ }
91
+ catch (_error) {
92
+ return null;
93
+ }
94
+ }
95
+ /**
96
+ * Add or update a server in the configuration
97
+ */
98
+ export function setServer(serverName, serverConfig) {
99
+ const configContext = ConfigContext.getInstance();
100
+ const filePath = configContext.getResolvedConfigPath();
101
+ let config;
102
+ // Check if config file exists before trying to load it
103
+ if (!fs.existsSync(filePath)) {
104
+ // Create a new config if it doesn't exist
105
+ config = { mcpServers: {} };
106
+ }
107
+ else {
108
+ // Load existing config (will throw on invalid JSON or other errors)
109
+ config = loadConfig();
110
+ }
111
+ config.mcpServers[serverName] = serverConfig;
112
+ saveConfig(config);
113
+ }
114
+ /**
115
+ * Remove a server from the configuration
116
+ */
117
+ export function removeServer(serverName) {
118
+ try {
119
+ const config = loadConfig();
120
+ if (!(serverName in config.mcpServers)) {
121
+ return false;
122
+ }
123
+ delete config.mcpServers[serverName];
124
+ saveConfig(config);
125
+ return true;
126
+ }
127
+ catch (error) {
128
+ throw new Error(`Failed to remove server ${serverName}: ${error}`);
129
+ }
130
+ }
131
+ /**
132
+ * Get all servers in the configuration
133
+ */
134
+ export function getAllServers() {
135
+ try {
136
+ const config = loadConfig();
137
+ return config.mcpServers;
138
+ }
139
+ catch (_error) {
140
+ return {};
141
+ }
142
+ }
143
+ /**
144
+ * Parse environment variables from key=value format
145
+ */
146
+ export function parseEnvVars(envArray) {
147
+ if (!envArray || envArray.length === 0) {
148
+ return {};
149
+ }
150
+ const env = {};
151
+ for (const envVar of envArray) {
152
+ const equalIndex = envVar.indexOf('=');
153
+ if (equalIndex === -1) {
154
+ throw new Error(`Invalid environment variable format: ${envVar}. Expected key=value`);
155
+ }
156
+ const key = envVar.substring(0, equalIndex).trim();
157
+ const value = envVar.substring(equalIndex + 1);
158
+ if (!key) {
159
+ throw new Error(`Invalid environment variable format: ${envVar}. Key cannot be empty`);
160
+ }
161
+ env[key] = value;
162
+ }
163
+ return env;
164
+ }
165
+ /**
166
+ * Parse headers from key=value format
167
+ */
168
+ export function parseHeaders(headersArray) {
169
+ if (!headersArray || headersArray.length === 0) {
170
+ return {};
171
+ }
172
+ const headers = {};
173
+ for (const header of headersArray) {
174
+ const colonIndex = header.indexOf('=');
175
+ if (colonIndex === -1) {
176
+ throw new Error(`Invalid header format: ${header}. Expected key=value`);
177
+ }
178
+ const key = header.substring(0, colonIndex).trim();
179
+ const value = header.substring(colonIndex + 1);
180
+ if (!key) {
181
+ throw new Error(`Invalid header format: ${header}. Key cannot be empty`);
182
+ }
183
+ headers[key] = value;
184
+ }
185
+ return headers;
186
+ }
187
+ /**
188
+ * Parse tags from comma-separated string
189
+ */
190
+ export function parseTags(tagsString) {
191
+ if (!tagsString) {
192
+ return [];
193
+ }
194
+ return tagsString
195
+ .split(',')
196
+ .map((tag) => tag.trim())
197
+ .filter((tag) => tag.length > 0);
198
+ }
199
+ /**
200
+ * Validate configuration file path
201
+ */
202
+ export function validateConfigPath(configPath) {
203
+ const configContext = ConfigContext.getInstance();
204
+ const filePath = configPath || configContext.getResolvedConfigPath();
205
+ try {
206
+ // Check if file exists
207
+ if (!fs.existsSync(filePath)) {
208
+ throw new Error(`Configuration file not found: ${filePath}`);
209
+ }
210
+ // Check if file is readable
211
+ fs.accessSync(filePath, fs.constants.R_OK);
212
+ // Check if file is writable
213
+ fs.accessSync(filePath, fs.constants.W_OK);
214
+ return filePath;
215
+ }
216
+ catch (error) {
217
+ if (error instanceof Error && error.message.includes('not found')) {
218
+ throw error;
219
+ }
220
+ throw new Error(`Cannot access configuration file: ${filePath}. ${error}`);
221
+ }
222
+ }
223
+ /**
224
+ * Create a backup of the configuration file
225
+ */
226
+ export function backupConfig() {
227
+ const configContext = ConfigContext.getInstance();
228
+ const filePath = configContext.getResolvedConfigPath();
229
+ const timestamp = Date.now();
230
+ const backupPath = `${filePath}.backup.${timestamp}`;
231
+ try {
232
+ fs.copyFileSync(filePath, backupPath);
233
+ logger.info(`Configuration backed up to: ${backupPath}`);
234
+ return backupPath;
235
+ }
236
+ catch (error) {
237
+ throw new Error(`Failed to create backup: ${error}`);
238
+ }
239
+ }
240
+ /**
241
+ * Validate server configuration against schema
242
+ */
243
+ export function validateServerConfig(serverConfig) {
244
+ // Basic validation - type is required
245
+ if (!serverConfig.type) {
246
+ throw new Error('Server type is required');
247
+ }
248
+ // Validate based on type
249
+ switch (serverConfig.type) {
250
+ case 'stdio':
251
+ if (!serverConfig.command) {
252
+ throw new Error('Command is required for stdio servers');
253
+ }
254
+ break;
255
+ case 'http':
256
+ case 'sse':
257
+ if (!serverConfig.url) {
258
+ throw new Error(`URL is required for ${serverConfig.type} servers`);
259
+ }
260
+ try {
261
+ new URL(serverConfig.url);
262
+ }
263
+ catch (_error) {
264
+ throw new Error(`Invalid URL format: ${serverConfig.url}`);
265
+ }
266
+ break;
267
+ default:
268
+ throw new Error(`Unsupported server type: ${serverConfig.type}`);
269
+ }
270
+ // Validate timeout if provided
271
+ if (serverConfig.timeout !== undefined) {
272
+ if (typeof serverConfig.timeout !== 'number' || serverConfig.timeout < 0) {
273
+ throw new Error('Timeout must be a positive number');
274
+ }
275
+ }
276
+ // Validate tags if provided
277
+ if (serverConfig.tags !== undefined) {
278
+ if (!Array.isArray(serverConfig.tags)) {
279
+ throw new Error('Tags must be an array');
280
+ }
281
+ for (const tag of serverConfig.tags) {
282
+ if (typeof tag !== 'string' || tag.trim().length === 0) {
283
+ throw new Error('All tags must be non-empty strings');
284
+ }
285
+ }
286
+ }
287
+ }
288
+ /**
289
+ * Reload MCP config manager after configuration changes
290
+ */
291
+ export function reloadMcpConfig() {
292
+ try {
293
+ const configContext = ConfigContext.getInstance();
294
+ const filePath = configContext.getResolvedConfigPath();
295
+ // Get the config manager instance and reload it
296
+ const configManager = McpConfigManager.getInstance(filePath);
297
+ configManager.reloadConfig();
298
+ logger.info('MCP configuration reloaded');
299
+ }
300
+ catch (error) {
301
+ logger.warn(`Failed to reload MCP configuration: ${error}`);
302
+ }
303
+ }
304
+ //# sourceMappingURL=configUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../../src/commands/shared/configUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,aAAa,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C;;GAEG;AAEH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAmB,EAAE,SAAkB;IAC7E,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAElD,IAAI,UAAU,EAAE,CAAC;QACf,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;SAAM,IAAI,SAAS,EAAE,CAAC;QACrB,aAAa,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,eAAe;IACxC,CAAC;AACH,CAAC;AAMD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,UAAmB;IAC5C,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAClD,MAAM,QAAQ,GAAG,UAAU,IAAI,aAAa,CAAC,qBAAqB,EAAE,CAAC;IAErE,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAEjE,2BAA2B;QAC3B,IAAI,CAAC,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AAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;YACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;QAEvD,gDAAgD;QAChD,MAAM,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC7D,aAAa,CAAC,YAAY,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,uCAAuC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { Prompt, Resource, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { MCPServerParams } from '../../core/types/index.js';
3
+ export interface ServerCapabilities {
4
+ serverName: string;
5
+ connected: boolean;
6
+ tools: Tool[];
7
+ resources: Resource[];
8
+ prompts: Prompt[];
9
+ error?: string;
10
+ }
11
+ /**
12
+ * Connection helper for connecting to MCP servers and retrieving their capabilities
13
+ */
14
+ export declare class McpConnectionHelper {
15
+ private connections;
16
+ /**
17
+ * Connect to MCP servers based on configuration
18
+ */
19
+ connectToServers(servers: Record<string, MCPServerParams>, timeoutMs?: number): Promise<ServerCapabilities[]>;
20
+ /**
21
+ * Get capabilities from a connected MCP server
22
+ */
23
+ private getServerCapabilities;
24
+ /**
25
+ * Clean up connections
26
+ */
27
+ cleanup(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=connectionHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectionHelper.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/connectionHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAIjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIhE,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,WAAW,CAA8C;IAEjE;;OAEG;IACG,gBAAgB,CACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACxC,SAAS,GAAE,MAAc,GACxB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAkFhC;;OAEG;YACW,qBAAqB;IAgEnC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA4B/B"}
@@ -0,0 +1,162 @@
1
+ import { ClientManager } from '../../core/client/clientManager.js';
2
+ import logger from '../../logger/logger.js';
3
+ import { createTransports } from '../../transport/transportFactory.js';
4
+ /**
5
+ * Connection helper for connecting to MCP servers and retrieving their capabilities
6
+ */
7
+ export class McpConnectionHelper {
8
+ connections = new Map();
9
+ /**
10
+ * Connect to MCP servers based on configuration
11
+ */
12
+ async connectToServers(servers, timeoutMs = 10000) {
13
+ logger.info(`Connecting to ${Object.keys(servers).length} MCP servers`);
14
+ const serverNames = Object.keys(servers);
15
+ if (serverNames.length === 0) {
16
+ return [];
17
+ }
18
+ // Create transports from server configurations
19
+ const transports = createTransports(servers);
20
+ logger.debug(`Created ${Object.keys(transports).length} transports`);
21
+ const results = [];
22
+ // Connect to servers in parallel with individual timeouts
23
+ const connectionPromises = serverNames.map(async (serverName) => {
24
+ try {
25
+ logger.debug(`Connecting to server: ${serverName}`);
26
+ // Create a timeout promise
27
+ const timeoutPromise = new Promise((_, reject) => {
28
+ setTimeout(() => {
29
+ reject(new Error(`Connection timeout after ${timeoutMs}ms`));
30
+ }, timeoutMs);
31
+ });
32
+ // Get transport for this server
33
+ const transport = transports[serverName];
34
+ if (!transport) {
35
+ throw new Error('Transport not found');
36
+ }
37
+ // Create clients with timeout
38
+ const tempClientManager = ClientManager.getOrCreateInstance();
39
+ const tempTransports = { [serverName]: transport };
40
+ // Connect with timeout
41
+ const connectPromise = tempClientManager.createClients(tempTransports);
42
+ // Race between connection and timeout
43
+ const clients = await Promise.race([connectPromise, timeoutPromise]);
44
+ const connection = clients.get(serverName);
45
+ if (!connection) {
46
+ throw new Error('Failed to establish connection');
47
+ }
48
+ this.connections.set(serverName, connection);
49
+ // Get capabilities from the connected server
50
+ const capabilities = await this.getServerCapabilities(serverName, connection);
51
+ results.push({
52
+ serverName,
53
+ connected: true,
54
+ ...capabilities,
55
+ });
56
+ logger.debug(`Successfully connected to ${serverName}`);
57
+ }
58
+ catch (error) {
59
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
60
+ logger.warn(`Failed to connect to server ${serverName}: ${errorMessage}`);
61
+ results.push({
62
+ serverName,
63
+ connected: false,
64
+ tools: [],
65
+ resources: [],
66
+ prompts: [],
67
+ error: errorMessage,
68
+ });
69
+ }
70
+ });
71
+ // Wait for all connections to complete (success or failure)
72
+ await Promise.allSettled(connectionPromises);
73
+ const connectedCount = results.filter((r) => r.connected).length;
74
+ logger.info(`Connected to ${connectedCount}/${serverNames.length} MCP servers`);
75
+ return results;
76
+ }
77
+ /**
78
+ * Get capabilities from a connected MCP server
79
+ */
80
+ async getServerCapabilities(serverName, connection) {
81
+ const tools = [];
82
+ const resources = [];
83
+ const prompts = [];
84
+ try {
85
+ // Get tools with timeout
86
+ try {
87
+ const toolsResult = await Promise.race([
88
+ connection.client.listTools({}),
89
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Tools listing timeout')), 5000)),
90
+ ]);
91
+ if (toolsResult && toolsResult.tools) {
92
+ tools.push(...toolsResult.tools);
93
+ logger.debug(`Got ${toolsResult.tools.length} tools from ${serverName}`);
94
+ }
95
+ }
96
+ catch (error) {
97
+ logger.debug(`Failed to get tools from ${serverName}: ${error instanceof Error ? error.message : error}`);
98
+ }
99
+ // Get resources with timeout
100
+ try {
101
+ const resourcesResult = await Promise.race([
102
+ connection.client.listResources({}),
103
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Resources listing timeout')), 5000)),
104
+ ]);
105
+ if (resourcesResult && resourcesResult.resources) {
106
+ resources.push(...resourcesResult.resources);
107
+ logger.debug(`Got ${resourcesResult.resources.length} resources from ${serverName}`);
108
+ }
109
+ }
110
+ catch (error) {
111
+ logger.debug(`Failed to get resources from ${serverName}: ${error instanceof Error ? error.message : error}`);
112
+ }
113
+ // Get prompts with timeout
114
+ try {
115
+ const promptsResult = await Promise.race([
116
+ connection.client.listPrompts({}),
117
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Prompts listing timeout')), 5000)),
118
+ ]);
119
+ if (promptsResult && promptsResult.prompts) {
120
+ prompts.push(...promptsResult.prompts);
121
+ logger.debug(`Got ${promptsResult.prompts.length} prompts from ${serverName}`);
122
+ }
123
+ }
124
+ catch (error) {
125
+ logger.debug(`Failed to get prompts from ${serverName}: ${error instanceof Error ? error.message : error}`);
126
+ }
127
+ }
128
+ catch (error) {
129
+ logger.warn(`Error getting capabilities from ${serverName}: ${error instanceof Error ? error.message : error}`);
130
+ }
131
+ return { tools, resources, prompts };
132
+ }
133
+ /**
134
+ * Clean up connections
135
+ */
136
+ async cleanup() {
137
+ logger.debug('Cleaning up MCP connections');
138
+ const cleanupPromises = [];
139
+ for (const [serverName, connection] of this.connections) {
140
+ const cleanupPromise = (async () => {
141
+ try {
142
+ if (connection.client && typeof connection.client.close === 'function') {
143
+ // Add timeout to close operation
144
+ await Promise.race([
145
+ connection.client.close(),
146
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Close operation timeout')), 3000)),
147
+ ]);
148
+ }
149
+ logger.debug(`Closed connection to ${serverName}`);
150
+ }
151
+ catch (error) {
152
+ logger.warn(`Error closing connection to ${serverName}: ${error instanceof Error ? error.message : error}`);
153
+ }
154
+ })();
155
+ cleanupPromises.push(cleanupPromise);
156
+ }
157
+ // Wait for all cleanup operations to complete
158
+ await Promise.allSettled(cleanupPromises);
159
+ this.connections.clear();
160
+ }
161
+ }
162
+ //# sourceMappingURL=connectionHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectionHelper.js","sourceRoot":"","sources":["../../../src/commands/shared/connectionHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAWtE;;GAEG;AACH,MAAM,OAAO,mBAAmB;IACtB,WAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IAEjE;;OAEG;IACH,KAAK,CAAC,gBAAgB,CACpB,OAAwC,EACxC,YAAoB,KAAK;QAEzB,MAAM,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,cAAc,CAAC,CAAC;QAExE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CA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C,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;gBAC9G,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;YAEL,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACvC,CAAC;QAED,8CAA8C;QAC9C,MAAM,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ import { MCPServerParams } from '../../core/types/index.js';
2
+ /**
3
+ * Validation utilities for server command inputs
4
+ */
5
+ /**
6
+ * Validate server name format
7
+ */
8
+ export declare function validateServerName(name: string): void;
9
+ /**
10
+ * Validate command line arguments for different server types
11
+ */
12
+ export declare function validateServerArgs(type: string, args: any): void;
13
+ /**
14
+ * Validate environment variables
15
+ */
16
+ export declare function validateEnvVars(envArray?: string[]): void;
17
+ /**
18
+ * Validate headers
19
+ */
20
+ export declare function validateHeaders(headersArray?: string[]): void;
21
+ /**
22
+ * Validate tags
23
+ */
24
+ export declare function validateTags(tagsString?: string): void;
25
+ /**
26
+ * Validate timeout value
27
+ */
28
+ export declare function validateTimeout(timeout?: number): void;
29
+ /**
30
+ * Validate complete server configuration
31
+ */
32
+ export declare function validateCompleteServerConfig(name: string, config: MCPServerParams): void;
33
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAsBrD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAYhE;AA2DD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAsCzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAqC7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAmCtD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAetD;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CA6BxF"}