@mcp-abap-adt/core 2.5.0 → 2.5.2

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 (400) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +3 -0
  3. package/dist/handlers/bdef/handleCreateBehaviorDefinition.d.ts +50 -0
  4. package/dist/handlers/bdef/handleCreateBehaviorDefinition.d.ts.map +1 -0
  5. package/dist/handlers/bdef/handleCreateBehaviorDefinition.js +101 -0
  6. package/dist/handlers/bdef/handleGetBdef.d.ts +54 -0
  7. package/dist/handlers/bdef/handleGetBdef.d.ts.map +1 -0
  8. package/dist/handlers/bdef/handleGetBdef.js +89 -0
  9. package/dist/handlers/bdef/handleUpdateBehaviorDefinition.d.ts +37 -0
  10. package/dist/handlers/bdef/handleUpdateBehaviorDefinition.d.ts.map +1 -0
  11. package/dist/handlers/bdef/handleUpdateBehaviorDefinition.js +85 -0
  12. package/dist/handlers/behavior_definition/readonly/handleGetBdef.d.ts +54 -0
  13. package/dist/handlers/behavior_definition/readonly/handleGetBdef.d.ts.map +1 -0
  14. package/dist/handlers/behavior_definition/readonly/handleGetBdef.js +89 -0
  15. package/dist/handlers/class/handleCheckClass.d.ts +59 -0
  16. package/dist/handlers/class/handleCheckClass.d.ts.map +1 -0
  17. package/dist/handlers/class/handleCheckClass.js +138 -0
  18. package/dist/handlers/class/handleCreateClass.d.ts +80 -0
  19. package/dist/handlers/class/handleCreateClass.d.ts.map +1 -0
  20. package/dist/handlers/class/handleCreateClass.js +192 -0
  21. package/dist/handlers/class/handleGetClass.d.ts +16 -0
  22. package/dist/handlers/class/handleGetClass.d.ts.map +1 -0
  23. package/dist/handlers/class/handleGetClass.js +159 -0
  24. package/dist/handlers/class/handleUpdateClassSource.d.ts +44 -0
  25. package/dist/handlers/class/handleUpdateClassSource.d.ts.map +1 -0
  26. package/dist/handlers/class/handleUpdateClassSource.js +131 -0
  27. package/dist/handlers/class/handleValidateClass.d.ts +62 -0
  28. package/dist/handlers/class/handleValidateClass.d.ts.map +1 -0
  29. package/dist/handlers/class/handleValidateClass.js +136 -0
  30. package/dist/handlers/class/readonly/handleGetClass.d.ts +20 -0
  31. package/dist/handlers/class/readonly/handleGetClass.d.ts.map +1 -0
  32. package/dist/handlers/class/readonly/handleGetClass.js +159 -0
  33. package/dist/handlers/common/handleActivateObject.d.ts +62 -0
  34. package/dist/handlers/common/handleActivateObject.d.ts.map +1 -0
  35. package/dist/handlers/common/handleActivateObject.js +137 -0
  36. package/dist/handlers/common/handleCheckObject.d.ts +63 -0
  37. package/dist/handlers/common/handleCheckObject.d.ts.map +1 -0
  38. package/dist/handlers/common/handleCheckObject.js +197 -0
  39. package/dist/handlers/common/handleDeleteObject.d.ts +46 -0
  40. package/dist/handlers/common/handleDeleteObject.d.ts.map +1 -0
  41. package/dist/handlers/common/handleDeleteObject.js +176 -0
  42. package/dist/handlers/common/handleLockObject.d.ts +57 -0
  43. package/dist/handlers/common/handleLockObject.d.ts.map +1 -0
  44. package/dist/handlers/common/handleLockObject.js +195 -0
  45. package/dist/handlers/common/handleUnlockObject.d.ts +61 -0
  46. package/dist/handlers/common/handleUnlockObject.d.ts.map +1 -0
  47. package/dist/handlers/common/handleUnlockObject.js +178 -0
  48. package/dist/handlers/common/handleValidateObject.d.ts +58 -0
  49. package/dist/handlers/common/handleValidateObject.d.ts.map +1 -0
  50. package/dist/handlers/common/handleValidateObject.js +177 -0
  51. package/dist/handlers/compact/high/compactSchemas.d.ts +218 -9
  52. package/dist/handlers/compact/high/compactSchemas.d.ts.map +1 -1
  53. package/dist/handlers/compact/high/compactSchemas.js +410 -134
  54. package/dist/handlers/compact/high/compactSchemas.js.map +1 -1
  55. package/dist/handlers/compact/high/handleHandlerActivate.d.ts +7 -1
  56. package/dist/handlers/compact/high/handleHandlerActivate.d.ts.map +1 -1
  57. package/dist/handlers/compact/high/handleHandlerActivate.js +1 -1
  58. package/dist/handlers/compact/high/handleHandlerActivate.js.map +1 -1
  59. package/dist/handlers/compact/high/handleHandlerCdsUnitTestResult.d.ts +4 -1
  60. package/dist/handlers/compact/high/handleHandlerCdsUnitTestResult.d.ts.map +1 -1
  61. package/dist/handlers/compact/high/handleHandlerCdsUnitTestResult.js +1 -1
  62. package/dist/handlers/compact/high/handleHandlerCdsUnitTestResult.js.map +1 -1
  63. package/dist/handlers/compact/high/handleHandlerCdsUnitTestStatus.d.ts +3 -1
  64. package/dist/handlers/compact/high/handleHandlerCdsUnitTestStatus.d.ts.map +1 -1
  65. package/dist/handlers/compact/high/handleHandlerCdsUnitTestStatus.js +1 -1
  66. package/dist/handlers/compact/high/handleHandlerCdsUnitTestStatus.js.map +1 -1
  67. package/dist/handlers/compact/high/handleHandlerCheckRun.d.ts +7 -1
  68. package/dist/handlers/compact/high/handleHandlerCheckRun.d.ts.map +1 -1
  69. package/dist/handlers/compact/high/handleHandlerCheckRun.js +1 -1
  70. package/dist/handlers/compact/high/handleHandlerCheckRun.js.map +1 -1
  71. package/dist/handlers/compact/high/handleHandlerCreate.d.ts +23 -1
  72. package/dist/handlers/compact/high/handleHandlerCreate.d.ts.map +1 -1
  73. package/dist/handlers/compact/high/handleHandlerCreate.js +1 -1
  74. package/dist/handlers/compact/high/handleHandlerCreate.js.map +1 -1
  75. package/dist/handlers/compact/high/handleHandlerDelete.d.ts +7 -1
  76. package/dist/handlers/compact/high/handleHandlerDelete.d.ts.map +1 -1
  77. package/dist/handlers/compact/high/handleHandlerDelete.js +1 -1
  78. package/dist/handlers/compact/high/handleHandlerDelete.js.map +1 -1
  79. package/dist/handlers/compact/high/handleHandlerDumpList.d.ts +6 -1
  80. package/dist/handlers/compact/high/handleHandlerDumpList.d.ts.map +1 -1
  81. package/dist/handlers/compact/high/handleHandlerDumpList.js +1 -1
  82. package/dist/handlers/compact/high/handleHandlerDumpList.js.map +1 -1
  83. package/dist/handlers/compact/high/handleHandlerDumpView.d.ts +3 -1
  84. package/dist/handlers/compact/high/handleHandlerDumpView.d.ts.map +1 -1
  85. package/dist/handlers/compact/high/handleHandlerDumpView.js +1 -1
  86. package/dist/handlers/compact/high/handleHandlerDumpView.js.map +1 -1
  87. package/dist/handlers/compact/high/handleHandlerGet.d.ts +60 -1
  88. package/dist/handlers/compact/high/handleHandlerGet.d.ts.map +1 -1
  89. package/dist/handlers/compact/high/handleHandlerGet.js +1 -1
  90. package/dist/handlers/compact/high/handleHandlerGet.js.map +1 -1
  91. package/dist/handlers/compact/high/handleHandlerLock.d.ts +7 -1
  92. package/dist/handlers/compact/high/handleHandlerLock.d.ts.map +1 -1
  93. package/dist/handlers/compact/high/handleHandlerLock.js +1 -1
  94. package/dist/handlers/compact/high/handleHandlerLock.js.map +1 -1
  95. package/dist/handlers/compact/high/handleHandlerProfileList.d.ts +1 -1
  96. package/dist/handlers/compact/high/handleHandlerProfileList.js +1 -1
  97. package/dist/handlers/compact/high/handleHandlerProfileList.js.map +1 -1
  98. package/dist/handlers/compact/high/handleHandlerProfileRun.d.ts +17 -1
  99. package/dist/handlers/compact/high/handleHandlerProfileRun.d.ts.map +1 -1
  100. package/dist/handlers/compact/high/handleHandlerProfileRun.js +1 -1
  101. package/dist/handlers/compact/high/handleHandlerProfileRun.js.map +1 -1
  102. package/dist/handlers/compact/high/handleHandlerProfileView.d.ts +7 -1
  103. package/dist/handlers/compact/high/handleHandlerProfileView.d.ts.map +1 -1
  104. package/dist/handlers/compact/high/handleHandlerProfileView.js +1 -1
  105. package/dist/handlers/compact/high/handleHandlerProfileView.js.map +1 -1
  106. package/dist/handlers/compact/high/handleHandlerServiceBindingListTypes.d.ts +2 -1
  107. package/dist/handlers/compact/high/handleHandlerServiceBindingListTypes.d.ts.map +1 -1
  108. package/dist/handlers/compact/high/handleHandlerServiceBindingListTypes.js +1 -1
  109. package/dist/handlers/compact/high/handleHandlerServiceBindingListTypes.js.map +1 -1
  110. package/dist/handlers/compact/high/handleHandlerServiceBindingValidate.d.ts +6 -1
  111. package/dist/handlers/compact/high/handleHandlerServiceBindingValidate.d.ts.map +1 -1
  112. package/dist/handlers/compact/high/handleHandlerServiceBindingValidate.js +1 -1
  113. package/dist/handlers/compact/high/handleHandlerServiceBindingValidate.js.map +1 -1
  114. package/dist/handlers/compact/high/handleHandlerTransportCreate.d.ts +5 -1
  115. package/dist/handlers/compact/high/handleHandlerTransportCreate.d.ts.map +1 -1
  116. package/dist/handlers/compact/high/handleHandlerTransportCreate.js +1 -1
  117. package/dist/handlers/compact/high/handleHandlerTransportCreate.js.map +1 -1
  118. package/dist/handlers/compact/high/handleHandlerUnitTestResult.d.ts +4 -1
  119. package/dist/handlers/compact/high/handleHandlerUnitTestResult.d.ts.map +1 -1
  120. package/dist/handlers/compact/high/handleHandlerUnitTestResult.js +1 -1
  121. package/dist/handlers/compact/high/handleHandlerUnitTestResult.js.map +1 -1
  122. package/dist/handlers/compact/high/handleHandlerUnitTestRun.d.ts +18 -1
  123. package/dist/handlers/compact/high/handleHandlerUnitTestRun.d.ts.map +1 -1
  124. package/dist/handlers/compact/high/handleHandlerUnitTestRun.js +1 -1
  125. package/dist/handlers/compact/high/handleHandlerUnitTestRun.js.map +1 -1
  126. package/dist/handlers/compact/high/handleHandlerUnitTestStatus.d.ts +3 -1
  127. package/dist/handlers/compact/high/handleHandlerUnitTestStatus.d.ts.map +1 -1
  128. package/dist/handlers/compact/high/handleHandlerUnitTestStatus.js +1 -1
  129. package/dist/handlers/compact/high/handleHandlerUnitTestStatus.js.map +1 -1
  130. package/dist/handlers/compact/high/handleHandlerUnlock.d.ts +7 -1
  131. package/dist/handlers/compact/high/handleHandlerUnlock.d.ts.map +1 -1
  132. package/dist/handlers/compact/high/handleHandlerUnlock.js +1 -1
  133. package/dist/handlers/compact/high/handleHandlerUnlock.js.map +1 -1
  134. package/dist/handlers/compact/high/handleHandlerUpdate.d.ts +21 -1
  135. package/dist/handlers/compact/high/handleHandlerUpdate.d.ts.map +1 -1
  136. package/dist/handlers/compact/high/handleHandlerUpdate.js +1 -1
  137. package/dist/handlers/compact/high/handleHandlerUpdate.js.map +1 -1
  138. package/dist/handlers/compact/high/handleHandlerValidate.d.ts +22 -10
  139. package/dist/handlers/compact/high/handleHandlerValidate.d.ts.map +1 -1
  140. package/dist/handlers/compact/high/handleHandlerValidate.js +1 -1
  141. package/dist/handlers/compact/high/handleHandlerValidate.js.map +1 -1
  142. package/dist/handlers/data_element/handleCreateDataElement.d.ts +83 -0
  143. package/dist/handlers/data_element/handleCreateDataElement.d.ts.map +1 -0
  144. package/dist/handlers/data_element/handleCreateDataElement.js +180 -0
  145. package/dist/handlers/data_element/handleGetDataElement.d.ts +29 -0
  146. package/dist/handlers/data_element/handleGetDataElement.d.ts.map +1 -0
  147. package/dist/handlers/data_element/handleGetDataElement.js +173 -0
  148. package/dist/handlers/data_element/handleUpdateDataElement.d.ts +131 -0
  149. package/dist/handlers/data_element/handleUpdateDataElement.d.ts.map +1 -0
  150. package/dist/handlers/data_element/handleUpdateDataElement.js +258 -0
  151. package/dist/handlers/data_element/readonly/handleGetDataElement.d.ts +33 -0
  152. package/dist/handlers/data_element/readonly/handleGetDataElement.d.ts.map +1 -0
  153. package/dist/handlers/data_element/readonly/handleGetDataElement.js +173 -0
  154. package/dist/handlers/ddlx/handleCreateMetadataExtension.d.ts +41 -0
  155. package/dist/handlers/ddlx/handleCreateMetadataExtension.d.ts.map +1 -0
  156. package/dist/handlers/ddlx/handleCreateMetadataExtension.js +92 -0
  157. package/dist/handlers/ddlx/handleUpdateMetadataExtension.d.ts +37 -0
  158. package/dist/handlers/ddlx/handleUpdateMetadataExtension.d.ts.map +1 -0
  159. package/dist/handlers/ddlx/handleUpdateMetadataExtension.js +81 -0
  160. package/dist/handlers/domain/handleCreateDomain.d.ts +104 -0
  161. package/dist/handlers/domain/handleCreateDomain.d.ts.map +1 -0
  162. package/dist/handlers/domain/handleCreateDomain.js +187 -0
  163. package/dist/handlers/domain/handleGetDomain.d.ts +19 -0
  164. package/dist/handlers/domain/handleGetDomain.d.ts.map +1 -0
  165. package/dist/handlers/domain/handleGetDomain.js +138 -0
  166. package/dist/handlers/domain/handleUpdateDomain.d.ts +99 -0
  167. package/dist/handlers/domain/handleUpdateDomain.d.ts.map +1 -0
  168. package/dist/handlers/domain/handleUpdateDomain.js +204 -0
  169. package/dist/handlers/domain/readonly/handleGetDomain.d.ts +23 -0
  170. package/dist/handlers/domain/readonly/handleGetDomain.d.ts.map +1 -0
  171. package/dist/handlers/domain/readonly/handleGetDomain.js +138 -0
  172. package/dist/handlers/enhancement/handleGetEnhancementImpl.d.ts +69 -0
  173. package/dist/handlers/enhancement/handleGetEnhancementImpl.d.ts.map +1 -0
  174. package/dist/handlers/enhancement/handleGetEnhancementImpl.js +171 -0
  175. package/dist/handlers/enhancement/handleGetEnhancementSpot.d.ts +53 -0
  176. package/dist/handlers/enhancement/handleGetEnhancementSpot.d.ts.map +1 -0
  177. package/dist/handlers/enhancement/handleGetEnhancementSpot.js +153 -0
  178. package/dist/handlers/enhancement/handleGetEnhancements.d.ts +64 -0
  179. package/dist/handlers/enhancement/handleGetEnhancements.d.ts.map +1 -0
  180. package/dist/handlers/enhancement/handleGetEnhancements.js +599 -0
  181. package/dist/handlers/function/handleCheckFunctionModule.d.ts +59 -0
  182. package/dist/handlers/function/handleCheckFunctionModule.d.ts.map +1 -0
  183. package/dist/handlers/function/handleCheckFunctionModule.js +140 -0
  184. package/dist/handlers/function/handleCreateFunctionGroup.d.ts +52 -0
  185. package/dist/handlers/function/handleCreateFunctionGroup.d.ts.map +1 -0
  186. package/dist/handlers/function/handleCreateFunctionGroup.js +114 -0
  187. package/dist/handlers/function/handleCreateFunctionModule.d.ts +57 -0
  188. package/dist/handlers/function/handleCreateFunctionModule.d.ts.map +1 -0
  189. package/dist/handlers/function/handleCreateFunctionModule.js +137 -0
  190. package/dist/handlers/function/handleGetFunction.d.ts +17 -0
  191. package/dist/handlers/function/handleGetFunction.d.ts.map +1 -0
  192. package/dist/handlers/function/handleGetFunction.js +172 -0
  193. package/dist/handlers/function/handleGetFunctionGroup.d.ts +16 -0
  194. package/dist/handlers/function/handleGetFunctionGroup.d.ts.map +1 -0
  195. package/dist/handlers/function/handleGetFunctionGroup.js +132 -0
  196. package/dist/handlers/function/handleUpdateFunctionModuleSource.d.ts +54 -0
  197. package/dist/handlers/function/handleUpdateFunctionModuleSource.d.ts.map +1 -0
  198. package/dist/handlers/function/handleUpdateFunctionModuleSource.js +108 -0
  199. package/dist/handlers/function/handleValidateFunctionModule.d.ts +58 -0
  200. package/dist/handlers/function/handleValidateFunctionModule.d.ts.map +1 -0
  201. package/dist/handlers/function/handleValidateFunctionModule.js +132 -0
  202. package/dist/handlers/function/readonly/handleGetFunctionGroup.d.ts +16 -0
  203. package/dist/handlers/function/readonly/handleGetFunctionGroup.d.ts.map +1 -0
  204. package/dist/handlers/function/readonly/handleGetFunctionGroup.js +132 -0
  205. package/dist/handlers/include/handleGetInclude.d.ts +16 -0
  206. package/dist/handlers/include/handleGetInclude.d.ts.map +1 -0
  207. package/dist/handlers/include/handleGetInclude.js +81 -0
  208. package/dist/handlers/include/handleGetIncludesList.d.ts +36 -0
  209. package/dist/handlers/include/handleGetIncludesList.d.ts.map +1 -0
  210. package/dist/handlers/include/handleGetIncludesList.js +223 -0
  211. package/dist/handlers/interface/handleCreateInterface.d.ts +64 -0
  212. package/dist/handlers/interface/handleCreateInterface.d.ts.map +1 -0
  213. package/dist/handlers/interface/handleCreateInterface.js +175 -0
  214. package/dist/handlers/interface/handleGetInterface.d.ts +40 -0
  215. package/dist/handlers/interface/handleGetInterface.d.ts.map +1 -0
  216. package/dist/handlers/interface/handleGetInterface.js +134 -0
  217. package/dist/handlers/interface/handleUpdateInterfaceSource.d.ts +48 -0
  218. package/dist/handlers/interface/handleUpdateInterfaceSource.d.ts.map +1 -0
  219. package/dist/handlers/interface/handleUpdateInterfaceSource.js +127 -0
  220. package/dist/handlers/interface/readonly/handleGetInterface.d.ts +44 -0
  221. package/dist/handlers/interface/readonly/handleGetInterface.d.ts.map +1 -0
  222. package/dist/handlers/interface/readonly/handleGetInterface.js +134 -0
  223. package/dist/handlers/package/handleCreatePackage.d.ts +38 -0
  224. package/dist/handlers/package/handleCreatePackage.d.ts.map +1 -0
  225. package/dist/handlers/package/handleCreatePackage.js +127 -0
  226. package/dist/handlers/package/handleGetPackage.d.ts +16 -0
  227. package/dist/handlers/package/handleGetPackage.d.ts.map +1 -0
  228. package/dist/handlers/package/handleGetPackage.js +94 -0
  229. package/dist/handlers/package/readonly/handleGetPackage.d.ts +21 -0
  230. package/dist/handlers/package/readonly/handleGetPackage.d.ts.map +1 -0
  231. package/dist/handlers/package/readonly/handleGetPackage.js +94 -0
  232. package/dist/handlers/program/handleCreateProgram.d.ts +73 -0
  233. package/dist/handlers/program/handleCreateProgram.d.ts.map +1 -0
  234. package/dist/handlers/program/handleCreateProgram.js +220 -0
  235. package/dist/handlers/program/handleGetProgFullCode.d.ts +67 -0
  236. package/dist/handlers/program/handleGetProgFullCode.d.ts.map +1 -0
  237. package/dist/handlers/program/handleGetProgFullCode.js +249 -0
  238. package/dist/handlers/program/handleGetProgram.d.ts +16 -0
  239. package/dist/handlers/program/handleGetProgram.d.ts.map +1 -0
  240. package/dist/handlers/program/handleGetProgram.js +71 -0
  241. package/dist/handlers/program/handleUpdateProgramSource.d.ts +44 -0
  242. package/dist/handlers/program/handleUpdateProgramSource.d.ts.map +1 -0
  243. package/dist/handlers/program/handleUpdateProgramSource.js +121 -0
  244. package/dist/handlers/program/readonly/handleGetProgram.d.ts +20 -0
  245. package/dist/handlers/program/readonly/handleGetProgram.d.ts.map +1 -0
  246. package/dist/handlers/program/readonly/handleGetProgram.js +71 -0
  247. package/dist/handlers/search/handleGetObjectsByType.d.ts +42 -0
  248. package/dist/handlers/search/handleGetObjectsByType.d.ts.map +1 -0
  249. package/dist/handlers/search/handleGetObjectsByType.js +166 -0
  250. package/dist/handlers/search/handleGetObjectsList.d.ts +46 -0
  251. package/dist/handlers/search/handleGetObjectsList.d.ts.map +1 -0
  252. package/dist/handlers/search/handleGetObjectsList.js +145 -0
  253. package/dist/handlers/search/handleSearchObject.d.ts +28 -0
  254. package/dist/handlers/search/handleSearchObject.d.ts.map +1 -0
  255. package/dist/handlers/search/handleSearchObject.js +119 -0
  256. package/dist/handlers/service_definition/readonly/handleGetServiceDefinition.d.ts +17 -0
  257. package/dist/handlers/service_definition/readonly/handleGetServiceDefinition.d.ts.map +1 -0
  258. package/dist/handlers/service_definition/readonly/handleGetServiceDefinition.js +136 -0
  259. package/dist/handlers/structure/handleCreateStructure.d.ts +107 -0
  260. package/dist/handlers/structure/handleCreateStructure.d.ts.map +1 -0
  261. package/dist/handlers/structure/handleCreateStructure.js +184 -0
  262. package/dist/handlers/structure/handleGetStructure.d.ts +16 -0
  263. package/dist/handlers/structure/handleGetStructure.d.ts.map +1 -0
  264. package/dist/handlers/structure/handleGetStructure.js +139 -0
  265. package/dist/handlers/structure/readonly/handleGetStructure.d.ts +16 -0
  266. package/dist/handlers/structure/readonly/handleGetStructure.d.ts.map +1 -0
  267. package/dist/handlers/structure/readonly/handleGetStructure.js +139 -0
  268. package/dist/handlers/system/handleDescribeByList.d.ts +36 -0
  269. package/dist/handlers/system/handleDescribeByList.d.ts.map +1 -0
  270. package/dist/handlers/system/handleDescribeByList.js +121 -0
  271. package/dist/handlers/system/handleGetAbapAST.d.ts +26 -0
  272. package/dist/handlers/system/handleGetAbapAST.d.ts.map +1 -0
  273. package/dist/handlers/system/handleGetAbapAST.js +172 -0
  274. package/dist/handlers/system/handleGetAbapSemanticAnalysis.d.ts +26 -0
  275. package/dist/handlers/system/handleGetAbapSemanticAnalysis.d.ts.map +1 -0
  276. package/dist/handlers/system/handleGetAbapSemanticAnalysis.js +353 -0
  277. package/dist/handlers/system/handleGetAbapSystemSymbols.d.ts +26 -0
  278. package/dist/handlers/system/handleGetAbapSystemSymbols.d.ts.map +1 -0
  279. package/dist/handlers/system/handleGetAbapSystemSymbols.js +574 -0
  280. package/dist/handlers/system/handleGetAllTypes.d.ts +22 -0
  281. package/dist/handlers/system/handleGetAllTypes.d.ts.map +1 -0
  282. package/dist/handlers/system/handleGetAllTypes.js +102 -0
  283. package/dist/handlers/system/handleGetInactiveObjects.d.ts +20 -0
  284. package/dist/handlers/system/handleGetInactiveObjects.d.ts.map +1 -0
  285. package/dist/handlers/system/handleGetInactiveObjects.js +41 -0
  286. package/dist/handlers/system/handleGetObjectInfo.d.ts +41 -0
  287. package/dist/handlers/system/handleGetObjectInfo.d.ts.map +1 -0
  288. package/dist/handlers/system/handleGetObjectInfo.js +210 -0
  289. package/dist/handlers/system/handleGetObjectNodeFromCache.d.ts +40 -0
  290. package/dist/handlers/system/handleGetObjectNodeFromCache.d.ts.map +1 -0
  291. package/dist/handlers/system/handleGetObjectNodeFromCache.js +70 -0
  292. package/dist/handlers/system/handleGetObjectStructure.d.ts +26 -0
  293. package/dist/handlers/system/handleGetObjectStructure.d.ts.map +1 -0
  294. package/dist/handlers/system/handleGetObjectStructure.js +103 -0
  295. package/dist/handlers/system/handleGetSession.d.ts +33 -0
  296. package/dist/handlers/system/handleGetSession.d.ts.map +1 -0
  297. package/dist/handlers/system/handleGetSession.js +63 -0
  298. package/dist/handlers/system/handleGetSqlQuery.d.ts +49 -0
  299. package/dist/handlers/system/handleGetSqlQuery.d.ts.map +1 -0
  300. package/dist/handlers/system/handleGetSqlQuery.js +176 -0
  301. package/dist/handlers/system/handleGetTransaction.d.ts +42 -0
  302. package/dist/handlers/system/handleGetTransaction.d.ts.map +1 -0
  303. package/dist/handlers/system/handleGetTransaction.js +91 -0
  304. package/dist/handlers/system/handleGetTypeInfo.d.ts +69 -0
  305. package/dist/handlers/system/handleGetTypeInfo.d.ts.map +1 -0
  306. package/dist/handlers/system/handleGetTypeInfo.js +169 -0
  307. package/dist/handlers/system/handleGetWhereUsed.d.ts +69 -0
  308. package/dist/handlers/system/handleGetWhereUsed.d.ts.map +1 -0
  309. package/dist/handlers/system/handleGetWhereUsed.js +405 -0
  310. package/dist/handlers/table/handleCheckTable.d.ts +55 -0
  311. package/dist/handlers/table/handleCheckTable.d.ts.map +1 -0
  312. package/dist/handlers/table/handleCheckTable.js +138 -0
  313. package/dist/handlers/table/handleCreateTable.d.ts +42 -0
  314. package/dist/handlers/table/handleCreateTable.d.ts.map +1 -0
  315. package/dist/handlers/table/handleCreateTable.js +118 -0
  316. package/dist/handlers/table/handleGetTable.d.ts +16 -0
  317. package/dist/handlers/table/handleGetTable.d.ts.map +1 -0
  318. package/dist/handlers/table/handleGetTable.js +140 -0
  319. package/dist/handlers/table/handleGetTableContents.d.ts +56 -0
  320. package/dist/handlers/table/handleGetTableContents.d.ts.map +1 -0
  321. package/dist/handlers/table/handleGetTableContents.js +387 -0
  322. package/dist/handlers/table/handleValidateTable.d.ts +53 -0
  323. package/dist/handlers/table/handleValidateTable.d.ts.map +1 -0
  324. package/dist/handlers/table/handleValidateTable.js +125 -0
  325. package/dist/handlers/table/readonly/handleGetTable.d.ts +20 -0
  326. package/dist/handlers/table/readonly/handleGetTable.d.ts.map +1 -0
  327. package/dist/handlers/table/readonly/handleGetTable.js +140 -0
  328. package/dist/handlers/transport/handleCreateTransport.d.ts +50 -0
  329. package/dist/handlers/transport/handleCreateTransport.d.ts.map +1 -0
  330. package/dist/handlers/transport/handleCreateTransport.js +151 -0
  331. package/dist/handlers/transport/handleGetTransport.d.ts +44 -0
  332. package/dist/handlers/transport/handleGetTransport.d.ts.map +1 -0
  333. package/dist/handlers/transport/handleGetTransport.js +183 -0
  334. package/dist/handlers/view/handleCreateView.d.ts +52 -0
  335. package/dist/handlers/view/handleCreateView.d.ts.map +1 -0
  336. package/dist/handlers/view/handleCreateView.js +139 -0
  337. package/dist/handlers/view/handleGetView.d.ts +26 -0
  338. package/dist/handlers/view/handleGetView.d.ts.map +1 -0
  339. package/dist/handlers/view/handleGetView.js +349 -0
  340. package/dist/handlers/view/handleUpdateViewSource.d.ts +44 -0
  341. package/dist/handlers/view/handleUpdateViewSource.d.ts.map +1 -0
  342. package/dist/handlers/view/handleUpdateViewSource.js +136 -0
  343. package/dist/handlers/view/readonly/handleGetView.d.ts +26 -0
  344. package/dist/handlers/view/readonly/handleGetView.d.ts.map +1 -0
  345. package/dist/handlers/view/readonly/handleGetView.js +349 -0
  346. package/dist/index.d.ts +94 -0
  347. package/dist/index.d.ts.map +1 -0
  348. package/dist/index.js +2453 -0
  349. package/dist/lib/activationUtils.d.ts +59 -0
  350. package/dist/lib/activationUtils.d.ts.map +1 -0
  351. package/dist/lib/activationUtils.js +168 -0
  352. package/dist/lib/config/ArgumentsParser.d.ts +2 -0
  353. package/dist/lib/config/ArgumentsParser.d.ts.map +1 -1
  354. package/dist/lib/config/ArgumentsParser.js +11 -1
  355. package/dist/lib/config/ArgumentsParser.js.map +1 -1
  356. package/dist/lib/config/IServerConfig.d.ts +2 -0
  357. package/dist/lib/config/IServerConfig.d.ts.map +1 -1
  358. package/dist/lib/config/ServerConfigManager.d.ts.map +1 -1
  359. package/dist/lib/config/ServerConfigManager.js +3 -0
  360. package/dist/lib/config/ServerConfigManager.js.map +1 -1
  361. package/dist/lib/getFullCodeCache.d.ts +3 -0
  362. package/dist/lib/getFullCodeCache.d.ts.map +1 -0
  363. package/dist/lib/getFullCodeCache.js +56 -0
  364. package/dist/lib/toolsRegistry.d.ts +13 -0
  365. package/dist/lib/toolsRegistry.d.ts.map +1 -0
  366. package/dist/lib/toolsRegistry.js +410 -0
  367. package/dist/server/AuthBrokerConfig.d.ts.map +1 -1
  368. package/dist/server/AuthBrokerConfig.js +14 -9
  369. package/dist/server/AuthBrokerConfig.js.map +1 -1
  370. package/dist/server/BaseMcpServer.d.ts.map +1 -1
  371. package/dist/server/BaseMcpServer.js +6 -0
  372. package/dist/server/BaseMcpServer.js.map +1 -1
  373. package/dist/server/launcher.js +4 -4
  374. package/dist/server/launcher.js.map +1 -1
  375. package/dist/utils/lockStateManager.d.ts +64 -0
  376. package/dist/utils/lockStateManager.d.ts.map +1 -0
  377. package/dist/utils/lockStateManager.js +173 -0
  378. package/dist/utils/lockStateManager.js.map +1 -0
  379. package/docs/user-guide/AUTHENTICATION.md +7 -0
  380. package/docs/user-guide/AVAILABLE_TOOLS.md +189 -174
  381. package/docs/user-guide/AVAILABLE_TOOLS_COMPACT.md +189 -174
  382. package/docs/user-guide/AVAILABLE_TOOLS_HIGH.md +189 -174
  383. package/docs/user-guide/CLI_OPTIONS.md +14 -0
  384. package/package.json +2 -1
  385. package/dist/handlers/service_binding/high/handleListServiceBindings.d.ts +0 -44
  386. package/dist/handlers/service_binding/high/handleListServiceBindings.d.ts.map +0 -1
  387. package/dist/handlers/service_binding/high/handleListServiceBindings.js +0 -211
  388. package/dist/handlers/service_binding/high/handleListServiceBindings.js.map +0 -1
  389. package/dist/handlers/service_binding/high/serviceBindingXmlBuilder.d.ts +0 -11
  390. package/dist/handlers/service_binding/high/serviceBindingXmlBuilder.d.ts.map +0 -1
  391. package/dist/handlers/service_binding/high/serviceBindingXmlBuilder.js +0 -27
  392. package/dist/handlers/service_binding/high/serviceBindingXmlBuilder.js.map +0 -1
  393. package/dist/handlers/system/readonly/handleRuntimeGetDumpByUri.d.ts +0 -27
  394. package/dist/handlers/system/readonly/handleRuntimeGetDumpByUri.d.ts.map +0 -1
  395. package/dist/handlers/system/readonly/handleRuntimeGetDumpByUri.js +0 -47
  396. package/dist/handlers/system/readonly/handleRuntimeGetDumpByUri.js.map +0 -1
  397. package/dist/handlers/system/readonly/runtimeDumpReadCompat.d.ts +0 -8
  398. package/dist/handlers/system/readonly/runtimeDumpReadCompat.d.ts.map +0 -1
  399. package/dist/handlers/system/readonly/runtimeDumpReadCompat.js +0 -55
  400. package/dist/handlers/system/readonly/runtimeDumpReadCompat.js.map +0 -1
package/dist/index.js ADDED
@@ -0,0 +1,2453 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // Simple stdio mode detection (like reference implementation)
4
+ // No output suppression needed - dotenv removed, manual .env parsing used
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.mcp_abap_adt_server = void 0;
43
+ exports.setSapConfigOverride = setSapConfigOverride;
44
+ exports.setAbapConnectionOverride = setAbapConnectionOverride;
45
+ exports.getConfig = getConfig;
46
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
47
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
48
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
49
+ const sse_js_1 = require("@modelcontextprotocol/sdk/server/sse.js");
50
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
51
+ const z = __importStar(require("zod"));
52
+ const path_1 = __importDefault(require("path"));
53
+ // dotenv removed - using manual .env parsing for all modes to avoid stdout pollution
54
+ const http_1 = require("http");
55
+ const crypto_1 = require("crypto");
56
+ // Import handler functions
57
+ // Import handler functions
58
+ const handleGetProgram_1 = require("./handlers/program/readonly/handleGetProgram");
59
+ const handleGetClass_1 = require("./handlers/class/readonly/handleGetClass");
60
+ const handleGetFunctionGroup_1 = require("./handlers/function/readonly/handleGetFunctionGroup");
61
+ const handleGetFunction_1 = require("./handlers/function/readonly/handleGetFunction");
62
+ const handleGetTable_1 = require("./handlers/table/readonly/handleGetTable");
63
+ const handleGetStructure_1 = require("./handlers/structure/readonly/handleGetStructure");
64
+ const handleGetTableContents_1 = require("./handlers/table/readonly/handleGetTableContents");
65
+ const handleGetPackage_1 = require("./handlers/package/readonly/handleGetPackage");
66
+ const handleCreatePackage_1 = require("./handlers/package/high/handleCreatePackage");
67
+ const handleGetInclude_1 = require("./handlers/include/readonly/handleGetInclude");
68
+ const handleGetIncludesList_1 = require("./handlers/include/readonly/handleGetIncludesList");
69
+ const handleGetTypeInfo_1 = require("./handlers/system/readonly/handleGetTypeInfo");
70
+ const handleGetInterface_1 = require("./handlers/interface/readonly/handleGetInterface");
71
+ const handleGetTransaction_1 = require("./handlers/system/readonly/handleGetTransaction");
72
+ const handleSearchObject_1 = require("./handlers/search/readonly/handleSearchObject");
73
+ const handleGetEnhancements_1 = require("./handlers/enhancement/readonly/handleGetEnhancements");
74
+ const handleGetEnhancementImpl_1 = require("./handlers/enhancement/readonly/handleGetEnhancementImpl");
75
+ const handleGetEnhancementSpot_1 = require("./handlers/enhancement/readonly/handleGetEnhancementSpot");
76
+ const handleGetBdef_1 = require("./handlers/behavior_definition/readonly/handleGetBdef");
77
+ const handleGetSqlQuery_1 = require("./handlers/system/readonly/handleGetSqlQuery");
78
+ const handleGetWhereUsed_1 = require("./handlers/system/readonly/handleGetWhereUsed");
79
+ const handleGetObjectInfo_1 = require("./handlers/system/readonly/handleGetObjectInfo");
80
+ const handleGetAbapAST_1 = require("./handlers/system/readonly/handleGetAbapAST");
81
+ const handleGetAbapSemanticAnalysis_1 = require("./handlers/system/readonly/handleGetAbapSemanticAnalysis");
82
+ const handleGetAbapSystemSymbols_1 = require("./handlers/system/readonly/handleGetAbapSystemSymbols");
83
+ const handleGetDomain_1 = require("./handlers/domain/readonly/handleGetDomain");
84
+ const handleCreateDomain_1 = require("./handlers/domain/high/handleCreateDomain");
85
+ const handleUpdateDomain_1 = require("./handlers/domain/high/handleUpdateDomain");
86
+ const handleCreateDataElement_1 = require("./handlers/data_element/high/handleCreateDataElement");
87
+ const handleUpdateDataElement_1 = require("./handlers/data_element/high/handleUpdateDataElement");
88
+ const handleGetDataElement_1 = require("./handlers/data_element/readonly/handleGetDataElement");
89
+ const handleCreateTransport_1 = require("./handlers/transport/high/handleCreateTransport");
90
+ const handleGetTransport_1 = require("./handlers/transport/readonly/handleGetTransport");
91
+ const handleCreateTable_1 = require("./handlers/table/high/handleCreateTable");
92
+ const handleCreateStructure_1 = require("./handlers/structure/high/handleCreateStructure");
93
+ const handleCreateView_1 = require("./handlers/view/high/handleCreateView");
94
+ const handleGetView_1 = require("./handlers/view/readonly/handleGetView");
95
+ const handleGetServiceDefinition_1 = require("./handlers/service_definition/readonly/handleGetServiceDefinition");
96
+ const handleCreateClass_1 = require("./handlers/class/high/handleCreateClass");
97
+ const handleCreateProgram_1 = require("./handlers/program/high/handleCreateProgram");
98
+ const handleCreateInterface_1 = require("./handlers/interface/high/handleCreateInterface");
99
+ const handleCreateFunctionGroup_1 = require("./handlers/function/high/handleCreateFunctionGroup");
100
+ const handleCreateFunctionModule_1 = require("./handlers/function/high/handleCreateFunctionModule");
101
+ const handleActivateObject_1 = require("./handlers/common/low/handleActivateObject");
102
+ const handleDeleteObject_1 = require("./handlers/common/low/handleDeleteObject");
103
+ const handleCheckObject_1 = require("./handlers/common/low/handleCheckObject");
104
+ const handleUpdateClass_1 = require("./handlers/class/high/handleUpdateClass");
105
+ const handleUpdateProgram_1 = require("./handlers/program/high/handleUpdateProgram");
106
+ const handleUpdateView_1 = require("./handlers/view/high/handleUpdateView");
107
+ const handleUpdateInterface_1 = require("./handlers/interface/high/handleUpdateInterface");
108
+ const handleUpdateFunctionModule_1 = require("./handlers/function/high/handleUpdateFunctionModule");
109
+ const handleUpdateStructure_1 = require("./handlers/structure/low/handleUpdateStructure");
110
+ const handleUpdatePackage_1 = require("./handlers/package/low/handleUpdatePackage");
111
+ const handleUpdateTable_1 = require("./handlers/table/low/handleUpdateTable");
112
+ const handleUnlockPackage_1 = require("./handlers/package/low/handleUnlockPackage");
113
+ const handleUpdateClass_2 = require("./handlers/class/low/handleUpdateClass");
114
+ const handleUpdateProgram_2 = require("./handlers/program/low/handleUpdateProgram");
115
+ const handleUpdateInterface_2 = require("./handlers/interface/low/handleUpdateInterface");
116
+ const handleUpdateFunctionModule_2 = require("./handlers/function/low/handleUpdateFunctionModule");
117
+ const handleUpdateView_2 = require("./handlers/view/low/handleUpdateView");
118
+ const handleUpdateDomain_2 = require("./handlers/domain/low/handleUpdateDomain");
119
+ const handleUpdateDataElement_2 = require("./handlers/data_element/low/handleUpdateDataElement");
120
+ const handleUpdateBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleUpdateBehaviorDefinition");
121
+ const handleUpdateMetadataExtension_1 = require("./handlers/ddlx/low/handleUpdateMetadataExtension");
122
+ const handleGetSession_1 = require("./handlers/system/readonly/handleGetSession");
123
+ const handleValidateObject_1 = require("./handlers/common/low/handleValidateObject");
124
+ const handleLockObject_1 = require("./handlers/common/low/handleLockObject");
125
+ const handleUnlockObject_1 = require("./handlers/common/low/handleUnlockObject");
126
+ const handleValidateClass_1 = require("./handlers/class/low/handleValidateClass");
127
+ const handleCheckClass_1 = require("./handlers/class/low/handleCheckClass");
128
+ const handleValidateTable_1 = require("./handlers/table/low/handleValidateTable");
129
+ const handleCheckTable_1 = require("./handlers/table/low/handleCheckTable");
130
+ const handleValidateFunctionModule_1 = require("./handlers/function/low/handleValidateFunctionModule");
131
+ const handleCheckFunctionModule_1 = require("./handlers/function/low/handleCheckFunctionModule");
132
+ const handleCreateBehaviorDefinition_1 = require("./handlers/behavior_definition/high/handleCreateBehaviorDefinition");
133
+ const handleUpdateBehaviorDefinition_2 = require("./handlers/behavior_definition/high/handleUpdateBehaviorDefinition");
134
+ const handleCreateMetadataExtension_1 = require("./handlers/ddlx/high/handleCreateMetadataExtension");
135
+ const handleUpdateMetadataExtension_2 = require("./handlers/ddlx/high/handleUpdateMetadataExtension");
136
+ const handleGetInactiveObjects_1 = require("./handlers/system/readonly/handleGetInactiveObjects");
137
+ // New low-level handlers imports
138
+ const handleDeleteClass_1 = require("./handlers/class/low/handleDeleteClass");
139
+ const handleLockClass_1 = require("./handlers/class/low/handleLockClass");
140
+ const handleUnlockClass_1 = require("./handlers/class/low/handleUnlockClass");
141
+ const handleCreateClass_2 = require("./handlers/class/low/handleCreateClass");
142
+ const handleLockClassTestClasses_1 = require("./handlers/class/low/handleLockClassTestClasses");
143
+ const handleUnlockClassTestClasses_1 = require("./handlers/class/low/handleUnlockClassTestClasses");
144
+ const handleUpdateClassTestClasses_1 = require("./handlers/class/low/handleUpdateClassTestClasses");
145
+ const handleActivateClassTestClasses_1 = require("./handlers/class/low/handleActivateClassTestClasses");
146
+ const handleRunClassUnitTests_1 = require("./handlers/class/low/handleRunClassUnitTests");
147
+ const handleGetClassUnitTestStatus_1 = require("./handlers/class/low/handleGetClassUnitTestStatus");
148
+ const handleGetClassUnitTestResult_1 = require("./handlers/class/low/handleGetClassUnitTestResult");
149
+ const handleCheckProgram_1 = require("./handlers/program/low/handleCheckProgram");
150
+ const handleDeleteProgram_1 = require("./handlers/program/low/handleDeleteProgram");
151
+ const handleLockProgram_1 = require("./handlers/program/low/handleLockProgram");
152
+ const handleUnlockProgram_1 = require("./handlers/program/low/handleUnlockProgram");
153
+ const handleValidateProgram_1 = require("./handlers/program/low/handleValidateProgram");
154
+ const handleCreateProgram_2 = require("./handlers/program/low/handleCreateProgram");
155
+ const handleCheckInterface_1 = require("./handlers/interface/low/handleCheckInterface");
156
+ const handleDeleteInterface_1 = require("./handlers/interface/low/handleDeleteInterface");
157
+ const handleLockInterface_1 = require("./handlers/interface/low/handleLockInterface");
158
+ const handleUnlockInterface_1 = require("./handlers/interface/low/handleUnlockInterface");
159
+ const handleValidateInterface_1 = require("./handlers/interface/low/handleValidateInterface");
160
+ const handleCreateInterface_2 = require("./handlers/interface/low/handleCreateInterface");
161
+ const handleCheckFunctionGroup_1 = require("./handlers/function/low/handleCheckFunctionGroup");
162
+ const handleDeleteFunctionGroup_1 = require("./handlers/function/low/handleDeleteFunctionGroup");
163
+ const handleDeleteFunctionModule_1 = require("./handlers/function/low/handleDeleteFunctionModule");
164
+ const handleLockFunctionGroup_1 = require("./handlers/function/low/handleLockFunctionGroup");
165
+ const handleLockFunctionModule_1 = require("./handlers/function/low/handleLockFunctionModule");
166
+ const handleUnlockFunctionGroup_1 = require("./handlers/function/low/handleUnlockFunctionGroup");
167
+ const handleUnlockFunctionModule_1 = require("./handlers/function/low/handleUnlockFunctionModule");
168
+ const handleValidateFunctionGroup_1 = require("./handlers/function/low/handleValidateFunctionGroup");
169
+ const handleCreateFunctionGroup_2 = require("./handlers/function/low/handleCreateFunctionGroup");
170
+ const handleCreateFunctionModule_2 = require("./handlers/function/low/handleCreateFunctionModule");
171
+ const handleCheckDataElement_1 = require("./handlers/data_element/low/handleCheckDataElement");
172
+ const handleDeleteDataElement_1 = require("./handlers/data_element/low/handleDeleteDataElement");
173
+ const handleLockDataElement_1 = require("./handlers/data_element/low/handleLockDataElement");
174
+ const handleUnlockDataElement_1 = require("./handlers/data_element/low/handleUnlockDataElement");
175
+ const handleValidateDataElement_1 = require("./handlers/data_element/low/handleValidateDataElement");
176
+ const handleCreateDataElement_2 = require("./handlers/data_element/low/handleCreateDataElement");
177
+ const handleCheckDomain_1 = require("./handlers/domain/low/handleCheckDomain");
178
+ const handleDeleteDomain_1 = require("./handlers/domain/low/handleDeleteDomain");
179
+ const handleLockDomain_1 = require("./handlers/domain/low/handleLockDomain");
180
+ const handleUnlockDomain_1 = require("./handlers/domain/low/handleUnlockDomain");
181
+ const handleValidateDomain_1 = require("./handlers/domain/low/handleValidateDomain");
182
+ const handleCreateDomain_2 = require("./handlers/domain/low/handleCreateDomain");
183
+ const handleCheckStructure_1 = require("./handlers/structure/low/handleCheckStructure");
184
+ const handleDeleteStructure_1 = require("./handlers/structure/low/handleDeleteStructure");
185
+ const handleLockStructure_1 = require("./handlers/structure/low/handleLockStructure");
186
+ const handleUnlockStructure_1 = require("./handlers/structure/low/handleUnlockStructure");
187
+ const handleValidateStructure_1 = require("./handlers/structure/low/handleValidateStructure");
188
+ const handleCreateStructure_2 = require("./handlers/structure/low/handleCreateStructure");
189
+ const handleDeleteTable_1 = require("./handlers/table/low/handleDeleteTable");
190
+ const handleLockTable_1 = require("./handlers/table/low/handleLockTable");
191
+ const handleUnlockTable_1 = require("./handlers/table/low/handleUnlockTable");
192
+ const handleCreateTable_2 = require("./handlers/table/low/handleCreateTable");
193
+ const handleCheckView_1 = require("./handlers/view/low/handleCheckView");
194
+ const handleDeleteView_1 = require("./handlers/view/low/handleDeleteView");
195
+ const handleLockView_1 = require("./handlers/view/low/handleLockView");
196
+ const handleUnlockView_1 = require("./handlers/view/low/handleUnlockView");
197
+ const handleValidateView_1 = require("./handlers/view/low/handleValidateView");
198
+ const handleCreateView_2 = require("./handlers/view/low/handleCreateView");
199
+ const handleCheckPackage_1 = require("./handlers/package/low/handleCheckPackage");
200
+ const handleDeletePackage_1 = require("./handlers/package/low/handleDeletePackage");
201
+ const handleLockPackage_1 = require("./handlers/package/low/handleLockPackage");
202
+ const handleValidatePackage_1 = require("./handlers/package/low/handleValidatePackage");
203
+ const handleCreatePackage_2 = require("./handlers/package/low/handleCreatePackage");
204
+ const handleCreateTransport_2 = require("./handlers/transport/low/handleCreateTransport");
205
+ const handleCheckBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleCheckBehaviorDefinition");
206
+ const handleDeleteBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleDeleteBehaviorDefinition");
207
+ const handleLockBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleLockBehaviorDefinition");
208
+ const handleUnlockBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleUnlockBehaviorDefinition");
209
+ const handleValidateBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleValidateBehaviorDefinition");
210
+ const handleCreateBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleCreateBehaviorDefinition");
211
+ const handleCheckMetadataExtension_1 = require("./handlers/ddlx/low/handleCheckMetadataExtension");
212
+ const handleDeleteMetadataExtension_1 = require("./handlers/ddlx/low/handleDeleteMetadataExtension");
213
+ const handleLockMetadataExtension_1 = require("./handlers/ddlx/low/handleLockMetadataExtension");
214
+ const handleUnlockMetadataExtension_1 = require("./handlers/ddlx/low/handleUnlockMetadataExtension");
215
+ const handleValidateMetadataExtension_1 = require("./handlers/ddlx/low/handleValidateMetadataExtension");
216
+ const handleCreateMetadataExtension_2 = require("./handlers/ddlx/low/handleCreateMetadataExtension");
217
+ const handleActivateProgram_1 = require("./handlers/program/low/handleActivateProgram");
218
+ const handleActivateClass_1 = require("./handlers/class/low/handleActivateClass");
219
+ const handleActivateInterface_1 = require("./handlers/interface/low/handleActivateInterface");
220
+ const handleActivateFunctionModule_1 = require("./handlers/function/low/handleActivateFunctionModule");
221
+ const handleActivateFunctionGroup_1 = require("./handlers/function/low/handleActivateFunctionGroup");
222
+ const handleActivateDataElement_1 = require("./handlers/data_element/low/handleActivateDataElement");
223
+ const handleActivateDomain_1 = require("./handlers/domain/low/handleActivateDomain");
224
+ const handleActivateStructure_1 = require("./handlers/structure/low/handleActivateStructure");
225
+ const handleActivateTable_1 = require("./handlers/table/low/handleActivateTable");
226
+ const handleActivateView_1 = require("./handlers/view/low/handleActivateView");
227
+ const handleActivateBehaviorDefinition_1 = require("./handlers/behavior_definition/low/handleActivateBehaviorDefinition");
228
+ const handleActivateMetadataExtension_1 = require("./handlers/ddlx/low/handleActivateMetadataExtension");
229
+ // Import shared utility functions and types
230
+ const utils_1 = require("./lib/utils");
231
+ // Import logger
232
+ const logger_1 = require("./lib/logger");
233
+ // Import tool registry
234
+ // Import TOOL_DEFINITION from handlers
235
+ const handleGetProgram_2 = require("./handlers/program/readonly/handleGetProgram");
236
+ const handleGetClass_2 = require("./handlers/class/readonly/handleGetClass");
237
+ const handleGetFunction_2 = require("./handlers/function/readonly/handleGetFunction");
238
+ const handleGetFunctionGroup_2 = require("./handlers/function/readonly/handleGetFunctionGroup");
239
+ const handleGetTable_2 = require("./handlers/table/readonly/handleGetTable");
240
+ const handleGetStructure_2 = require("./handlers/structure/readonly/handleGetStructure");
241
+ const handleGetTableContents_2 = require("./handlers/table/readonly/handleGetTableContents");
242
+ const handleGetPackage_2 = require("./handlers/package/readonly/handleGetPackage");
243
+ const handleCreatePackage_3 = require("./handlers/package/high/handleCreatePackage");
244
+ const handleGetInclude_2 = require("./handlers/include/readonly/handleGetInclude");
245
+ const handleGetIncludesList_2 = require("./handlers/include/readonly/handleGetIncludesList");
246
+ const handleGetTypeInfo_2 = require("./handlers/system/readonly/handleGetTypeInfo");
247
+ const handleGetInterface_2 = require("./handlers/interface/readonly/handleGetInterface");
248
+ const handleGetTransaction_2 = require("./handlers/system/readonly/handleGetTransaction");
249
+ const handleSearchObject_2 = require("./handlers/search/readonly/handleSearchObject");
250
+ const handleGetEnhancements_2 = require("./handlers/enhancement/readonly/handleGetEnhancements");
251
+ const handleGetEnhancementImpl_2 = require("./handlers/enhancement/readonly/handleGetEnhancementImpl");
252
+ const handleGetEnhancementSpot_2 = require("./handlers/enhancement/readonly/handleGetEnhancementSpot");
253
+ const handleGetBdef_2 = require("./handlers/behavior_definition/readonly/handleGetBdef");
254
+ const handleGetSqlQuery_2 = require("./handlers/system/readonly/handleGetSqlQuery");
255
+ const handleGetWhereUsed_2 = require("./handlers/system/readonly/handleGetWhereUsed");
256
+ const handleGetObjectInfo_2 = require("./handlers/system/readonly/handleGetObjectInfo");
257
+ const handleGetAbapAST_2 = require("./handlers/system/readonly/handleGetAbapAST");
258
+ const handleGetAbapSemanticAnalysis_2 = require("./handlers/system/readonly/handleGetAbapSemanticAnalysis");
259
+ const handleGetAbapSystemSymbols_2 = require("./handlers/system/readonly/handleGetAbapSystemSymbols");
260
+ const handleGetDomain_2 = require("./handlers/domain/readonly/handleGetDomain");
261
+ const handleCreateDomain_3 = require("./handlers/domain/high/handleCreateDomain");
262
+ const handleUpdateDomain_3 = require("./handlers/domain/high/handleUpdateDomain");
263
+ const handleCreateDataElement_3 = require("./handlers/data_element/high/handleCreateDataElement");
264
+ const handleUpdateDataElement_3 = require("./handlers/data_element/high/handleUpdateDataElement");
265
+ const handleGetDataElement_2 = require("./handlers/data_element/readonly/handleGetDataElement");
266
+ const handleCreateTransport_3 = require("./handlers/transport/high/handleCreateTransport");
267
+ const handleGetTransport_2 = require("./handlers/transport/readonly/handleGetTransport");
268
+ const handleCreateTable_3 = require("./handlers/table/high/handleCreateTable");
269
+ const handleCreateStructure_3 = require("./handlers/structure/high/handleCreateStructure");
270
+ const handleCreateView_3 = require("./handlers/view/high/handleCreateView");
271
+ const handleGetView_2 = require("./handlers/view/readonly/handleGetView");
272
+ const handleGetServiceDefinition_2 = require("./handlers/service_definition/readonly/handleGetServiceDefinition");
273
+ const handleCreateClass_3 = require("./handlers/class/high/handleCreateClass");
274
+ const handleCreateProgram_3 = require("./handlers/program/high/handleCreateProgram");
275
+ const handleCreateInterface_3 = require("./handlers/interface/high/handleCreateInterface");
276
+ const handleCreateFunctionGroup_3 = require("./handlers/function/high/handleCreateFunctionGroup");
277
+ const handleCreateFunctionModule_3 = require("./handlers/function/high/handleCreateFunctionModule");
278
+ const handleActivateObject_2 = require("./handlers/common/low/handleActivateObject");
279
+ const handleDeleteObject_2 = require("./handlers/common/low/handleDeleteObject");
280
+ const handleCheckObject_2 = require("./handlers/common/low/handleCheckObject");
281
+ const handleUpdateClass_3 = require("./handlers/class/high/handleUpdateClass");
282
+ const handleUpdateProgram_3 = require("./handlers/program/high/handleUpdateProgram");
283
+ const handleUpdateView_3 = require("./handlers/view/high/handleUpdateView");
284
+ const handleUpdateInterface_3 = require("./handlers/interface/high/handleUpdateInterface");
285
+ const handleUpdateFunctionModule_3 = require("./handlers/function/high/handleUpdateFunctionModule");
286
+ const handleUpdateStructure_2 = require("./handlers/structure/low/handleUpdateStructure");
287
+ const handleUpdatePackage_2 = require("./handlers/package/low/handleUpdatePackage");
288
+ const handleUpdateTable_2 = require("./handlers/table/low/handleUpdateTable");
289
+ const handleUnlockPackage_2 = require("./handlers/package/low/handleUnlockPackage");
290
+ const handleUpdateClass_4 = require("./handlers/class/low/handleUpdateClass");
291
+ const handleUpdateProgram_4 = require("./handlers/program/low/handleUpdateProgram");
292
+ const handleUpdateInterface_4 = require("./handlers/interface/low/handleUpdateInterface");
293
+ const handleUpdateFunctionModule_4 = require("./handlers/function/low/handleUpdateFunctionModule");
294
+ const handleUpdateView_4 = require("./handlers/view/low/handleUpdateView");
295
+ const handleUpdateDomain_4 = require("./handlers/domain/low/handleUpdateDomain");
296
+ const handleUpdateDataElement_4 = require("./handlers/data_element/low/handleUpdateDataElement");
297
+ const handleUpdateBehaviorDefinition_3 = require("./handlers/behavior_definition/low/handleUpdateBehaviorDefinition");
298
+ const handleUpdateMetadataExtension_3 = require("./handlers/ddlx/low/handleUpdateMetadataExtension");
299
+ const handleGetSession_2 = require("./handlers/system/readonly/handleGetSession");
300
+ const handleValidateObject_2 = require("./handlers/common/low/handleValidateObject");
301
+ const handleLockObject_2 = require("./handlers/common/low/handleLockObject");
302
+ const handleUnlockObject_2 = require("./handlers/common/low/handleUnlockObject");
303
+ const handleValidateClass_2 = require("./handlers/class/low/handleValidateClass");
304
+ const handleCheckClass_2 = require("./handlers/class/low/handleCheckClass");
305
+ const handleValidateTable_2 = require("./handlers/table/low/handleValidateTable");
306
+ const handleCheckTable_2 = require("./handlers/table/low/handleCheckTable");
307
+ const handleValidateFunctionModule_2 = require("./handlers/function/low/handleValidateFunctionModule");
308
+ const handleCheckFunctionModule_2 = require("./handlers/function/low/handleCheckFunctionModule");
309
+ const handleActivateProgram_2 = require("./handlers/program/low/handleActivateProgram");
310
+ const handleActivateClass_2 = require("./handlers/class/low/handleActivateClass");
311
+ const handleActivateInterface_2 = require("./handlers/interface/low/handleActivateInterface");
312
+ const handleActivateFunctionModule_2 = require("./handlers/function/low/handleActivateFunctionModule");
313
+ const handleActivateFunctionGroup_2 = require("./handlers/function/low/handleActivateFunctionGroup");
314
+ const handleActivateDataElement_2 = require("./handlers/data_element/low/handleActivateDataElement");
315
+ const handleActivateDomain_2 = require("./handlers/domain/low/handleActivateDomain");
316
+ const handleActivateStructure_2 = require("./handlers/structure/low/handleActivateStructure");
317
+ const handleActivateTable_2 = require("./handlers/table/low/handleActivateTable");
318
+ const handleActivateView_2 = require("./handlers/view/low/handleActivateView");
319
+ const handleActivateBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleActivateBehaviorDefinition");
320
+ const handleActivateMetadataExtension_2 = require("./handlers/ddlx/low/handleActivateMetadataExtension");
321
+ const handleCreateBehaviorDefinition_3 = require("./handlers/behavior_definition/high/handleCreateBehaviorDefinition");
322
+ const handleUpdateBehaviorDefinition_4 = require("./handlers/behavior_definition/high/handleUpdateBehaviorDefinition");
323
+ const handleCreateMetadataExtension_3 = require("./handlers/ddlx/high/handleCreateMetadataExtension");
324
+ const handleUpdateMetadataExtension_4 = require("./handlers/ddlx/high/handleUpdateMetadataExtension");
325
+ const handleGetInactiveObjects_2 = require("./handlers/system/readonly/handleGetInactiveObjects");
326
+ // New low-level handlers TOOL_DEFINITION imports
327
+ const handleDeleteClass_2 = require("./handlers/class/low/handleDeleteClass");
328
+ const handleLockClass_2 = require("./handlers/class/low/handleLockClass");
329
+ const handleUnlockClass_2 = require("./handlers/class/low/handleUnlockClass");
330
+ const handleCreateClass_4 = require("./handlers/class/low/handleCreateClass");
331
+ const handleLockClassTestClasses_2 = require("./handlers/class/low/handleLockClassTestClasses");
332
+ const handleUnlockClassTestClasses_2 = require("./handlers/class/low/handleUnlockClassTestClasses");
333
+ const handleUpdateClassTestClasses_2 = require("./handlers/class/low/handleUpdateClassTestClasses");
334
+ const handleActivateClassTestClasses_2 = require("./handlers/class/low/handleActivateClassTestClasses");
335
+ const handleRunClassUnitTests_2 = require("./handlers/class/low/handleRunClassUnitTests");
336
+ const handleGetClassUnitTestStatus_2 = require("./handlers/class/low/handleGetClassUnitTestStatus");
337
+ const handleGetClassUnitTestResult_2 = require("./handlers/class/low/handleGetClassUnitTestResult");
338
+ const handleCheckProgram_2 = require("./handlers/program/low/handleCheckProgram");
339
+ const handleDeleteProgram_2 = require("./handlers/program/low/handleDeleteProgram");
340
+ const handleLockProgram_2 = require("./handlers/program/low/handleLockProgram");
341
+ const handleUnlockProgram_2 = require("./handlers/program/low/handleUnlockProgram");
342
+ const handleValidateProgram_2 = require("./handlers/program/low/handleValidateProgram");
343
+ const handleCreateProgram_4 = require("./handlers/program/low/handleCreateProgram");
344
+ const handleCheckInterface_2 = require("./handlers/interface/low/handleCheckInterface");
345
+ const handleDeleteInterface_2 = require("./handlers/interface/low/handleDeleteInterface");
346
+ const handleLockInterface_2 = require("./handlers/interface/low/handleLockInterface");
347
+ const handleUnlockInterface_2 = require("./handlers/interface/low/handleUnlockInterface");
348
+ const handleValidateInterface_2 = require("./handlers/interface/low/handleValidateInterface");
349
+ const handleCreateInterface_4 = require("./handlers/interface/low/handleCreateInterface");
350
+ const handleCheckFunctionGroup_2 = require("./handlers/function/low/handleCheckFunctionGroup");
351
+ const handleDeleteFunctionGroup_2 = require("./handlers/function/low/handleDeleteFunctionGroup");
352
+ const handleDeleteFunctionModule_2 = require("./handlers/function/low/handleDeleteFunctionModule");
353
+ const handleLockFunctionGroup_2 = require("./handlers/function/low/handleLockFunctionGroup");
354
+ const handleLockFunctionModule_2 = require("./handlers/function/low/handleLockFunctionModule");
355
+ const handleUnlockFunctionGroup_2 = require("./handlers/function/low/handleUnlockFunctionGroup");
356
+ const handleUnlockFunctionModule_2 = require("./handlers/function/low/handleUnlockFunctionModule");
357
+ const handleValidateFunctionGroup_2 = require("./handlers/function/low/handleValidateFunctionGroup");
358
+ const handleCreateFunctionGroup_4 = require("./handlers/function/low/handleCreateFunctionGroup");
359
+ const handleCreateFunctionModule_4 = require("./handlers/function/low/handleCreateFunctionModule");
360
+ const handleCheckDataElement_2 = require("./handlers/data_element/low/handleCheckDataElement");
361
+ const handleDeleteDataElement_2 = require("./handlers/data_element/low/handleDeleteDataElement");
362
+ const handleLockDataElement_2 = require("./handlers/data_element/low/handleLockDataElement");
363
+ const handleUnlockDataElement_2 = require("./handlers/data_element/low/handleUnlockDataElement");
364
+ const handleValidateDataElement_2 = require("./handlers/data_element/low/handleValidateDataElement");
365
+ const handleCreateDataElement_4 = require("./handlers/data_element/low/handleCreateDataElement");
366
+ const handleCheckDomain_2 = require("./handlers/domain/low/handleCheckDomain");
367
+ const handleDeleteDomain_2 = require("./handlers/domain/low/handleDeleteDomain");
368
+ const handleLockDomain_2 = require("./handlers/domain/low/handleLockDomain");
369
+ const handleUnlockDomain_2 = require("./handlers/domain/low/handleUnlockDomain");
370
+ const handleValidateDomain_2 = require("./handlers/domain/low/handleValidateDomain");
371
+ const handleCreateDomain_4 = require("./handlers/domain/low/handleCreateDomain");
372
+ const handleCheckStructure_2 = require("./handlers/structure/low/handleCheckStructure");
373
+ const handleDeleteStructure_2 = require("./handlers/structure/low/handleDeleteStructure");
374
+ const handleLockStructure_2 = require("./handlers/structure/low/handleLockStructure");
375
+ const handleUnlockStructure_2 = require("./handlers/structure/low/handleUnlockStructure");
376
+ const handleValidateStructure_2 = require("./handlers/structure/low/handleValidateStructure");
377
+ const handleCreateStructure_4 = require("./handlers/structure/low/handleCreateStructure");
378
+ const handleDeleteTable_2 = require("./handlers/table/low/handleDeleteTable");
379
+ const handleLockTable_2 = require("./handlers/table/low/handleLockTable");
380
+ const handleUnlockTable_2 = require("./handlers/table/low/handleUnlockTable");
381
+ const handleCreateTable_4 = require("./handlers/table/low/handleCreateTable");
382
+ const handleCheckView_2 = require("./handlers/view/low/handleCheckView");
383
+ const handleDeleteView_2 = require("./handlers/view/low/handleDeleteView");
384
+ const handleLockView_2 = require("./handlers/view/low/handleLockView");
385
+ const handleUnlockView_2 = require("./handlers/view/low/handleUnlockView");
386
+ const handleValidateView_2 = require("./handlers/view/low/handleValidateView");
387
+ const handleCreateView_4 = require("./handlers/view/low/handleCreateView");
388
+ const handleCheckPackage_2 = require("./handlers/package/low/handleCheckPackage");
389
+ const handleDeletePackage_2 = require("./handlers/package/low/handleDeletePackage");
390
+ const handleLockPackage_2 = require("./handlers/package/low/handleLockPackage");
391
+ const handleValidatePackage_2 = require("./handlers/package/low/handleValidatePackage");
392
+ const handleCreatePackage_4 = require("./handlers/package/low/handleCreatePackage");
393
+ const handleCreateTransport_4 = require("./handlers/transport/low/handleCreateTransport");
394
+ const handleCheckBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleCheckBehaviorDefinition");
395
+ const handleDeleteBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleDeleteBehaviorDefinition");
396
+ const handleLockBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleLockBehaviorDefinition");
397
+ const handleUnlockBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleUnlockBehaviorDefinition");
398
+ const handleValidateBehaviorDefinition_2 = require("./handlers/behavior_definition/low/handleValidateBehaviorDefinition");
399
+ const handleCreateBehaviorDefinition_4 = require("./handlers/behavior_definition/low/handleCreateBehaviorDefinition");
400
+ const handleCheckMetadataExtension_2 = require("./handlers/ddlx/low/handleCheckMetadataExtension");
401
+ const handleDeleteMetadataExtension_2 = require("./handlers/ddlx/low/handleDeleteMetadataExtension");
402
+ const handleLockMetadataExtension_2 = require("./handlers/ddlx/low/handleLockMetadataExtension");
403
+ const handleUnlockMetadataExtension_2 = require("./handlers/ddlx/low/handleUnlockMetadataExtension");
404
+ const handleValidateMetadataExtension_2 = require("./handlers/ddlx/low/handleValidateMetadataExtension");
405
+ const handleCreateMetadataExtension_4 = require("./handlers/ddlx/low/handleCreateMetadataExtension");
406
+ // --- ENV FILE LOADING LOGIC ---
407
+ const fs_1 = __importDefault(require("fs"));
408
+ /**
409
+ * Display help message
410
+ */
411
+ function showHelp() {
412
+ const help = `
413
+ MCP ABAP ADT Server - SAP ABAP Development Tools MCP Integration
414
+
415
+ USAGE:
416
+ mcp-abap-adt [options]
417
+
418
+ DESCRIPTION:
419
+ MCP server for interacting with SAP ABAP systems via ADT (ABAP Development Tools).
420
+ Supports multiple transport modes: HTTP (default), stdio, and SSE.
421
+
422
+ TRANSPORT MODES:
423
+ Default: HTTP (can work without .env file, receives config via HTTP headers)
424
+ stdio: --transport=stdio (for MCP clients like Cline, Cursor, Claude Desktop)
425
+ SSE: --transport=sse
426
+
427
+ OPTIONS:
428
+ --help Show this help message
429
+
430
+ ENVIRONMENT FILE:
431
+ --env=<path> Path to .env file (default: ./.env)
432
+ --env <path> Alternative syntax for --env
433
+
434
+ TRANSPORT SELECTION:
435
+ --transport=<type> Transport type: stdio|http|streamable-http|sse
436
+ Default: http (streamable-http)
437
+ Shortcuts: --http (same as --transport=http)
438
+ --sse (same as --transport=sse)
439
+ --stdio (same as --transport=stdio)
440
+
441
+ HTTP/STREAMABLE-HTTP OPTIONS:
442
+ --http-port=<port> HTTP server port (default: 3000)
443
+ --http-host=<host> HTTP server host (default: 0.0.0.0)
444
+ --http-json-response Enable JSON response format
445
+ --http-allowed-origins=<list> Comma-separated allowed origins for CORS
446
+ Example: --http-allowed-origins=http://localhost:3000,https://example.com
447
+ --http-allowed-hosts=<list> Comma-separated allowed hosts
448
+ --http-enable-dns-protection Enable DNS rebinding protection
449
+
450
+ SSE (SERVER-SENT EVENTS) OPTIONS:
451
+ --sse-port=<port> SSE server port (default: 3001)
452
+ --sse-host=<host> SSE server host (default: 0.0.0.0)
453
+ --sse-allowed-origins=<list> Comma-separated allowed origins for CORS
454
+ Example: --sse-allowed-origins=http://localhost:3000
455
+ --sse-allowed-hosts=<list> Comma-separated allowed hosts
456
+ --sse-enable-dns-protection Enable DNS rebinding protection
457
+
458
+ ENVIRONMENT VARIABLES:
459
+ MCP_ENV_PATH Path to .env file
460
+ MCP_SKIP_ENV_LOAD Skip automatic .env loading (true|false)
461
+ MCP_SKIP_AUTO_START Skip automatic server start (true|false)
462
+ MCP_TRANSPORT Default transport type (stdio|http|sse)
463
+ MCP_HTTP_PORT Default HTTP port (default: 3000)
464
+ MCP_HTTP_HOST Default HTTP host (default: 0.0.0.0)
465
+ MCP_HTTP_ENABLE_JSON_RESPONSE Enable JSON responses (true|false)
466
+ MCP_HTTP_ALLOWED_ORIGINS Allowed CORS origins (comma-separated)
467
+ MCP_HTTP_ALLOWED_HOSTS Allowed hosts (comma-separated)
468
+ MCP_HTTP_ENABLE_DNS_PROTECTION Enable DNS protection (true|false)
469
+ MCP_SSE_PORT Default SSE port (default: 3001)
470
+ MCP_SSE_HOST Default SSE host (default: 0.0.0.0)
471
+ MCP_SSE_ALLOWED_ORIGINS Allowed CORS origins for SSE (comma-separated)
472
+ MCP_SSE_ALLOWED_HOSTS Allowed hosts for SSE (comma-separated)
473
+ MCP_SSE_ENABLE_DNS_PROTECTION Enable DNS protection for SSE (true|false)
474
+
475
+ SAP CONNECTION (.env file):
476
+ SAP_URL SAP system URL (required)
477
+ Example: https://your-system.sap.com
478
+ SAP_CLIENT SAP client number (required)
479
+ Example: 100
480
+ SAP_AUTH_TYPE Authentication type: basic|jwt (default: basic)
481
+ SAP_USERNAME SAP username (required for basic auth)
482
+ SAP_PASSWORD SAP password (required for basic auth)
483
+ SAP_JWT_TOKEN JWT token (required for jwt auth)
484
+
485
+ GENERATING .ENV FROM SERVICE KEY (JWT Authentication):
486
+ To generate .env file from SAP BTP service key JSON file, install the
487
+ connection package globally:
488
+
489
+ npm install -g @mcp-abap-adt/connection
490
+
491
+ Then use the sap-abap-auth command:
492
+
493
+ sap-abap-auth auth -k path/to/service-key.json
494
+
495
+ This will create/update .env file with JWT tokens and connection details.
496
+
497
+ EXAMPLES:
498
+ # Default HTTP mode (works without .env file)
499
+ mcp-abap-adt
500
+
501
+ # HTTP server on custom port
502
+ mcp-abap-adt --http-port=8080
503
+
504
+ # Use stdio mode (for MCP clients, requires .env file)
505
+ mcp-abap-adt --transport=stdio
506
+
507
+ # Use custom .env file
508
+ mcp-abap-adt --env=/path/to/my.env
509
+
510
+ # Start HTTP server with CORS enabled
511
+ mcp-abap-adt --transport=http --http-port=3000 \\
512
+ --http-allowed-origins=http://localhost:3000,https://example.com
513
+
514
+ # Start SSE server on custom port
515
+ mcp-abap-adt --transport=sse --sse-port=3001
516
+
517
+ # Start SSE server with CORS and DNS protection
518
+ mcp-abap-adt --transport=sse --sse-port=3001 \\
519
+ --sse-allowed-origins=http://localhost:3000 \\
520
+ --sse-enable-dns-protection
521
+
522
+ # Using shortcuts
523
+ mcp-abap-adt --http --http-port=8080
524
+ mcp-abap-adt --sse --sse-port=3001
525
+
526
+ QUICK REFERENCE:
527
+ Transport types:
528
+ http - HTTP StreamableHTTP transport (default)
529
+ streamable-http - Same as http
530
+ stdio - Standard input/output (for MCP clients, requires .env file)
531
+ sse - Server-Sent Events transport
532
+
533
+ Common use cases:
534
+ Web interfaces (HTTP): mcp-abap-adt (default, no .env needed)
535
+ MCP clients (Cline, Cursor): mcp-abap-adt --transport=stdio
536
+ Web interfaces (SSE): mcp-abap-adt --transport=sse --sse-port=3001
537
+
538
+ DOCUMENTATION:
539
+ https://github.com/fr0ster/mcp-abap-adt
540
+ Installation: doc/installation/INSTALLATION.md
541
+ Configuration: doc/user-guide/CLIENT_CONFIGURATION.md
542
+ Available Tools: doc/user-guide/AVAILABLE_TOOLS.md
543
+
544
+ AUTHENTICATION:
545
+ For JWT authentication with SAP BTP service keys:
546
+ 1. Install: npm install -g @mcp-abap-adt/connection
547
+ 2. Run: sap-abap-auth auth -k path/to/service-key.json
548
+ 3. This generates .env file with JWT tokens automatically
549
+
550
+ `;
551
+ console.log(help);
552
+ process.exit(0);
553
+ }
554
+ // Check for version/help flags
555
+ if (process.argv.includes("--version") || process.argv.includes("-v")) {
556
+ const packageJsonPath = path_1.default.join(__dirname, "..", "package.json");
557
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
558
+ console.log(packageJson.version);
559
+ process.exit(0);
560
+ }
561
+ if (process.argv.includes("--help") || process.argv.includes("-h")) {
562
+ showHelp();
563
+ }
564
+ /**
565
+ * Helper to determine transport type early for .env loading logic
566
+ * Returns the transport type if explicitly specified, or null if not specified
567
+ *
568
+ * Auto-detects stdio mode if:
569
+ * - stdin is not a TTY (piped/redirected, e.g., by MCP Inspector)
570
+ * - and no explicit transport was specified
571
+ */
572
+ function getTransportType() {
573
+ const args = process.argv;
574
+ for (let i = 0; i < args.length; i++) {
575
+ const arg = args[i];
576
+ if (arg.startsWith("--transport=")) {
577
+ return arg.split("=")[1].toLowerCase();
578
+ }
579
+ if (arg === "--transport" && i + 1 < args.length) {
580
+ return args[i + 1].toLowerCase();
581
+ }
582
+ if (arg === "--http")
583
+ return "streamable-http";
584
+ if (arg === "--stdio")
585
+ return "stdio";
586
+ if (arg === "--sse")
587
+ return "sse";
588
+ }
589
+ // Check environment variable
590
+ if (process.env.MCP_TRANSPORT) {
591
+ return process.env.MCP_TRANSPORT.toLowerCase();
592
+ }
593
+ // Auto-detect stdio mode: if stdin is not a TTY, we're likely in stdio mode (piped by MCP Inspector)
594
+ if (!process.stdin.isTTY) {
595
+ return "stdio";
596
+ }
597
+ // Not explicitly specified
598
+ return null;
599
+ }
600
+ /**
601
+ * Parses command line arguments to find env file path
602
+ * Supports both formats:
603
+ * 1. --env=/path/to/.env
604
+ * 2. --env /path/to/.env
605
+ */
606
+ function parseEnvArg() {
607
+ const args = process.argv;
608
+ for (let i = 0; i < args.length; i++) {
609
+ // Format: --env=/path/to/.env
610
+ if (args[i].startsWith("--env=")) {
611
+ return args[i].slice("--env=".length);
612
+ }
613
+ // Format: --env /path/to/.env
614
+ else if (args[i] === "--env" && i + 1 < args.length) {
615
+ return args[i + 1];
616
+ }
617
+ }
618
+ return undefined;
619
+ }
620
+ // Find .env file path from arguments
621
+ // Skip .env loading if launcher already loaded it
622
+ const skipEnvAutoload = process.env.MCP_SKIP_ENV_LOAD === "true" || process.env.MCP_ENV_LOADED_BY_LAUNCHER === "true";
623
+ const explicitTransportType = getTransportType();
624
+ // If transport not explicitly specified, default to HTTP mode
625
+ // Stdio mode is only used if explicitly specified via --transport=stdio
626
+ const transportType = explicitTransportType || "streamable-http";
627
+ const isHttp = transportType === "http" || transportType === "streamable-http" || transportType === "server";
628
+ const isSse = transportType === "sse";
629
+ const isStdio = transportType === "stdio";
630
+ // .env is mandatory only if transport is explicitly set to stdio or sse
631
+ const isEnvMandatory = explicitTransportType !== null && (isStdio || isSse);
632
+ let envFilePath = parseEnvArg() ?? process.env.MCP_ENV_PATH;
633
+ if (!skipEnvAutoload) {
634
+ if (!envFilePath) {
635
+ // Only search in current working directory (where user runs the command)
636
+ const cwdEnvPath = path_1.default.resolve(process.cwd(), ".env");
637
+ if (fs_1.default.existsSync(cwdEnvPath)) {
638
+ envFilePath = cwdEnvPath;
639
+ // Only write to stderr if not in stdio mode (stdio mode requires clean JSON only)
640
+ if (!isStdio) {
641
+ process.stderr.write(`[MCP-ENV] Found .env file: ${envFilePath}\n`);
642
+ }
643
+ }
644
+ }
645
+ else {
646
+ // Only write to stderr if not in stdio mode
647
+ if (!isStdio) {
648
+ process.stderr.write(`[MCP-ENV] Using .env from argument/env: ${envFilePath}\n`);
649
+ }
650
+ }
651
+ if (envFilePath) {
652
+ if (!path_1.default.isAbsolute(envFilePath)) {
653
+ envFilePath = path_1.default.resolve(process.cwd(), envFilePath);
654
+ // Only write to stderr if not in stdio mode
655
+ if (!isStdio) {
656
+ process.stderr.write(`[MCP-ENV] Resolved relative path to: ${envFilePath}\n`);
657
+ }
658
+ }
659
+ if (fs_1.default.existsSync(envFilePath)) {
660
+ // For stdio mode, load .env manually to avoid any output from dotenv library
661
+ if (isStdio) {
662
+ // Manual .env parsing for stdio mode (no library output)
663
+ try {
664
+ const envContent = fs_1.default.readFileSync(envFilePath, "utf8");
665
+ const lines = envContent.split(/\r?\n/);
666
+ for (const line of lines) {
667
+ const trimmed = line.trim();
668
+ // Skip empty lines and comments
669
+ if (!trimmed || trimmed.startsWith("#")) {
670
+ continue;
671
+ }
672
+ // Parse KEY=VALUE format
673
+ const eqIndex = trimmed.indexOf("=");
674
+ if (eqIndex === -1) {
675
+ continue;
676
+ }
677
+ const key = trimmed.substring(0, eqIndex).trim();
678
+ let value = trimmed.substring(eqIndex + 1);
679
+ // Remove inline comments (everything after #)
680
+ // This handles cases like: KEY=value # comment or KEY=value#comment
681
+ // Find first # and remove everything after it (including the #)
682
+ const commentIndex = value.indexOf('#');
683
+ if (commentIndex !== -1) {
684
+ // Remove everything from # onwards, then trim trailing whitespace
685
+ const beforeComment = value.substring(0, commentIndex);
686
+ value = beforeComment.trim();
687
+ }
688
+ else {
689
+ value = value.trim();
690
+ }
691
+ // Aggressive cleaning for Windows compatibility (same as launcher)
692
+ // Step 1: Remove ALL control characters (including \r from Windows line endings)
693
+ let unquotedValue = String(value).replace(/[\x00-\x1F\x7F-\x9F]/g, '');
694
+ // Step 2: Trim whitespace
695
+ unquotedValue = unquotedValue.trim();
696
+ // Step 3: Remove quotes (handle nested quotes)
697
+ unquotedValue = unquotedValue.replace(/^["']+|["']+$/g, '');
698
+ // Step 4: Trim again after quote removal
699
+ unquotedValue = unquotedValue.trim();
700
+ // Step 5: For URLs specifically, remove trailing slashes
701
+ if (key === 'SAP_URL') {
702
+ unquotedValue = unquotedValue.replace(/\/+$/, '').trim();
703
+ // Debug logging for Windows
704
+ if (process.platform === 'win32' && !isStdio) {
705
+ process.stderr.write(`[MCP-ENV] Parsed SAP_URL: "${unquotedValue}" (length: ${unquotedValue.length})\n`);
706
+ }
707
+ }
708
+ // Only set if not already in process.env (don't override launcher's cleaned values)
709
+ if (key && !process.env[key]) {
710
+ process.env[key] = unquotedValue;
711
+ }
712
+ }
713
+ }
714
+ catch (error) {
715
+ // Silent fail for stdio mode - just exit
716
+ process.exit(1);
717
+ }
718
+ }
719
+ else {
720
+ // For non-stdio modes, use manual parsing (dotenv removed to avoid stdout pollution)
721
+ try {
722
+ const envContent = fs_1.default.readFileSync(envFilePath, "utf8");
723
+ const lines = envContent.split(/\r?\n/);
724
+ for (const line of lines) {
725
+ const trimmed = line.trim();
726
+ if (!trimmed || trimmed.startsWith("#")) {
727
+ continue;
728
+ }
729
+ const eqIndex = trimmed.indexOf("=");
730
+ if (eqIndex === -1) {
731
+ continue;
732
+ }
733
+ const key = trimmed.substring(0, eqIndex).trim();
734
+ let value = trimmed.substring(eqIndex + 1);
735
+ // Remove inline comments (everything after #)
736
+ // This handles cases like: KEY=value # comment or KEY=value#comment
737
+ // Find first # and remove everything after it (including the #)
738
+ const commentIndex = value.indexOf('#');
739
+ if (commentIndex !== -1) {
740
+ // Remove everything from # onwards, then trim trailing whitespace
741
+ const beforeComment = value.substring(0, commentIndex);
742
+ value = beforeComment.trim();
743
+ }
744
+ else {
745
+ value = value.trim();
746
+ }
747
+ // Aggressive cleaning for Windows compatibility (same as launcher)
748
+ // Step 1: Remove ALL control characters (including \r from Windows line endings)
749
+ let unquotedValue = String(value).replace(/[\x00-\x1F\x7F-\x9F]/g, '');
750
+ // Step 2: Trim whitespace
751
+ unquotedValue = unquotedValue.trim();
752
+ // Step 3: Remove quotes (handle nested quotes)
753
+ unquotedValue = unquotedValue.replace(/^["']+|["']+$/g, '');
754
+ // Step 4: Trim again after quote removal
755
+ unquotedValue = unquotedValue.trim();
756
+ // Step 5: For URLs specifically, remove trailing slashes
757
+ if (key === 'SAP_URL') {
758
+ unquotedValue = unquotedValue.replace(/\/+$/, '').trim();
759
+ // Debug logging for Windows
760
+ if (process.platform === 'win32' && !isStdio) {
761
+ process.stderr.write(`[MCP-ENV] Parsed SAP_URL: "${unquotedValue}" (length: ${unquotedValue.length})\n`);
762
+ }
763
+ }
764
+ // Only set if not already in process.env (don't override launcher's cleaned values)
765
+ if (key && !process.env[key]) {
766
+ process.env[key] = unquotedValue;
767
+ }
768
+ }
769
+ process.stderr.write(`[MCP-ENV] ✓ Successfully loaded: ${envFilePath}\n`);
770
+ // Debug: log SAP_URL if loaded (for troubleshooting on Windows)
771
+ if (process.env.SAP_URL) {
772
+ const urlHex = Buffer.from(process.env.SAP_URL, 'utf8').toString('hex');
773
+ process.stderr.write(`[MCP-ENV] SAP_URL loaded: "${process.env.SAP_URL}" (length: ${process.env.SAP_URL.length})\n`);
774
+ if (process.platform === 'win32') {
775
+ process.stderr.write(`[MCP-ENV] SAP_URL (hex): ${urlHex.substring(0, 60)}...\n`);
776
+ // Check for comments
777
+ if (process.env.SAP_URL.includes('#')) {
778
+ process.stderr.write(`[MCP-ENV] ⚠ WARNING: SAP_URL contains # character (comment not removed?)\n`);
779
+ }
780
+ }
781
+ }
782
+ else {
783
+ process.stderr.write(`[MCP-ENV] ⚠ WARNING: SAP_URL not found in .env file\n`);
784
+ }
785
+ }
786
+ catch (error) {
787
+ process.stderr.write(`[MCP-ENV] ✗ Failed to load: ${envFilePath}\n`);
788
+ if (error instanceof Error) {
789
+ process.stderr.write(`[MCP-ENV] Error: ${error.message}\n`);
790
+ }
791
+ }
792
+ }
793
+ }
794
+ else {
795
+ // .env file specified but not found
796
+ if (isEnvMandatory) {
797
+ // Always write error to stderr (stderr is safe even in stdio mode, unlike stdout)
798
+ logger_1.logger.error(".env file not found", { path: envFilePath });
799
+ process.stderr.write(`[MCP-ENV] ✗ ERROR: .env file not found at: ${envFilePath}\n`);
800
+ process.stderr.write(`[MCP-ENV] Current working directory: ${process.cwd()}\n`);
801
+ process.stderr.write(`[MCP-ENV] Transport mode '${transportType}' requires .env file.\n`);
802
+ process.stderr.write(`[MCP-ENV] Use --env=/path/to/.env to specify custom location\n`);
803
+ // On Windows, add a small delay before exit to allow error message to be visible
804
+ if (process.platform === 'win32') {
805
+ setTimeout(() => process.exit(1), 100);
806
+ }
807
+ else {
808
+ process.exit(1);
809
+ }
810
+ }
811
+ else {
812
+ // Always write error to stderr (stderr is safe even in stdio mode)
813
+ process.stderr.write(`[MCP-ENV] ✗ ERROR: .env file not found at: ${envFilePath}\n`);
814
+ process.stderr.write(`[MCP-ENV] Transport mode '${transportType}' was explicitly specified but .env file is missing.\n`);
815
+ process.stderr.write(`[MCP-ENV] Use --env=/path/to/.env to specify custom location\n`);
816
+ // On Windows, add a small delay before exit to allow error message to be visible
817
+ if (process.platform === 'win32') {
818
+ setTimeout(() => process.exit(1), 100);
819
+ }
820
+ else {
821
+ process.exit(1);
822
+ }
823
+ }
824
+ }
825
+ }
826
+ else {
827
+ // No .env file found and none specified
828
+ if (isEnvMandatory) {
829
+ // Transport explicitly set to stdio/sse but no .env found
830
+ const cwdEnvPath = path_1.default.resolve(process.cwd(), ".env");
831
+ // Always write error to stderr (stderr is safe even in stdio mode)
832
+ logger_1.logger.error(".env file not found", { path: cwdEnvPath });
833
+ process.stderr.write(`[MCP-ENV] ✗ ERROR: .env file not found in current directory: ${process.cwd()}\n`);
834
+ process.stderr.write(`[MCP-ENV] Transport mode '${transportType}' requires .env file.\n`);
835
+ process.stderr.write(`[MCP-ENV] Use --env=/path/to/.env to specify custom location\n`);
836
+ // On Windows, add a small delay before exit to allow error message to be visible
837
+ if (process.platform === 'win32') {
838
+ setTimeout(() => process.exit(1), 100);
839
+ }
840
+ else {
841
+ process.exit(1);
842
+ }
843
+ }
844
+ else {
845
+ // No .env found, but transport is HTTP (default) - this is OK
846
+ if (explicitTransportType === null) {
847
+ // Transport not specified, defaulting to HTTP mode
848
+ // For stdio mode, don't write to stderr
849
+ if (!isStdio) {
850
+ process.stderr.write(`[MCP-ENV] NOTE: No .env file found in current directory: ${process.cwd()}\n`);
851
+ process.stderr.write(`[MCP-ENV] Starting in HTTP mode (no .env file required)\n`);
852
+ }
853
+ }
854
+ else {
855
+ // Transport explicitly set to HTTP - this is OK
856
+ // For stdio mode, don't write to stderr
857
+ if (!isStdio) {
858
+ process.stderr.write(`[MCP-ENV] NOTE: No .env file found, continuing in ${transportType} mode\n`);
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+ else if (envFilePath) {
865
+ if (!path_1.default.isAbsolute(envFilePath)) {
866
+ envFilePath = path_1.default.resolve(process.cwd(), envFilePath);
867
+ }
868
+ // For stdio mode, don't write to stderr
869
+ if (!isStdio) {
870
+ process.stderr.write(`[MCP-ENV] Environment autoload skipped; using provided path reference: ${envFilePath}\n`);
871
+ }
872
+ }
873
+ else {
874
+ // For stdio mode, don't write to stderr
875
+ if (!isStdio) {
876
+ process.stderr.write(`[MCP-ENV] Environment autoload skipped (MCP_SKIP_ENV_LOAD=true).\n`);
877
+ }
878
+ }
879
+ // --- END ENV FILE LOADING LOGIC ---
880
+ // Debug: Log loaded SAP_URL and SAP_CLIENT using the MCP-compatible logger
881
+ // Skip logging in stdio mode (MCP protocol requires clean JSON only)
882
+ if (!isStdio) {
883
+ const envLogPath = envFilePath ?? "(skipped)";
884
+ logger_1.logger.info("SAP configuration loaded", {
885
+ type: "CONFIG_INFO",
886
+ SAP_URL: process.env.SAP_URL,
887
+ SAP_CLIENT: process.env.SAP_CLIENT || "(not set)",
888
+ SAP_AUTH_TYPE: process.env.SAP_AUTH_TYPE || "(not set)",
889
+ SAP_JWT_TOKEN: process.env.SAP_JWT_TOKEN ? "[set]" : "(not set)",
890
+ ENV_PATH: envLogPath,
891
+ CWD: process.cwd(),
892
+ DIRNAME: __dirname,
893
+ TRANSPORT: transportType
894
+ });
895
+ }
896
+ function getArgValue(name) {
897
+ const args = process.argv;
898
+ for (let i = 0; i < args.length; i++) {
899
+ const arg = args[i];
900
+ if (arg.startsWith(`${name}=`)) {
901
+ return arg.slice(name.length + 1);
902
+ }
903
+ if (arg === name && i + 1 < args.length) {
904
+ return args[i + 1];
905
+ }
906
+ }
907
+ return undefined;
908
+ }
909
+ function hasFlag(name) {
910
+ return process.argv.includes(name);
911
+ }
912
+ function parseBoolean(value) {
913
+ if (!value) {
914
+ return false;
915
+ }
916
+ const normalized = value.trim().toLowerCase();
917
+ return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
918
+ }
919
+ function resolvePortOption(argName, envName, defaultValue) {
920
+ const rawValue = getArgValue(argName) ?? process.env[envName];
921
+ if (!rawValue) {
922
+ return defaultValue;
923
+ }
924
+ const port = Number.parseInt(rawValue, 10);
925
+ if (!Number.isInteger(port) || port <= 0 || port > 65535) {
926
+ throw new Error(`Invalid port value for ${argName}: ${rawValue}`);
927
+ }
928
+ return port;
929
+ }
930
+ function resolveBooleanOption(argName, envName, defaultValue) {
931
+ const argValue = getArgValue(argName);
932
+ if (argValue !== undefined) {
933
+ return parseBoolean(argValue);
934
+ }
935
+ if (hasFlag(argName)) {
936
+ return true;
937
+ }
938
+ const envValue = process.env[envName];
939
+ if (envValue !== undefined) {
940
+ return parseBoolean(envValue);
941
+ }
942
+ return defaultValue;
943
+ }
944
+ function resolveListOption(argName, envName) {
945
+ const rawValue = getArgValue(argName) ?? process.env[envName];
946
+ if (!rawValue) {
947
+ return undefined;
948
+ }
949
+ const items = rawValue
950
+ .split(",")
951
+ .map((entry) => entry.trim())
952
+ .filter((entry) => entry.length > 0);
953
+ return items.length > 0 ? items : undefined;
954
+ }
955
+ function parseTransportConfig() {
956
+ // Use the transport type we already determined (handles explicit args, env vars, and defaults)
957
+ const normalized = transportType;
958
+ if (normalized &&
959
+ normalized !== "stdio" &&
960
+ normalized !== "http" &&
961
+ normalized !== "streamable-http" &&
962
+ normalized !== "server" &&
963
+ normalized !== "sse") {
964
+ throw new Error(`Unsupported transport: ${normalized}`);
965
+ }
966
+ const sseRequested = normalized === "sse" ||
967
+ hasFlag("--sse");
968
+ if (sseRequested) {
969
+ const port = resolvePortOption("--sse-port", "MCP_SSE_PORT", 3001);
970
+ const host = getArgValue("--sse-host") ?? process.env.MCP_SSE_HOST ?? "0.0.0.0";
971
+ const allowedOrigins = resolveListOption("--sse-allowed-origins", "MCP_SSE_ALLOWED_ORIGINS");
972
+ const allowedHosts = resolveListOption("--sse-allowed-hosts", "MCP_SSE_ALLOWED_HOSTS");
973
+ const enableDnsRebindingProtection = resolveBooleanOption("--sse-enable-dns-protection", "MCP_SSE_ENABLE_DNS_PROTECTION", false);
974
+ return {
975
+ type: "sse",
976
+ host,
977
+ port,
978
+ allowedOrigins,
979
+ allowedHosts,
980
+ enableDnsRebindingProtection,
981
+ };
982
+ }
983
+ const httpRequested = normalized === "http" ||
984
+ normalized === "streamable-http" ||
985
+ normalized === "server" ||
986
+ hasFlag("--http") ||
987
+ // Default to HTTP if not stdio/sse
988
+ (!sseRequested && normalized !== "stdio");
989
+ if (httpRequested) {
990
+ const port = resolvePortOption("--http-port", "MCP_HTTP_PORT", 3000);
991
+ const host = getArgValue("--http-host") ?? process.env.MCP_HTTP_HOST ?? "0.0.0.0";
992
+ const enableJsonResponse = resolveBooleanOption("--http-json-response", "MCP_HTTP_ENABLE_JSON_RESPONSE", false);
993
+ const allowedOrigins = resolveListOption("--http-allowed-origins", "MCP_HTTP_ALLOWED_ORIGINS");
994
+ const allowedHosts = resolveListOption("--http-allowed-hosts", "MCP_HTTP_ALLOWED_HOSTS");
995
+ const enableDnsRebindingProtection = resolveBooleanOption("--http-enable-dns-protection", "MCP_HTTP_ENABLE_DNS_PROTECTION", false);
996
+ return {
997
+ type: "streamable-http",
998
+ host,
999
+ port,
1000
+ enableJsonResponse,
1001
+ allowedOrigins,
1002
+ allowedHosts,
1003
+ enableDnsRebindingProtection,
1004
+ };
1005
+ }
1006
+ return { type: "stdio" };
1007
+ }
1008
+ let sapConfigOverride;
1009
+ function setSapConfigOverride(config) {
1010
+ sapConfigOverride = config;
1011
+ (0, utils_1.setConfigOverride)(config);
1012
+ }
1013
+ function setAbapConnectionOverride(connection) {
1014
+ (0, utils_1.setConnectionOverride)(connection);
1015
+ }
1016
+ /**
1017
+ * Retrieves SAP configuration from environment variables.
1018
+ * Reads configuration from process.env (caller is responsible for loading .env file if needed).
1019
+ *
1020
+ * @returns {SapConfig} The SAP configuration object.
1021
+ * @throws {Error} If any required environment variable is missing.
1022
+ */
1023
+ // Helper function for Windows-compatible logging
1024
+ function debugLog(message) {
1025
+ // Try stderr first
1026
+ try {
1027
+ process.stderr.write(message);
1028
+ }
1029
+ catch (e) {
1030
+ // Fallback to console.error for Windows
1031
+ console.error(message.trim());
1032
+ }
1033
+ // Also try to write to a debug file on Windows
1034
+ if (process.platform === 'win32') {
1035
+ try {
1036
+ const fs = require('fs');
1037
+ const path = require('path');
1038
+ const debugFile = path.join(process.cwd(), 'mcp-debug.log');
1039
+ fs.appendFileSync(debugFile, `${new Date().toISOString()} ${message}`, 'utf8');
1040
+ }
1041
+ catch (e) {
1042
+ // Ignore file write errors
1043
+ }
1044
+ }
1045
+ }
1046
+ function getConfig() {
1047
+ debugLog(`[MCP-CONFIG] getConfig() called\n`);
1048
+ if (sapConfigOverride) {
1049
+ debugLog(`[MCP-CONFIG] Using override config\n`);
1050
+ return sapConfigOverride;
1051
+ }
1052
+ // Read from process.env (already loaded and cleaned by launcher or at startup)
1053
+ // No need to reload .env here - it's already in process.env
1054
+ let url = process.env.SAP_URL;
1055
+ let client = process.env.SAP_CLIENT;
1056
+ debugLog(`[MCP-CONFIG] Raw process.env.SAP_URL: "${url}" (type: ${typeof url}, length: ${url?.length || 0})\n`);
1057
+ // Final cleaning for Windows compatibility (in case values weren't cleaned properly)
1058
+ // This is a safety net, not a reload
1059
+ if (url) {
1060
+ const originalUrl = url;
1061
+ // Remove inline comments (safety net - should already be removed)
1062
+ const commentIndex = url.indexOf('#');
1063
+ if (commentIndex !== -1) {
1064
+ url = url.substring(0, commentIndex).trim();
1065
+ // Log if comment was found (indicates .env parsing issue)
1066
+ debugLog(`[MCP-CONFIG] ⚠ Found comment in URL, removed: "${originalUrl}" → "${url}"\n`);
1067
+ }
1068
+ // Remove ALL control characters (safety net)
1069
+ url = String(url).replace(/[\x00-\x1F\x7F-\x9F]/g, '');
1070
+ url = url.trim();
1071
+ // Remove quotes (safety net)
1072
+ url = url.replace(/^["']+|["']+$/g, '');
1073
+ url = url.trim();
1074
+ // Remove trailing slashes
1075
+ url = url.replace(/\/+$/, '');
1076
+ url = url.trim();
1077
+ // Log cleaned URL for debugging (always, not just Windows)
1078
+ if (url !== originalUrl) {
1079
+ const urlHex = Buffer.from(url, 'utf8').toString('hex');
1080
+ debugLog(`[MCP-CONFIG] Cleaned URL: "${url}" (length: ${url.length}, hex: ${urlHex.substring(0, 60)}...)\n`);
1081
+ }
1082
+ }
1083
+ else {
1084
+ // Log if URL is missing
1085
+ debugLog(`[MCP-CONFIG] ✗ SAP_URL is missing from process.env\n`);
1086
+ debugLog(`[MCP-CONFIG] Available env vars: ${Object.keys(process.env).filter(k => k.startsWith('SAP_')).join(', ')}\n`);
1087
+ }
1088
+ if (client) {
1089
+ client = client.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1090
+ client = client.replace(/^["']|["']$/g, '');
1091
+ }
1092
+ // Auto-detect auth type: if JWT token is present, use JWT; otherwise check SAP_AUTH_TYPE or default to basic
1093
+ let authType = 'basic';
1094
+ if (process.env.SAP_JWT_TOKEN) {
1095
+ authType = 'jwt';
1096
+ }
1097
+ else if (process.env.SAP_AUTH_TYPE) {
1098
+ const rawAuthType = process.env.SAP_AUTH_TYPE.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1099
+ authType = rawAuthType === 'xsuaa' ? 'jwt' : rawAuthType;
1100
+ }
1101
+ if (!url) {
1102
+ throw new Error(`Missing SAP_URL in environment variables. Please check your .env file.`);
1103
+ }
1104
+ // Final validation - URL should be clean now
1105
+ if (!/^https?:\/\//.test(url)) {
1106
+ // Log URL in hex for debugging
1107
+ const urlHex = Buffer.from(url, 'utf8').toString('hex');
1108
+ throw new Error(`Invalid SAP_URL format: "${url}" (hex: ${urlHex.substring(0, 100)}...). Expected format: https://your-system.sap.com`);
1109
+ }
1110
+ // Additional validation: try to create URL object to catch any remaining issues
1111
+ try {
1112
+ const testUrl = new URL(url);
1113
+ // If URL object creation succeeds, use the normalized URL
1114
+ url = testUrl.href.replace(/\/$/, ''); // Remove trailing slash if present
1115
+ }
1116
+ catch (urlError) {
1117
+ const urlHex = Buffer.from(url, 'utf8').toString('hex');
1118
+ throw new Error(`Invalid SAP_URL: "${url}" (hex: ${urlHex.substring(0, 100)}...). Error: ${urlError instanceof Error ? urlError.message : urlError}`);
1119
+ }
1120
+ // Log cleaned URL for debugging (always)
1121
+ const cleanedUrlHex = Buffer.from(url, 'utf8').toString('hex');
1122
+ debugLog(`[MCP-CONFIG] Final SAP_URL: "${url}" (length: ${url.length}, hex: ${cleanedUrlHex.substring(0, 60)}...)\n`);
1123
+ // Verify URL is clean
1124
+ if (url.includes('#')) {
1125
+ debugLog(`[MCP-CONFIG] ✗ ERROR: URL still contains # character!\n`);
1126
+ }
1127
+ if (/[\x00-\x1F\x7F-\x9F]/.test(url)) {
1128
+ debugLog(`[MCP-CONFIG] ✗ ERROR: URL still contains control characters!\n`);
1129
+ }
1130
+ const config = {
1131
+ url, // Already cleaned and validated above
1132
+ authType,
1133
+ };
1134
+ if (client) {
1135
+ config.client = client;
1136
+ }
1137
+ if (authType === 'jwt') {
1138
+ const jwtToken = process.env.SAP_JWT_TOKEN;
1139
+ if (!jwtToken) {
1140
+ throw new Error('Missing SAP_JWT_TOKEN for JWT authentication');
1141
+ }
1142
+ // Clean JWT token (remove control characters)
1143
+ config.jwtToken = jwtToken.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1144
+ const refreshToken = process.env.SAP_REFRESH_TOKEN;
1145
+ if (refreshToken) {
1146
+ config.refreshToken = refreshToken.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1147
+ }
1148
+ const uaaUrl = process.env.SAP_UAA_URL || process.env.UAA_URL;
1149
+ const uaaClientId = process.env.SAP_UAA_CLIENT_ID || process.env.UAA_CLIENT_ID;
1150
+ const uaaClientSecret = process.env.SAP_UAA_CLIENT_SECRET || process.env.UAA_CLIENT_SECRET;
1151
+ if (uaaUrl)
1152
+ config.uaaUrl = uaaUrl.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1153
+ if (uaaClientId)
1154
+ config.uaaClientId = uaaClientId.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1155
+ if (uaaClientSecret)
1156
+ config.uaaClientSecret = uaaClientSecret.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1157
+ }
1158
+ else {
1159
+ const username = process.env.SAP_USERNAME;
1160
+ const password = process.env.SAP_PASSWORD;
1161
+ if (!username || !password) {
1162
+ throw new Error('Missing SAP_USERNAME or SAP_PASSWORD for basic authentication');
1163
+ }
1164
+ // Clean username and password (remove control characters)
1165
+ config.username = username.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1166
+ config.password = password.replace(/[\x00-\x1F\x7F-\x9F]/g, '').trim();
1167
+ }
1168
+ return config;
1169
+ }
1170
+ /**
1171
+ * Server class for interacting with ABAP systems via ADT.
1172
+ */
1173
+ class mcp_abap_adt_server {
1174
+ allowProcessExit;
1175
+ registerSignalHandlers;
1176
+ mcpServer; // MCP server for all transports
1177
+ sapConfig; // SAP configuration
1178
+ hasEnvFile; // Track if .env file was found at startup
1179
+ transportConfig;
1180
+ httpServer;
1181
+ shuttingDown = false;
1182
+ // Client session tracking for StreamableHTTP (like the example)
1183
+ streamableHttpSessions = new Map();
1184
+ // SSE session tracking (McpServer + SSEServerTransport per session)
1185
+ sseSessions = new Map();
1186
+ applyAuthHeaders(headers, sessionId) {
1187
+ if (!headers) {
1188
+ return;
1189
+ }
1190
+ const getHeaderValue = (value) => {
1191
+ if (!value) {
1192
+ return undefined;
1193
+ }
1194
+ return Array.isArray(value) ? value[0] : value;
1195
+ };
1196
+ // Extract SAP URL and auth type from headers
1197
+ const sapUrl = getHeaderValue(headers["x-sap-url"])?.trim();
1198
+ const sapAuthType = getHeaderValue(headers["x-sap-auth-type"])?.trim();
1199
+ // If no URL or auth type, skip processing
1200
+ if (!sapUrl || !sapAuthType) {
1201
+ return;
1202
+ }
1203
+ const isJwtAuth = sapAuthType === "jwt" || sapAuthType === "xsuaa";
1204
+ const isBasicAuth = sapAuthType === "basic";
1205
+ // Process JWT authentication
1206
+ if (isJwtAuth) {
1207
+ // Extract JWT token - required for JWT auth
1208
+ const jwtToken = getHeaderValue(headers["x-sap-jwt-token"])?.trim();
1209
+ if (!jwtToken) {
1210
+ return; // JWT token is required for JWT authentication
1211
+ }
1212
+ // Extract refresh token - optional for JWT auth
1213
+ const refreshToken = getHeaderValue(headers["x-sap-refresh-token"]);
1214
+ // Process JWT config update
1215
+ this.processJwtConfigUpdate(sapUrl, jwtToken, refreshToken, sessionId);
1216
+ return;
1217
+ }
1218
+ // Process basic authentication
1219
+ if (isBasicAuth) {
1220
+ // Extract username and password - required for basic auth
1221
+ const username = getHeaderValue(headers["x-sap-login"])?.trim();
1222
+ const password = getHeaderValue(headers["x-sap-password"])?.trim();
1223
+ if (!username || !password) {
1224
+ return; // Username and password are required for basic authentication
1225
+ }
1226
+ // Process basic auth config update
1227
+ this.processBasicAuthConfigUpdate(sapUrl, username, password, sessionId);
1228
+ return;
1229
+ }
1230
+ }
1231
+ processJwtConfigUpdate(sapUrl, jwtToken, refreshToken, sessionId) {
1232
+ const sanitizeToken = (token) => token.length <= 10 ? token : `${token.substring(0, 6)}…${token.substring(token.length - 4)}`;
1233
+ let baseConfig = this.sapConfig;
1234
+ if (!baseConfig || baseConfig.url === "http://placeholder") {
1235
+ try {
1236
+ baseConfig = getConfig();
1237
+ }
1238
+ catch (error) {
1239
+ logger_1.logger.warn("Failed to load base SAP config when applying headers", {
1240
+ type: "SAP_CONFIG_HEADER_APPLY_FAILED",
1241
+ error: error instanceof Error ? error.message : String(error),
1242
+ });
1243
+ baseConfig = {
1244
+ url: sapUrl,
1245
+ authType: "jwt",
1246
+ };
1247
+ }
1248
+ }
1249
+ // Check if any configuration changed
1250
+ const urlChanged = sapUrl !== baseConfig.url;
1251
+ const authTypeChanged = "jwt" !== baseConfig.authType;
1252
+ const tokenChanged = baseConfig.jwtToken !== jwtToken ||
1253
+ (!!refreshToken && refreshToken.trim() !== baseConfig.refreshToken);
1254
+ if (!urlChanged && !authTypeChanged && !tokenChanged) {
1255
+ return;
1256
+ }
1257
+ const newConfig = {
1258
+ ...baseConfig,
1259
+ url: sapUrl,
1260
+ authType: "jwt",
1261
+ jwtToken,
1262
+ };
1263
+ if (refreshToken && refreshToken.trim()) {
1264
+ newConfig.refreshToken = refreshToken.trim();
1265
+ }
1266
+ setSapConfigOverride(newConfig);
1267
+ this.sapConfig = newConfig;
1268
+ // Store config in session if sessionId is provided
1269
+ if (sessionId) {
1270
+ const session = this.streamableHttpSessions.get(sessionId);
1271
+ if (session) {
1272
+ session.sapConfig = newConfig;
1273
+ }
1274
+ }
1275
+ // Force connection cache invalidation (for backward compatibility)
1276
+ const { invalidateConnectionCache } = require('./lib/utils');
1277
+ try {
1278
+ invalidateConnectionCache();
1279
+ }
1280
+ catch (error) {
1281
+ logger_1.logger.debug("Connection cache invalidation failed", {
1282
+ type: "CONNECTION_CACHE_INVALIDATION_FAILED",
1283
+ error: error instanceof Error ? error.message : String(error),
1284
+ });
1285
+ }
1286
+ logger_1.logger.info("Updated SAP configuration from HTTP headers (JWT)", {
1287
+ type: "SAP_CONFIG_UPDATED",
1288
+ urlChanged: Boolean(urlChanged),
1289
+ authTypeChanged: Boolean(authTypeChanged),
1290
+ tokenChanged: Boolean(tokenChanged),
1291
+ hasRefreshToken: Boolean(refreshToken),
1292
+ jwtPreview: sanitizeToken(jwtToken),
1293
+ sessionId: sessionId?.substring(0, 8),
1294
+ });
1295
+ }
1296
+ processBasicAuthConfigUpdate(sapUrl, username, password, sessionId) {
1297
+ let baseConfig = this.sapConfig;
1298
+ if (!baseConfig || baseConfig.url === "http://placeholder") {
1299
+ try {
1300
+ baseConfig = getConfig();
1301
+ }
1302
+ catch (error) {
1303
+ logger_1.logger.warn("Failed to load base SAP config when applying headers", {
1304
+ type: "SAP_CONFIG_HEADER_APPLY_FAILED",
1305
+ error: error instanceof Error ? error.message : String(error),
1306
+ });
1307
+ baseConfig = {
1308
+ url: sapUrl,
1309
+ authType: "basic",
1310
+ };
1311
+ }
1312
+ }
1313
+ // Check if any configuration changed
1314
+ const urlChanged = sapUrl !== baseConfig.url;
1315
+ const authTypeChanged = "basic" !== baseConfig.authType;
1316
+ const credentialsChanged = baseConfig.username !== username ||
1317
+ baseConfig.password !== password;
1318
+ if (!urlChanged && !authTypeChanged && !credentialsChanged) {
1319
+ return;
1320
+ }
1321
+ const newConfig = {
1322
+ ...baseConfig,
1323
+ url: sapUrl,
1324
+ authType: "basic",
1325
+ username,
1326
+ password,
1327
+ };
1328
+ setSapConfigOverride(newConfig);
1329
+ this.sapConfig = newConfig;
1330
+ // Store config in session if sessionId is provided
1331
+ if (sessionId) {
1332
+ const session = this.streamableHttpSessions.get(sessionId);
1333
+ if (session) {
1334
+ session.sapConfig = newConfig;
1335
+ }
1336
+ }
1337
+ // Force connection cache invalidation (for backward compatibility)
1338
+ const { invalidateConnectionCache } = require('./lib/utils');
1339
+ try {
1340
+ invalidateConnectionCache();
1341
+ }
1342
+ catch (error) {
1343
+ logger_1.logger.debug("Connection cache invalidation failed", {
1344
+ type: "CONNECTION_CACHE_INVALIDATION_FAILED",
1345
+ error: error instanceof Error ? error.message : String(error),
1346
+ });
1347
+ }
1348
+ logger_1.logger.info("Updated SAP configuration from HTTP headers (Basic)", {
1349
+ type: "SAP_CONFIG_UPDATED",
1350
+ urlChanged: Boolean(urlChanged),
1351
+ authTypeChanged: Boolean(authTypeChanged),
1352
+ credentialsChanged: Boolean(credentialsChanged),
1353
+ hasUsername: Boolean(username),
1354
+ sessionId: sessionId?.substring(0, 8),
1355
+ });
1356
+ }
1357
+ /**
1358
+ * Check if connection is from localhost
1359
+ */
1360
+ isLocalConnection(remoteAddress) {
1361
+ if (!remoteAddress) {
1362
+ return false;
1363
+ }
1364
+ // Check for IPv4 localhost
1365
+ if (remoteAddress === "127.0.0.1" || remoteAddress === "localhost") {
1366
+ return true;
1367
+ }
1368
+ // Check for IPv6 localhost
1369
+ if (remoteAddress === "::1" || remoteAddress === "::ffff:127.0.0.1") {
1370
+ return true;
1371
+ }
1372
+ // Check if it's a loopback interface
1373
+ if (remoteAddress.startsWith("127.") || remoteAddress.startsWith("::1")) {
1374
+ return true;
1375
+ }
1376
+ return false;
1377
+ }
1378
+ /**
1379
+ * Check if request has SAP connection headers
1380
+ */
1381
+ hasSapHeaders(headers) {
1382
+ if (!headers) {
1383
+ return false;
1384
+ }
1385
+ const sapUrl = headers["x-sap-url"];
1386
+ const sapAuthType = headers["x-sap-auth-type"];
1387
+ return !!(sapUrl && sapAuthType);
1388
+ }
1389
+ /**
1390
+ * Constructor for the mcp_abap_adt_server class.
1391
+ */
1392
+ constructor(options) {
1393
+ this.allowProcessExit = options?.allowProcessExit ?? true;
1394
+ this.registerSignalHandlers = options?.registerSignalHandlers ?? true;
1395
+ // Check if .env file exists (was loaded at startup)
1396
+ // This is used to determine if we should restrict non-local connections
1397
+ this.hasEnvFile = fs_1.default.existsSync(envFilePath || path_1.default.resolve(process.cwd(), ".env"));
1398
+ if (options?.connection) {
1399
+ setAbapConnectionOverride(options.connection);
1400
+ }
1401
+ else {
1402
+ setAbapConnectionOverride(undefined);
1403
+ }
1404
+ if (!options?.connection) {
1405
+ setSapConfigOverride(options?.sapConfig);
1406
+ }
1407
+ // CHANGED: Don't validate config in constructor - will validate on actual ABAP requests
1408
+ // This allows creating server instance without .env file when using runtime config (e.g., from HTTP headers)
1409
+ try {
1410
+ if (options?.sapConfig) {
1411
+ this.sapConfig = options.sapConfig;
1412
+ }
1413
+ else if (!options?.connection) {
1414
+ // Try to get config, but don't fail if it's invalid - server should still initialize
1415
+ // Invalid config will be caught when handlers try to use it
1416
+ try {
1417
+ this.sapConfig = getConfig();
1418
+ }
1419
+ catch (configError) {
1420
+ // For stdio mode, we want the server to initialize even with invalid config
1421
+ // The error will be shown when user tries to use a tool
1422
+ // Check stdio mode using environment variable or stdin check (transportConfig not set yet)
1423
+ const isStdioMode = process.env.MCP_TRANSPORT === "stdio" || !process.stdin.isTTY;
1424
+ if (isStdioMode) {
1425
+ // In stdio mode, write error to stderr (safe for MCP protocol)
1426
+ process.stderr.write(`[MCP] ⚠ WARNING: Invalid SAP configuration: ${configError instanceof Error ? configError.message : String(configError)}\n`);
1427
+ process.stderr.write(`[MCP] Server will start, but tools will fail until configuration is fixed.\n`);
1428
+ }
1429
+ logger_1.logger.warn("SAP config invalid at initialization, will use placeholder", {
1430
+ type: "CONFIG_INVALID",
1431
+ error: configError instanceof Error ? configError.message : String(configError),
1432
+ });
1433
+ // Set a placeholder that will be replaced when valid config is provided
1434
+ this.sapConfig = { url: "http://placeholder", authType: "jwt", jwtToken: "placeholder" };
1435
+ }
1436
+ }
1437
+ else {
1438
+ this.sapConfig = { url: "http://injected-connection", authType: "jwt", jwtToken: "injected" };
1439
+ }
1440
+ }
1441
+ catch (error) {
1442
+ // If config is not available yet, that's OK - it will be provided later via setSapConfigOverride or DI
1443
+ logger_1.logger.warn("SAP config not available at initialization, will use runtime config", {
1444
+ type: "CONFIG_DEFERRED",
1445
+ error: error instanceof Error ? error.message : String(error),
1446
+ });
1447
+ // Set a placeholder that will be replaced
1448
+ this.sapConfig = { url: "http://placeholder", authType: "jwt", jwtToken: "placeholder" };
1449
+ }
1450
+ try {
1451
+ this.transportConfig = options?.transportConfig ?? parseTransportConfig();
1452
+ }
1453
+ catch (error) {
1454
+ const message = error instanceof Error ? error.message : String(error);
1455
+ // Always write error to stderr (stderr is safe even in stdio mode)
1456
+ logger_1.logger.error("Failed to parse transport configuration", {
1457
+ type: "TRANSPORT_CONFIG_ERROR",
1458
+ error: message,
1459
+ });
1460
+ process.stderr.write(`[MCP] ✗ ERROR: Failed to parse transport configuration: ${message}\n`);
1461
+ if (this.allowProcessExit) {
1462
+ // On Windows, add a small delay before exit to allow error message to be visible
1463
+ if (process.platform === 'win32') {
1464
+ setTimeout(() => process.exit(1), 100);
1465
+ }
1466
+ else {
1467
+ process.exit(1);
1468
+ }
1469
+ }
1470
+ throw error instanceof Error ? error : new Error(message);
1471
+ }
1472
+ // Create McpServer (for all transports)
1473
+ this.mcpServer = new mcp_js_1.McpServer({
1474
+ name: "mcp-abap-adt",
1475
+ version: "0.1.0"
1476
+ });
1477
+ this.setupMcpServerHandlers(); // Setup handlers for McpServer
1478
+ if (this.registerSignalHandlers) {
1479
+ this.setupSignalHandlers();
1480
+ }
1481
+ if (this.transportConfig.type === "streamable-http") {
1482
+ logger_1.logger.info("Transport configured", {
1483
+ type: "TRANSPORT_CONFIG",
1484
+ transport: this.transportConfig.type,
1485
+ host: this.transportConfig.host,
1486
+ port: this.transportConfig.port,
1487
+ enableJsonResponse: this.transportConfig.enableJsonResponse,
1488
+ allowedOrigins: this.transportConfig.allowedOrigins ?? [],
1489
+ allowedHosts: this.transportConfig.allowedHosts ?? [],
1490
+ enableDnsRebindingProtection: this.transportConfig.enableDnsRebindingProtection,
1491
+ });
1492
+ }
1493
+ else if (this.transportConfig.type === "sse") {
1494
+ logger_1.logger.info("Transport configured", {
1495
+ type: "TRANSPORT_CONFIG",
1496
+ transport: this.transportConfig.type,
1497
+ host: this.transportConfig.host,
1498
+ port: this.transportConfig.port,
1499
+ allowedOrigins: this.transportConfig.allowedOrigins ?? [],
1500
+ allowedHosts: this.transportConfig.allowedHosts ?? [],
1501
+ enableDnsRebindingProtection: this.transportConfig.enableDnsRebindingProtection,
1502
+ });
1503
+ }
1504
+ else {
1505
+ logger_1.logger.info("Transport configured", {
1506
+ type: "TRANSPORT_CONFIG",
1507
+ transport: this.transportConfig.type,
1508
+ });
1509
+ }
1510
+ }
1511
+ /**
1512
+ * Creates a new McpServer instance with all handlers registered
1513
+ * Used for SSE sessions where each session needs its own server instance
1514
+ * @private
1515
+ */
1516
+ createMcpServerForSession() {
1517
+ const server = new mcp_js_1.McpServer({
1518
+ name: "mcp-abap-adt",
1519
+ version: "0.1.0"
1520
+ });
1521
+ // Register all tools using the same method as main server
1522
+ this.registerAllToolsOnServer(server);
1523
+ return server;
1524
+ }
1525
+ /**
1526
+ * Converts JSON Schema to Zod schema object (not z.object(), but object with Zod fields)
1527
+ * SDK expects inputSchema to be an object with Zod schemas as values, not z.object()
1528
+ */
1529
+ jsonSchemaToZod(jsonSchema) {
1530
+ // If already a Zod schema object (object with Zod fields), return as-is
1531
+ if (jsonSchema && typeof jsonSchema === 'object' && !jsonSchema.type && !jsonSchema.properties) {
1532
+ // Check if it looks like a Zod schema object (has Zod types as values)
1533
+ const firstValue = Object.values(jsonSchema)[0];
1534
+ if (firstValue && (firstValue.def || firstValue._def || typeof firstValue.parse === 'function')) {
1535
+ return jsonSchema;
1536
+ }
1537
+ }
1538
+ // If it's a JSON Schema object
1539
+ if (jsonSchema && typeof jsonSchema === 'object' && jsonSchema.type === 'object' && jsonSchema.properties) {
1540
+ const zodShape = {};
1541
+ const required = jsonSchema.required || [];
1542
+ for (const [key, prop] of Object.entries(jsonSchema.properties)) {
1543
+ const propSchema = prop;
1544
+ let zodType;
1545
+ if (propSchema.type === 'string') {
1546
+ if (propSchema.enum && Array.isArray(propSchema.enum) && propSchema.enum.length > 0) {
1547
+ // Use z.enum() for enum values (requires at least 1 element, but z.enum needs 2+)
1548
+ if (propSchema.enum.length === 1) {
1549
+ zodType = z.literal(propSchema.enum[0]);
1550
+ }
1551
+ else {
1552
+ zodType = z.enum(propSchema.enum);
1553
+ }
1554
+ }
1555
+ else {
1556
+ zodType = z.string();
1557
+ }
1558
+ }
1559
+ else if (propSchema.type === 'number' || propSchema.type === 'integer') {
1560
+ zodType = z.number();
1561
+ }
1562
+ else if (propSchema.type === 'boolean') {
1563
+ zodType = z.boolean();
1564
+ }
1565
+ else if (propSchema.type === 'array') {
1566
+ const items = propSchema.items;
1567
+ if (items?.type === 'string') {
1568
+ zodType = z.array(z.string());
1569
+ }
1570
+ else if (items?.type === 'number' || items?.type === 'integer') {
1571
+ zodType = z.array(z.number());
1572
+ }
1573
+ else if (items?.type === 'boolean') {
1574
+ zodType = z.array(z.boolean());
1575
+ }
1576
+ else if (items?.type === 'object' && items.properties) {
1577
+ // For nested objects in arrays, create object schema
1578
+ const nestedShape = {};
1579
+ const nestedRequired = items.required || [];
1580
+ for (const [nestedKey, nestedProp] of Object.entries(items.properties)) {
1581
+ const nestedPropSchema = nestedProp;
1582
+ let nestedZodType;
1583
+ if (nestedPropSchema.type === 'string') {
1584
+ if (nestedPropSchema.enum && Array.isArray(nestedPropSchema.enum) && nestedPropSchema.enum.length > 0) {
1585
+ if (nestedPropSchema.enum.length === 1) {
1586
+ nestedZodType = z.literal(nestedPropSchema.enum[0]);
1587
+ }
1588
+ else {
1589
+ nestedZodType = z.enum(nestedPropSchema.enum);
1590
+ }
1591
+ }
1592
+ else {
1593
+ nestedZodType = z.string();
1594
+ }
1595
+ }
1596
+ else if (nestedPropSchema.type === 'number' || nestedPropSchema.type === 'integer') {
1597
+ nestedZodType = z.number();
1598
+ }
1599
+ else if (nestedPropSchema.type === 'boolean') {
1600
+ nestedZodType = z.boolean();
1601
+ }
1602
+ else {
1603
+ nestedZodType = z.any();
1604
+ }
1605
+ if (nestedPropSchema.default !== undefined) {
1606
+ nestedZodType = nestedZodType.default(nestedPropSchema.default);
1607
+ }
1608
+ if (!nestedRequired.includes(nestedKey)) {
1609
+ nestedZodType = nestedZodType.optional();
1610
+ }
1611
+ if (nestedPropSchema.description) {
1612
+ nestedZodType = nestedZodType.describe(nestedPropSchema.description);
1613
+ }
1614
+ nestedShape[nestedKey] = nestedZodType;
1615
+ }
1616
+ zodType = z.array(z.object(nestedShape));
1617
+ }
1618
+ else {
1619
+ zodType = z.array(z.any());
1620
+ }
1621
+ }
1622
+ else if (propSchema.type === 'object' && propSchema.properties) {
1623
+ // For nested objects, create object schema
1624
+ const nestedShape = {};
1625
+ const nestedRequired = propSchema.required || [];
1626
+ for (const [nestedKey, nestedProp] of Object.entries(propSchema.properties)) {
1627
+ const nestedPropSchema = nestedProp;
1628
+ let nestedZodType;
1629
+ if (nestedPropSchema.type === 'string') {
1630
+ if (nestedPropSchema.enum && Array.isArray(nestedPropSchema.enum)) {
1631
+ nestedZodType = z.enum(nestedPropSchema.enum);
1632
+ }
1633
+ else {
1634
+ nestedZodType = z.string();
1635
+ }
1636
+ }
1637
+ else if (nestedPropSchema.type === 'number' || nestedPropSchema.type === 'integer') {
1638
+ nestedZodType = z.number();
1639
+ }
1640
+ else if (nestedPropSchema.type === 'boolean') {
1641
+ nestedZodType = z.boolean();
1642
+ }
1643
+ else {
1644
+ nestedZodType = z.any();
1645
+ }
1646
+ if (nestedPropSchema.default !== undefined) {
1647
+ nestedZodType = nestedZodType.default(nestedPropSchema.default);
1648
+ }
1649
+ if (!nestedRequired.includes(nestedKey)) {
1650
+ nestedZodType = nestedZodType.optional();
1651
+ }
1652
+ if (nestedPropSchema.description) {
1653
+ nestedZodType = nestedZodType.describe(nestedPropSchema.description);
1654
+ }
1655
+ nestedShape[nestedKey] = nestedZodType;
1656
+ }
1657
+ zodType = z.object(nestedShape);
1658
+ }
1659
+ else {
1660
+ zodType = z.any();
1661
+ }
1662
+ // Add default value if present (before optional)
1663
+ if (propSchema.default !== undefined) {
1664
+ zodType = zodType.default(propSchema.default);
1665
+ }
1666
+ // Make optional if not in required array (must be after default, before describe)
1667
+ if (!required.includes(key)) {
1668
+ zodType = zodType.optional();
1669
+ }
1670
+ // Add description if present (after optional)
1671
+ if (propSchema.description) {
1672
+ zodType = zodType.describe(propSchema.description);
1673
+ }
1674
+ zodShape[key] = zodType;
1675
+ }
1676
+ // Return object with Zod fields, not z.object()
1677
+ return zodShape;
1678
+ }
1679
+ // Fallback: if it's already a Zod schema object, return as-is
1680
+ if (jsonSchema && typeof jsonSchema === 'object' && !jsonSchema.type) {
1681
+ return jsonSchema;
1682
+ }
1683
+ // Fallback: return empty object for unknown schemas
1684
+ return {};
1685
+ }
1686
+ /**
1687
+ * Helper function to register a tool on McpServer
1688
+ * Wraps handler to convert our response format to MCP format
1689
+ */
1690
+ registerToolOnServer(server, toolName, description, inputSchema, handler) {
1691
+ // Convert JSON Schema to Zod if needed, otherwise pass as-is (like in the example)
1692
+ const zodSchema = (inputSchema && typeof inputSchema === 'object' && inputSchema.type === 'object' && inputSchema.properties)
1693
+ ? this.jsonSchemaToZod(inputSchema)
1694
+ : inputSchema;
1695
+ server.registerTool(toolName, {
1696
+ description,
1697
+ inputSchema: zodSchema,
1698
+ }, async (args) => {
1699
+ const result = await handler(args);
1700
+ // If error, throw it
1701
+ if (result.isError) {
1702
+ const errorText = result.content
1703
+ ?.map((item) => {
1704
+ if (item?.type === "json" && item.json !== undefined) {
1705
+ return JSON.stringify(item.json);
1706
+ }
1707
+ return item?.text || String(item);
1708
+ })
1709
+ .join("\n") || "Unknown error";
1710
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, errorText);
1711
+ }
1712
+ // Convert content to MCP format - JSON items become text
1713
+ const content = (result.content || []).map((item) => {
1714
+ if (item?.type === "json" && item.json !== undefined) {
1715
+ return {
1716
+ type: "text",
1717
+ text: JSON.stringify(item.json),
1718
+ };
1719
+ }
1720
+ return {
1721
+ type: "text",
1722
+ text: item?.text || String(item || ""),
1723
+ };
1724
+ });
1725
+ return { content };
1726
+ });
1727
+ }
1728
+ /**
1729
+ * Registers all tools on a McpServer instance
1730
+ * Used for both main server and per-session servers
1731
+ */
1732
+ registerAllToolsOnServer(server) {
1733
+ this.registerToolOnServer(server, handleGetProgram_2.TOOL_DEFINITION.name, handleGetProgram_2.TOOL_DEFINITION.description, handleGetProgram_2.TOOL_DEFINITION.inputSchema, handleGetProgram_1.handleGetProgram);
1734
+ this.registerToolOnServer(server, handleGetClass_2.TOOL_DEFINITION.name, handleGetClass_2.TOOL_DEFINITION.description, handleGetClass_2.TOOL_DEFINITION.inputSchema, handleGetClass_1.handleGetClass);
1735
+ this.registerToolOnServer(server, handleGetFunction_2.TOOL_DEFINITION.name, handleGetFunction_2.TOOL_DEFINITION.description, handleGetFunction_2.TOOL_DEFINITION.inputSchema, handleGetFunction_1.handleGetFunction);
1736
+ this.registerToolOnServer(server, handleGetFunctionGroup_2.TOOL_DEFINITION.name, handleGetFunctionGroup_2.TOOL_DEFINITION.description, handleGetFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleGetFunctionGroup_1.handleGetFunctionGroup);
1737
+ this.registerToolOnServer(server, handleGetTable_2.TOOL_DEFINITION.name, handleGetTable_2.TOOL_DEFINITION.description, handleGetTable_2.TOOL_DEFINITION.inputSchema, handleGetTable_1.handleGetTable);
1738
+ this.registerToolOnServer(server, handleGetStructure_2.TOOL_DEFINITION.name, handleGetStructure_2.TOOL_DEFINITION.description, handleGetStructure_2.TOOL_DEFINITION.inputSchema, handleGetStructure_1.handleGetStructure);
1739
+ this.registerToolOnServer(server, handleGetTableContents_2.TOOL_DEFINITION.name, handleGetTableContents_2.TOOL_DEFINITION.description, handleGetTableContents_2.TOOL_DEFINITION.inputSchema, handleGetTableContents_1.handleGetTableContents);
1740
+ this.registerToolOnServer(server, handleGetPackage_2.TOOL_DEFINITION.name, handleGetPackage_2.TOOL_DEFINITION.description, handleGetPackage_2.TOOL_DEFINITION.inputSchema, handleGetPackage_1.handleGetPackage);
1741
+ this.registerToolOnServer(server, handleCreatePackage_3.TOOL_DEFINITION.name, handleCreatePackage_3.TOOL_DEFINITION.description, handleCreatePackage_3.TOOL_DEFINITION.inputSchema, handleCreatePackage_1.handleCreatePackage);
1742
+ this.registerToolOnServer(server, handleUpdatePackage_2.TOOL_DEFINITION.name, handleUpdatePackage_2.TOOL_DEFINITION.description, handleUpdatePackage_2.TOOL_DEFINITION.inputSchema, handleUpdatePackage_1.handleUpdatePackage);
1743
+ this.registerToolOnServer(server, handleUnlockPackage_2.TOOL_DEFINITION.name, handleUnlockPackage_2.TOOL_DEFINITION.description, handleUnlockPackage_2.TOOL_DEFINITION.inputSchema, handleUnlockPackage_1.handleUnlockPackage);
1744
+ this.registerToolOnServer(server, handleGetInclude_2.TOOL_DEFINITION.name, handleGetInclude_2.TOOL_DEFINITION.description, handleGetInclude_2.TOOL_DEFINITION.inputSchema, handleGetInclude_1.handleGetInclude);
1745
+ this.registerToolOnServer(server, handleGetIncludesList_2.TOOL_DEFINITION.name, handleGetIncludesList_2.TOOL_DEFINITION.description, handleGetIncludesList_2.TOOL_DEFINITION.inputSchema, handleGetIncludesList_1.handleGetIncludesList);
1746
+ this.registerToolOnServer(server, handleGetTypeInfo_2.TOOL_DEFINITION.name, handleGetTypeInfo_2.TOOL_DEFINITION.description, handleGetTypeInfo_2.TOOL_DEFINITION.inputSchema, handleGetTypeInfo_1.handleGetTypeInfo);
1747
+ this.registerToolOnServer(server, handleGetInterface_2.TOOL_DEFINITION.name, handleGetInterface_2.TOOL_DEFINITION.description, handleGetInterface_2.TOOL_DEFINITION.inputSchema, handleGetInterface_1.handleGetInterface);
1748
+ this.registerToolOnServer(server, handleGetTransaction_2.TOOL_DEFINITION.name, handleGetTransaction_2.TOOL_DEFINITION.description, handleGetTransaction_2.TOOL_DEFINITION.inputSchema, handleGetTransaction_1.handleGetTransaction);
1749
+ this.registerToolOnServer(server, handleSearchObject_2.TOOL_DEFINITION.name, handleSearchObject_2.TOOL_DEFINITION.description, handleSearchObject_2.TOOL_DEFINITION.inputSchema, handleSearchObject_1.handleSearchObject);
1750
+ this.registerToolOnServer(server, handleGetEnhancements_2.TOOL_DEFINITION.name, handleGetEnhancements_2.TOOL_DEFINITION.description, handleGetEnhancements_2.TOOL_DEFINITION.inputSchema, handleGetEnhancements_1.handleGetEnhancements);
1751
+ this.registerToolOnServer(server, handleGetEnhancementSpot_2.TOOL_DEFINITION.name, handleGetEnhancementSpot_2.TOOL_DEFINITION.description, handleGetEnhancementSpot_2.TOOL_DEFINITION.inputSchema, handleGetEnhancementSpot_1.handleGetEnhancementSpot);
1752
+ this.registerToolOnServer(server, handleGetEnhancementImpl_2.TOOL_DEFINITION.name, handleGetEnhancementImpl_2.TOOL_DEFINITION.description, handleGetEnhancementImpl_2.TOOL_DEFINITION.inputSchema, handleGetEnhancementImpl_1.handleGetEnhancementImpl);
1753
+ this.registerToolOnServer(server, handleGetBdef_2.TOOL_DEFINITION.name, handleGetBdef_2.TOOL_DEFINITION.description, handleGetBdef_2.TOOL_DEFINITION.inputSchema, handleGetBdef_1.handleGetBdef);
1754
+ this.registerToolOnServer(server, handleGetSqlQuery_2.TOOL_DEFINITION.name, handleGetSqlQuery_2.TOOL_DEFINITION.description, handleGetSqlQuery_2.TOOL_DEFINITION.inputSchema, handleGetSqlQuery_1.handleGetSqlQuery);
1755
+ this.registerToolOnServer(server, handleGetWhereUsed_2.TOOL_DEFINITION.name, handleGetWhereUsed_2.TOOL_DEFINITION.description, handleGetWhereUsed_2.TOOL_DEFINITION.inputSchema, handleGetWhereUsed_1.handleGetWhereUsed);
1756
+ this.registerToolOnServer(server, handleGetObjectInfo_2.TOOL_DEFINITION.name, handleGetObjectInfo_2.TOOL_DEFINITION.description, handleGetObjectInfo_2.TOOL_DEFINITION.inputSchema, async (args) => {
1757
+ if (!args || typeof args !== "object") {
1758
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, "Missing or invalid arguments for GetObjectInfo");
1759
+ }
1760
+ return await (0, handleGetObjectInfo_1.handleGetObjectInfo)(args);
1761
+ });
1762
+ this.registerToolOnServer(server, handleGetAbapAST_2.TOOL_DEFINITION.name, handleGetAbapAST_2.TOOL_DEFINITION.description, handleGetAbapAST_2.TOOL_DEFINITION.inputSchema, handleGetAbapAST_1.handleGetAbapAST);
1763
+ this.registerToolOnServer(server, handleGetAbapSemanticAnalysis_2.TOOL_DEFINITION.name, handleGetAbapSemanticAnalysis_2.TOOL_DEFINITION.description, handleGetAbapSemanticAnalysis_2.TOOL_DEFINITION.inputSchema, handleGetAbapSemanticAnalysis_1.handleGetAbapSemanticAnalysis);
1764
+ this.registerToolOnServer(server, handleGetAbapSystemSymbols_2.TOOL_DEFINITION.name, handleGetAbapSystemSymbols_2.TOOL_DEFINITION.description, handleGetAbapSystemSymbols_2.TOOL_DEFINITION.inputSchema, handleGetAbapSystemSymbols_1.handleGetAbapSystemSymbols);
1765
+ this.registerToolOnServer(server, handleGetDomain_2.TOOL_DEFINITION.name, handleGetDomain_2.TOOL_DEFINITION.description, handleGetDomain_2.TOOL_DEFINITION.inputSchema, handleGetDomain_1.handleGetDomain);
1766
+ this.registerToolOnServer(server, handleCreateDomain_3.TOOL_DEFINITION.name, handleCreateDomain_3.TOOL_DEFINITION.description, handleCreateDomain_3.TOOL_DEFINITION.inputSchema, handleCreateDomain_1.handleCreateDomain);
1767
+ this.registerToolOnServer(server, handleUpdateDomain_4.TOOL_DEFINITION.name, handleUpdateDomain_4.TOOL_DEFINITION.description, handleUpdateDomain_4.TOOL_DEFINITION.inputSchema, handleUpdateDomain_2.handleUpdateDomain);
1768
+ this.registerToolOnServer(server, handleUpdateDomain_3.TOOL_DEFINITION.name, handleUpdateDomain_3.TOOL_DEFINITION.description, handleUpdateDomain_3.TOOL_DEFINITION.inputSchema, handleUpdateDomain_1.handleUpdateDomain);
1769
+ this.registerToolOnServer(server, handleCreateDataElement_3.TOOL_DEFINITION.name, handleCreateDataElement_3.TOOL_DEFINITION.description, handleCreateDataElement_3.TOOL_DEFINITION.inputSchema, handleCreateDataElement_1.handleCreateDataElement);
1770
+ this.registerToolOnServer(server, handleUpdateDataElement_4.TOOL_DEFINITION.name, handleUpdateDataElement_4.TOOL_DEFINITION.description, handleUpdateDataElement_4.TOOL_DEFINITION.inputSchema, handleUpdateDataElement_2.handleUpdateDataElement);
1771
+ this.registerToolOnServer(server, handleUpdateDataElement_3.TOOL_DEFINITION.name, handleUpdateDataElement_3.TOOL_DEFINITION.description, handleUpdateDataElement_3.TOOL_DEFINITION.inputSchema, handleUpdateDataElement_1.handleUpdateDataElement);
1772
+ this.registerToolOnServer(server, handleGetDataElement_2.TOOL_DEFINITION.name, handleGetDataElement_2.TOOL_DEFINITION.description, handleGetDataElement_2.TOOL_DEFINITION.inputSchema, handleGetDataElement_1.handleGetDataElement);
1773
+ this.registerToolOnServer(server, handleCreateTransport_3.TOOL_DEFINITION.name, handleCreateTransport_3.TOOL_DEFINITION.description, handleCreateTransport_3.TOOL_DEFINITION.inputSchema, handleCreateTransport_1.handleCreateTransport);
1774
+ this.registerToolOnServer(server, handleGetTransport_2.TOOL_DEFINITION.name, handleGetTransport_2.TOOL_DEFINITION.description, handleGetTransport_2.TOOL_DEFINITION.inputSchema, handleGetTransport_1.handleGetTransport);
1775
+ this.registerToolOnServer(server, handleCreateTable_3.TOOL_DEFINITION.name, handleCreateTable_3.TOOL_DEFINITION.description, handleCreateTable_3.TOOL_DEFINITION.inputSchema, handleCreateTable_1.handleCreateTable);
1776
+ this.registerToolOnServer(server, handleUpdateTable_2.TOOL_DEFINITION.name, handleUpdateTable_2.TOOL_DEFINITION.description, handleUpdateTable_2.TOOL_DEFINITION.inputSchema, handleUpdateTable_1.handleUpdateTable);
1777
+ this.registerToolOnServer(server, handleCreateStructure_3.TOOL_DEFINITION.name, handleCreateStructure_3.TOOL_DEFINITION.description, handleCreateStructure_3.TOOL_DEFINITION.inputSchema, handleCreateStructure_1.handleCreateStructure);
1778
+ this.registerToolOnServer(server, handleUpdateStructure_2.TOOL_DEFINITION.name, handleUpdateStructure_2.TOOL_DEFINITION.description, handleUpdateStructure_2.TOOL_DEFINITION.inputSchema, handleUpdateStructure_1.handleUpdateStructure);
1779
+ this.registerToolOnServer(server, handleCreateView_3.TOOL_DEFINITION.name, handleCreateView_3.TOOL_DEFINITION.description, handleCreateView_3.TOOL_DEFINITION.inputSchema, handleCreateView_1.handleCreateView);
1780
+ this.registerToolOnServer(server, handleGetView_2.TOOL_DEFINITION.name, handleGetView_2.TOOL_DEFINITION.description, handleGetView_2.TOOL_DEFINITION.inputSchema, handleGetView_1.handleGetView);
1781
+ this.registerToolOnServer(server, handleGetServiceDefinition_2.TOOL_DEFINITION.name, handleGetServiceDefinition_2.TOOL_DEFINITION.description, handleGetServiceDefinition_2.TOOL_DEFINITION.inputSchema, handleGetServiceDefinition_1.handleGetServiceDefinition);
1782
+ this.registerToolOnServer(server, handleUpdateView_4.TOOL_DEFINITION.name, handleUpdateView_4.TOOL_DEFINITION.description, handleUpdateView_4.TOOL_DEFINITION.inputSchema, handleUpdateView_2.handleUpdateView);
1783
+ this.registerToolOnServer(server, handleCreateClass_3.TOOL_DEFINITION.name, handleCreateClass_3.TOOL_DEFINITION.description, handleCreateClass_3.TOOL_DEFINITION.inputSchema, handleCreateClass_1.handleCreateClass);
1784
+ this.registerToolOnServer(server, handleUpdateClass_4.TOOL_DEFINITION.name, handleUpdateClass_4.TOOL_DEFINITION.description, handleUpdateClass_4.TOOL_DEFINITION.inputSchema, handleUpdateClass_2.handleUpdateClass);
1785
+ this.registerToolOnServer(server, handleUpdateClass_3.TOOL_DEFINITION.name, handleUpdateClass_3.TOOL_DEFINITION.description, handleUpdateClass_3.TOOL_DEFINITION.inputSchema, handleUpdateClass_1.handleUpdateClass);
1786
+ this.registerToolOnServer(server, handleCreateProgram_3.TOOL_DEFINITION.name, handleCreateProgram_3.TOOL_DEFINITION.description, handleCreateProgram_3.TOOL_DEFINITION.inputSchema, handleCreateProgram_1.handleCreateProgram);
1787
+ this.registerToolOnServer(server, handleUpdateProgram_4.TOOL_DEFINITION.name, handleUpdateProgram_4.TOOL_DEFINITION.description, handleUpdateProgram_4.TOOL_DEFINITION.inputSchema, handleUpdateProgram_2.handleUpdateProgram);
1788
+ this.registerToolOnServer(server, handleUpdateProgram_3.TOOL_DEFINITION.name, handleUpdateProgram_3.TOOL_DEFINITION.description, handleUpdateProgram_3.TOOL_DEFINITION.inputSchema, handleUpdateProgram_1.handleUpdateProgram);
1789
+ this.registerToolOnServer(server, handleCreateInterface_3.TOOL_DEFINITION.name, handleCreateInterface_3.TOOL_DEFINITION.description, handleCreateInterface_3.TOOL_DEFINITION.inputSchema, handleCreateInterface_1.handleCreateInterface);
1790
+ this.registerToolOnServer(server, handleUpdateInterface_4.TOOL_DEFINITION.name, handleUpdateInterface_4.TOOL_DEFINITION.description, handleUpdateInterface_4.TOOL_DEFINITION.inputSchema, handleUpdateInterface_2.handleUpdateInterface);
1791
+ this.registerToolOnServer(server, handleCreateFunctionGroup_3.TOOL_DEFINITION.name, handleCreateFunctionGroup_3.TOOL_DEFINITION.description, handleCreateFunctionGroup_3.TOOL_DEFINITION.inputSchema, handleCreateFunctionGroup_1.handleCreateFunctionGroup);
1792
+ this.registerToolOnServer(server, handleCreateFunctionModule_3.TOOL_DEFINITION.name, handleCreateFunctionModule_3.TOOL_DEFINITION.description, handleCreateFunctionModule_3.TOOL_DEFINITION.inputSchema, handleCreateFunctionModule_1.handleCreateFunctionModule);
1793
+ this.registerToolOnServer(server, handleUpdateFunctionModule_4.TOOL_DEFINITION.name, handleUpdateFunctionModule_4.TOOL_DEFINITION.description, handleUpdateFunctionModule_4.TOOL_DEFINITION.inputSchema, handleUpdateFunctionModule_2.handleUpdateFunctionModule);
1794
+ this.registerToolOnServer(server, handleUpdateView_3.TOOL_DEFINITION.name, handleUpdateView_3.TOOL_DEFINITION.description, handleUpdateView_3.TOOL_DEFINITION.inputSchema, handleUpdateView_1.handleUpdateView);
1795
+ this.registerToolOnServer(server, handleUpdateInterface_3.TOOL_DEFINITION.name, handleUpdateInterface_3.TOOL_DEFINITION.description, handleUpdateInterface_3.TOOL_DEFINITION.inputSchema, handleUpdateInterface_1.handleUpdateInterface);
1796
+ this.registerToolOnServer(server, handleUpdateFunctionModule_3.TOOL_DEFINITION.name, handleUpdateFunctionModule_3.TOOL_DEFINITION.description, handleUpdateFunctionModule_3.TOOL_DEFINITION.inputSchema, handleUpdateFunctionModule_1.handleUpdateFunctionModule);
1797
+ this.registerToolOnServer(server, handleActivateObject_2.TOOL_DEFINITION.name, handleActivateObject_2.TOOL_DEFINITION.description, handleActivateObject_2.TOOL_DEFINITION.inputSchema, handleActivateObject_1.handleActivateObject);
1798
+ this.registerToolOnServer(server, handleDeleteObject_2.TOOL_DEFINITION.name, handleDeleteObject_2.TOOL_DEFINITION.description, handleDeleteObject_2.TOOL_DEFINITION.inputSchema, handleDeleteObject_1.handleDeleteObject);
1799
+ this.registerToolOnServer(server, handleCheckObject_2.TOOL_DEFINITION.name, handleCheckObject_2.TOOL_DEFINITION.description, handleCheckObject_2.TOOL_DEFINITION.inputSchema, handleCheckObject_1.handleCheckObject);
1800
+ this.registerToolOnServer(server, handleGetSession_2.TOOL_DEFINITION.name, handleGetSession_2.TOOL_DEFINITION.description, handleGetSession_2.TOOL_DEFINITION.inputSchema, handleGetSession_1.handleGetSession);
1801
+ this.registerToolOnServer(server, handleValidateObject_2.TOOL_DEFINITION.name, handleValidateObject_2.TOOL_DEFINITION.description, handleValidateObject_2.TOOL_DEFINITION.inputSchema, handleValidateObject_1.handleValidateObject);
1802
+ this.registerToolOnServer(server, handleLockObject_2.TOOL_DEFINITION.name, handleLockObject_2.TOOL_DEFINITION.description, handleLockObject_2.TOOL_DEFINITION.inputSchema, handleLockObject_1.handleLockObject);
1803
+ this.registerToolOnServer(server, handleUnlockObject_2.TOOL_DEFINITION.name, handleUnlockObject_2.TOOL_DEFINITION.description, handleUnlockObject_2.TOOL_DEFINITION.inputSchema, handleUnlockObject_1.handleUnlockObject);
1804
+ this.registerToolOnServer(server, handleValidateClass_2.TOOL_DEFINITION.name, handleValidateClass_2.TOOL_DEFINITION.description, handleValidateClass_2.TOOL_DEFINITION.inputSchema, handleValidateClass_1.handleValidateClass);
1805
+ this.registerToolOnServer(server, handleCheckClass_2.TOOL_DEFINITION.name, handleCheckClass_2.TOOL_DEFINITION.description, handleCheckClass_2.TOOL_DEFINITION.inputSchema, handleCheckClass_1.handleCheckClass);
1806
+ this.registerToolOnServer(server, handleValidateTable_2.TOOL_DEFINITION.name, handleValidateTable_2.TOOL_DEFINITION.description, handleValidateTable_2.TOOL_DEFINITION.inputSchema, handleValidateTable_1.handleValidateTable);
1807
+ this.registerToolOnServer(server, handleCheckTable_2.TOOL_DEFINITION.name, handleCheckTable_2.TOOL_DEFINITION.description, handleCheckTable_2.TOOL_DEFINITION.inputSchema, handleCheckTable_1.handleCheckTable);
1808
+ this.registerToolOnServer(server, handleValidateFunctionModule_2.TOOL_DEFINITION.name, handleValidateFunctionModule_2.TOOL_DEFINITION.description, handleValidateFunctionModule_2.TOOL_DEFINITION.inputSchema, handleValidateFunctionModule_1.handleValidateFunctionModule);
1809
+ this.registerToolOnServer(server, handleCheckFunctionModule_2.TOOL_DEFINITION.name, handleCheckFunctionModule_2.TOOL_DEFINITION.description, handleCheckFunctionModule_2.TOOL_DEFINITION.inputSchema, handleCheckFunctionModule_1.handleCheckFunctionModule);
1810
+ this.registerToolOnServer(server, handleCreateBehaviorDefinition_3.TOOL_DEFINITION.name, handleCreateBehaviorDefinition_3.TOOL_DEFINITION.description, handleCreateBehaviorDefinition_3.TOOL_DEFINITION.inputSchema, handleCreateBehaviorDefinition_1.handleCreateBehaviorDefinition);
1811
+ this.registerToolOnServer(server, handleUpdateBehaviorDefinition_4.TOOL_DEFINITION.name, handleUpdateBehaviorDefinition_4.TOOL_DEFINITION.description, handleUpdateBehaviorDefinition_4.TOOL_DEFINITION.inputSchema, handleUpdateBehaviorDefinition_2.handleUpdateBehaviorDefinition);
1812
+ this.registerToolOnServer(server, handleUpdateBehaviorDefinition_3.TOOL_DEFINITION.name, handleUpdateBehaviorDefinition_3.TOOL_DEFINITION.description, handleUpdateBehaviorDefinition_3.TOOL_DEFINITION.inputSchema, handleUpdateBehaviorDefinition_1.handleUpdateBehaviorDefinition);
1813
+ this.registerToolOnServer(server, handleCreateMetadataExtension_3.TOOL_DEFINITION.name, handleCreateMetadataExtension_3.TOOL_DEFINITION.description, handleCreateMetadataExtension_3.TOOL_DEFINITION.inputSchema, handleCreateMetadataExtension_1.handleCreateMetadataExtension);
1814
+ this.registerToolOnServer(server, handleUpdateMetadataExtension_4.TOOL_DEFINITION.name, handleUpdateMetadataExtension_4.TOOL_DEFINITION.description, handleUpdateMetadataExtension_4.TOOL_DEFINITION.inputSchema, handleUpdateMetadataExtension_2.handleUpdateMetadataExtension);
1815
+ this.registerToolOnServer(server, handleUpdateMetadataExtension_3.TOOL_DEFINITION.name, handleUpdateMetadataExtension_3.TOOL_DEFINITION.description, handleUpdateMetadataExtension_3.TOOL_DEFINITION.inputSchema, handleUpdateMetadataExtension_1.handleUpdateMetadataExtension);
1816
+ this.registerToolOnServer(server, handleGetInactiveObjects_2.TOOL_DEFINITION.name, handleGetInactiveObjects_2.TOOL_DEFINITION.description, handleGetInactiveObjects_2.TOOL_DEFINITION.inputSchema, handleGetInactiveObjects_1.handleGetInactiveObjects);
1817
+ // New low-level handlers registration
1818
+ this.registerToolOnServer(server, handleDeleteClass_2.TOOL_DEFINITION.name, handleDeleteClass_2.TOOL_DEFINITION.description, handleDeleteClass_2.TOOL_DEFINITION.inputSchema, handleDeleteClass_1.handleDeleteClass);
1819
+ this.registerToolOnServer(server, handleLockClass_2.TOOL_DEFINITION.name, handleLockClass_2.TOOL_DEFINITION.description, handleLockClass_2.TOOL_DEFINITION.inputSchema, handleLockClass_1.handleLockClass);
1820
+ this.registerToolOnServer(server, handleUnlockClass_2.TOOL_DEFINITION.name, handleUnlockClass_2.TOOL_DEFINITION.description, handleUnlockClass_2.TOOL_DEFINITION.inputSchema, handleUnlockClass_1.handleUnlockClass);
1821
+ this.registerToolOnServer(server, handleCreateClass_4.TOOL_DEFINITION.name, handleCreateClass_4.TOOL_DEFINITION.description, handleCreateClass_4.TOOL_DEFINITION.inputSchema, handleCreateClass_2.handleCreateClass);
1822
+ this.registerToolOnServer(server, handleLockClassTestClasses_2.TOOL_DEFINITION.name, handleLockClassTestClasses_2.TOOL_DEFINITION.description, handleLockClassTestClasses_2.TOOL_DEFINITION.inputSchema, handleLockClassTestClasses_1.handleLockClassTestClasses);
1823
+ this.registerToolOnServer(server, handleUnlockClassTestClasses_2.TOOL_DEFINITION.name, handleUnlockClassTestClasses_2.TOOL_DEFINITION.description, handleUnlockClassTestClasses_2.TOOL_DEFINITION.inputSchema, handleUnlockClassTestClasses_1.handleUnlockClassTestClasses);
1824
+ this.registerToolOnServer(server, handleUpdateClassTestClasses_2.TOOL_DEFINITION.name, handleUpdateClassTestClasses_2.TOOL_DEFINITION.description, handleUpdateClassTestClasses_2.TOOL_DEFINITION.inputSchema, handleUpdateClassTestClasses_1.handleUpdateClassTestClasses);
1825
+ this.registerToolOnServer(server, handleActivateClassTestClasses_2.TOOL_DEFINITION.name, handleActivateClassTestClasses_2.TOOL_DEFINITION.description, handleActivateClassTestClasses_2.TOOL_DEFINITION.inputSchema, handleActivateClassTestClasses_1.handleActivateClassTestClasses);
1826
+ this.registerToolOnServer(server, handleRunClassUnitTests_2.TOOL_DEFINITION.name, handleRunClassUnitTests_2.TOOL_DEFINITION.description, handleRunClassUnitTests_2.TOOL_DEFINITION.inputSchema, handleRunClassUnitTests_1.handleRunClassUnitTests);
1827
+ this.registerToolOnServer(server, handleGetClassUnitTestStatus_2.TOOL_DEFINITION.name, handleGetClassUnitTestStatus_2.TOOL_DEFINITION.description, handleGetClassUnitTestStatus_2.TOOL_DEFINITION.inputSchema, handleGetClassUnitTestStatus_1.handleGetClassUnitTestStatus);
1828
+ this.registerToolOnServer(server, handleGetClassUnitTestResult_2.TOOL_DEFINITION.name, handleGetClassUnitTestResult_2.TOOL_DEFINITION.description, handleGetClassUnitTestResult_2.TOOL_DEFINITION.inputSchema, handleGetClassUnitTestResult_1.handleGetClassUnitTestResult);
1829
+ this.registerToolOnServer(server, handleCheckProgram_2.TOOL_DEFINITION.name, handleCheckProgram_2.TOOL_DEFINITION.description, handleCheckProgram_2.TOOL_DEFINITION.inputSchema, handleCheckProgram_1.handleCheckProgram);
1830
+ this.registerToolOnServer(server, handleDeleteProgram_2.TOOL_DEFINITION.name, handleDeleteProgram_2.TOOL_DEFINITION.description, handleDeleteProgram_2.TOOL_DEFINITION.inputSchema, handleDeleteProgram_1.handleDeleteProgram);
1831
+ this.registerToolOnServer(server, handleLockProgram_2.TOOL_DEFINITION.name, handleLockProgram_2.TOOL_DEFINITION.description, handleLockProgram_2.TOOL_DEFINITION.inputSchema, handleLockProgram_1.handleLockProgram);
1832
+ this.registerToolOnServer(server, handleUnlockProgram_2.TOOL_DEFINITION.name, handleUnlockProgram_2.TOOL_DEFINITION.description, handleUnlockProgram_2.TOOL_DEFINITION.inputSchema, handleUnlockProgram_1.handleUnlockProgram);
1833
+ this.registerToolOnServer(server, handleValidateProgram_2.TOOL_DEFINITION.name, handleValidateProgram_2.TOOL_DEFINITION.description, handleValidateProgram_2.TOOL_DEFINITION.inputSchema, handleValidateProgram_1.handleValidateProgram);
1834
+ this.registerToolOnServer(server, handleCreateProgram_4.TOOL_DEFINITION.name, handleCreateProgram_4.TOOL_DEFINITION.description, handleCreateProgram_4.TOOL_DEFINITION.inputSchema, handleCreateProgram_2.handleCreateProgram);
1835
+ this.registerToolOnServer(server, handleCheckInterface_2.TOOL_DEFINITION.name, handleCheckInterface_2.TOOL_DEFINITION.description, handleCheckInterface_2.TOOL_DEFINITION.inputSchema, handleCheckInterface_1.handleCheckInterface);
1836
+ this.registerToolOnServer(server, handleDeleteInterface_2.TOOL_DEFINITION.name, handleDeleteInterface_2.TOOL_DEFINITION.description, handleDeleteInterface_2.TOOL_DEFINITION.inputSchema, handleDeleteInterface_1.handleDeleteInterface);
1837
+ this.registerToolOnServer(server, handleLockInterface_2.TOOL_DEFINITION.name, handleLockInterface_2.TOOL_DEFINITION.description, handleLockInterface_2.TOOL_DEFINITION.inputSchema, handleLockInterface_1.handleLockInterface);
1838
+ this.registerToolOnServer(server, handleUnlockInterface_2.TOOL_DEFINITION.name, handleUnlockInterface_2.TOOL_DEFINITION.description, handleUnlockInterface_2.TOOL_DEFINITION.inputSchema, handleUnlockInterface_1.handleUnlockInterface);
1839
+ this.registerToolOnServer(server, handleValidateInterface_2.TOOL_DEFINITION.name, handleValidateInterface_2.TOOL_DEFINITION.description, handleValidateInterface_2.TOOL_DEFINITION.inputSchema, handleValidateInterface_1.handleValidateInterface);
1840
+ this.registerToolOnServer(server, handleCreateInterface_4.TOOL_DEFINITION.name, handleCreateInterface_4.TOOL_DEFINITION.description, handleCreateInterface_4.TOOL_DEFINITION.inputSchema, handleCreateInterface_2.handleCreateInterface);
1841
+ this.registerToolOnServer(server, handleCheckFunctionGroup_2.TOOL_DEFINITION.name, handleCheckFunctionGroup_2.TOOL_DEFINITION.description, handleCheckFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleCheckFunctionGroup_1.handleCheckFunctionGroup);
1842
+ this.registerToolOnServer(server, handleDeleteFunctionGroup_2.TOOL_DEFINITION.name, handleDeleteFunctionGroup_2.TOOL_DEFINITION.description, handleDeleteFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleDeleteFunctionGroup_1.handleDeleteFunctionGroup);
1843
+ this.registerToolOnServer(server, handleDeleteFunctionModule_2.TOOL_DEFINITION.name, handleDeleteFunctionModule_2.TOOL_DEFINITION.description, handleDeleteFunctionModule_2.TOOL_DEFINITION.inputSchema, handleDeleteFunctionModule_1.handleDeleteFunctionModule);
1844
+ this.registerToolOnServer(server, handleLockFunctionGroup_2.TOOL_DEFINITION.name, handleLockFunctionGroup_2.TOOL_DEFINITION.description, handleLockFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleLockFunctionGroup_1.handleLockFunctionGroup);
1845
+ this.registerToolOnServer(server, handleLockFunctionModule_2.TOOL_DEFINITION.name, handleLockFunctionModule_2.TOOL_DEFINITION.description, handleLockFunctionModule_2.TOOL_DEFINITION.inputSchema, handleLockFunctionModule_1.handleLockFunctionModule);
1846
+ this.registerToolOnServer(server, handleUnlockFunctionGroup_2.TOOL_DEFINITION.name, handleUnlockFunctionGroup_2.TOOL_DEFINITION.description, handleUnlockFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleUnlockFunctionGroup_1.handleUnlockFunctionGroup);
1847
+ this.registerToolOnServer(server, handleUnlockFunctionModule_2.TOOL_DEFINITION.name, handleUnlockFunctionModule_2.TOOL_DEFINITION.description, handleUnlockFunctionModule_2.TOOL_DEFINITION.inputSchema, handleUnlockFunctionModule_1.handleUnlockFunctionModule);
1848
+ this.registerToolOnServer(server, handleValidateFunctionGroup_2.TOOL_DEFINITION.name, handleValidateFunctionGroup_2.TOOL_DEFINITION.description, handleValidateFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleValidateFunctionGroup_1.handleValidateFunctionGroup);
1849
+ this.registerToolOnServer(server, handleCreateFunctionGroup_4.TOOL_DEFINITION.name, handleCreateFunctionGroup_4.TOOL_DEFINITION.description, handleCreateFunctionGroup_4.TOOL_DEFINITION.inputSchema, handleCreateFunctionGroup_2.handleCreateFunctionGroup);
1850
+ this.registerToolOnServer(server, handleCreateFunctionModule_4.TOOL_DEFINITION.name, handleCreateFunctionModule_4.TOOL_DEFINITION.description, handleCreateFunctionModule_4.TOOL_DEFINITION.inputSchema, handleCreateFunctionModule_2.handleCreateFunctionModule);
1851
+ this.registerToolOnServer(server, handleCheckDataElement_2.TOOL_DEFINITION.name, handleCheckDataElement_2.TOOL_DEFINITION.description, handleCheckDataElement_2.TOOL_DEFINITION.inputSchema, handleCheckDataElement_1.handleCheckDataElement);
1852
+ this.registerToolOnServer(server, handleDeleteDataElement_2.TOOL_DEFINITION.name, handleDeleteDataElement_2.TOOL_DEFINITION.description, handleDeleteDataElement_2.TOOL_DEFINITION.inputSchema, handleDeleteDataElement_1.handleDeleteDataElement);
1853
+ this.registerToolOnServer(server, handleLockDataElement_2.TOOL_DEFINITION.name, handleLockDataElement_2.TOOL_DEFINITION.description, handleLockDataElement_2.TOOL_DEFINITION.inputSchema, handleLockDataElement_1.handleLockDataElement);
1854
+ this.registerToolOnServer(server, handleUnlockDataElement_2.TOOL_DEFINITION.name, handleUnlockDataElement_2.TOOL_DEFINITION.description, handleUnlockDataElement_2.TOOL_DEFINITION.inputSchema, handleUnlockDataElement_1.handleUnlockDataElement);
1855
+ this.registerToolOnServer(server, handleValidateDataElement_2.TOOL_DEFINITION.name, handleValidateDataElement_2.TOOL_DEFINITION.description, handleValidateDataElement_2.TOOL_DEFINITION.inputSchema, handleValidateDataElement_1.handleValidateDataElement);
1856
+ this.registerToolOnServer(server, handleCreateDataElement_4.TOOL_DEFINITION.name, handleCreateDataElement_4.TOOL_DEFINITION.description, handleCreateDataElement_4.TOOL_DEFINITION.inputSchema, handleCreateDataElement_2.handleCreateDataElement);
1857
+ this.registerToolOnServer(server, handleCheckDomain_2.TOOL_DEFINITION.name, handleCheckDomain_2.TOOL_DEFINITION.description, handleCheckDomain_2.TOOL_DEFINITION.inputSchema, handleCheckDomain_1.handleCheckDomain);
1858
+ this.registerToolOnServer(server, handleDeleteDomain_2.TOOL_DEFINITION.name, handleDeleteDomain_2.TOOL_DEFINITION.description, handleDeleteDomain_2.TOOL_DEFINITION.inputSchema, handleDeleteDomain_1.handleDeleteDomain);
1859
+ this.registerToolOnServer(server, handleLockDomain_2.TOOL_DEFINITION.name, handleLockDomain_2.TOOL_DEFINITION.description, handleLockDomain_2.TOOL_DEFINITION.inputSchema, handleLockDomain_1.handleLockDomain);
1860
+ this.registerToolOnServer(server, handleUnlockDomain_2.TOOL_DEFINITION.name, handleUnlockDomain_2.TOOL_DEFINITION.description, handleUnlockDomain_2.TOOL_DEFINITION.inputSchema, handleUnlockDomain_1.handleUnlockDomain);
1861
+ this.registerToolOnServer(server, handleValidateDomain_2.TOOL_DEFINITION.name, handleValidateDomain_2.TOOL_DEFINITION.description, handleValidateDomain_2.TOOL_DEFINITION.inputSchema, handleValidateDomain_1.handleValidateDomain);
1862
+ this.registerToolOnServer(server, handleCreateDomain_4.TOOL_DEFINITION.name, handleCreateDomain_4.TOOL_DEFINITION.description, handleCreateDomain_4.TOOL_DEFINITION.inputSchema, handleCreateDomain_2.handleCreateDomain);
1863
+ this.registerToolOnServer(server, handleCheckStructure_2.TOOL_DEFINITION.name, handleCheckStructure_2.TOOL_DEFINITION.description, handleCheckStructure_2.TOOL_DEFINITION.inputSchema, handleCheckStructure_1.handleCheckStructure);
1864
+ this.registerToolOnServer(server, handleDeleteStructure_2.TOOL_DEFINITION.name, handleDeleteStructure_2.TOOL_DEFINITION.description, handleDeleteStructure_2.TOOL_DEFINITION.inputSchema, handleDeleteStructure_1.handleDeleteStructure);
1865
+ this.registerToolOnServer(server, handleLockStructure_2.TOOL_DEFINITION.name, handleLockStructure_2.TOOL_DEFINITION.description, handleLockStructure_2.TOOL_DEFINITION.inputSchema, handleLockStructure_1.handleLockStructure);
1866
+ this.registerToolOnServer(server, handleUnlockStructure_2.TOOL_DEFINITION.name, handleUnlockStructure_2.TOOL_DEFINITION.description, handleUnlockStructure_2.TOOL_DEFINITION.inputSchema, handleUnlockStructure_1.handleUnlockStructure);
1867
+ this.registerToolOnServer(server, handleValidateStructure_2.TOOL_DEFINITION.name, handleValidateStructure_2.TOOL_DEFINITION.description, handleValidateStructure_2.TOOL_DEFINITION.inputSchema, handleValidateStructure_1.handleValidateStructure);
1868
+ this.registerToolOnServer(server, handleCreateStructure_4.TOOL_DEFINITION.name, handleCreateStructure_4.TOOL_DEFINITION.description, handleCreateStructure_4.TOOL_DEFINITION.inputSchema, handleCreateStructure_2.handleCreateStructure);
1869
+ this.registerToolOnServer(server, handleDeleteTable_2.TOOL_DEFINITION.name, handleDeleteTable_2.TOOL_DEFINITION.description, handleDeleteTable_2.TOOL_DEFINITION.inputSchema, handleDeleteTable_1.handleDeleteTable);
1870
+ this.registerToolOnServer(server, handleLockTable_2.TOOL_DEFINITION.name, handleLockTable_2.TOOL_DEFINITION.description, handleLockTable_2.TOOL_DEFINITION.inputSchema, handleLockTable_1.handleLockTable);
1871
+ this.registerToolOnServer(server, handleUnlockTable_2.TOOL_DEFINITION.name, handleUnlockTable_2.TOOL_DEFINITION.description, handleUnlockTable_2.TOOL_DEFINITION.inputSchema, handleUnlockTable_1.handleUnlockTable);
1872
+ this.registerToolOnServer(server, handleCreateTable_4.TOOL_DEFINITION.name, handleCreateTable_4.TOOL_DEFINITION.description, handleCreateTable_4.TOOL_DEFINITION.inputSchema, handleCreateTable_2.handleCreateTable);
1873
+ this.registerToolOnServer(server, handleCheckView_2.TOOL_DEFINITION.name, handleCheckView_2.TOOL_DEFINITION.description, handleCheckView_2.TOOL_DEFINITION.inputSchema, handleCheckView_1.handleCheckView);
1874
+ this.registerToolOnServer(server, handleDeleteView_2.TOOL_DEFINITION.name, handleDeleteView_2.TOOL_DEFINITION.description, handleDeleteView_2.TOOL_DEFINITION.inputSchema, handleDeleteView_1.handleDeleteView);
1875
+ this.registerToolOnServer(server, handleLockView_2.TOOL_DEFINITION.name, handleLockView_2.TOOL_DEFINITION.description, handleLockView_2.TOOL_DEFINITION.inputSchema, handleLockView_1.handleLockView);
1876
+ this.registerToolOnServer(server, handleUnlockView_2.TOOL_DEFINITION.name, handleUnlockView_2.TOOL_DEFINITION.description, handleUnlockView_2.TOOL_DEFINITION.inputSchema, handleUnlockView_1.handleUnlockView);
1877
+ this.registerToolOnServer(server, handleValidateView_2.TOOL_DEFINITION.name, handleValidateView_2.TOOL_DEFINITION.description, handleValidateView_2.TOOL_DEFINITION.inputSchema, handleValidateView_1.handleValidateView);
1878
+ this.registerToolOnServer(server, handleCreateView_4.TOOL_DEFINITION.name, handleCreateView_4.TOOL_DEFINITION.description, handleCreateView_4.TOOL_DEFINITION.inputSchema, handleCreateView_2.handleCreateView);
1879
+ this.registerToolOnServer(server, handleCheckPackage_2.TOOL_DEFINITION.name, handleCheckPackage_2.TOOL_DEFINITION.description, handleCheckPackage_2.TOOL_DEFINITION.inputSchema, handleCheckPackage_1.handleCheckPackage);
1880
+ this.registerToolOnServer(server, handleDeletePackage_2.TOOL_DEFINITION.name, handleDeletePackage_2.TOOL_DEFINITION.description, handleDeletePackage_2.TOOL_DEFINITION.inputSchema, handleDeletePackage_1.handleDeletePackage);
1881
+ this.registerToolOnServer(server, handleLockPackage_2.TOOL_DEFINITION.name, handleLockPackage_2.TOOL_DEFINITION.description, handleLockPackage_2.TOOL_DEFINITION.inputSchema, handleLockPackage_1.handleLockPackage);
1882
+ this.registerToolOnServer(server, handleValidatePackage_2.TOOL_DEFINITION.name, handleValidatePackage_2.TOOL_DEFINITION.description, handleValidatePackage_2.TOOL_DEFINITION.inputSchema, handleValidatePackage_1.handleValidatePackage);
1883
+ this.registerToolOnServer(server, handleCreatePackage_4.TOOL_DEFINITION.name, handleCreatePackage_4.TOOL_DEFINITION.description, handleCreatePackage_4.TOOL_DEFINITION.inputSchema, handleCreatePackage_2.handleCreatePackage);
1884
+ this.registerToolOnServer(server, handleCreateTransport_4.TOOL_DEFINITION.name, handleCreateTransport_4.TOOL_DEFINITION.description, handleCreateTransport_4.TOOL_DEFINITION.inputSchema, handleCreateTransport_2.handleCreateTransport);
1885
+ this.registerToolOnServer(server, handleCheckBehaviorDefinition_2.TOOL_DEFINITION.name, handleCheckBehaviorDefinition_2.TOOL_DEFINITION.description, handleCheckBehaviorDefinition_2.TOOL_DEFINITION.inputSchema, handleCheckBehaviorDefinition_1.handleCheckBehaviorDefinition);
1886
+ this.registerToolOnServer(server, handleDeleteBehaviorDefinition_2.TOOL_DEFINITION.name, handleDeleteBehaviorDefinition_2.TOOL_DEFINITION.description, handleDeleteBehaviorDefinition_2.TOOL_DEFINITION.inputSchema, handleDeleteBehaviorDefinition_1.handleDeleteBehaviorDefinition);
1887
+ this.registerToolOnServer(server, handleLockBehaviorDefinition_2.TOOL_DEFINITION.name, handleLockBehaviorDefinition_2.TOOL_DEFINITION.description, handleLockBehaviorDefinition_2.TOOL_DEFINITION.inputSchema, handleLockBehaviorDefinition_1.handleLockBehaviorDefinition);
1888
+ this.registerToolOnServer(server, handleUnlockBehaviorDefinition_2.TOOL_DEFINITION.name, handleUnlockBehaviorDefinition_2.TOOL_DEFINITION.description, handleUnlockBehaviorDefinition_2.TOOL_DEFINITION.inputSchema, handleUnlockBehaviorDefinition_1.handleUnlockBehaviorDefinition);
1889
+ this.registerToolOnServer(server, handleValidateBehaviorDefinition_2.TOOL_DEFINITION.name, handleValidateBehaviorDefinition_2.TOOL_DEFINITION.description, handleValidateBehaviorDefinition_2.TOOL_DEFINITION.inputSchema, handleValidateBehaviorDefinition_1.handleValidateBehaviorDefinition);
1890
+ this.registerToolOnServer(server, handleCreateBehaviorDefinition_4.TOOL_DEFINITION.name, handleCreateBehaviorDefinition_4.TOOL_DEFINITION.description, handleCreateBehaviorDefinition_4.TOOL_DEFINITION.inputSchema, handleCreateBehaviorDefinition_2.handleCreateBehaviorDefinition);
1891
+ this.registerToolOnServer(server, handleCheckMetadataExtension_2.TOOL_DEFINITION.name, handleCheckMetadataExtension_2.TOOL_DEFINITION.description, handleCheckMetadataExtension_2.TOOL_DEFINITION.inputSchema, handleCheckMetadataExtension_1.handleCheckMetadataExtension);
1892
+ this.registerToolOnServer(server, handleDeleteMetadataExtension_2.TOOL_DEFINITION.name, handleDeleteMetadataExtension_2.TOOL_DEFINITION.description, handleDeleteMetadataExtension_2.TOOL_DEFINITION.inputSchema, handleDeleteMetadataExtension_1.handleDeleteMetadataExtension);
1893
+ this.registerToolOnServer(server, handleLockMetadataExtension_2.TOOL_DEFINITION.name, handleLockMetadataExtension_2.TOOL_DEFINITION.description, handleLockMetadataExtension_2.TOOL_DEFINITION.inputSchema, handleLockMetadataExtension_1.handleLockMetadataExtension);
1894
+ this.registerToolOnServer(server, handleUnlockMetadataExtension_2.TOOL_DEFINITION.name, handleUnlockMetadataExtension_2.TOOL_DEFINITION.description, handleUnlockMetadataExtension_2.TOOL_DEFINITION.inputSchema, handleUnlockMetadataExtension_1.handleUnlockMetadataExtension);
1895
+ this.registerToolOnServer(server, handleValidateMetadataExtension_2.TOOL_DEFINITION.name, handleValidateMetadataExtension_2.TOOL_DEFINITION.description, handleValidateMetadataExtension_2.TOOL_DEFINITION.inputSchema, handleValidateMetadataExtension_1.handleValidateMetadataExtension);
1896
+ this.registerToolOnServer(server, handleCreateMetadataExtension_4.TOOL_DEFINITION.name, handleCreateMetadataExtension_4.TOOL_DEFINITION.description, handleCreateMetadataExtension_4.TOOL_DEFINITION.inputSchema, handleCreateMetadataExtension_2.handleCreateMetadataExtension);
1897
+ this.registerToolOnServer(server, handleActivateProgram_2.TOOL_DEFINITION.name, handleActivateProgram_2.TOOL_DEFINITION.description, handleActivateProgram_2.TOOL_DEFINITION.inputSchema, handleActivateProgram_1.handleActivateProgram);
1898
+ this.registerToolOnServer(server, handleActivateClass_2.TOOL_DEFINITION.name, handleActivateClass_2.TOOL_DEFINITION.description, handleActivateClass_2.TOOL_DEFINITION.inputSchema, handleActivateClass_1.handleActivateClass);
1899
+ this.registerToolOnServer(server, handleActivateInterface_2.TOOL_DEFINITION.name, handleActivateInterface_2.TOOL_DEFINITION.description, handleActivateInterface_2.TOOL_DEFINITION.inputSchema, handleActivateInterface_1.handleActivateInterface);
1900
+ this.registerToolOnServer(server, handleActivateFunctionModule_2.TOOL_DEFINITION.name, handleActivateFunctionModule_2.TOOL_DEFINITION.description, handleActivateFunctionModule_2.TOOL_DEFINITION.inputSchema, handleActivateFunctionModule_1.handleActivateFunctionModule);
1901
+ this.registerToolOnServer(server, handleActivateFunctionGroup_2.TOOL_DEFINITION.name, handleActivateFunctionGroup_2.TOOL_DEFINITION.description, handleActivateFunctionGroup_2.TOOL_DEFINITION.inputSchema, handleActivateFunctionGroup_1.handleActivateFunctionGroup);
1902
+ this.registerToolOnServer(server, handleActivateDataElement_2.TOOL_DEFINITION.name, handleActivateDataElement_2.TOOL_DEFINITION.description, handleActivateDataElement_2.TOOL_DEFINITION.inputSchema, handleActivateDataElement_1.handleActivateDataElement);
1903
+ this.registerToolOnServer(server, handleActivateDomain_2.TOOL_DEFINITION.name, handleActivateDomain_2.TOOL_DEFINITION.description, handleActivateDomain_2.TOOL_DEFINITION.inputSchema, handleActivateDomain_1.handleActivateDomain);
1904
+ this.registerToolOnServer(server, handleActivateStructure_2.TOOL_DEFINITION.name, handleActivateStructure_2.TOOL_DEFINITION.description, handleActivateStructure_2.TOOL_DEFINITION.inputSchema, handleActivateStructure_1.handleActivateStructure);
1905
+ this.registerToolOnServer(server, handleActivateTable_2.TOOL_DEFINITION.name, handleActivateTable_2.TOOL_DEFINITION.description, handleActivateTable_2.TOOL_DEFINITION.inputSchema, handleActivateTable_1.handleActivateTable);
1906
+ this.registerToolOnServer(server, handleActivateView_2.TOOL_DEFINITION.name, handleActivateView_2.TOOL_DEFINITION.description, handleActivateView_2.TOOL_DEFINITION.inputSchema, handleActivateView_1.handleActivateView);
1907
+ this.registerToolOnServer(server, handleActivateBehaviorDefinition_2.TOOL_DEFINITION.name, handleActivateBehaviorDefinition_2.TOOL_DEFINITION.description, handleActivateBehaviorDefinition_2.TOOL_DEFINITION.inputSchema, handleActivateBehaviorDefinition_1.handleActivateBehaviorDefinition);
1908
+ this.registerToolOnServer(server, handleActivateMetadataExtension_2.TOOL_DEFINITION.name, handleActivateMetadataExtension_2.TOOL_DEFINITION.description, handleActivateMetadataExtension_2.TOOL_DEFINITION.inputSchema, handleActivateMetadataExtension_1.handleActivateMetadataExtension);
1909
+ // Dynamic import tools
1910
+ this.registerToolOnServer(server, "GetAdtTypes", "Get all ADT types available in the system", { type: "object", properties: {}, required: [] }, async (args) => {
1911
+ return await (await import("./handlers/system/readonly/handleGetAllTypes.js")).handleGetAdtTypes(args);
1912
+ });
1913
+ this.registerToolOnServer(server, "GetObjectStructure", "Get object structure with includes hierarchy", { type: "object", properties: { object_name: { type: "string" }, object_type: { type: "string" } }, required: ["object_name", "object_type"] }, async (args) => {
1914
+ return await (await import("./handlers/system/readonly/handleGetObjectStructure.js")).handleGetObjectStructure(args);
1915
+ });
1916
+ this.registerToolOnServer(server, "GetObjectsList", "Get list of objects by package", { type: "object", properties: { package_name: { type: "string" } }, required: ["package_name"] }, async (args) => {
1917
+ return await (await import("./handlers/search/readonly/handleGetObjectsList.js")).handleGetObjectsList(args);
1918
+ });
1919
+ this.registerToolOnServer(server, "GetObjectsByType", "Get objects by type", { type: "object", properties: { object_type: { type: "string" }, package_name: { type: "string" } }, required: ["object_type"] }, async (args) => {
1920
+ return await (await import("./handlers/search/readonly/handleGetObjectsByType.js")).handleGetObjectsByType(args);
1921
+ });
1922
+ this.registerToolOnServer(server, "GetProgFullCode", "Get full program code with includes", { type: "object", properties: { program_name: { type: "string" } }, required: ["program_name"] }, async (args) => {
1923
+ return await (await import("./handlers/program/readonly/handleGetProgFullCode.js")).handleGetProgFullCode(args);
1924
+ });
1925
+ this.registerToolOnServer(server, "GetObjectNodeFromCache", "Get object node from cache", { type: "object", properties: { object_name: { type: "string" }, object_type: { type: "string" } }, required: ["object_name", "object_type"] }, async (args) => {
1926
+ return await (await import("./handlers/system/readonly/handleGetObjectNodeFromCache.js")).handleGetObjectNodeFromCache(args);
1927
+ });
1928
+ this.registerToolOnServer(server, "DescribeByList", "Describe objects by list", { type: "object", properties: { objects: { type: "array", items: { type: "string" } } }, required: ["objects"] }, async (args) => {
1929
+ return await (await import("./handlers/system/readonly/handleDescribeByList.js")).handleDescribeByList(args);
1930
+ });
1931
+ }
1932
+ /**
1933
+ * Sets up handlers for new McpServer using registerTool (recommended API)
1934
+ * @private
1935
+ */
1936
+ setupMcpServerHandlers() {
1937
+ // Register all tools using TOOL_DEFINITION from handlers
1938
+ // McpServer automatically handles listTools requests for registered tools
1939
+ this.registerAllToolsOnServer(this.mcpServer);
1940
+ }
1941
+ setupSignalHandlers() {
1942
+ const signals = ["SIGINT", "SIGTERM"];
1943
+ for (const signal of signals) {
1944
+ process.on(signal, () => {
1945
+ if (this.shuttingDown) {
1946
+ return;
1947
+ }
1948
+ this.shuttingDown = true;
1949
+ logger_1.logger.info("Received shutdown signal", {
1950
+ type: "SERVER_SHUTDOWN_SIGNAL",
1951
+ signal,
1952
+ transport: this.transportConfig.type,
1953
+ });
1954
+ void this.shutdown().finally(() => {
1955
+ if (this.allowProcessExit) {
1956
+ process.exit(0);
1957
+ }
1958
+ });
1959
+ });
1960
+ }
1961
+ }
1962
+ async shutdown() {
1963
+ try {
1964
+ await this.mcpServer.close();
1965
+ }
1966
+ catch (error) {
1967
+ logger_1.logger.error("Failed to close MCP server", {
1968
+ type: "SERVER_SHUTDOWN_ERROR",
1969
+ error: error instanceof Error ? error.message : String(error),
1970
+ });
1971
+ }
1972
+ // Close all SSE sessions
1973
+ for (const [sessionId, session] of this.sseSessions.entries()) {
1974
+ try {
1975
+ await session.transport.close();
1976
+ session.server.server.close();
1977
+ logger_1.logger.debug("SSE session closed during shutdown", {
1978
+ type: "SSE_SESSION_SHUTDOWN",
1979
+ sessionId,
1980
+ });
1981
+ }
1982
+ catch (error) {
1983
+ logger_1.logger.error("Failed to close SSE session", {
1984
+ type: "SSE_SHUTDOWN_ERROR",
1985
+ error: error instanceof Error ? error.message : String(error),
1986
+ sessionId,
1987
+ });
1988
+ }
1989
+ }
1990
+ this.sseSessions.clear();
1991
+ if (this.httpServer) {
1992
+ await new Promise((resolve) => {
1993
+ this.httpServer?.close((closeError) => {
1994
+ if (closeError) {
1995
+ logger_1.logger.error("Failed to close HTTP server", {
1996
+ type: "HTTP_SERVER_SHUTDOWN_ERROR",
1997
+ error: closeError instanceof Error ? closeError.message : String(closeError),
1998
+ });
1999
+ }
2000
+ resolve();
2001
+ });
2002
+ });
2003
+ this.httpServer = undefined;
2004
+ }
2005
+ }
2006
+ /**
2007
+ * Starts the MCP server and connects it to the transport.
2008
+ */
2009
+ async run() {
2010
+ if (this.transportConfig.type === "stdio") {
2011
+ // Simple stdio setup like reference implementation
2012
+ const transport = new stdio_js_1.StdioServerTransport();
2013
+ await this.mcpServer.server.connect(transport);
2014
+ // Process stays alive waiting for messages from stdin
2015
+ return;
2016
+ }
2017
+ if (this.transportConfig.type === "streamable-http") {
2018
+ const httpConfig = this.transportConfig;
2019
+ // HTTP Server wrapper for StreamableHTTP transport (like the SDK example)
2020
+ const httpServer = (0, http_1.createServer)(async (req, res) => {
2021
+ // Only handle POST requests (like the example)
2022
+ if (req.method !== "POST") {
2023
+ res.writeHead(405, { "Content-Type": "text/plain" });
2024
+ res.end("Method not allowed");
2025
+ return;
2026
+ }
2027
+ // HTTP: Restrict non-local connections if .env file exists and no SAP headers provided
2028
+ const remoteAddress = req.socket.remoteAddress;
2029
+ if (this.hasEnvFile && !this.hasSapHeaders(req.headers)) {
2030
+ if (!this.isLocalConnection(remoteAddress)) {
2031
+ logger_1.logger.warn("HTTP: Non-local connection rejected (has .env but no SAP headers)", {
2032
+ type: "HTTP_NON_LOCAL_REJECTED",
2033
+ remoteAddress,
2034
+ hasEnvFile: this.hasEnvFile,
2035
+ });
2036
+ res.writeHead(403, { "Content-Type": "text/plain" });
2037
+ res.end("Forbidden: Non-local connections require SAP connection headers (x-sap-url, x-sap-auth-type)");
2038
+ return;
2039
+ }
2040
+ }
2041
+ // Track client (like the example)
2042
+ const clientID = `${req.socket.remoteAddress}:${req.socket.remotePort}`;
2043
+ logger_1.logger.debug("Client connected", {
2044
+ type: "STREAMABLE_HTTP_CLIENT_CONNECTED",
2045
+ clientID,
2046
+ });
2047
+ // Extract session ID from headers (like the example)
2048
+ const clientSessionId = (req.headers["x-session-id"] || req.headers["mcp-session-id"]);
2049
+ let session = this.streamableHttpSessions.get(clientID);
2050
+ // If client sent session ID, try to find existing session
2051
+ if (clientSessionId && !session) {
2052
+ // Search for existing session by sessionId (client might have new IP:PORT)
2053
+ for (const [key, sess] of this.streamableHttpSessions.entries()) {
2054
+ if (sess.sessionId === clientSessionId) {
2055
+ session = sess;
2056
+ // Update clientID (port might have changed)
2057
+ this.streamableHttpSessions.delete(key);
2058
+ this.streamableHttpSessions.set(clientID, session);
2059
+ logger_1.logger.debug("Existing session restored", {
2060
+ type: "STREAMABLE_HTTP_SESSION_RESTORED",
2061
+ sessionId: session.sessionId,
2062
+ clientID,
2063
+ });
2064
+ break;
2065
+ }
2066
+ }
2067
+ }
2068
+ // If no session found, create new one
2069
+ if (!session) {
2070
+ session = {
2071
+ sessionId: (0, crypto_1.randomUUID)(),
2072
+ clientIP: req.socket.remoteAddress || "unknown",
2073
+ connectedAt: new Date(),
2074
+ requestCount: 0,
2075
+ };
2076
+ this.streamableHttpSessions.set(clientID, session);
2077
+ logger_1.logger.debug("New session created", {
2078
+ type: "STREAMABLE_HTTP_SESSION_CREATED",
2079
+ sessionId: session.sessionId,
2080
+ clientID,
2081
+ totalSessions: this.streamableHttpSessions.size,
2082
+ });
2083
+ }
2084
+ session.requestCount++;
2085
+ logger_1.logger.debug("Request received", {
2086
+ type: "STREAMABLE_HTTP_REQUEST",
2087
+ sessionId: session.sessionId,
2088
+ requestNumber: session.requestCount,
2089
+ clientID,
2090
+ });
2091
+ // Handle client disconnect (like the example)
2092
+ req.on("close", () => {
2093
+ const closedSession = this.streamableHttpSessions.get(clientID);
2094
+ if (closedSession) {
2095
+ // Clean up connection cache for this session
2096
+ if (closedSession.sapConfig) {
2097
+ (0, utils_1.removeConnectionForSession)(closedSession.sessionId, closedSession.sapConfig);
2098
+ }
2099
+ this.streamableHttpSessions.delete(clientID);
2100
+ logger_1.logger.debug("Session closed", {
2101
+ type: "STREAMABLE_HTTP_SESSION_CLOSED",
2102
+ sessionId: closedSession.sessionId,
2103
+ requestCount: closedSession.requestCount,
2104
+ totalSessions: this.streamableHttpSessions.size,
2105
+ });
2106
+ }
2107
+ });
2108
+ try {
2109
+ // Apply auth headers before processing and store config in session
2110
+ this.applyAuthHeaders(req.headers, session.sessionId);
2111
+ // Get SAP config for this session (from headers or existing session)
2112
+ const sessionSapConfig = session.sapConfig || this.sapConfig;
2113
+ // Read request body (like the SDK example with Express)
2114
+ let body = null;
2115
+ const chunks = [];
2116
+ for await (const chunk of req) {
2117
+ chunks.push(chunk);
2118
+ }
2119
+ if (chunks.length > 0) {
2120
+ const bodyString = Buffer.concat(chunks).toString('utf-8');
2121
+ try {
2122
+ body = JSON.parse(bodyString);
2123
+ }
2124
+ catch (parseError) {
2125
+ // If body is not JSON, pass as string or null
2126
+ body = bodyString || null;
2127
+ }
2128
+ }
2129
+ // KEY MOMENT: Create new StreamableHTTP transport for each request (like the SDK example)
2130
+ // SDK automatically handles:
2131
+ // - Chunked transfer encoding
2132
+ // - Session tracking
2133
+ // - JSON-RPC protocol
2134
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
2135
+ sessionIdGenerator: undefined, // Stateless mode (like the SDK example)
2136
+ enableJsonResponse: httpConfig.enableJsonResponse,
2137
+ allowedOrigins: httpConfig.allowedOrigins,
2138
+ allowedHosts: httpConfig.allowedHosts,
2139
+ enableDnsRebindingProtection: httpConfig.enableDnsRebindingProtection,
2140
+ });
2141
+ // Close transport when response closes (like the SDK example)
2142
+ res.on("close", () => {
2143
+ transport.close();
2144
+ });
2145
+ // Connect transport to new McpServer (like the SDK example)
2146
+ await this.mcpServer.connect(transport);
2147
+ logger_1.logger.debug("Transport connected", {
2148
+ type: "STREAMABLE_HTTP_TRANSPORT_CONNECTED",
2149
+ sessionId: session.sessionId,
2150
+ clientID,
2151
+ });
2152
+ // Run handlers in AsyncLocalStorage context with session info
2153
+ // This allows getManagedConnection() to access sessionId and config
2154
+ await utils_1.sessionContext.run({
2155
+ sessionId: session.sessionId,
2156
+ sapConfig: sessionSapConfig,
2157
+ }, async () => {
2158
+ // Handle HTTP request through transport (like the SDK example)
2159
+ // Pass body as third parameter if available (like the SDK example)
2160
+ await transport.handleRequest(req, res, body);
2161
+ });
2162
+ logger_1.logger.debug("Request completed", {
2163
+ type: "STREAMABLE_HTTP_REQUEST_COMPLETED",
2164
+ sessionId: session.sessionId,
2165
+ clientID,
2166
+ });
2167
+ }
2168
+ catch (error) {
2169
+ logger_1.logger.error("Failed to handle HTTP request", {
2170
+ type: "HTTP_REQUEST_ERROR",
2171
+ error: error instanceof Error ? error.message : String(error),
2172
+ sessionId: session.sessionId,
2173
+ clientID,
2174
+ });
2175
+ if (!res.headersSent) {
2176
+ res.writeHead(500).end("Internal Server Error");
2177
+ }
2178
+ else {
2179
+ res.end();
2180
+ }
2181
+ }
2182
+ });
2183
+ httpServer.on("clientError", (err, socket) => {
2184
+ logger_1.logger.error("HTTP client error", {
2185
+ type: "HTTP_CLIENT_ERROR",
2186
+ error: err instanceof Error ? err.message : String(err),
2187
+ });
2188
+ socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
2189
+ });
2190
+ await new Promise((resolve, reject) => {
2191
+ const onError = (error) => {
2192
+ logger_1.logger.error("HTTP server failed to start", {
2193
+ type: "HTTP_SERVER_ERROR",
2194
+ error: error.message,
2195
+ });
2196
+ httpServer.off("error", onError);
2197
+ reject(error);
2198
+ };
2199
+ httpServer.once("error", onError);
2200
+ httpServer.listen(httpConfig.port, httpConfig.host, () => {
2201
+ httpServer.off("error", onError);
2202
+ logger_1.logger.info("HTTP server listening", {
2203
+ type: "HTTP_SERVER_LISTENING",
2204
+ host: httpConfig.host,
2205
+ port: httpConfig.port,
2206
+ enableJsonResponse: httpConfig.enableJsonResponse,
2207
+ });
2208
+ resolve();
2209
+ });
2210
+ });
2211
+ this.httpServer = httpServer;
2212
+ return;
2213
+ }
2214
+ const sseConfig = this.transportConfig;
2215
+ const streamPathMap = new Map([
2216
+ ["/", "/messages"],
2217
+ ["/mcp/events", "/mcp/messages"],
2218
+ ["/sse", "/messages"],
2219
+ ]);
2220
+ const streamPaths = Array.from(streamPathMap.keys());
2221
+ const postPathSet = new Set(streamPathMap.values());
2222
+ postPathSet.add("/messages");
2223
+ postPathSet.add("/mcp/messages");
2224
+ const httpServer = (0, http_1.createServer)(async (req, res) => {
2225
+ // SSE: Always restrict to local connections only
2226
+ const remoteAddress = req.socket.remoteAddress;
2227
+ if (!this.isLocalConnection(remoteAddress)) {
2228
+ logger_1.logger.warn("SSE: Non-local connection rejected", {
2229
+ type: "SSE_NON_LOCAL_REJECTED",
2230
+ remoteAddress,
2231
+ });
2232
+ res.writeHead(403, { "Content-Type": "text/plain" });
2233
+ res.end("Forbidden: SSE transport only accepts local connections");
2234
+ return;
2235
+ }
2236
+ const requestUrl = req.url ? new URL(req.url, `http://${req.headers.host ?? `${sseConfig.host}:${sseConfig.port}`}`) : undefined;
2237
+ let pathname = requestUrl?.pathname ?? "/";
2238
+ if (pathname.length > 1 && pathname.endsWith("/")) {
2239
+ pathname = pathname.slice(0, -1);
2240
+ }
2241
+ this.applyAuthHeaders(req.headers);
2242
+ logger_1.logger.debug("SSE request received", {
2243
+ type: "SSE_HTTP_REQUEST",
2244
+ method: req.method,
2245
+ pathname,
2246
+ originalUrl: req.url,
2247
+ headers: {
2248
+ accept: req.headers.accept,
2249
+ "content-type": req.headers["content-type"],
2250
+ },
2251
+ });
2252
+ // GET /sse, /mcp/events, or / - establish SSE connection
2253
+ if (req.method === "GET" && streamPathMap.has(pathname)) {
2254
+ const postEndpoint = streamPathMap.get(pathname) ?? "/messages";
2255
+ logger_1.logger.debug("SSE client connecting", {
2256
+ type: "SSE_CLIENT_CONNECTING",
2257
+ pathname,
2258
+ postEndpoint,
2259
+ });
2260
+ // Create new McpServer instance for this session (like the working example)
2261
+ const server = this.createMcpServerForSession();
2262
+ // Create SSE transport
2263
+ const transport = new sse_js_1.SSEServerTransport(postEndpoint, res, {
2264
+ allowedHosts: sseConfig.allowedHosts,
2265
+ allowedOrigins: sseConfig.allowedOrigins,
2266
+ enableDnsRebindingProtection: sseConfig.enableDnsRebindingProtection,
2267
+ });
2268
+ const sessionId = transport.sessionId;
2269
+ logger_1.logger.info("New SSE session created", {
2270
+ type: "SSE_SESSION_CREATED",
2271
+ sessionId,
2272
+ pathname,
2273
+ });
2274
+ // Store transport and server for this session
2275
+ this.sseSessions.set(sessionId, {
2276
+ server,
2277
+ transport,
2278
+ });
2279
+ // Connect transport to server (using server.server like in the example)
2280
+ try {
2281
+ await server.server.connect(transport);
2282
+ logger_1.logger.info("SSE transport connected", {
2283
+ type: "SSE_CONNECTION_READY",
2284
+ sessionId,
2285
+ pathname,
2286
+ postEndpoint,
2287
+ });
2288
+ }
2289
+ catch (error) {
2290
+ logger_1.logger.error("Failed to connect SSE transport", {
2291
+ type: "SSE_CONNECT_ERROR",
2292
+ error: error instanceof Error ? error.message : String(error),
2293
+ sessionId,
2294
+ });
2295
+ this.sseSessions.delete(sessionId);
2296
+ if (!res.headersSent) {
2297
+ res.writeHead(500).end("Internal Server Error");
2298
+ }
2299
+ else {
2300
+ res.end();
2301
+ }
2302
+ return;
2303
+ }
2304
+ // Cleanup on connection close
2305
+ res.on("close", () => {
2306
+ logger_1.logger.info("SSE connection closed", {
2307
+ type: "SSE_CONNECTION_CLOSED",
2308
+ sessionId,
2309
+ pathname,
2310
+ });
2311
+ this.sseSessions.delete(sessionId);
2312
+ server.server.close();
2313
+ });
2314
+ transport.onerror = (error) => {
2315
+ logger_1.logger.error("SSE transport error", {
2316
+ type: "SSE_TRANSPORT_ERROR",
2317
+ error: error instanceof Error ? error.message : String(error),
2318
+ sessionId,
2319
+ });
2320
+ };
2321
+ return;
2322
+ }
2323
+ // POST /messages or /mcp/messages - handle client messages
2324
+ if (req.method === "POST" && postPathSet.has(pathname)) {
2325
+ // Extract sessionId from query string or header
2326
+ let sessionId;
2327
+ if (requestUrl) {
2328
+ sessionId = requestUrl.searchParams.get("sessionId") || undefined;
2329
+ }
2330
+ if (!sessionId) {
2331
+ sessionId = req.headers["x-session-id"];
2332
+ }
2333
+ logger_1.logger.debug("SSE POST request received", {
2334
+ type: "SSE_POST_REQUEST",
2335
+ sessionId,
2336
+ pathname,
2337
+ });
2338
+ if (!sessionId || !this.sseSessions.has(sessionId)) {
2339
+ logger_1.logger.error("Invalid or missing SSE session", {
2340
+ type: "SSE_INVALID_SESSION",
2341
+ sessionId,
2342
+ });
2343
+ res.writeHead(400, { "Content-Type": "application/json" }).end(JSON.stringify({
2344
+ jsonrpc: "2.0",
2345
+ error: {
2346
+ code: -32000,
2347
+ message: "Invalid or missing sessionId",
2348
+ },
2349
+ id: null,
2350
+ }));
2351
+ return;
2352
+ }
2353
+ const session = this.sseSessions.get(sessionId);
2354
+ const { transport } = session;
2355
+ try {
2356
+ // Read request body
2357
+ let body = null;
2358
+ const chunks = [];
2359
+ for await (const chunk of req) {
2360
+ chunks.push(chunk);
2361
+ }
2362
+ if (chunks.length > 0) {
2363
+ const bodyString = Buffer.concat(chunks).toString('utf-8');
2364
+ try {
2365
+ body = JSON.parse(bodyString);
2366
+ }
2367
+ catch (parseError) {
2368
+ body = bodyString || null;
2369
+ }
2370
+ }
2371
+ // Handle POST message through transport (like the working example)
2372
+ await transport.handlePostMessage(req, res, body);
2373
+ logger_1.logger.debug("SSE POST request processed", {
2374
+ type: "SSE_POST_PROCESSED",
2375
+ sessionId,
2376
+ });
2377
+ }
2378
+ catch (error) {
2379
+ logger_1.logger.error("Failed to handle SSE POST message", {
2380
+ type: "SSE_POST_ERROR",
2381
+ error: error instanceof Error ? error.message : String(error),
2382
+ sessionId,
2383
+ });
2384
+ if (!res.headersSent) {
2385
+ res.writeHead(500).end("Internal Server Error");
2386
+ }
2387
+ else {
2388
+ res.end();
2389
+ }
2390
+ }
2391
+ return;
2392
+ }
2393
+ // OPTIONS - CORS preflight
2394
+ if (req.method === "OPTIONS" && (streamPathMap.has(pathname) || postPathSet.has(pathname))) {
2395
+ res.writeHead(204, {
2396
+ "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
2397
+ "Access-Control-Allow-Headers": "Content-Type",
2398
+ }).end();
2399
+ return;
2400
+ }
2401
+ res.writeHead(404, { "Content-Type": "application/json" }).end(JSON.stringify({ error: "Not Found" }));
2402
+ });
2403
+ httpServer.on("clientError", (err, socket) => {
2404
+ logger_1.logger.error("SSE HTTP client error", {
2405
+ type: "SSE_HTTP_CLIENT_ERROR",
2406
+ error: err instanceof Error ? err.message : String(err),
2407
+ });
2408
+ socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
2409
+ });
2410
+ await new Promise((resolve, reject) => {
2411
+ const onError = (error) => {
2412
+ logger_1.logger.error("SSE HTTP server failed to start", {
2413
+ type: "SSE_HTTP_SERVER_ERROR",
2414
+ error: error.message,
2415
+ });
2416
+ httpServer.off("error", onError);
2417
+ reject(error);
2418
+ };
2419
+ httpServer.once("error", onError);
2420
+ httpServer.listen(sseConfig.port, sseConfig.host, () => {
2421
+ httpServer.off("error", onError);
2422
+ logger_1.logger.info("SSE HTTP server listening", {
2423
+ type: "SSE_HTTP_SERVER_LISTENING",
2424
+ host: sseConfig.host,
2425
+ port: sseConfig.port,
2426
+ streamPaths,
2427
+ postPaths: Array.from(postPathSet.values()),
2428
+ });
2429
+ resolve();
2430
+ });
2431
+ });
2432
+ this.httpServer = httpServer;
2433
+ }
2434
+ }
2435
+ exports.mcp_abap_adt_server = mcp_abap_adt_server;
2436
+ if (process.env.MCP_SKIP_AUTO_START !== "true") {
2437
+ const server = new mcp_abap_adt_server();
2438
+ server.run().catch((error) => {
2439
+ logger_1.logger.error("Fatal error while running MCP server", {
2440
+ type: "SERVER_FATAL_ERROR",
2441
+ error: error instanceof Error ? error.message : String(error),
2442
+ });
2443
+ // Always write to stderr (safe even in stdio mode)
2444
+ process.stderr.write(`[MCP] ✗ Fatal error: ${error instanceof Error ? error.message : String(error)}\n`);
2445
+ // On Windows, add a small delay before exit to allow error message to be visible
2446
+ if (process.platform === 'win32') {
2447
+ setTimeout(() => process.exit(1), 100);
2448
+ }
2449
+ else {
2450
+ process.exit(1);
2451
+ }
2452
+ });
2453
+ }