mcp-adr-analysis-server 2.1.11 → 2.1.20

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 (362) hide show
  1. package/README.md +55 -8
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/src/index.d.ts +69 -2
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +1638 -551
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/prompts/index.d.ts.map +1 -1
  8. package/dist/src/prompts/index.js +23 -6
  9. package/dist/src/prompts/index.js.map +1 -1
  10. package/dist/src/prompts/validated-pattern-prompts.d.ts +33 -0
  11. package/dist/src/prompts/validated-pattern-prompts.d.ts.map +1 -0
  12. package/dist/src/prompts/validated-pattern-prompts.js +337 -0
  13. package/dist/src/prompts/validated-pattern-prompts.js.map +1 -0
  14. package/dist/src/resources/adr-by-id-resource.d.ts +116 -0
  15. package/dist/src/resources/adr-by-id-resource.d.ts.map +1 -0
  16. package/dist/src/resources/adr-by-id-resource.js +213 -0
  17. package/dist/src/resources/adr-by-id-resource.js.map +1 -0
  18. package/dist/src/resources/code-quality-resource.d.ts +105 -0
  19. package/dist/src/resources/code-quality-resource.d.ts.map +1 -0
  20. package/dist/src/resources/code-quality-resource.js +282 -0
  21. package/dist/src/resources/code-quality-resource.js.map +1 -0
  22. package/dist/src/resources/deployment-history-resource.d.ts +214 -0
  23. package/dist/src/resources/deployment-history-resource.d.ts.map +1 -0
  24. package/dist/src/resources/deployment-history-resource.js +308 -0
  25. package/dist/src/resources/deployment-history-resource.js.map +1 -0
  26. package/dist/src/resources/deployment-status-resource.d.ts +256 -0
  27. package/dist/src/resources/deployment-status-resource.d.ts.map +1 -0
  28. package/dist/src/resources/deployment-status-resource.js +665 -0
  29. package/dist/src/resources/deployment-status-resource.js.map +1 -0
  30. package/dist/src/resources/environment-analysis-resource.d.ts +237 -0
  31. package/dist/src/resources/environment-analysis-resource.d.ts.map +1 -0
  32. package/dist/src/resources/environment-analysis-resource.js +646 -0
  33. package/dist/src/resources/environment-analysis-resource.js.map +1 -0
  34. package/dist/src/resources/index.d.ts +6 -2
  35. package/dist/src/resources/index.d.ts.map +1 -1
  36. package/dist/src/resources/index.js +247 -492
  37. package/dist/src/resources/index.js.map +1 -1
  38. package/dist/src/resources/memory-snapshots-resource.d.ts +180 -0
  39. package/dist/src/resources/memory-snapshots-resource.d.ts.map +1 -0
  40. package/dist/src/resources/memory-snapshots-resource.js +847 -0
  41. package/dist/src/resources/memory-snapshots-resource.js.map +1 -0
  42. package/dist/src/resources/pattern-base-code-by-platform-resource.d.ts +35 -0
  43. package/dist/src/resources/pattern-base-code-by-platform-resource.d.ts.map +1 -0
  44. package/dist/src/resources/pattern-base-code-by-platform-resource.js +72 -0
  45. package/dist/src/resources/pattern-base-code-by-platform-resource.js.map +1 -0
  46. package/dist/src/resources/pattern-by-name-resource.d.ts +53 -0
  47. package/dist/src/resources/pattern-by-name-resource.d.ts.map +1 -0
  48. package/dist/src/resources/pattern-by-name-resource.js +200 -0
  49. package/dist/src/resources/pattern-by-name-resource.js.map +1 -0
  50. package/dist/src/resources/pattern-sources-by-platform-resource.d.ts +26 -0
  51. package/dist/src/resources/pattern-sources-by-platform-resource.d.ts.map +1 -0
  52. package/dist/src/resources/pattern-sources-by-platform-resource.js +59 -0
  53. package/dist/src/resources/pattern-sources-by-platform-resource.js.map +1 -0
  54. package/dist/src/resources/project-metrics-resource.d.ts +180 -0
  55. package/dist/src/resources/project-metrics-resource.d.ts.map +1 -0
  56. package/dist/src/resources/project-metrics-resource.js +487 -0
  57. package/dist/src/resources/project-metrics-resource.js.map +1 -0
  58. package/dist/src/resources/project-status-resource.d.ts +75 -0
  59. package/dist/src/resources/project-status-resource.d.ts.map +1 -0
  60. package/dist/src/resources/project-status-resource.js +189 -0
  61. package/dist/src/resources/project-status-resource.js.map +1 -0
  62. package/dist/src/resources/research-by-topic-resource.d.ts +21 -0
  63. package/dist/src/resources/research-by-topic-resource.d.ts.map +1 -0
  64. package/dist/src/resources/research-by-topic-resource.js +125 -0
  65. package/dist/src/resources/research-by-topic-resource.js.map +1 -0
  66. package/dist/src/resources/research-index-resource.d.ts +100 -0
  67. package/dist/src/resources/research-index-resource.d.ts.map +1 -0
  68. package/dist/src/resources/research-index-resource.js +200 -0
  69. package/dist/src/resources/research-index-resource.js.map +1 -0
  70. package/dist/src/resources/resource-cache.d.ts +144 -0
  71. package/dist/src/resources/resource-cache.d.ts.map +1 -0
  72. package/dist/src/resources/resource-cache.js +316 -0
  73. package/dist/src/resources/resource-cache.js.map +1 -0
  74. package/dist/src/resources/resource-router.d.ts +45 -0
  75. package/dist/src/resources/resource-router.d.ts.map +1 -0
  76. package/dist/src/resources/resource-router.js +96 -0
  77. package/dist/src/resources/resource-router.js.map +1 -0
  78. package/dist/src/resources/rule-by-id-resource.d.ts +38 -0
  79. package/dist/src/resources/rule-by-id-resource.d.ts.map +1 -0
  80. package/dist/src/resources/rule-by-id-resource.js +104 -0
  81. package/dist/src/resources/rule-by-id-resource.js.map +1 -0
  82. package/dist/src/resources/rule-catalog-resource.d.ts +126 -0
  83. package/dist/src/resources/rule-catalog-resource.d.ts.map +1 -0
  84. package/dist/src/resources/rule-catalog-resource.js +224 -0
  85. package/dist/src/resources/rule-catalog-resource.js.map +1 -0
  86. package/dist/src/resources/rule-generation-resource.d.ts +80 -0
  87. package/dist/src/resources/rule-generation-resource.d.ts.map +1 -0
  88. package/dist/src/resources/rule-generation-resource.js +282 -0
  89. package/dist/src/resources/rule-generation-resource.js.map +1 -0
  90. package/dist/src/resources/technology-by-name-resource.d.ts +43 -0
  91. package/dist/src/resources/technology-by-name-resource.d.ts.map +1 -0
  92. package/dist/src/resources/technology-by-name-resource.js +176 -0
  93. package/dist/src/resources/technology-by-name-resource.js.map +1 -0
  94. package/dist/src/resources/todo-by-id-resource.d.ts +46 -0
  95. package/dist/src/resources/todo-by-id-resource.d.ts.map +1 -0
  96. package/dist/src/resources/todo-by-id-resource.js +192 -0
  97. package/dist/src/resources/todo-by-id-resource.js.map +1 -0
  98. package/dist/src/resources/todo-list-resource.d.ts +96 -0
  99. package/dist/src/resources/todo-list-resource.d.ts.map +1 -0
  100. package/dist/src/resources/todo-list-resource.js +209 -0
  101. package/dist/src/resources/todo-list-resource.js.map +1 -0
  102. package/dist/src/resources/validated-pattern-by-platform-resource.d.ts +14 -0
  103. package/dist/src/resources/validated-pattern-by-platform-resource.d.ts.map +1 -0
  104. package/dist/src/resources/validated-pattern-by-platform-resource.js +45 -0
  105. package/dist/src/resources/validated-pattern-by-platform-resource.js.map +1 -0
  106. package/dist/src/resources/validated-patterns-catalog-resource.d.ts +36 -0
  107. package/dist/src/resources/validated-patterns-catalog-resource.d.ts.map +1 -0
  108. package/dist/src/resources/validated-patterns-catalog-resource.js +57 -0
  109. package/dist/src/resources/validated-patterns-catalog-resource.js.map +1 -0
  110. package/dist/src/tools/adr-bootstrap-validation-tool.d.ts.map +1 -1
  111. package/dist/src/tools/adr-bootstrap-validation-tool.js +214 -4
  112. package/dist/src/tools/adr-bootstrap-validation-tool.js.map +1 -1
  113. package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
  114. package/dist/src/tools/adr-suggestion-tool.js +4 -1
  115. package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
  116. package/dist/src/tools/adr-validation-tool.d.ts +52 -0
  117. package/dist/src/tools/adr-validation-tool.d.ts.map +1 -1
  118. package/dist/src/tools/adr-validation-tool.js +52 -0
  119. package/dist/src/tools/adr-validation-tool.js.map +1 -1
  120. package/dist/src/tools/bootstrap-validation-loop-tool.d.ts +262 -0
  121. package/dist/src/tools/bootstrap-validation-loop-tool.d.ts.map +1 -0
  122. package/dist/src/tools/bootstrap-validation-loop-tool.js +1934 -0
  123. package/dist/src/tools/bootstrap-validation-loop-tool.js.map +1 -0
  124. package/dist/src/tools/conversation-memory-tool.d.ts +48 -0
  125. package/dist/src/tools/conversation-memory-tool.d.ts.map +1 -0
  126. package/dist/src/tools/conversation-memory-tool.js +254 -0
  127. package/dist/src/tools/conversation-memory-tool.js.map +1 -0
  128. package/dist/src/tools/deployment-analysis-tool.d.ts.map +1 -1
  129. package/dist/src/tools/deployment-analysis-tool.js +47 -5
  130. package/dist/src/tools/deployment-analysis-tool.js.map +1 -1
  131. package/dist/src/tools/deployment-guidance-tool.d.ts.map +1 -1
  132. package/dist/src/tools/deployment-guidance-tool.js +48 -1
  133. package/dist/src/tools/deployment-guidance-tool.js.map +1 -1
  134. package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
  135. package/dist/src/tools/deployment-readiness-tool.js +15 -1
  136. package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
  137. package/dist/src/tools/expand-analysis-tool.d.ts +23 -0
  138. package/dist/src/tools/expand-analysis-tool.d.ts.map +1 -0
  139. package/dist/src/tools/expand-analysis-tool.js +107 -0
  140. package/dist/src/tools/expand-analysis-tool.js.map +1 -0
  141. package/dist/src/tools/get-server-context-tool.d.ts +67 -0
  142. package/dist/src/tools/get-server-context-tool.d.ts.map +1 -0
  143. package/dist/src/tools/get-server-context-tool.js +75 -0
  144. package/dist/src/tools/get-server-context-tool.js.map +1 -0
  145. package/dist/src/tools/llm-cloud-management-tool.d.ts +62 -0
  146. package/dist/src/tools/llm-cloud-management-tool.d.ts.map +1 -0
  147. package/dist/src/tools/llm-cloud-management-tool.js +202 -0
  148. package/dist/src/tools/llm-cloud-management-tool.js.map +1 -0
  149. package/dist/src/tools/llm-database-management-tool.d.ts +62 -0
  150. package/dist/src/tools/llm-database-management-tool.d.ts.map +1 -0
  151. package/dist/src/tools/llm-database-management-tool.js +203 -0
  152. package/dist/src/tools/llm-database-management-tool.js.map +1 -0
  153. package/dist/src/tools/llm-web-search-tool.d.ts +59 -0
  154. package/dist/src/tools/llm-web-search-tool.d.ts.map +1 -0
  155. package/dist/src/tools/llm-web-search-tool.js +165 -0
  156. package/dist/src/tools/llm-web-search-tool.js.map +1 -0
  157. package/dist/src/tools/mcp-planning-tool.d.ts.map +1 -1
  158. package/dist/src/tools/mcp-planning-tool.js +10 -3
  159. package/dist/src/tools/mcp-planning-tool.js.map +1 -1
  160. package/dist/src/tools/memory-loading-tool.d.ts.map +1 -1
  161. package/dist/src/tools/memory-loading-tool.js +4 -2
  162. package/dist/src/tools/memory-loading-tool.js.map +1 -1
  163. package/dist/src/tools/perform-research-tool.d.ts +45 -1
  164. package/dist/src/tools/perform-research-tool.d.ts.map +1 -1
  165. package/dist/src/tools/perform-research-tool.js +146 -2
  166. package/dist/src/tools/perform-research-tool.js.map +1 -1
  167. package/dist/src/tools/review-existing-adrs-tool.d.ts.map +1 -1
  168. package/dist/src/tools/review-existing-adrs-tool.js +4 -1
  169. package/dist/src/tools/review-existing-adrs-tool.js.map +1 -1
  170. package/dist/src/tools/tool-chain-orchestrator.d.ts +15 -94
  171. package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
  172. package/dist/src/tools/tool-chain-orchestrator.js +2 -2
  173. package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
  174. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +25 -120
  175. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
  176. package/dist/src/tools/troubleshoot-guided-workflow-tool.js +2 -2
  177. package/dist/src/types/ape-framework.d.ts +50 -283
  178. package/dist/src/types/ape-framework.d.ts.map +1 -1
  179. package/dist/src/types/conversation-memory.d.ts +184 -0
  180. package/dist/src/types/conversation-memory.d.ts.map +1 -0
  181. package/dist/src/types/conversation-memory.js +8 -0
  182. package/dist/src/types/conversation-memory.js.map +1 -0
  183. package/dist/src/types/index.d.ts +112 -339
  184. package/dist/src/types/index.d.ts.map +1 -1
  185. package/dist/src/types/knowledge-generation.d.ts +96 -401
  186. package/dist/src/types/knowledge-generation.d.ts.map +1 -1
  187. package/dist/src/types/knowledge-graph-schemas.d.ts +77 -715
  188. package/dist/src/types/knowledge-graph-schemas.d.ts.map +1 -1
  189. package/dist/src/types/knowledge-graph-schemas.js +8 -8
  190. package/dist/src/types/knowledge-graph-schemas.js.map +1 -1
  191. package/dist/src/types/memory-entities.d.ts +1230 -6164
  192. package/dist/src/types/memory-entities.d.ts.map +1 -1
  193. package/dist/src/types/memory-entities.js +8 -8
  194. package/dist/src/types/memory-entities.js.map +1 -1
  195. package/dist/src/types/reflexion-framework.d.ts +35 -264
  196. package/dist/src/types/reflexion-framework.d.ts.map +1 -1
  197. package/dist/src/types/reflexion-framework.js +1 -1
  198. package/dist/src/types/reflexion-framework.js.map +1 -1
  199. package/dist/src/types/state-reinforcement.d.ts +87 -0
  200. package/dist/src/types/state-reinforcement.d.ts.map +1 -0
  201. package/dist/src/types/state-reinforcement.js +5 -0
  202. package/dist/src/types/state-reinforcement.js.map +1 -0
  203. package/dist/src/types/tiered-response.d.ts +61 -0
  204. package/dist/src/types/tiered-response.d.ts.map +1 -0
  205. package/dist/src/types/tiered-response.js +8 -0
  206. package/dist/src/types/tiered-response.js.map +1 -0
  207. package/dist/src/types/tool-context.d.ts +50 -0
  208. package/dist/src/types/tool-context.d.ts.map +1 -0
  209. package/dist/src/types/tool-context.js +20 -0
  210. package/dist/src/types/tool-context.js.map +1 -0
  211. package/dist/src/utils/adr-action-analyzer.d.ts +23 -0
  212. package/dist/src/utils/adr-action-analyzer.d.ts.map +1 -0
  213. package/dist/src/utils/adr-action-analyzer.js +323 -0
  214. package/dist/src/utils/adr-action-analyzer.js.map +1 -0
  215. package/dist/src/utils/adr-context-detector.d.ts +33 -0
  216. package/dist/src/utils/adr-context-detector.d.ts.map +1 -0
  217. package/dist/src/utils/adr-context-detector.js +279 -0
  218. package/dist/src/utils/adr-context-detector.js.map +1 -0
  219. package/dist/src/utils/adr-discovery.d.ts +28 -2
  220. package/dist/src/utils/adr-discovery.d.ts.map +1 -1
  221. package/dist/src/utils/adr-discovery.js +91 -7
  222. package/dist/src/utils/adr-discovery.js.map +1 -1
  223. package/dist/src/utils/adr-knowledge-initializer.d.ts +54 -0
  224. package/dist/src/utils/adr-knowledge-initializer.d.ts.map +1 -0
  225. package/dist/src/utils/adr-knowledge-initializer.js +240 -0
  226. package/dist/src/utils/adr-knowledge-initializer.js.map +1 -0
  227. package/dist/src/utils/adr-timeline-extractor.d.ts +21 -0
  228. package/dist/src/utils/adr-timeline-extractor.d.ts.map +1 -0
  229. package/dist/src/utils/adr-timeline-extractor.js +294 -0
  230. package/dist/src/utils/adr-timeline-extractor.js.map +1 -0
  231. package/dist/src/utils/adr-timeline-types.d.ts +234 -0
  232. package/dist/src/utils/adr-timeline-types.d.ts.map +1 -0
  233. package/dist/src/utils/adr-timeline-types.js +7 -0
  234. package/dist/src/utils/adr-timeline-types.js.map +1 -0
  235. package/dist/src/utils/ai-executor.d.ts +36 -0
  236. package/dist/src/utils/ai-executor.d.ts.map +1 -1
  237. package/dist/src/utils/ai-executor.js +36 -0
  238. package/dist/src/utils/ai-executor.js.map +1 -1
  239. package/dist/src/utils/conditional-request.d.ts +105 -0
  240. package/dist/src/utils/conditional-request.d.ts.map +1 -0
  241. package/dist/src/utils/conditional-request.js +186 -0
  242. package/dist/src/utils/conditional-request.js.map +1 -0
  243. package/dist/src/utils/config.d.ts +72 -18
  244. package/dist/src/utils/config.d.ts.map +1 -1
  245. package/dist/src/utils/config.js +75 -0
  246. package/dist/src/utils/config.js.map +1 -1
  247. package/dist/src/utils/context-document-manager.d.ts +112 -0
  248. package/dist/src/utils/context-document-manager.d.ts.map +1 -0
  249. package/dist/src/utils/context-document-manager.js +351 -0
  250. package/dist/src/utils/context-document-manager.js.map +1 -0
  251. package/dist/src/utils/conversation-memory-manager.d.ts +86 -0
  252. package/dist/src/utils/conversation-memory-manager.d.ts.map +1 -0
  253. package/dist/src/utils/conversation-memory-manager.js +443 -0
  254. package/dist/src/utils/conversation-memory-manager.js.map +1 -0
  255. package/dist/src/utils/dag-executor.d.ts +106 -0
  256. package/dist/src/utils/dag-executor.d.ts.map +1 -0
  257. package/dist/src/utils/dag-executor.js +453 -0
  258. package/dist/src/utils/dag-executor.js.map +1 -0
  259. package/dist/src/utils/deployment-analysis.d.ts.map +1 -1
  260. package/dist/src/utils/deployment-analysis.js +4 -1
  261. package/dist/src/utils/deployment-analysis.js.map +1 -1
  262. package/dist/src/utils/deployment-type-registry.d.ts +52 -0
  263. package/dist/src/utils/deployment-type-registry.d.ts.map +1 -0
  264. package/dist/src/utils/deployment-type-registry.js +543 -0
  265. package/dist/src/utils/deployment-type-registry.js.map +1 -0
  266. package/dist/src/utils/dynamic-deployment-intelligence.d.ts +117 -0
  267. package/dist/src/utils/dynamic-deployment-intelligence.d.ts.map +1 -0
  268. package/dist/src/utils/dynamic-deployment-intelligence.js +445 -0
  269. package/dist/src/utils/dynamic-deployment-intelligence.js.map +1 -0
  270. package/dist/src/utils/environment-analysis.d.ts.map +1 -1
  271. package/dist/src/utils/environment-analysis.js +4 -1
  272. package/dist/src/utils/environment-analysis.js.map +1 -1
  273. package/dist/src/utils/knowledge-graph-manager.d.ts +16 -1
  274. package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
  275. package/dist/src/utils/knowledge-graph-manager.js +159 -3
  276. package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
  277. package/dist/src/utils/mermaid-diagrams.d.ts +101 -0
  278. package/dist/src/utils/mermaid-diagrams.d.ts.map +1 -0
  279. package/dist/src/utils/mermaid-diagrams.js +445 -0
  280. package/dist/src/utils/mermaid-diagrams.js.map +1 -0
  281. package/dist/src/utils/monitoring.d.ts +249 -0
  282. package/dist/src/utils/monitoring.d.ts.map +1 -0
  283. package/dist/src/utils/monitoring.js +513 -0
  284. package/dist/src/utils/monitoring.js.map +1 -0
  285. package/dist/src/utils/pattern-contribution-helper.d.ts +60 -0
  286. package/dist/src/utils/pattern-contribution-helper.d.ts.map +1 -0
  287. package/dist/src/utils/pattern-contribution-helper.js +308 -0
  288. package/dist/src/utils/pattern-contribution-helper.js.map +1 -0
  289. package/dist/src/utils/pattern-loader.d.ts +183 -0
  290. package/dist/src/utils/pattern-loader.d.ts.map +1 -0
  291. package/dist/src/utils/pattern-loader.js +200 -0
  292. package/dist/src/utils/pattern-loader.js.map +1 -0
  293. package/dist/src/utils/pattern-research-utility.d.ts +107 -0
  294. package/dist/src/utils/pattern-research-utility.d.ts.map +1 -0
  295. package/dist/src/utils/pattern-research-utility.js +360 -0
  296. package/dist/src/utils/pattern-research-utility.js.map +1 -0
  297. package/dist/src/utils/pattern-to-dag-converter.d.ts +62 -0
  298. package/dist/src/utils/pattern-to-dag-converter.d.ts.map +1 -0
  299. package/dist/src/utils/pattern-to-dag-converter.js +265 -0
  300. package/dist/src/utils/pattern-to-dag-converter.js.map +1 -0
  301. package/dist/src/utils/platform-detector.d.ts +86 -0
  302. package/dist/src/utils/platform-detector.d.ts.map +1 -0
  303. package/dist/src/utils/platform-detector.js +509 -0
  304. package/dist/src/utils/platform-detector.js.map +1 -0
  305. package/dist/src/utils/research-integration.d.ts.map +1 -1
  306. package/dist/src/utils/research-integration.js +8 -2
  307. package/dist/src/utils/research-integration.js.map +1 -1
  308. package/dist/src/utils/research-orchestrator.d.ts +135 -3
  309. package/dist/src/utils/research-orchestrator.d.ts.map +1 -1
  310. package/dist/src/utils/research-orchestrator.js +440 -27
  311. package/dist/src/utils/research-orchestrator.js.map +1 -1
  312. package/dist/src/utils/research-questions.d.ts.map +1 -1
  313. package/dist/src/utils/research-questions.js +4 -1
  314. package/dist/src/utils/research-questions.js.map +1 -1
  315. package/dist/src/utils/resource-extractor.d.ts +57 -0
  316. package/dist/src/utils/resource-extractor.d.ts.map +1 -0
  317. package/dist/src/utils/resource-extractor.js +323 -0
  318. package/dist/src/utils/resource-extractor.js.map +1 -0
  319. package/dist/src/utils/resource-versioning.d.ts +124 -0
  320. package/dist/src/utils/resource-versioning.d.ts.map +1 -0
  321. package/dist/src/utils/resource-versioning.js +272 -0
  322. package/dist/src/utils/resource-versioning.js.map +1 -0
  323. package/dist/src/utils/root-manager.d.ts +118 -0
  324. package/dist/src/utils/root-manager.d.ts.map +1 -0
  325. package/dist/src/utils/root-manager.js +154 -0
  326. package/dist/src/utils/root-manager.js.map +1 -0
  327. package/dist/src/utils/rule-generation.d.ts.map +1 -1
  328. package/dist/src/utils/rule-generation.js +4 -1
  329. package/dist/src/utils/rule-generation.js.map +1 -1
  330. package/dist/src/utils/server-context-generator.d.ts +47 -0
  331. package/dist/src/utils/server-context-generator.d.ts.map +1 -0
  332. package/dist/src/utils/server-context-generator.js +666 -0
  333. package/dist/src/utils/server-context-generator.js.map +1 -0
  334. package/dist/src/utils/state-reinforcement-manager.d.ts +60 -0
  335. package/dist/src/utils/state-reinforcement-manager.d.ts.map +1 -0
  336. package/dist/src/utils/state-reinforcement-manager.js +200 -0
  337. package/dist/src/utils/state-reinforcement-manager.js.map +1 -0
  338. package/dist/src/utils/system-card-manager.d.ts +194 -0
  339. package/dist/src/utils/system-card-manager.d.ts.map +1 -0
  340. package/dist/src/utils/system-card-manager.js +336 -0
  341. package/dist/src/utils/system-card-manager.js.map +1 -0
  342. package/dist/src/utils/tiered-response-manager.d.ts +40 -0
  343. package/dist/src/utils/tiered-response-manager.d.ts.map +1 -0
  344. package/dist/src/utils/tiered-response-manager.js +243 -0
  345. package/dist/src/utils/tiered-response-manager.js.map +1 -0
  346. package/dist/src/utils/validated-pattern-definitions.d.ts +219 -0
  347. package/dist/src/utils/validated-pattern-definitions.d.ts.map +1 -0
  348. package/dist/src/utils/validated-pattern-definitions.js +1511 -0
  349. package/dist/src/utils/validated-pattern-definitions.js.map +1 -0
  350. package/package.json +22 -13
  351. package/dist/src/prompts/todo-prompts.d.ts +0 -49
  352. package/dist/src/prompts/todo-prompts.d.ts.map +0 -1
  353. package/dist/src/prompts/todo-prompts.js +0 -824
  354. package/dist/src/prompts/todo-prompts.js.map +0 -1
  355. package/dist/src/types/todo-json-schemas.d.ts +0 -17
  356. package/dist/src/types/todo-json-schemas.d.ts.map +0 -1
  357. package/dist/src/types/todo-json-schemas.js +0 -9
  358. package/dist/src/types/todo-json-schemas.js.map +0 -1
  359. package/dist/src/utils/todo-file-watcher.d.ts +0 -14
  360. package/dist/src/utils/todo-file-watcher.d.ts.map +0 -1
  361. package/dist/src/utils/todo-file-watcher.js +0 -25
  362. package/dist/src/utils/todo-file-watcher.js.map +0 -1
package/dist/src/index.js CHANGED
@@ -17,6 +17,12 @@ import { CONVERSATION_CONTEXT_SCHEMA } from './types/conversation-context.js';
17
17
  import { maskMcpResponse, createMaskingConfig, } from './utils/output-masking.js';
18
18
  import { loadConfig, validateProjectPath, createLogger, printConfigSummary, } from './utils/config.js';
19
19
  import { KnowledgeGraphManager } from './utils/knowledge-graph-manager.js';
20
+ import { StateReinforcementManager } from './utils/state-reinforcement-manager.js';
21
+ import { ConversationMemoryManager } from './utils/conversation-memory-manager.js';
22
+ import { MemoryEntityManager } from './utils/memory-entity-manager.js';
23
+ import { RootManager } from './utils/root-manager.js';
24
+ import { ServerContextGenerator } from './utils/server-context-generator.js';
25
+ import { createNoOpContext } from './types/tool-context.js';
20
26
  /**
21
27
  * Get version from package.json
22
28
  */
@@ -72,11 +78,23 @@ export class McpAdrAnalysisServer {
72
78
  config;
73
79
  logger;
74
80
  kgManager;
81
+ stateReinforcementManager;
82
+ conversationMemoryManager;
83
+ memoryEntityManager;
84
+ rootManager;
85
+ contextGenerator;
75
86
  constructor() {
76
87
  // Load and validate configuration
77
88
  this.config = loadConfig();
78
89
  this.logger = createLogger(this.config);
79
90
  this.kgManager = new KnowledgeGraphManager();
91
+ this.stateReinforcementManager = new StateReinforcementManager(this.kgManager);
92
+ this.conversationMemoryManager = new ConversationMemoryManager(this.kgManager);
93
+ this.memoryEntityManager = new MemoryEntityManager();
94
+ // Initialize root manager for file access control
95
+ this.rootManager = new RootManager(this.config.projectPath, this.config.adrDirectory);
96
+ // Initialize server context generator
97
+ this.contextGenerator = new ServerContextGenerator();
80
98
  // Print configuration summary
81
99
  printConfigSummary(this.config);
82
100
  // Note: Validation will be done during startup
@@ -113,9 +131,38 @@ export class McpAdrAnalysisServer {
113
131
  }
114
132
  /**
115
133
  * Setup MCP protocol handlers
134
+ *
135
+ * @description Configures all Model Context Protocol request handlers for the ADR Analysis Server.
136
+ * Implements the complete MCP specification including tools, resources, and prompts.
137
+ *
138
+ * @private
139
+ * @since 2.0.0
140
+ * @category MCP Protocol
116
141
  */
117
142
  setupHandlers() {
118
- // Tools handler
143
+ /**
144
+ * List Tools Handler - MCP Protocol Endpoint
145
+ *
146
+ * @description Returns the complete catalog of available tools for ADR analysis,
147
+ * research, validation, and deployment operations. Each tool includes comprehensive
148
+ * input schemas and descriptions for client integration.
149
+ *
150
+ * @returns {Promise<{tools: Array}>} Complete tool catalog with schemas
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // MCP Client usage
155
+ * const tools = await mcpClient.listTools();
156
+ * console.log(tools.tools.length); // 20+ available tools
157
+ *
158
+ * // Find specific tool
159
+ * const researchTool = tools.tools.find(t => t.name === 'perform_research');
160
+ * console.log(researchTool.description); // Tool description
161
+ * ```
162
+ *
163
+ * @mcp-endpoint
164
+ * @category Tools
165
+ */
119
166
  this.server.setRequestHandler(ListToolsRequestSchema, async () => {
120
167
  return {
121
168
  tools: [
@@ -247,72 +294,6 @@ export class McpAdrAnalysisServer {
247
294
  required: ['prdPath'],
248
295
  },
249
296
  },
250
- {
251
- name: 'generate_adr_todo',
252
- description: 'Generate TDD-focused todo.md from existing ADRs with JSON-first approach: creates structured JSON TODO and syncs to markdown',
253
- inputSchema: {
254
- type: 'object',
255
- properties: {
256
- adrDirectory: {
257
- type: 'string',
258
- description: 'Directory containing ADR files (optional, uses configured ADR_DIRECTORY if not provided)',
259
- },
260
- scope: {
261
- type: 'string',
262
- enum: ['all', 'pending', 'in_progress'],
263
- description: 'Scope of tasks to include',
264
- default: 'all',
265
- },
266
- phase: {
267
- type: 'string',
268
- enum: ['both', 'test', 'production'],
269
- description: 'TDD phase: both (default), test (mock test generation), production (implementation after tests)',
270
- default: 'both',
271
- },
272
- linkAdrs: {
273
- type: 'boolean',
274
- description: 'Auto-detect and link ADR dependencies in task creation',
275
- default: true,
276
- },
277
- includeRules: {
278
- type: 'boolean',
279
- description: 'Include architectural rules validation in TDD tasks',
280
- default: true,
281
- },
282
- ruleSource: {
283
- type: 'string',
284
- enum: ['adrs', 'patterns', 'both'],
285
- description: 'Source for architectural rules (only used if includeRules is true)',
286
- default: 'both',
287
- },
288
- todoPath: {
289
- type: 'string',
290
- description: 'Path to TODO.md file (relative to project root)',
291
- default: 'TODO.md',
292
- },
293
- preserveExisting: {
294
- type: 'boolean',
295
- description: 'Preserve existing TODO.md content by merging instead of overwriting',
296
- default: true,
297
- },
298
- forceSyncToMarkdown: {
299
- type: 'boolean',
300
- description: 'Force sync JSON to markdown even if markdown is newer',
301
- default: false,
302
- },
303
- intentId: {
304
- type: 'string',
305
- description: 'Link generated tasks to specific knowledge graph intent',
306
- },
307
- createJsonBackup: {
308
- type: 'boolean',
309
- description: 'Create backup of existing JSON TODO data before import',
310
- default: true,
311
- },
312
- conversationContext: CONVERSATION_CONTEXT_SCHEMA,
313
- },
314
- },
315
- },
316
297
  {
317
298
  name: 'compare_adr_progress',
318
299
  description: 'Compare TODO.md progress against ADRs and current environment to validate implementation status',
@@ -585,7 +566,7 @@ export class McpAdrAnalysisServer {
585
566
  },
586
567
  {
587
568
  name: 'suggest_adrs',
588
- description: 'Suggest architectural decisions with advanced prompting techniques (Knowledge Generation + Reflexion)',
569
+ description: 'Suggest architectural decisions with advanced prompting techniques (Knowledge Generation + Reflexion). TIP: Read @.mcp-server-context.md first for project history, patterns, and previous ADRs to ensure consistency.',
589
570
  inputSchema: {
590
571
  type: 'object',
591
572
  properties: {
@@ -643,7 +624,7 @@ export class McpAdrAnalysisServer {
643
624
  },
644
625
  {
645
626
  name: 'generate_adr_from_decision',
646
- description: 'Generate a complete ADR from decision data',
627
+ description: 'Generate a complete ADR from decision data. TIP: Reference @.mcp-server-context.md to align with existing architectural patterns and decisions.',
647
628
  inputSchema: {
648
629
  type: 'object',
649
630
  properties: {
@@ -689,7 +670,7 @@ export class McpAdrAnalysisServer {
689
670
  },
690
671
  {
691
672
  name: 'generate_adr_bootstrap',
692
- description: 'Generate bootstrap.sh and validate_bootstrap.sh scripts to ensure deployed code follows ADR requirements',
673
+ description: "Generate bootstrap.sh and validate_bootstrap.sh scripts to ensure deployed code follows ADR requirements. **CRITICAL**: Before generating scripts, use WebFetch to query the base code repository (e.g., https://github.com/validatedpatterns/common for OpenShift) and authoritative pattern documentation (e.g., https://play.validatedpatterns.io/). Merge the base repository code into your project and have bootstrap.sh call the pattern's scripts rather than generating everything from scratch. This ensures compliance with validated deployment patterns.",
693
674
  inputSchema: {
694
675
  type: 'object',
695
676
  properties: {
@@ -733,6 +714,67 @@ export class McpAdrAnalysisServer {
733
714
  },
734
715
  },
735
716
  },
717
+ {
718
+ name: 'bootstrap_validation_loop',
719
+ description: '**GUIDED EXECUTION MODE**: This tool guides you through an interactive, step-by-step deployment validation workflow. It does NOT execute commands internally - instead, it tells YOU what commands to run and processes the results iteratively. **Workflow**: (1) First call with iteration=0: Detects platform (OpenShift/K8s/Docker), validates environment connection, and requests human approval for target platform. (2) Subsequent calls: After running each command and reporting back with output, the tool provides next steps. **Environment Validation**: Before deployment, the tool verifies connection to the target platform (e.g., `oc status` for OpenShift, `kubectl cluster-info` for K8s) and requires explicit human confirmation. **Validated Patterns Integration**: Automatically identifies base code repositories (e.g., validatedpatterns/common for OpenShift) and guides you to merge them into your project. **Deployment Cleanup**: Supports CI/CD-style workflows with deployment teardown/restart guidance. **Call this tool iteratively**, passing previous command output back each time.',
720
+ inputSchema: {
721
+ type: 'object',
722
+ properties: {
723
+ projectPath: {
724
+ type: 'string',
725
+ description: 'Path to the project directory',
726
+ default: '.',
727
+ },
728
+ adrDirectory: {
729
+ type: 'string',
730
+ description: 'Directory where ADRs are stored',
731
+ default: 'docs/adrs',
732
+ },
733
+ targetEnvironment: {
734
+ type: 'string',
735
+ enum: ['development', 'staging', 'production', 'testing'],
736
+ description: 'Target deployment environment',
737
+ default: 'development',
738
+ },
739
+ maxIterations: {
740
+ type: 'number',
741
+ description: 'Maximum validation/fix iterations',
742
+ default: 5,
743
+ },
744
+ autoFix: {
745
+ type: 'boolean',
746
+ description: 'Whether to generate auto-fix suggestions in guidance',
747
+ default: true,
748
+ },
749
+ updateAdrsWithLearnings: {
750
+ type: 'boolean',
751
+ description: 'Update ADRs with deployment learnings (non-sensitive)',
752
+ default: true,
753
+ },
754
+ currentIteration: {
755
+ type: 'number',
756
+ description: 'Current iteration number (0 for initial call, then increment). Used to track workflow progress.',
757
+ default: 0,
758
+ },
759
+ previousExecutionOutput: {
760
+ type: 'string',
761
+ description: 'Output from the previous command execution. Paste the stdout/stderr from running the command that was recommended in the previous iteration.',
762
+ default: '',
763
+ },
764
+ previousExecutionSuccess: {
765
+ type: 'boolean',
766
+ description: 'Whether the previous command execution succeeded (exit code 0). Set to true if command succeeded, false if it failed.',
767
+ default: false,
768
+ },
769
+ deploymentCleanupRequested: {
770
+ type: 'boolean',
771
+ description: 'Set to true to request deployment cleanup/teardown guidance (for CI/CD workflows that need to delete and restart deployments).',
772
+ default: false,
773
+ },
774
+ conversationContext: CONVERSATION_CONTEXT_SCHEMA,
775
+ },
776
+ },
777
+ },
736
778
  {
737
779
  name: 'discover_existing_adrs',
738
780
  description: 'Discover and catalog existing ADRs in the project',
@@ -752,9 +794,53 @@ export class McpAdrAnalysisServer {
752
794
  },
753
795
  },
754
796
  },
797
+ {
798
+ name: 'analyze_adr_timeline',
799
+ description: 'Analyze ADR timeline with smart time tracking, adaptive thresholds, and actionable recommendations. Auto-detects project context (startup/growth/mature) and generates prioritized work queue based on staleness, implementation lag, and technical debt.',
800
+ inputSchema: {
801
+ type: 'object',
802
+ properties: {
803
+ projectPath: {
804
+ type: 'string',
805
+ description: 'Path to the project directory',
806
+ default: '.',
807
+ },
808
+ adrDirectory: {
809
+ type: 'string',
810
+ description: 'Directory containing ADR files',
811
+ default: 'docs/adrs',
812
+ },
813
+ generateActions: {
814
+ type: 'boolean',
815
+ description: 'Generate actionable work items with priority and effort estimates',
816
+ default: true,
817
+ },
818
+ thresholdProfile: {
819
+ type: 'string',
820
+ enum: ['startup', 'growth', 'mature', 'maintenance', 'feature_development'],
821
+ description: 'Threshold profile for action generation (auto-detected if not specified)',
822
+ },
823
+ autoDetectContext: {
824
+ type: 'boolean',
825
+ description: 'Auto-detect project phase from git activity and ADR patterns',
826
+ default: true,
827
+ },
828
+ includeContent: {
829
+ type: 'boolean',
830
+ description: 'Include ADR content for better analysis',
831
+ default: true,
832
+ },
833
+ forceExtract: {
834
+ type: 'boolean',
835
+ description: 'Force timeline extraction even if ADRs have dates',
836
+ default: false,
837
+ },
838
+ },
839
+ },
840
+ },
755
841
  {
756
842
  name: 'review_existing_adrs',
757
- description: 'Review existing ADRs against actual code implementation with cloud/DevOps expertise',
843
+ description: 'Review existing ADRs against actual code implementation with cloud/DevOps expertise. TIP: After review, call get_server_context to update @.mcp-server-context.md with findings.',
758
844
  inputSchema: {
759
845
  type: 'object',
760
846
  properties: {
@@ -794,7 +880,7 @@ export class McpAdrAnalysisServer {
794
880
  },
795
881
  {
796
882
  name: 'validate_adr',
797
- description: 'Validate an existing ADR against actual infrastructure reality using research-driven analysis',
883
+ description: 'Validate an existing ADR against actual infrastructure reality using research-driven analysis. TIP: Compare findings against patterns in @.mcp-server-context.md for consistency checks.',
798
884
  inputSchema: {
799
885
  type: 'object',
800
886
  properties: {
@@ -1302,6 +1388,130 @@ export class McpAdrAnalysisServer {
1302
1388
  required: ['question'],
1303
1389
  },
1304
1390
  },
1391
+ {
1392
+ name: 'llm_web_search',
1393
+ description: 'LLM-managed web search using Firecrawl for cross-platform support',
1394
+ inputSchema: {
1395
+ type: 'object',
1396
+ properties: {
1397
+ query: {
1398
+ type: 'string',
1399
+ description: 'The search query to execute',
1400
+ },
1401
+ maxResults: {
1402
+ type: 'number',
1403
+ description: 'Maximum results to return',
1404
+ default: 5,
1405
+ minimum: 1,
1406
+ maximum: 20,
1407
+ },
1408
+ includeContent: {
1409
+ type: 'boolean',
1410
+ description: 'Include full content in results',
1411
+ default: true,
1412
+ },
1413
+ llmInstructions: {
1414
+ type: 'string',
1415
+ description: 'LLM instructions for search optimization',
1416
+ },
1417
+ projectPath: {
1418
+ type: 'string',
1419
+ description: 'Path to project directory',
1420
+ default: '.',
1421
+ },
1422
+ adrDirectory: {
1423
+ type: 'string',
1424
+ description: 'Directory containing ADR files',
1425
+ default: 'docs/adrs',
1426
+ },
1427
+ },
1428
+ required: ['query'],
1429
+ },
1430
+ },
1431
+ {
1432
+ name: 'llm_cloud_management',
1433
+ description: 'LLM-managed cloud provider operations with research-driven approach',
1434
+ inputSchema: {
1435
+ type: 'object',
1436
+ properties: {
1437
+ provider: {
1438
+ type: 'string',
1439
+ enum: ['aws', 'azure', 'gcp', 'redhat', 'ubuntu', 'macos'],
1440
+ description: 'Cloud provider to use',
1441
+ },
1442
+ action: {
1443
+ type: 'string',
1444
+ description: 'Action to perform',
1445
+ },
1446
+ parameters: {
1447
+ type: 'object',
1448
+ description: 'Action parameters',
1449
+ },
1450
+ llmInstructions: {
1451
+ type: 'string',
1452
+ description: 'LLM instructions for command generation',
1453
+ },
1454
+ researchFirst: {
1455
+ type: 'boolean',
1456
+ description: 'Research best approach first',
1457
+ default: true,
1458
+ },
1459
+ projectPath: {
1460
+ type: 'string',
1461
+ description: 'Path to project directory',
1462
+ default: '.',
1463
+ },
1464
+ adrDirectory: {
1465
+ type: 'string',
1466
+ description: 'Directory containing ADR files',
1467
+ default: 'docs/adrs',
1468
+ },
1469
+ },
1470
+ required: ['provider', 'action', 'llmInstructions'],
1471
+ },
1472
+ },
1473
+ {
1474
+ name: 'llm_database_management',
1475
+ description: 'LLM-managed database operations with research-driven approach',
1476
+ inputSchema: {
1477
+ type: 'object',
1478
+ properties: {
1479
+ database: {
1480
+ type: 'string',
1481
+ enum: ['postgresql', 'mongodb', 'redis', 'mysql', 'mariadb'],
1482
+ description: 'Database type to use',
1483
+ },
1484
+ action: {
1485
+ type: 'string',
1486
+ description: 'Database action to perform',
1487
+ },
1488
+ parameters: {
1489
+ type: 'object',
1490
+ description: 'Action parameters',
1491
+ },
1492
+ llmInstructions: {
1493
+ type: 'string',
1494
+ description: 'LLM instructions for command generation',
1495
+ },
1496
+ researchFirst: {
1497
+ type: 'boolean',
1498
+ description: 'Research best approach first',
1499
+ default: true,
1500
+ },
1501
+ projectPath: {
1502
+ type: 'string',
1503
+ description: 'Path to project directory',
1504
+ default: '.',
1505
+ },
1506
+ adrDirectory: {
1507
+ type: 'string',
1508
+ description: 'Directory containing ADR files',
1509
+ default: 'docs/adrs',
1510
+ },
1511
+ },
1512
+ required: ['database', 'action', 'llmInstructions'],
1513
+ },
1514
+ },
1305
1515
  {
1306
1516
  name: 'analyze_deployment_progress',
1307
1517
  description: 'Analyze deployment progress and verify completion with outcome rules',
@@ -1501,18 +1711,44 @@ export class McpAdrAnalysisServer {
1501
1711
  required: ['developmentPhase'],
1502
1712
  },
1503
1713
  },
1714
+ {
1715
+ name: 'list_roots',
1716
+ description: 'List available file system roots that can be accessed. Use this to discover what directories are available before reading files.',
1717
+ inputSchema: {
1718
+ type: 'object',
1719
+ properties: {},
1720
+ },
1721
+ },
1722
+ {
1723
+ name: 'read_directory',
1724
+ description: 'List files and folders in a directory. Use this to explore the file structure within accessible roots.',
1725
+ inputSchema: {
1726
+ type: 'object',
1727
+ properties: {
1728
+ path: {
1729
+ type: 'string',
1730
+ description: 'Directory path to list (relative to project root or absolute within roots)',
1731
+ },
1732
+ },
1733
+ required: ['path'],
1734
+ },
1735
+ },
1504
1736
  {
1505
1737
  name: 'read_file',
1506
1738
  description: 'Read contents of a file',
1507
1739
  inputSchema: {
1508
1740
  type: 'object',
1509
1741
  properties: {
1510
- path: {
1742
+ filePath: {
1511
1743
  type: 'string',
1512
1744
  description: 'Path to the file to read',
1513
1745
  },
1746
+ path: {
1747
+ type: 'string',
1748
+ description: 'Path to the file to read (alias for filePath)',
1749
+ },
1514
1750
  },
1515
- required: ['path'],
1751
+ required: [],
1516
1752
  },
1517
1753
  },
1518
1754
  {
@@ -1548,230 +1784,36 @@ export class McpAdrAnalysisServer {
1548
1784
  },
1549
1785
  },
1550
1786
  {
1551
- name: 'manage_todo_json',
1552
- description: 'JSON-first TODO management with consistent LLM interactions, automatic scoring sync, and knowledge graph integration',
1787
+ name: 'generate_deployment_guidance',
1788
+ description: 'Generate deployment guidance and instructions from ADRs with environment-specific configurations',
1553
1789
  inputSchema: {
1554
1790
  type: 'object',
1555
1791
  properties: {
1556
- operation: {
1792
+ adrDirectory: {
1557
1793
  type: 'string',
1558
- enum: [
1559
- 'create_task',
1560
- 'update_task',
1561
- 'bulk_update',
1562
- 'get_tasks',
1563
- 'get_analytics',
1564
- 'import_adr_tasks',
1565
- 'sync_knowledge_graph',
1566
- 'sync_to_markdown',
1567
- 'import_from_markdown',
1568
- ],
1569
- description: 'Operation to perform on TODO JSON backend',
1794
+ default: 'docs/adrs',
1795
+ description: 'Directory containing ADR files',
1570
1796
  },
1571
- projectPath: {
1797
+ environment: {
1572
1798
  type: 'string',
1573
- description: 'Project root path (uses configured PROJECT_PATH if not provided)',
1799
+ enum: ['development', 'staging', 'production', 'all'],
1800
+ default: 'production',
1801
+ description: 'Target deployment environment',
1574
1802
  },
1575
- taskId: {
1803
+ format: {
1576
1804
  type: 'string',
1577
- description: 'Task ID for update operations',
1805
+ enum: ['markdown', 'scripts', 'structured', 'all'],
1806
+ default: 'markdown',
1807
+ description: 'Output format for guidance',
1578
1808
  },
1579
- title: {
1809
+ projectPath: {
1580
1810
  type: 'string',
1581
- description: 'Task title for create operations',
1811
+ description: 'Project root path (optional, uses configured PROJECT_PATH if not provided)',
1582
1812
  },
1583
- description: {
1584
- type: 'string',
1585
- description: 'Task description',
1586
- },
1587
- priority: {
1588
- type: 'string',
1589
- enum: ['low', 'medium', 'high', 'critical'],
1590
- default: 'medium',
1591
- description: 'Task priority level',
1592
- },
1593
- assignee: {
1594
- type: 'string',
1595
- description: 'Task assignee',
1596
- },
1597
- dueDate: {
1598
- type: 'string',
1599
- description: 'Due date (ISO string format)',
1600
- },
1601
- category: {
1602
- type: 'string',
1603
- description: 'Task category',
1604
- },
1605
- tags: {
1606
- type: 'array',
1607
- items: { type: 'string' },
1608
- description: 'Task tags',
1609
- },
1610
- dependencies: {
1611
- type: 'array',
1612
- items: { type: 'string' },
1613
- description: 'Task dependencies (task IDs)',
1614
- },
1615
- intentId: {
1616
- type: 'string',
1617
- description: 'Link to knowledge graph intent',
1618
- },
1619
- linkedAdrs: {
1620
- type: 'array',
1621
- items: { type: 'string' },
1622
- description: 'Related ADR files',
1623
- },
1624
- autoComplete: {
1625
- type: 'boolean',
1626
- default: false,
1627
- description: 'Auto-complete when criteria are met',
1628
- },
1629
- completionCriteria: {
1630
- type: 'string',
1631
- description: 'Auto-completion rules',
1632
- },
1633
- updates: {
1634
- type: 'object',
1635
- properties: {
1636
- title: { type: 'string' },
1637
- description: { type: 'string' },
1638
- status: {
1639
- type: 'string',
1640
- enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'],
1641
- },
1642
- priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1643
- assignee: { type: 'string' },
1644
- dueDate: { type: 'string' },
1645
- progressPercentage: { type: 'number', minimum: 0, maximum: 100 },
1646
- notes: { type: 'string' },
1647
- tags: { type: 'array', items: { type: 'string' } },
1648
- },
1649
- description: 'Fields to update for update operations',
1650
- },
1651
- reason: {
1652
- type: 'string',
1653
- description: 'Reason for update (for changelog)',
1654
- },
1655
- filters: {
1656
- type: 'object',
1657
- properties: {
1658
- status: {
1659
- type: 'string',
1660
- enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'],
1661
- },
1662
- priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1663
- assignee: { type: 'string' },
1664
- category: { type: 'string' },
1665
- hasDeadline: { type: 'boolean' },
1666
- overdue: { type: 'boolean' },
1667
- tags: { type: 'array', items: { type: 'string' } },
1668
- },
1669
- description: 'Filter criteria for get_tasks operation',
1670
- },
1671
- sortBy: {
1672
- type: 'string',
1673
- enum: ['priority', 'dueDate', 'createdAt', 'updatedAt'],
1674
- default: 'priority',
1675
- description: 'Sort field for get_tasks operation',
1676
- },
1677
- sortOrder: {
1678
- type: 'string',
1679
- enum: ['asc', 'desc'],
1680
- default: 'desc',
1681
- description: 'Sort order for get_tasks operation',
1682
- },
1683
- limit: {
1684
- type: 'number',
1685
- description: 'Maximum number of tasks to return',
1686
- },
1687
- timeframe: {
1688
- type: 'string',
1689
- enum: ['day', 'week', 'month', 'all'],
1690
- default: 'week',
1691
- description: 'Analysis timeframe for analytics',
1692
- },
1693
- includeVelocity: {
1694
- type: 'boolean',
1695
- default: true,
1696
- description: 'Include velocity metrics in analytics',
1697
- },
1698
- includeScoring: {
1699
- type: 'boolean',
1700
- default: true,
1701
- description: 'Include scoring metrics in analytics',
1702
- },
1703
- adrDirectory: {
1704
- type: 'string',
1705
- default: 'docs/adrs',
1706
- description: 'ADR directory path for imports',
1707
- },
1708
- preserveExisting: {
1709
- type: 'boolean',
1710
- default: true,
1711
- description: 'Keep existing tasks during imports',
1712
- },
1713
- autoLinkDependencies: {
1714
- type: 'boolean',
1715
- default: true,
1716
- description: 'Auto-detect task dependencies',
1717
- },
1718
- direction: {
1719
- type: 'string',
1720
- enum: ['to_kg', 'from_kg', 'bidirectional'],
1721
- default: 'bidirectional',
1722
- description: 'Knowledge graph sync direction',
1723
- },
1724
- force: {
1725
- type: 'boolean',
1726
- default: false,
1727
- description: 'Force operation even if conflicts exist',
1728
- },
1729
- mergeStrategy: {
1730
- type: 'string',
1731
- enum: ['overwrite', 'merge', 'preserve_json'],
1732
- default: 'merge',
1733
- description: 'Merge strategy for imports',
1734
- },
1735
- backupExisting: {
1736
- type: 'boolean',
1737
- default: true,
1738
- description: 'Create backup before destructive operations',
1739
- },
1740
- },
1741
- required: ['operation'],
1742
- },
1743
- },
1744
- {
1745
- name: 'generate_deployment_guidance',
1746
- description: 'Generate deployment guidance and instructions from ADRs with environment-specific configurations',
1747
- inputSchema: {
1748
- type: 'object',
1749
- properties: {
1750
- adrDirectory: {
1751
- type: 'string',
1752
- default: 'docs/adrs',
1753
- description: 'Directory containing ADR files',
1754
- },
1755
- environment: {
1756
- type: 'string',
1757
- enum: ['development', 'staging', 'production', 'all'],
1758
- default: 'production',
1759
- description: 'Target deployment environment',
1760
- },
1761
- format: {
1762
- type: 'string',
1763
- enum: ['markdown', 'scripts', 'structured', 'all'],
1764
- default: 'markdown',
1765
- description: 'Output format for guidance',
1766
- },
1767
- projectPath: {
1768
- type: 'string',
1769
- description: 'Project root path (optional, uses configured PROJECT_PATH if not provided)',
1770
- },
1771
- includeScripts: {
1772
- type: 'boolean',
1773
- default: true,
1774
- description: 'Generate deployment scripts',
1813
+ includeScripts: {
1814
+ type: 'boolean',
1815
+ default: true,
1816
+ description: 'Generate deployment scripts',
1775
1817
  },
1776
1818
  includeConfigs: {
1777
1819
  type: 'boolean',
@@ -2236,7 +2278,6 @@ export class McpAdrAnalysisServer {
2236
2278
  items: {
2237
2279
  type: 'string',
2238
2280
  enum: [
2239
- 'manage_todo_json',
2240
2281
  'smart_git_push',
2241
2282
  'compare_adr_progress',
2242
2283
  'analyze_content_security',
@@ -2559,7 +2600,7 @@ export class McpAdrAnalysisServer {
2559
2600
  },
2560
2601
  {
2561
2602
  name: 'interactive_adr_planning',
2562
- description: 'Interactive guided ADR planning and creation tool - walks users through structured decision-making process with research integration, option evaluation, and automatic ADR generation',
2603
+ description: 'Interactive guided ADR planning and creation tool - walks users through structured decision-making process with research integration, option evaluation, and automatic ADR generation. TIP: Start by reading @.mcp-server-context.md to understand project context and previous decisions.',
2563
2604
  inputSchema: {
2564
2605
  type: 'object',
2565
2606
  properties: {
@@ -2759,6 +2800,30 @@ export class McpAdrAnalysisServer {
2759
2800
  },
2760
2801
  },
2761
2802
  },
2803
+ {
2804
+ name: 'expand_analysis_section',
2805
+ description: 'Retrieve full analysis content from tiered responses. Expand entire analysis or specific sections stored in memory. Use this when a tool returns a summary with an expandable ID.',
2806
+ inputSchema: {
2807
+ type: 'object',
2808
+ properties: {
2809
+ expandableId: {
2810
+ type: 'string',
2811
+ description: 'ID of the expandable analysis (provided in tiered response)',
2812
+ },
2813
+ section: {
2814
+ type: 'string',
2815
+ description: 'Optional: Specific section to expand (omit to get full analysis). Available sections are listed in the tiered response.',
2816
+ },
2817
+ format: {
2818
+ type: 'string',
2819
+ enum: ['markdown', 'json'],
2820
+ description: 'Output format (default: markdown)',
2821
+ default: 'markdown',
2822
+ },
2823
+ },
2824
+ required: ['expandableId'],
2825
+ },
2826
+ },
2762
2827
  {
2763
2828
  name: 'tool_chain_orchestrator',
2764
2829
  description: 'AI-powered dynamic tool sequencing - intelligently analyze user requests and generate structured tool execution plans',
@@ -2799,27 +2864,191 @@ export class McpAdrAnalysisServer {
2799
2864
  required: ['userRequest'],
2800
2865
  },
2801
2866
  },
2867
+ {
2868
+ name: 'expand_memory',
2869
+ description: 'Phase 3: Retrieve and expand stored content from a tiered response using its expandable ID',
2870
+ inputSchema: {
2871
+ type: 'object',
2872
+ properties: {
2873
+ expandableId: {
2874
+ type: 'string',
2875
+ description: 'Expandable ID from a tiered response',
2876
+ },
2877
+ section: {
2878
+ type: 'string',
2879
+ description: 'Optional: specific section to expand',
2880
+ },
2881
+ includeContext: {
2882
+ type: 'boolean',
2883
+ description: 'Include related conversation context and knowledge graph state',
2884
+ default: true,
2885
+ },
2886
+ },
2887
+ required: ['expandableId'],
2888
+ },
2889
+ },
2890
+ {
2891
+ name: 'query_conversation_history',
2892
+ description: 'Phase 3: Search and retrieve conversation sessions based on filters',
2893
+ inputSchema: {
2894
+ type: 'object',
2895
+ properties: {
2896
+ projectPath: {
2897
+ type: 'string',
2898
+ description: 'Filter by project path',
2899
+ },
2900
+ dateRange: {
2901
+ type: 'object',
2902
+ properties: {
2903
+ start: { type: 'string', description: 'Start date (ISO 8601)' },
2904
+ end: { type: 'string', description: 'End date (ISO 8601)' },
2905
+ },
2906
+ description: 'Filter by date range',
2907
+ },
2908
+ toolsUsed: {
2909
+ type: 'array',
2910
+ items: { type: 'string' },
2911
+ description: 'Filter by tools used in the session',
2912
+ },
2913
+ keyword: {
2914
+ type: 'string',
2915
+ description: 'Search keyword in conversation turns',
2916
+ },
2917
+ limit: {
2918
+ type: 'number',
2919
+ description: 'Maximum number of sessions to return',
2920
+ default: 10,
2921
+ },
2922
+ },
2923
+ },
2924
+ },
2925
+ {
2926
+ name: 'get_conversation_snapshot',
2927
+ description: 'Phase 3: Get current conversation context snapshot for resumption or analysis',
2928
+ inputSchema: {
2929
+ type: 'object',
2930
+ properties: {
2931
+ recentTurnCount: {
2932
+ type: 'number',
2933
+ description: 'Number of recent turns to include',
2934
+ default: 5,
2935
+ },
2936
+ },
2937
+ },
2938
+ },
2939
+ {
2940
+ name: 'get_memory_stats',
2941
+ description: 'Phase 3: Get statistics about stored conversation memory',
2942
+ inputSchema: {
2943
+ type: 'object',
2944
+ properties: {},
2945
+ },
2946
+ },
2947
+ {
2948
+ name: 'get_server_context',
2949
+ description: "Generate a comprehensive context file showing the server's current state, memory, and capabilities. Creates .mcp-server-context.md that can be @ referenced in conversations for instant LLM awareness",
2950
+ inputSchema: {
2951
+ type: 'object',
2952
+ properties: {
2953
+ writeToFile: {
2954
+ type: 'boolean',
2955
+ description: 'Whether to write the context to .mcp-server-context.md file',
2956
+ default: true,
2957
+ },
2958
+ outputPath: {
2959
+ type: 'string',
2960
+ description: 'Custom output path for the context file',
2961
+ },
2962
+ includeDetailed: {
2963
+ type: 'boolean',
2964
+ description: 'Include detailed information',
2965
+ default: true,
2966
+ },
2967
+ maxRecentItems: {
2968
+ type: 'number',
2969
+ description: 'Maximum number of recent items to show',
2970
+ default: 5,
2971
+ },
2972
+ },
2973
+ },
2974
+ },
2802
2975
  ],
2803
2976
  };
2804
2977
  });
2805
- // Tool execution handler
2978
+ /**
2979
+ * Call Tool Handler - MCP Protocol Endpoint
2980
+ *
2981
+ * @description Executes specific tools with provided arguments. This is the core
2982
+ * execution endpoint that routes tool calls to their respective implementations.
2983
+ * Includes comprehensive error handling, argument validation, and response masking.
2984
+ *
2985
+ * @param {CallToolRequest} request - MCP tool execution request
2986
+ * @param {string} request.params.name - Tool name to execute
2987
+ * @param {Object} request.params.arguments - Tool-specific arguments
2988
+ *
2989
+ * @returns {Promise<CallToolResult>} Tool execution result with content and metadata
2990
+ *
2991
+ * @throws {McpAdrError} When tool execution fails or arguments are invalid
2992
+ *
2993
+ * @example
2994
+ * ```typescript
2995
+ * // Execute research tool
2996
+ * const result = await mcpClient.callTool('perform_research', {
2997
+ * question: 'What authentication methods are used?',
2998
+ * projectPath: '/path/to/project'
2999
+ * });
3000
+ *
3001
+ * console.log(result.content); // Research findings
3002
+ * ```
3003
+ *
3004
+ * @example
3005
+ * ```typescript
3006
+ * // Execute ADR validation
3007
+ * const validation = await mcpClient.callTool('validate_adr', {
3008
+ * adrPath: 'docs/adrs/0001-auth-choice.md',
3009
+ * includeEnvironmentCheck: true
3010
+ * });
3011
+ *
3012
+ * console.log(validation.isValid); // true/false
3013
+ * console.log(validation.findings); // Validation issues
3014
+ * ```
3015
+ *
3016
+ * @mcp-endpoint
3017
+ * @category Tools
3018
+ * @category Execution
3019
+ */
2806
3020
  this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
2807
3021
  const { name, arguments: args } = request.params;
3022
+ // Create context for progress notifications and logging
3023
+ const context = {
3024
+ info: (message) => {
3025
+ this.logger.info(message);
3026
+ // Note: MCP progress notifications will be available in future SDK versions
3027
+ // For now, we log to server console for visibility
3028
+ },
3029
+ report_progress: (progress, total) => {
3030
+ const percentage = total ? Math.round((progress / total) * 100) : progress;
3031
+ this.logger.info(`Progress: ${percentage}%${total ? ` (${progress}/${total})` : ''}`);
3032
+ },
3033
+ warn: (message) => {
3034
+ this.logger.warn(message);
3035
+ },
3036
+ error: (message) => {
3037
+ this.logger.error(message);
3038
+ },
3039
+ };
2808
3040
  try {
2809
3041
  let response;
2810
3042
  const safeArgs = args || {};
2811
3043
  switch (name) {
2812
3044
  case 'analyze_project_ecosystem':
2813
- response = await this.analyzeProjectEcosystem(safeArgs);
3045
+ response = await this.analyzeProjectEcosystem(safeArgs, context);
2814
3046
  break;
2815
3047
  case 'get_architectural_context':
2816
3048
  response = await this.getArchitecturalContext(safeArgs);
2817
3049
  break;
2818
3050
  case 'generate_adrs_from_prd':
2819
- response = await this.generateAdrsFromPrd(safeArgs);
2820
- break;
2821
- case 'generate_adr_todo':
2822
- response = await this.generateAdrTodo(safeArgs);
3051
+ response = await this.generateAdrsFromPrd(safeArgs, context);
2823
3052
  break;
2824
3053
  case 'compare_adr_progress':
2825
3054
  response = await this.compareAdrProgress(safeArgs);
@@ -2854,8 +3083,14 @@ export class McpAdrAnalysisServer {
2854
3083
  case 'generate_adr_bootstrap':
2855
3084
  response = await this.generateAdrBootstrap(safeArgs);
2856
3085
  break;
3086
+ case 'bootstrap_validation_loop':
3087
+ response = await this.bootstrapValidationLoop(safeArgs);
3088
+ break;
2857
3089
  case 'discover_existing_adrs':
2858
- response = await this.discoverExistingAdrs(safeArgs);
3090
+ response = await this.discoverExistingAdrs(safeArgs, context);
3091
+ break;
3092
+ case 'analyze_adr_timeline':
3093
+ response = await this.analyzeAdrTimeline(safeArgs);
2859
3094
  break;
2860
3095
  case 'review_existing_adrs':
2861
3096
  response = await this.reviewExistingAdrs(safeArgs);
@@ -2891,7 +3126,16 @@ export class McpAdrAnalysisServer {
2891
3126
  response = await this.generateResearchQuestions(safeArgs);
2892
3127
  break;
2893
3128
  case 'perform_research':
2894
- response = await this.performResearch(safeArgs);
3129
+ response = await this.performResearch(safeArgs, context);
3130
+ break;
3131
+ case 'llm_web_search':
3132
+ response = await this.llmWebSearch(safeArgs);
3133
+ break;
3134
+ case 'llm_cloud_management':
3135
+ response = await this.llmCloudManagement(safeArgs);
3136
+ break;
3137
+ case 'llm_database_management':
3138
+ response = await this.llmDatabaseManagement(safeArgs);
2895
3139
  break;
2896
3140
  case 'analyze_deployment_progress':
2897
3141
  response = await this.analyzeDeploymentProgress(safeArgs);
@@ -2905,18 +3149,26 @@ export class McpAdrAnalysisServer {
2905
3149
  case 'get_development_guidance':
2906
3150
  response = await this.getDevelopmentGuidance(safeArgs);
2907
3151
  break;
2908
- case 'read_file':
2909
- response = await this.readFile(safeArgs);
3152
+ case 'list_roots':
3153
+ response = await this.listRoots();
3154
+ break;
3155
+ case 'read_directory':
3156
+ response = await this.readDirectory(safeArgs);
2910
3157
  break;
3158
+ case 'read_file': {
3159
+ // Map 'path' parameter to 'filePath' for compatibility
3160
+ const readFileArgs = safeArgs;
3161
+ response = await this.readFile({
3162
+ filePath: readFileArgs.filePath || readFileArgs.path || '',
3163
+ });
3164
+ break;
3165
+ }
2911
3166
  case 'write_file':
2912
3167
  response = await this.writeFile(safeArgs);
2913
3168
  break;
2914
3169
  case 'list_directory':
2915
3170
  response = await this.listDirectory(safeArgs);
2916
3171
  break;
2917
- case 'manage_todo_json':
2918
- response = await this.manageTodoJson(safeArgs);
2919
- break;
2920
3172
  case 'generate_deployment_guidance':
2921
3173
  response = await this.generateDeploymentGuidance(safeArgs);
2922
3174
  break;
@@ -2938,19 +3190,38 @@ export class McpAdrAnalysisServer {
2938
3190
  case 'memory_loading':
2939
3191
  response = await this.memoryLoading(safeArgs);
2940
3192
  break;
3193
+ case 'expand_analysis_section':
3194
+ response = await this.expandAnalysisSection(safeArgs);
3195
+ break;
2941
3196
  case 'interactive_adr_planning':
2942
3197
  response = await this.interactiveAdrPlanning(safeArgs);
2943
3198
  break;
2944
3199
  case 'tool_chain_orchestrator':
2945
3200
  response = await this.toolChainOrchestrator(safeArgs);
2946
3201
  break;
3202
+ case 'expand_memory':
3203
+ response = await this.expandMemory(safeArgs);
3204
+ break;
3205
+ case 'query_conversation_history':
3206
+ response = await this.queryConversationHistory(safeArgs);
3207
+ break;
3208
+ case 'get_conversation_snapshot':
3209
+ response = await this.getConversationSnapshot(safeArgs);
3210
+ break;
3211
+ case 'get_memory_stats':
3212
+ response = await this.getMemoryStats();
3213
+ break;
3214
+ case 'get_server_context':
3215
+ response = await this.getServerContext(safeArgs);
3216
+ break;
2947
3217
  default:
2948
3218
  throw new McpAdrError(`Unknown tool: ${name}`, 'UNKNOWN_TOOL');
2949
3219
  }
2950
- // Apply content masking to response
2951
3220
  // Track tool execution in knowledge graph
2952
3221
  await this.trackToolExecution(name, args, response, true);
2953
- return await this.applyOutputMasking(response);
3222
+ // Apply state reinforcement (Phase 2: Context Decay Mitigation) and content masking
3223
+ // Also record conversation turn (Phase 3: Structured External Memory)
3224
+ return await this.enrichResponseWithStateReinforcement(response, name, args);
2954
3225
  }
2955
3226
  catch (error) {
2956
3227
  // Track failed execution
@@ -2961,67 +3232,312 @@ export class McpAdrAnalysisServer {
2961
3232
  throw new McpAdrError(`Tool execution failed: ${error instanceof Error ? error.message : String(error)}`, 'TOOL_EXECUTION_ERROR');
2962
3233
  }
2963
3234
  });
2964
- // Resources handler
3235
+ /**
3236
+ * List Resources Handler - MCP Protocol Endpoint
3237
+ *
3238
+ * @description Returns available resources for client access including the
3239
+ * architectural knowledge graph and project analysis data. Resources provide
3240
+ * read-only access to server-managed data structures.
3241
+ *
3242
+ * @returns {Promise<{resources: Array}>} Available resources with URIs and descriptions
3243
+ *
3244
+ * @example
3245
+ * ```typescript
3246
+ * // List available resources
3247
+ * const resources = await mcpClient.listResources();
3248
+ * console.log(resources.resources.length); // Available resources
3249
+ *
3250
+ * // Find knowledge graph resource
3251
+ * const kgResource = resources.resources.find(r =>
3252
+ * r.uri === 'adr://architectural_knowledge_graph'
3253
+ * );
3254
+ * console.log(kgResource.name); // "Architectural Knowledge Graph"
3255
+ * ```
3256
+ *
3257
+ * @mcp-endpoint
3258
+ * @category Resources
3259
+ */
2965
3260
  this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
2966
3261
  return {
2967
3262
  resources: [
3263
+ // Existing resources (refactored to return data)
2968
3264
  {
2969
3265
  uri: 'adr://architectural_knowledge_graph',
2970
3266
  name: 'Architectural Knowledge Graph',
2971
- description: 'Complete architectural knowledge graph of the project',
3267
+ description: 'Complete architectural knowledge graph with technologies, patterns, and relationships',
2972
3268
  mimeType: 'application/json',
2973
3269
  },
2974
3270
  {
2975
3271
  uri: 'adr://analysis_report',
2976
3272
  name: 'Analysis Report',
2977
- description: 'Comprehensive project analysis report',
3273
+ description: 'Comprehensive project analysis report with metrics and recommendations',
2978
3274
  mimeType: 'application/json',
2979
3275
  },
2980
3276
  {
2981
3277
  uri: 'adr://adr_list',
2982
3278
  name: 'ADR List',
2983
- description: 'List of all Architectural Decision Records',
3279
+ description: 'List of all Architectural Decision Records with status and metadata',
2984
3280
  mimeType: 'application/json',
2985
3281
  },
2986
- ],
2987
- };
2988
- });
2989
- // Resource reading handler
2990
- this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
2991
- const { uri } = request.params;
2992
- try {
2993
- const response = await this.readResource(uri);
2994
- return await this.applyOutputMasking(response);
2995
- }
2996
- catch (error) {
2997
- if (error instanceof McpAdrError) {
2998
- throw error;
2999
- }
3000
- throw new McpAdrError(`Resource reading failed: ${error instanceof Error ? error.message : String(error)}`, 'RESOURCE_ERROR');
3001
- }
3002
- });
3003
- // Prompts handler
3004
- this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
3005
- const { allPrompts } = await import('./prompts/index.js');
3006
- return {
3007
- prompts: allPrompts.map(prompt => ({
3008
- name: prompt.name,
3009
- description: prompt.description,
3010
- arguments: prompt.arguments,
3011
- })),
3012
- };
3013
- });
3014
- // Prompt execution handler
3015
- this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
3016
- const { name, arguments: args } = request.params;
3017
- try {
3018
- const { allPrompts } = await import('./prompts/index.js');
3019
- const prompt = allPrompts.find(p => p.name === name);
3020
- if (!prompt) {
3021
- throw new McpAdrError(`Unknown prompt: ${name}`, 'UNKNOWN_PROMPT');
3022
- }
3023
- // Simple template rendering (replace {{variable}} with values)
3024
- let renderedTemplate = prompt.template;
3282
+ // NEW Phase 1 Resources
3283
+ {
3284
+ uri: 'adr://todo_list',
3285
+ name: 'Todo List',
3286
+ description: 'Current project task list with status, priorities, and dependencies',
3287
+ mimeType: 'application/json',
3288
+ },
3289
+ {
3290
+ uri: 'adr://research_index',
3291
+ name: 'Research Index',
3292
+ description: 'Index of all research documents and findings with metadata',
3293
+ mimeType: 'application/json',
3294
+ },
3295
+ {
3296
+ uri: 'adr://rule_catalog',
3297
+ name: 'Rule Catalog',
3298
+ description: 'Catalog of all architectural and validation rules from ADRs and code',
3299
+ mimeType: 'application/json',
3300
+ },
3301
+ {
3302
+ uri: 'adr://rule_generation',
3303
+ name: 'Rule Generation',
3304
+ description: 'AI-powered rule generation from ADRs and code patterns. Supports query parameters: ?operation=generate|validate|create_set, ?source=adrs|patterns|both, ?knowledge=true|false, ?enhanced=true|false, ?format=json|yaml|both, ?comprehensive=true|false',
3305
+ mimeType: 'application/json',
3306
+ },
3307
+ {
3308
+ uri: 'adr://project_status',
3309
+ name: 'Project Status',
3310
+ description: 'Current project status and health metrics aggregated from all sources',
3311
+ mimeType: 'application/json',
3312
+ },
3313
+ // NEW Phase 2 Templated Resources
3314
+ {
3315
+ uri: 'adr://adr/{id}',
3316
+ name: 'ADR by ID',
3317
+ description: 'Individual Architectural Decision Record by ID or title match',
3318
+ mimeType: 'application/json',
3319
+ },
3320
+ {
3321
+ uri: 'adr://research/{topic}',
3322
+ name: 'Research by Topic',
3323
+ description: 'Research documents filtered by topic with full content',
3324
+ mimeType: 'application/json',
3325
+ },
3326
+ {
3327
+ uri: 'adr://todo/{task_id}',
3328
+ name: 'Todo by Task ID',
3329
+ description: 'Individual task details by ID or title match with dependencies and history',
3330
+ mimeType: 'application/json',
3331
+ },
3332
+ {
3333
+ uri: 'adr://rule/{rule_id}',
3334
+ name: 'Rule by ID',
3335
+ description: 'Individual architectural rule by ID or name match with violations and usage stats',
3336
+ mimeType: 'application/json',
3337
+ },
3338
+ // NEW Phase 3 Advanced Resources
3339
+ {
3340
+ uri: 'adr://deployment_status',
3341
+ name: 'Deployment Status',
3342
+ description: 'Current deployment state with health checks, build status, and readiness score',
3343
+ mimeType: 'application/json',
3344
+ },
3345
+ {
3346
+ uri: 'adr://environment_analysis',
3347
+ name: 'Environment Analysis',
3348
+ description: 'System environment details including platform, dependencies, and capabilities',
3349
+ mimeType: 'application/json',
3350
+ },
3351
+ {
3352
+ uri: 'adr://memory_snapshots',
3353
+ name: 'Memory Snapshots',
3354
+ description: 'Knowledge graph snapshots with statistics, insights, and relationship data',
3355
+ mimeType: 'application/json',
3356
+ },
3357
+ {
3358
+ uri: 'adr://project_metrics',
3359
+ name: 'Project Metrics',
3360
+ description: 'Code metrics and quality scores including codebase stats, quality assessment, and git metrics',
3361
+ mimeType: 'application/json',
3362
+ },
3363
+ {
3364
+ uri: 'adr://technology/{name}',
3365
+ name: 'Technology by Name',
3366
+ description: 'Individual technology analysis by name with usage, relationships, and adoption status',
3367
+ mimeType: 'application/json',
3368
+ },
3369
+ {
3370
+ uri: 'adr://pattern/{name}',
3371
+ name: 'Pattern by Name',
3372
+ description: 'Individual pattern analysis by name with quality metrics, relationships, and examples',
3373
+ mimeType: 'application/json',
3374
+ },
3375
+ // NEW Phase 4 Final Resources
3376
+ {
3377
+ uri: 'adr://deployment_history',
3378
+ name: 'Deployment History',
3379
+ description: 'Historical deployment data with trends, failure analysis, and patterns. Supports query parameters: ?period=7d|30d|90d|1y|all, ?environment=production|staging|development|all, ?includeFailures=true|false, ?includeMetrics=true|false, ?format=summary|detailed',
3380
+ mimeType: 'application/json',
3381
+ },
3382
+ {
3383
+ uri: 'adr://code_quality',
3384
+ name: 'Code Quality',
3385
+ description: 'Comprehensive code quality assessment with metrics, issues, and recommendations. Supports query parameters: ?scope=full|changes|critical, ?includeMetrics=true|false, ?includeRecommendations=true|false, ?threshold=0-100, ?format=summary|detailed',
3386
+ mimeType: 'application/json',
3387
+ },
3388
+ // NEW Phase 5 Validated Pattern Resources
3389
+ {
3390
+ uri: 'adr://validated_patterns',
3391
+ name: 'Validated Patterns Catalog',
3392
+ description: 'Complete catalog of validated deployment patterns for different platforms (OpenShift, Kubernetes, Docker, Node.js, Python, MCP, A2A) with bill of materials, deployment phases, validation checks, and authoritative sources',
3393
+ mimeType: 'application/json',
3394
+ },
3395
+ {
3396
+ uri: 'adr://validated_pattern/{platform}',
3397
+ name: 'Validated Pattern by Platform',
3398
+ description: 'Individual validated pattern by platform type (openshift, kubernetes, docker, nodejs, python, mcp, a2a) with complete bill of materials, deployment phases, validation checks, health checks, and authoritative sources for LLM research',
3399
+ mimeType: 'application/json',
3400
+ },
3401
+ {
3402
+ uri: 'adr://pattern_sources/{platform}',
3403
+ name: 'Pattern Authoritative Sources',
3404
+ description: 'Authoritative documentation and repository sources for a specific platform pattern, prioritized by importance with query instructions for LLMs',
3405
+ mimeType: 'application/json',
3406
+ },
3407
+ {
3408
+ uri: 'adr://pattern_base_code/{platform}',
3409
+ name: 'Pattern Base Code Repository',
3410
+ description: 'Base code repository information for a platform pattern including URL, integration instructions, required files, and script entrypoint',
3411
+ mimeType: 'application/json',
3412
+ },
3413
+ ],
3414
+ };
3415
+ });
3416
+ /**
3417
+ * Read Resource Handler - MCP Protocol Endpoint
3418
+ *
3419
+ * @description Reads specific resource content by URI. Provides access to
3420
+ * architectural knowledge graphs, project analysis data, and other server-managed
3421
+ * resources with appropriate content masking applied.
3422
+ *
3423
+ * @param {ReadResourceRequest} request - MCP resource read request
3424
+ * @param {string} request.params.uri - Resource URI to read
3425
+ *
3426
+ * @returns {Promise<ReadResourceResult>} Resource content with metadata
3427
+ *
3428
+ * @throws {McpAdrError} When resource URI is invalid or access fails
3429
+ *
3430
+ * @example
3431
+ * ```typescript
3432
+ * // Read knowledge graph resource
3433
+ * const kgData = await mcpClient.readResource(
3434
+ * 'adr://architectural_knowledge_graph'
3435
+ * );
3436
+ * console.log(kgData.contents); // Knowledge graph JSON
3437
+ * ```
3438
+ *
3439
+ * @mcp-endpoint
3440
+ * @category Resources
3441
+ */
3442
+ this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
3443
+ const { uri } = request.params;
3444
+ try {
3445
+ const response = await this.readResource(uri);
3446
+ return await this.applyOutputMasking(response);
3447
+ }
3448
+ catch (error) {
3449
+ if (error instanceof McpAdrError) {
3450
+ throw error;
3451
+ }
3452
+ throw new McpAdrError(`Resource reading failed: ${error instanceof Error ? error.message : String(error)}`, 'RESOURCE_ERROR');
3453
+ }
3454
+ });
3455
+ /**
3456
+ * List Prompts Handler - MCP Protocol Endpoint
3457
+ *
3458
+ * @description Returns available prompt templates for ADR analysis, research,
3459
+ * and architectural decision support. Prompts can be executed directly or
3460
+ * used as templates for custom implementations.
3461
+ *
3462
+ * @returns {Promise<{prompts: Array}>} Available prompt templates with metadata
3463
+ *
3464
+ * @example
3465
+ * ```typescript
3466
+ * // List available prompts
3467
+ * const prompts = await mcpClient.listPrompts();
3468
+ * console.log(prompts.prompts.length); // Available prompt templates
3469
+ *
3470
+ * // Find ADR analysis prompt
3471
+ * const adrPrompt = prompts.prompts.find(p =>
3472
+ * p.name === 'adr_analysis_prompt'
3473
+ * );
3474
+ * console.log(adrPrompt.description); // Prompt description
3475
+ * ```
3476
+ *
3477
+ * @mcp-endpoint
3478
+ * @category Prompts
3479
+ */
3480
+ this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
3481
+ const { allPrompts } = await import('./prompts/index.js');
3482
+ return {
3483
+ prompts: allPrompts.map(prompt => ({
3484
+ name: prompt.name,
3485
+ description: prompt.description,
3486
+ arguments: prompt.arguments,
3487
+ })),
3488
+ };
3489
+ });
3490
+ /**
3491
+ * Get Prompt Handler - MCP Protocol Endpoint
3492
+ *
3493
+ * @description Executes specific prompt templates with provided arguments.
3494
+ * Returns formatted prompts ready for AI execution or further processing.
3495
+ * Supports dynamic argument injection and template customization.
3496
+ *
3497
+ * @param {GetPromptRequest} request - MCP prompt execution request
3498
+ * @param {string} request.params.name - Prompt template name
3499
+ * @param {Object} request.params.arguments - Template-specific arguments
3500
+ *
3501
+ * @returns {Promise<GetPromptResult>} Formatted prompt with metadata
3502
+ *
3503
+ * @throws {McpAdrError} When prompt template is not found or arguments are invalid
3504
+ *
3505
+ * @example
3506
+ * ```typescript
3507
+ * // Execute ADR analysis prompt
3508
+ * const prompt = await mcpClient.getPrompt('adr_analysis_prompt', {
3509
+ * adrPath: 'docs/adrs/0001-auth.md',
3510
+ * projectContext: 'microservices architecture'
3511
+ * });
3512
+ *
3513
+ * console.log(prompt.messages); // Formatted prompt messages
3514
+ * ```
3515
+ *
3516
+ * @example
3517
+ * ```typescript
3518
+ * // Execute research prompt
3519
+ * const researchPrompt = await mcpClient.getPrompt('research_question_prompt', {
3520
+ * domain: 'authentication',
3521
+ * complexity: 'advanced'
3522
+ * });
3523
+ *
3524
+ * console.log(researchPrompt.messages[0].content); // Research prompt
3525
+ * ```
3526
+ *
3527
+ * @mcp-endpoint
3528
+ * @category Prompts
3529
+ * @category Execution
3530
+ */
3531
+ this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
3532
+ const { name, arguments: args } = request.params;
3533
+ try {
3534
+ const { allPrompts } = await import('./prompts/index.js');
3535
+ const prompt = allPrompts.find(p => p.name === name);
3536
+ if (!prompt) {
3537
+ throw new McpAdrError(`Unknown prompt: ${name}`, 'UNKNOWN_PROMPT');
3538
+ }
3539
+ // Simple template rendering (replace {{variable}} with values)
3540
+ let renderedTemplate = prompt.template;
3025
3541
  if (args) {
3026
3542
  for (const [key, value] of Object.entries(args)) {
3027
3543
  const regex = new RegExp(`{{${key}}}`, 'g');
@@ -3179,18 +3695,17 @@ Verify these environment variables are set in your MCP configuration:
3179
3695
  5. **suggest_adrs** - Auto-suggest ADRs from implicit decisions
3180
3696
  6. **generate_adr_from_decision** - Create ADRs from specific decisions
3181
3697
  7. **discover_existing_adrs** - Intelligent ADR discovery and analysis
3182
- 8. **generate_adr_todo** - Create actionable task lists from ADRs
3183
3698
 
3184
3699
  ### 🔍 **Research & Documentation Tools** (AI-Powered ✅)
3185
- 9. **generate_research_questions** - Create context-aware research questions
3186
- 10. **incorporate_research** - Integrate research findings into decisions
3187
- 11. **create_research_template** - Generate research documentation templates
3700
+ 8. **generate_research_questions** - Create context-aware research questions
3701
+ 9. **incorporate_research** - Integrate research findings into decisions
3702
+ 10. **create_research_template** - Generate research documentation templates
3188
3703
 
3189
3704
  ### 🛡️ **Security & Compliance Tools** (AI-Powered ✅)
3190
- 12. **generate_content_masking** - Intelligent content masking and protection
3191
- 13. **configure_custom_patterns** - Customize security and masking settings
3192
- 14. **apply_basic_content_masking** - Basic content masking (fallback)
3193
- 15. **validate_content_masking** - Validate masking effectiveness
3705
+ 11. **generate_content_masking** - Intelligent content masking and protection
3706
+ 12. **configure_custom_patterns** - Customize security and masking settings
3707
+ 13. **apply_basic_content_masking** - Basic content masking (fallback)
3708
+ 14. **validate_content_masking** - Validate masking effectiveness
3194
3709
 
3195
3710
  ### 🏗️ **Rule & Governance Tools** (AI-Powered ✅)
3196
3711
  16. **generate_rules** - Extract architectural rules from ADRs
@@ -3248,13 +3763,13 @@ Define how to measure success:
3248
3763
  1. analyze_project_ecosystem → 2. get_architectural_context → 3. suggest_adrs → 4. generate_adr_from_decision
3249
3764
 
3250
3765
  ### **Existing Project Analysis**
3251
- 1. discover_existing_adrs → 2. get_architectural_context → 3. generate_adr_todo → 4. validate_rules
3766
+ 1. discover_existing_adrs → 2. get_architectural_context → 3. validate_rules
3252
3767
 
3253
3768
  ### **Security Audit**
3254
3769
  1. analyze_content_security → 2. generate_content_masking → 3. configure_custom_patterns → 4. validate_content_masking
3255
3770
 
3256
3771
  ### **PRD to Implementation**
3257
- 1. generate_adrs_from_prd → 2. generate_adr_todo → 3. analyze_deployment_progress
3772
+ 1. generate_adrs_from_prd → 2. analyze_deployment_progress
3258
3773
 
3259
3774
  ### **Legacy Modernization**
3260
3775
  1. analyze_project_ecosystem → 2. get_architectural_context → 3. suggest_adrs → 4. generate_rules → 5. validate_rules
@@ -3302,7 +3817,7 @@ ${executionResult.content}
3302
3817
  ## Quick Reference: Available Tools
3303
3818
 
3304
3819
  **Core Analysis**: analyze_project_ecosystem, get_architectural_context, generate_adrs_from_prd, analyze_content_security
3305
- **ADR Management**: suggest_adrs, generate_adr_from_decision, discover_existing_adrs, generate_adr_todo
3820
+ **ADR Management**: suggest_adrs, generate_adr_from_decision, discover_existing_adrs
3306
3821
  **Security**: generate_content_masking, configure_custom_patterns, validate_content_masking
3307
3822
  **Governance**: generate_rules, validate_rules, create_rule_set
3308
3823
  **Environment**: analyze_environment, analyze_deployment_progress
@@ -3345,7 +3860,10 @@ This guidance is tailored to your specific context and goals for maximum effecti
3345
3860
  const { getAdrDirectoryPath } = await import('./utils/config.js');
3346
3861
  const { discoverAdrsInDirectory } = await import('./utils/adr-discovery.js');
3347
3862
  const absoluteAdrPath = getAdrDirectoryPath(this.config);
3348
- const discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, true, this.config.projectPath);
3863
+ const discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, this.config.projectPath, {
3864
+ includeContent: true,
3865
+ includeTimeline: false,
3866
+ });
3349
3867
  // Filter ADRs to only those specified for implementation
3350
3868
  const targetAdrs = discoveryResult.adrs.filter(adr => adrsToImplement.some((target) => adr.title.toLowerCase().includes(target.toLowerCase()) ||
3351
3869
  adr.filename.toLowerCase().includes(target.toLowerCase())));
@@ -3540,7 +4058,6 @@ This development guidance works seamlessly with other MCP tools:
3540
4058
  - **analyze_content_security** → Security validation during development
3541
4059
 
3542
4060
  ### **Documentation Tools**
3543
- - **generate_adr_todo** → Create implementation task lists
3544
4061
  - **discover_existing_adrs** → Reference existing architectural decisions
3545
4062
 
3546
4063
  ## Next Steps: From Architecture to Code
@@ -3571,7 +4088,8 @@ This guidance ensures your development work is **architecturally aligned**, **qu
3571
4088
  throw new McpAdrError(`Failed to generate development guidance: ${error instanceof Error ? error.message : String(error)}`, 'DEVELOPMENT_ERROR');
3572
4089
  }
3573
4090
  }
3574
- async analyzeProjectEcosystem(args) {
4091
+ async analyzeProjectEcosystem(args, context) {
4092
+ const ctx = context || createNoOpContext();
3575
4093
  // Use configured project path if not provided in args
3576
4094
  const projectPath = args.projectPath || this.config.projectPath;
3577
4095
  const { includePatterns, enhancedMode = true, knowledgeEnhancement = true, learningEnabled = true, technologyFocus = [], analysisDepth = 'comprehensive', includeEnvironment = true, recursiveDepth = 'comprehensive', analysisScope = [],
@@ -3581,9 +4099,38 @@ This guidance ensures your development work is **architecturally aligned**, **qu
3581
4099
  this.logger.info(`Analysis configuration - Depth: ${analysisDepth}, Recursive: ${recursiveDepth}, Environment: ${includeEnvironment}`);
3582
4100
  this.logger.info(`Enhancement features - Knowledge: ${knowledgeEnhancement}, Learning: ${learningEnabled}`);
3583
4101
  this.logger.info(`Analysis scope: ${analysisScope.length > 0 ? analysisScope.join(', ') : 'Full ecosystem analysis'}`);
4102
+ ctx.info(`🌐 Starting comprehensive ecosystem analysis: ${projectPath}`);
4103
+ ctx.report_progress(0, 100);
3584
4104
  try {
4105
+ ctx.info('📊 Phase 1: Analyzing project structure');
4106
+ ctx.report_progress(10, 100);
3585
4107
  // Import utilities dynamically to avoid circular dependencies
3586
4108
  const { analyzeProjectStructureCompat: analyzeProjectStructure } = await import('./utils/file-system.js');
4109
+ // Initialize ADR knowledge base on first run
4110
+ ctx.info('📚 Phase 1.5: Initializing ADR knowledge base');
4111
+ ctx.report_progress(15, 100);
4112
+ try {
4113
+ const { initializeAdrKnowledgeBase, isAdrKnowledgeBaseInitialized } = await import('./utils/adr-knowledge-initializer.js');
4114
+ const isInitialized = await isAdrKnowledgeBaseInitialized(this.kgManager);
4115
+ if (!isInitialized) {
4116
+ this.logger.info('First run detected - initializing ADR knowledge base');
4117
+ const initResult = await initializeAdrKnowledgeBase(this.kgManager, this.config.adrDirectory, projectPath);
4118
+ if (initResult.success) {
4119
+ this.logger.info(`✅ ADR knowledge base initialized with ${initResult.adrsIndexed} ADRs`);
4120
+ ctx.info(`📚 Indexed ${initResult.adrsIndexed} existing ADRs to knowledge base`);
4121
+ }
4122
+ else {
4123
+ this.logger.warn(`ADR knowledge base initialization completed with errors: ${initResult.errors.join(', ')}`);
4124
+ }
4125
+ }
4126
+ else {
4127
+ this.logger.info('ADR knowledge base already initialized - skipping');
4128
+ }
4129
+ }
4130
+ catch (error) {
4131
+ this.logger.warn('Failed to initialize ADR knowledge base:', error);
4132
+ // Don't fail the entire analysis if ADR initialization fails
4133
+ }
3587
4134
  // Import advanced prompting utilities if enhanced mode is enabled
3588
4135
  let generateArchitecturalKnowledge = null;
3589
4136
  let executeWithReflexion = null;
@@ -3602,6 +4149,8 @@ This guidance ensures your development work is **architecturally aligned**, **qu
3602
4149
  }
3603
4150
  }
3604
4151
  // Step 1: Generate technology-specific knowledge if enabled
4152
+ ctx.info('🧠 Phase 2: Generating architectural knowledge');
4153
+ ctx.report_progress(25, 100);
3605
4154
  let knowledgeContext = '';
3606
4155
  if (enhancedMode && knowledgeEnhancement && generateArchitecturalKnowledge) {
3607
4156
  try {
@@ -3652,8 +4201,12 @@ ${memoryResult.prompt}
3652
4201
  }
3653
4202
  }
3654
4203
  // Step 3: Generate base project analysis prompt with recursive depth
4204
+ ctx.info('📁 Phase 3: Scanning project files and structure');
4205
+ ctx.report_progress(40, 100);
3655
4206
  const baseProjectAnalysisPrompt = await analyzeProjectStructure(projectPath);
3656
4207
  // Step 4: Generate environment analysis if enabled
4208
+ ctx.info('🔧 Phase 4: Analyzing environment and infrastructure');
4209
+ ctx.report_progress(55, 100);
3657
4210
  let environmentAnalysisContext = '';
3658
4211
  if (includeEnvironment) {
3659
4212
  try {
@@ -3687,6 +4240,8 @@ ${environmentResult.content[0].text}
3687
4240
  }
3688
4241
  }
3689
4242
  // Step 5: Apply Reflexion execution if learning is enabled
4243
+ ctx.info('🧪 Phase 5: Applying learning and reflexion');
4244
+ ctx.report_progress(70, 100);
3690
4245
  let enhancedAnalysisPrompt = baseProjectAnalysisPrompt.prompt + environmentAnalysisContext;
3691
4246
  if (enhancedMode && learningEnabled && executeWithReflexion && createToolReflexionConfig) {
3692
4247
  try {
@@ -3723,6 +4278,8 @@ ${environmentResult.content[0].text}
3723
4278
  baseProjectAnalysisPrompt.prompt + knowledgeContext + environmentAnalysisContext;
3724
4279
  }
3725
4280
  // Execute the analysis with AI if enabled, otherwise return prompt
4281
+ ctx.info('🤖 Phase 6: Executing AI-powered ecosystem analysis');
4282
+ ctx.report_progress(85, 100);
3726
4283
  const { executeEcosystemAnalysisPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
3727
4284
  const executionResult = await executeEcosystemAnalysisPrompt(enhancedAnalysisPrompt, baseProjectAnalysisPrompt.instructions, {
3728
4285
  temperature: 0.1,
@@ -3748,6 +4305,8 @@ ${environmentResult.content[0].text}
3748
4305
  this.logger.warn('Failed to record project structure to knowledge graph:', kgError);
3749
4306
  // Don't fail the entire analysis if KG recording fails
3750
4307
  }
4308
+ ctx.info('✅ Ecosystem analysis completed successfully');
4309
+ ctx.report_progress(100, 100);
3751
4310
  // Return appropriate response based on execution result
3752
4311
  if (executionResult.isAIGenerated) {
3753
4312
  // AI execution successful - return actual analysis results
@@ -4137,16 +4696,24 @@ This **outcome-focused approach** ensures architectural work delivers **measurab
4137
4696
  throw new McpAdrError(`Failed to get architectural context: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
4138
4697
  }
4139
4698
  }
4140
- async generateAdrsFromPrd(args) {
4699
+ async generateAdrsFromPrd(args, context) {
4700
+ const ctx = context || createNoOpContext();
4141
4701
  const { prdPath, enhancedMode = true, promptOptimization = true, knowledgeEnhancement = true, prdType = 'general', } = args;
4142
4702
  const outputDirectory = args['outputDirectory'] || this.config.adrDirectory;
4143
4703
  this.logger.info(`Generating enhanced ADRs from PRD: ${prdPath} to ${outputDirectory}`);
4144
4704
  this.logger.info(`Enhancement features - APE: ${promptOptimization}, Knowledge: ${knowledgeEnhancement}, Type: ${prdType}`);
4705
+ ctx.info(`📝 Starting ADR generation from PRD: ${prdPath}`);
4706
+ ctx.report_progress(0, 100);
4145
4707
  try {
4708
+ ctx.info('📂 Phase 1: Validating PRD file');
4709
+ ctx.report_progress(10, 100);
4146
4710
  const { readFileContentCompat: readFileContent, fileExistsCompat: fileExists } = await import('./utils/file-system.js');
4147
4711
  // Import advanced prompting utilities if enhanced mode is enabled
4712
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4148
4713
  let generateArchitecturalKnowledge = null;
4714
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4149
4715
  let optimizePromptWithAPE = null;
4716
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4150
4717
  let createToolAPEConfig = null;
4151
4718
  if (enhancedMode) {
4152
4719
  if (knowledgeEnhancement) {
@@ -4163,7 +4730,11 @@ This **outcome-focused approach** ensures architectural work delivers **measurab
4163
4730
  const fileExistsPrompt = await fileExists(prdPath);
4164
4731
  // Generate file content reading prompt
4165
4732
  const fileContentPrompt = await readFileContent(prdPath);
4733
+ ctx.info('📚 Phase 2: Reading PRD content');
4734
+ ctx.report_progress(25, 100);
4166
4735
  // Step 1: Generate domain-specific knowledge if enabled
4736
+ ctx.info('🧠 Phase 3: Generating domain knowledge');
4737
+ ctx.report_progress(40, 100);
4167
4738
  let knowledgeContext = '';
4168
4739
  if (enhancedMode && knowledgeEnhancement && generateArchitecturalKnowledge) {
4169
4740
  try {
@@ -4194,8 +4765,12 @@ ${knowledgeResult.prompt}
4194
4765
  }
4195
4766
  }
4196
4767
  // Step 2: Create base ADR generation prompt
4768
+ ctx.info('📋 Phase 4: Creating base ADR prompts');
4769
+ ctx.report_progress(60, 100);
4197
4770
  const baseAdrPrompt = this.createBaseAdrPrompt(prdPath, outputDirectory, knowledgeContext);
4198
4771
  // Step 3: Apply APE optimization if enabled
4772
+ ctx.info('⚡ Phase 5: Optimizing prompts with APE');
4773
+ ctx.report_progress(75, 100);
4199
4774
  let finalAdrPrompt = baseAdrPrompt;
4200
4775
  if (enhancedMode && promptOptimization && optimizePromptWithAPE && createToolAPEConfig) {
4201
4776
  try {
@@ -4274,6 +4849,8 @@ For each generated ADR, create a file creation prompt using the following patter
4274
4849
  - Confirm all decisions are traceable back to PRD requirements with domain context
4275
4850
  `;
4276
4851
  // Execute the ADR generation with AI if enabled, otherwise return prompt
4852
+ ctx.info('🤖 Phase 6: Executing AI-powered ADR generation');
4853
+ ctx.report_progress(90, 100);
4277
4854
  const { executeADRGenerationPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
4278
4855
  const executionResult = await executeADRGenerationPrompt(adrPrompt, 'Generate comprehensive ADRs from PRD analysis with enhanced domain knowledge and optimization', {
4279
4856
  temperature: 0.1,
@@ -4282,6 +4859,8 @@ For each generated ADR, create a file creation prompt using the following patter
4282
4859
  Generate well-structured ADRs that follow best practices and include all necessary sections.
4283
4860
  Focus on extracting architectural decisions from the PRD and creating actionable ADRs with clear reasoning.`,
4284
4861
  });
4862
+ ctx.info('✅ ADR generation completed successfully');
4863
+ ctx.report_progress(100, 100);
4285
4864
  if (executionResult.isAIGenerated) {
4286
4865
  // AI execution successful - return actual ADR generation results
4287
4866
  return formatMCPResponse({
@@ -4407,109 +4986,6 @@ The enhanced process maintains full traceability from PRD requirements to genera
4407
4986
  throw new McpAdrError(`Failed to generate ADR prompts from PRD: ${error instanceof Error ? error.message : String(error)}`, 'PROMPT_GENERATION_ERROR');
4408
4987
  }
4409
4988
  }
4410
- async generateAdrTodo(args) {
4411
- const { scope = 'all', phase = 'both', linkAdrs = true, includeRules = true, ruleSource = 'both', preserveExisting = true, forceSyncToMarkdown = false, intentId, createJsonBackup = true, } = args;
4412
- const { getAdrDirectoryPath } = await import('./utils/config.js');
4413
- const path = await import('path');
4414
- // Use absolute ADR path relative to project
4415
- const absoluteAdrPath = args['adrDirectory']
4416
- ? path.resolve(this.config.projectPath, args['adrDirectory'])
4417
- : getAdrDirectoryPath(this.config);
4418
- // Keep relative path for display purposes
4419
- const adrDirectory = args['adrDirectory'] || this.config.adrDirectory;
4420
- this.logger.info(`Generating JSON-first TODO for ADRs in: ${absoluteAdrPath} (phase: ${phase})`);
4421
- try {
4422
- // Always use JSON-first TODO system
4423
- this.logger.info('Using JSON-first TODO system for ADR task generation');
4424
- // TODO management has been deprecated and moved to mcp-shrimp-task-manager
4425
- this.logger.warn('⚠️ TODO management has been deprecated - use mcp-shrimp-task-manager instead');
4426
- // Optional: Create backup if requested and JSON exists
4427
- if (createJsonBackup) {
4428
- try {
4429
- this.logger.info('Backup feature deprecated - use mcp-shrimp-task-manager for task management');
4430
- }
4431
- catch {
4432
- // Continue if backup fails - might be first time setup
4433
- this.logger.debug('No existing JSON data to backup');
4434
- }
4435
- }
4436
- // Import ADR tasks into JSON system has been deprecated
4437
- const importResult = {
4438
- content: [
4439
- {
4440
- type: 'text',
4441
- text: `⚠️ **TODO Management Deprecated**
4442
-
4443
- This feature has been moved to mcp-shrimp-task-manager.
4444
-
4445
- **Replacement:** Use the external \`mcp-shrimp-task-manager\` for:
4446
- - Task planning and breaking down from ADRs
4447
- - Task tracking and status updates
4448
- - Task dependencies and priorities
4449
- - Task completion and verification
4450
-
4451
- **Migration:** The system now uses memory-centric architecture where task management is handled by external MCP servers.`,
4452
- },
4453
- ],
4454
- };
4455
- return {
4456
- content: [
4457
- {
4458
- type: 'text',
4459
- text: `# ✅ JSON-First TODO Generated from ADRs
4460
-
4461
- ## 🏗️ JSON-First TODO System Active
4462
- ✅ **todo-data.json** - JSON-first TODO backend created/updated
4463
- ✅ **TODO.md** - Markdown frontend ${forceSyncToMarkdown ? 'synchronized' : 'available for sync'}
4464
-
4465
- ## Configuration Applied
4466
- - **ADR Directory**: ${adrDirectory}
4467
- - **Scope**: ${scope}
4468
- - **TDD Phase**: ${phase}
4469
- - **ADR Dependency Linking**: ${linkAdrs ? 'Enabled' : 'Disabled'}
4470
- - **Rules Integration**: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}
4471
- - **Preserve Existing**: ${preserveExisting}
4472
- - **Force Markdown Sync**: ${forceSyncToMarkdown ? 'Enabled' : 'Disabled'}
4473
- - **Intent Linking**: ${intentId ? `Linked to ${intentId}` : 'None'}
4474
- - **JSON Backup**: ${createJsonBackup ? 'Created' : 'Skipped'}
4475
-
4476
- ## JSON-First Architecture Benefits
4477
- ✅ **Structured Data**: JSON backend ensures consistent LLM interactions
4478
- ✅ **Automatic Sync**: JSON-to-markdown conversion maintains TODO.md compatibility
4479
- ✅ **Enhanced Metadata**: Full task lifecycle with dependencies, assignees, priorities
4480
- ✅ **Complete Integration**: Native support for scoring, git automation, and knowledge graph
4481
- ✅ **Backup Protection**: Automatic data preservation during updates
4482
- ✅ **No Manual Setup**: All cache files auto-generated, tests can immediately validate
4483
-
4484
- ${importResult.content?.[0]?.text || 'TODO management feature has been deprecated'}
4485
-
4486
- ## Available Operations (use manage_todo_v2 tool)
4487
- 1. **View Tasks**: \`get_tasks\` operation with filtering and sorting
4488
- 2. **Update Status**: \`update_task\` operation with status, progress, notes
4489
- 3. **Bulk Updates**: \`bulk_update\` operation for multiple tasks
4490
- 4. **Analytics**: \`get_analytics\` operation for progress metrics
4491
- 5. **Sync Control**: \`sync_to_markdown\` and \`sync_knowledge_graph\` operations
4492
-
4493
- ## Validation & Progress Tracking
4494
- - **Progress Check**: Use \`compare_adr_progress\` to validate implementation vs ADRs
4495
- - **Git Integration**: Use \`smart_git_push\` for automatic task status updates
4496
- - **Scoring**: Integrated with smart scoring for release readiness assessment
4497
-
4498
- ## TDD Workflow Integration
4499
- - **Phase 1**: Mock test generation tasks created
4500
- - **Phase 2**: Production implementation tasks linked to tests
4501
- - **Dependencies**: ADR relationships mapped to task dependencies
4502
- - **Validation**: Architectural rules integrated into task criteria
4503
-
4504
- *All TODO data is now managed in JSON format with automatic markdown sync*`,
4505
- },
4506
- ],
4507
- };
4508
- }
4509
- catch (error) {
4510
- throw new McpAdrError(`Failed to generate ADR todo: ${error instanceof Error ? error.message : String(error)}`, 'GENERATION_ERROR');
4511
- }
4512
- }
4513
4989
  async compareAdrProgress(args) {
4514
4990
  const { todoPath = 'TODO.md', adrDirectory = this.config.adrDirectory, projectPath = this.config.projectPath, environment = 'auto-detect', environmentConfig = {}, validationType = 'full', includeFileChecks = true, includeRuleValidation = true, deepCodeAnalysis = true, functionalValidation = true, strictMode = true, environmentValidation = true, } = args;
4515
4991
  const { getAdrDirectoryPath } = await import('./utils/config.js');
@@ -4566,7 +5042,10 @@ ${importResult.content?.[0]?.text || 'TODO management feature has been deprecate
4566
5042
  let discoveryResult = null;
4567
5043
  if (validationType === 'full' || validationType === 'adr-only') {
4568
5044
  const { discoverAdrsInDirectory } = await import('./utils/adr-discovery.js');
4569
- discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, true, projectPath);
5045
+ discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, projectPath, {
5046
+ includeContent: true,
5047
+ includeTimeline: false,
5048
+ });
4570
5049
  }
4571
5050
  const analysis = await this.performLocalAdrProgressAnalysis({
4572
5051
  todoContent,
@@ -4751,14 +5230,17 @@ ${importResult.content?.[0]?.text || 'TODO management feature has been deprecate
4751
5230
 
4752
5231
  ## Environment Context
4753
5232
  - **Target Environment**: ${environment}
4754
- - **Security Level**: ${environmentConfig.securityLevel || 'Not specified'}
4755
- - **Required Files**: ${environmentConfig.requiredFiles?.length || 0} files
4756
- - **Required Services**: ${environmentConfig.requiredServices?.length || 0} services
5233
+ - **Security Level**: ${environmentConfig?.['securityLevel'] || 'Not specified'}
5234
+ - **Required Files**: ${environmentConfig?.['requiredFiles']?.length || 0} files
5235
+ - **Required Services**: ${environmentConfig?.['requiredServices']?.length || 0} services
4757
5236
 
4758
5237
  ## ADR Discovery Results
4759
5238
  ${totalAdrs > 0
4760
5239
  ? `Found ${totalAdrs} ADRs:\n${discoveredAdrs
4761
- .map((adr, i) => `${i + 1}. **${adr.title}** (${adr.status}) - ${adr.filename}`)
5240
+ .map((adr, i) => {
5241
+ const adrRecord = adr;
5242
+ return `${i + 1}. **${adrRecord['title']}** (${adrRecord['status']}) - ${adrRecord['filename']}`;
5243
+ })
4762
5244
  .join('\n')}`
4763
5245
  : 'No ADRs found in the specified directory.'}
4764
5246
 
@@ -4824,23 +5306,9 @@ ${environmentValidation
4824
5306
 
4825
5307
  ## Next Steps
4826
5308
  1. Address high-priority alignment issues identified above
4827
- 2. ${totalTasks === 0 ? 'Create initial TODO.md from ADR requirements using generate_adr_todo tool' : 'Update TODO.md with missing tasks'}
5309
+ 2. ${totalTasks === 0 ? 'Create initial TODO.md from ADR requirements' : 'Update TODO.md with missing tasks'}
4828
5310
  3. ${includeFileChecks ? 'Verify implementation of completed tasks' : 'Enable file checks for detailed implementation verification'}
4829
5311
  4. ${includeRuleValidation ? 'Resolve architectural rule compliance violations' : 'Enable rule validation for compliance checking'}
4830
-
4831
- ## Integration Commands
4832
-
4833
- To regenerate TODO after fixes:
4834
- \`\`\`json
4835
- {
4836
- "tool": "generate_adr_todo",
4837
- "args": {
4838
- "adrDirectory": "${adrDirectory}",
4839
- "phase": "both",
4840
- "linkAdrs": true,
4841
- "includeRules": ${includeRuleValidation}
4842
- }
4843
- }
4844
5312
  \`\`\`
4845
5313
 
4846
5314
  To re-run this validation with strict mode:
@@ -4900,17 +5368,20 @@ To re-run this validation with strict mode:
4900
5368
  const misaligned = [];
4901
5369
  const missing = [];
4902
5370
  // Simple keyword matching for alignment detection
4903
- const adrKeywords = adrs.flatMap(adr => [
4904
- adr.title.toLowerCase(),
4905
- ...(adr.decision || '')
4906
- .toLowerCase()
4907
- .split(/\s+/)
4908
- .filter((w) => w.length > 4),
4909
- ...(adr.context || '')
4910
- .toLowerCase()
4911
- .split(/\s+/)
4912
- .filter((w) => w.length > 4),
4913
- ]);
5371
+ const adrKeywords = adrs.flatMap(adr => {
5372
+ const adrRecord = adr;
5373
+ return [
5374
+ String(adrRecord['title'] || '').toLowerCase(),
5375
+ ...String(adrRecord['decision'] || '')
5376
+ .toLowerCase()
5377
+ .split(/\s+/)
5378
+ .filter((w) => w.length > 4),
5379
+ ...String(adrRecord['context'] || '')
5380
+ .toLowerCase()
5381
+ .split(/\s+/)
5382
+ .filter((w) => w.length > 4),
5383
+ ];
5384
+ });
4914
5385
  // Environment-specific keywords that should be prioritized
4915
5386
  const envKeywords = [];
4916
5387
  if (environment && environmentConfig) {
@@ -4926,7 +5397,8 @@ To re-run this validation with strict mode:
4926
5397
  }
4927
5398
  for (const task of tasks) {
4928
5399
  const taskLower = task.title.toLowerCase();
4929
- const hasKeywordMatch = adrKeywords.some(keyword => taskLower.includes(keyword) || keyword.includes(taskLower.split(' ')[0]));
5400
+ const firstWord = taskLower.split(' ')[0] || '';
5401
+ const hasKeywordMatch = adrKeywords.some(keyword => taskLower.includes(keyword) || keyword.includes(firstWord));
4930
5402
  // Environment-aware alignment scoring
4931
5403
  const hasEnvKeywordMatch = envKeywords.some(keyword => taskLower.includes(keyword));
4932
5404
  if (hasKeywordMatch || hasEnvKeywordMatch) {
@@ -4938,8 +5410,9 @@ To re-run this validation with strict mode:
4938
5410
  }
4939
5411
  // Identify potential missing tasks based on ADR content
4940
5412
  for (const adr of adrs) {
4941
- if (adr.status === 'accepted' && adr.decision) {
4942
- const decisionWords = adr.decision.toLowerCase().split(/\s+/);
5413
+ const adrRecord = adr;
5414
+ if (adrRecord['status'] === 'accepted' && adrRecord['decision']) {
5415
+ const decisionWords = String(adrRecord['decision']).toLowerCase().split(/\s+/);
4943
5416
  const implementationWords = [
4944
5417
  'implement',
4945
5418
  'create',
@@ -4950,25 +5423,28 @@ To re-run this validation with strict mode:
4950
5423
  'configure',
4951
5424
  ];
4952
5425
  if (implementationWords.some(word => decisionWords.includes(word))) {
4953
- const hasCorrespondingTask = tasks.some(task => task.title.toLowerCase().includes(adr.title.toLowerCase().split(' ')[0]));
5426
+ const adrTitle = String(adrRecord['title'] || '');
5427
+ const adrFirstWord = adrTitle.toLowerCase().split(' ')[0] || '';
5428
+ const hasCorrespondingTask = tasks.some(task => task.title.toLowerCase().includes(adrFirstWord));
4954
5429
  if (!hasCorrespondingTask) {
4955
- missing.push(`Implement ${adr.title}`);
5430
+ missing.push(`Implement ${adrTitle}`);
4956
5431
  }
4957
5432
  }
4958
5433
  }
4959
5434
  }
4960
5435
  // Environment-specific missing tasks
4961
5436
  if (environment && environmentConfig) {
4962
- if (environmentConfig.requiredFiles) {
4963
- for (const file of environmentConfig.requiredFiles) {
5437
+ const envConfig = environmentConfig;
5438
+ if (envConfig['requiredFiles']) {
5439
+ for (const file of envConfig['requiredFiles']) {
4964
5440
  const hasFileTask = tasks.some(task => task.title.toLowerCase().includes(file.toLowerCase()));
4965
5441
  if (!hasFileTask) {
4966
5442
  missing.push(`Create ${file} for ${environment} environment`);
4967
5443
  }
4968
5444
  }
4969
5445
  }
4970
- if (environmentConfig.requiredServices) {
4971
- for (const service of environmentConfig.requiredServices) {
5446
+ if (envConfig['requiredServices']) {
5447
+ for (const service of envConfig['requiredServices']) {
4972
5448
  const hasServiceTask = tasks.some(task => task.title.toLowerCase().includes(service.toLowerCase()));
4973
5449
  if (!hasServiceTask) {
4974
5450
  missing.push(`Setup ${service} service for ${environment}`);
@@ -5652,9 +6128,114 @@ Please provide:
5652
6128
  const { default: generateAdrBootstrapScripts } = await import('./tools/adr-bootstrap-validation-tool.js');
5653
6129
  return await generateAdrBootstrapScripts(args);
5654
6130
  }
5655
- async discoverExistingAdrs(args) {
5656
- const { discoverExistingAdrs } = await import('./tools/adr-suggestion-tool.js');
5657
- return await discoverExistingAdrs(args);
6131
+ async bootstrapValidationLoop(args) {
6132
+ const { default: bootstrapValidationLoop } = await import('./tools/bootstrap-validation-loop-tool.js');
6133
+ return await bootstrapValidationLoop(args);
6134
+ }
6135
+ async discoverExistingAdrs(args, context) {
6136
+ const ctx = context || createNoOpContext();
6137
+ try {
6138
+ ctx.info('🔍 Starting ADR discovery process...');
6139
+ ctx.report_progress(0, 100);
6140
+ ctx.info('📂 Phase 1: Scanning ADR directory');
6141
+ ctx.report_progress(30, 100);
6142
+ const { discoverExistingAdrs } = await import('./tools/adr-suggestion-tool.js');
6143
+ ctx.info('📄 Phase 2: Analyzing ADR files');
6144
+ ctx.report_progress(60, 100);
6145
+ const result = await discoverExistingAdrs(args);
6146
+ ctx.info('✅ ADR discovery completed successfully');
6147
+ ctx.report_progress(100, 100);
6148
+ return result;
6149
+ }
6150
+ catch (error) {
6151
+ ctx.error?.(`❌ ADR discovery failed: ${error instanceof Error ? error.message : String(error)}`);
6152
+ throw error;
6153
+ }
6154
+ }
6155
+ async analyzeAdrTimeline(args) {
6156
+ try {
6157
+ const projectPath = args['projectPath'] || this.config.projectPath;
6158
+ const adrDirectory = args['adrDirectory'] || 'docs/adrs';
6159
+ const generateActions = args['generateActions'] ?? true;
6160
+ const thresholdProfile = args['thresholdProfile'];
6161
+ const autoDetectContext = args['autoDetectContext'] ?? true;
6162
+ const includeContent = args['includeContent'] ?? true;
6163
+ const forceExtract = args['forceExtract'] ?? false;
6164
+ const { discoverAdrsInDirectory } = await import('./utils/adr-discovery.js');
6165
+ const { formatActionReport } = await import('./utils/adr-action-analyzer.js');
6166
+ // Discover ADRs with timeline analysis
6167
+ const result = await discoverAdrsInDirectory(adrDirectory, projectPath, {
6168
+ includeContent,
6169
+ includeTimeline: true,
6170
+ timelineOptions: {
6171
+ forceExtract,
6172
+ useCache: true,
6173
+ cacheTTL: 3600,
6174
+ },
6175
+ generateActions,
6176
+ ...(thresholdProfile ? { thresholdProfile } : {}),
6177
+ autoDetectContext,
6178
+ });
6179
+ // Format response
6180
+ let responseText = `# ADR Timeline Analysis\n\n`;
6181
+ responseText += `**Project:** ${projectPath}\n`;
6182
+ responseText += `**ADR Directory:** ${adrDirectory}\n`;
6183
+ responseText += `**Total ADRs:** ${result.totalAdrs}\n\n`;
6184
+ // Add timeline summary
6185
+ if (result.adrs.some((adr) => adr.timeline)) {
6186
+ const withTimeline = result.adrs.filter((adr) => adr.timeline).length;
6187
+ responseText += `## Timeline Data\n\n`;
6188
+ responseText += `- **ADRs with Timeline:** ${withTimeline}/${result.totalAdrs}\n`;
6189
+ const ages = result.adrs
6190
+ .filter((adr) => adr.timeline)
6191
+ .map((adr) => adr.timeline.age_days);
6192
+ if (ages.length > 0) {
6193
+ const avgAge = Math.floor(ages.reduce((a, b) => a + b, 0) / ages.length);
6194
+ const oldestAge = Math.max(...ages);
6195
+ responseText += `- **Average ADR Age:** ${avgAge} days\n`;
6196
+ responseText += `- **Oldest ADR:** ${oldestAge} days\n`;
6197
+ }
6198
+ responseText += `\n`;
6199
+ }
6200
+ // Add action queue report
6201
+ if (result.actionQueue) {
6202
+ responseText += `---\n\n`;
6203
+ responseText += formatActionReport(result.actionQueue, {
6204
+ projectPath,
6205
+ thresholdProfile: thresholdProfile || 'auto-detected',
6206
+ });
6207
+ }
6208
+ else if (generateActions) {
6209
+ responseText += `## No Actions Required\n\n`;
6210
+ responseText += `All ADRs are up to date and within acceptable thresholds.\n`;
6211
+ }
6212
+ // Add summary stats
6213
+ if (result.summary.byStatus) {
6214
+ responseText += `\n---\n\n## ADR Status Distribution\n\n`;
6215
+ Object.entries(result.summary.byStatus).forEach(([status, count]) => {
6216
+ responseText += `- **${status}:** ${count}\n`;
6217
+ });
6218
+ }
6219
+ return {
6220
+ content: [
6221
+ {
6222
+ type: 'text',
6223
+ text: responseText,
6224
+ },
6225
+ ],
6226
+ };
6227
+ }
6228
+ catch (error) {
6229
+ return {
6230
+ content: [
6231
+ {
6232
+ type: 'text',
6233
+ text: `# ADR Timeline Analysis Failed\n\n**Error:** ${error instanceof Error ? error.message : String(error)}\n\nPlease check that the ADR directory exists and contains valid ADR files.`,
6234
+ },
6235
+ ],
6236
+ isError: true,
6237
+ };
6238
+ }
5658
6239
  }
5659
6240
  async reviewExistingAdrs(args) {
5660
6241
  const { reviewExistingAdrs } = await import('./tools/review-existing-adrs-tool.js');
@@ -5718,12 +6299,69 @@ Please provide:
5718
6299
  /**
5719
6300
  * Perform research tool implementation
5720
6301
  */
5721
- async performResearch(args) {
6302
+ async performResearch(args, context) {
6303
+ const ctx = context || createNoOpContext();
5722
6304
  if (!('question' in args) || typeof args['question'] !== 'string') {
5723
6305
  throw new McpAdrError('Missing required parameter: question', 'INVALID_ARGUMENTS');
5724
6306
  }
5725
- const { performResearch } = await import('./tools/perform-research-tool.js');
5726
- return await performResearch(args);
6307
+ try {
6308
+ ctx.info('🔍 Starting research process...');
6309
+ ctx.report_progress(0, 100);
6310
+ ctx.info('📊 Phase 1: Initializing research framework');
6311
+ ctx.report_progress(10, 100);
6312
+ const { performResearch } = await import('./tools/perform-research-tool.js');
6313
+ ctx.info('📚 Phase 2: Executing research orchestration');
6314
+ ctx.report_progress(20, 100);
6315
+ const result = await performResearch(args, ctx // ✅ Pass context to tool function for progress updates
6316
+ );
6317
+ return result;
6318
+ }
6319
+ catch (error) {
6320
+ ctx.error?.(`❌ Research execution failed: ${error instanceof Error ? error.message : String(error)}`);
6321
+ throw new McpAdrError(`Failed to perform research: ${error instanceof Error ? error.message : String(error)}`, 'RESEARCH_EXECUTION_ERROR');
6322
+ }
6323
+ }
6324
+ /**
6325
+ * LLM web search tool implementation
6326
+ */
6327
+ async llmWebSearch(args, context) {
6328
+ const ctx = context || createNoOpContext();
6329
+ if (!('query' in args) || typeof args['query'] !== 'string') {
6330
+ throw new McpAdrError('Missing required parameter: query', 'INVALID_ARGUMENTS');
6331
+ }
6332
+ ctx.info('🌐 Starting LLM-managed web search...');
6333
+ ctx.report_progress(0, 100);
6334
+ const { llmWebSearch } = await import('./tools/llm-web-search-tool.js');
6335
+ return await llmWebSearch(args, ctx // ✅ Pass context to tool function for progress updates
6336
+ );
6337
+ }
6338
+ /**
6339
+ * LLM cloud management tool implementation
6340
+ */
6341
+ async llmCloudManagement(args, context) {
6342
+ const ctx = context || createNoOpContext();
6343
+ if (!('provider' in args) || !('action' in args) || !('llmInstructions' in args)) {
6344
+ throw new McpAdrError('Missing required parameters: provider, action, llmInstructions', 'INVALID_ARGUMENTS');
6345
+ }
6346
+ ctx.info('🔧 Starting LLM-managed cloud operation...');
6347
+ ctx.report_progress(0, 100);
6348
+ const { llmCloudManagement } = await import('./tools/llm-cloud-management-tool.js');
6349
+ return await llmCloudManagement(args, ctx // ✅ Pass context to tool function for progress updates
6350
+ );
6351
+ }
6352
+ /**
6353
+ * LLM database management tool implementation
6354
+ */
6355
+ async llmDatabaseManagement(args, context) {
6356
+ const ctx = context || createNoOpContext();
6357
+ if (!('database' in args) || !('action' in args) || !('llmInstructions' in args)) {
6358
+ throw new McpAdrError('Missing required parameters: database, action, llmInstructions', 'INVALID_ARGUMENTS');
6359
+ }
6360
+ ctx.info('🗄️ Starting LLM-managed database operation...');
6361
+ ctx.report_progress(0, 100);
6362
+ const { llmDatabaseManagement } = await import('./tools/llm-database-management-tool.js');
6363
+ return await llmDatabaseManagement(args, ctx // ✅ Pass context to tool function for progress updates
6364
+ );
5727
6365
  }
5728
6366
  /**
5729
6367
  * Deployment analysis tool implementation
@@ -5936,11 +6574,117 @@ Please provide:
5936
6574
  return response;
5937
6575
  }
5938
6576
  }
6577
+ /**
6578
+ * Enrich response with state reinforcement and apply masking
6579
+ *
6580
+ * Implements Phase 2 of context decay mitigation by injecting
6581
+ * context reminders every N turns or when response exceeds token threshold.
6582
+ *
6583
+ * Phase 3 extension: Records conversation turns to structured external memory.
6584
+ */
6585
+ async enrichResponseWithStateReinforcement(response, toolName, toolArgs) {
6586
+ const startTime = Date.now();
6587
+ try {
6588
+ // Extract text content from response
6589
+ const textContent = response.content
6590
+ .filter((item) => item.type === 'text')
6591
+ .map(item => item.text)
6592
+ .join('\n\n');
6593
+ if (!textContent) {
6594
+ // No text content to enrich, just apply masking
6595
+ return await this.applyOutputMasking(response);
6596
+ }
6597
+ // Enrich with state reinforcement (Phase 2)
6598
+ const enriched = await this.stateReinforcementManager.enrichResponseWithContext(textContent);
6599
+ // Prepare final response
6600
+ let finalResponse;
6601
+ // Replace text content with enriched version if context was injected
6602
+ if (enriched.contextInjected) {
6603
+ finalResponse = {
6604
+ ...response,
6605
+ content: response.content.map(item => {
6606
+ if (item.type === 'text') {
6607
+ return {
6608
+ type: 'text',
6609
+ text: enriched.enrichedContent,
6610
+ };
6611
+ }
6612
+ return item;
6613
+ }),
6614
+ };
6615
+ }
6616
+ else {
6617
+ finalResponse = response;
6618
+ }
6619
+ // Record conversation turn (Phase 3: Structured External Memory)
6620
+ if (toolName) {
6621
+ const duration = Date.now() - startTime;
6622
+ // Check if response has expandableId (from tiered response)
6623
+ const expandableIdMatch = textContent.match(/expandableId:\s*(\S+)/);
6624
+ const expandableId = expandableIdMatch ? expandableIdMatch[1] : undefined;
6625
+ await this.conversationMemoryManager.recordTurn({
6626
+ type: 'tool_call',
6627
+ toolName,
6628
+ toolArgs,
6629
+ }, {
6630
+ content: enriched.enrichedContent || textContent,
6631
+ tokenCount: enriched.tokenCount,
6632
+ contextInjected: enriched.contextInjected,
6633
+ ...(expandableId ? { expandableId } : {}),
6634
+ }, {
6635
+ duration,
6636
+ cacheHit: false, // Could be enhanced to track cache hits
6637
+ errorOccurred: false,
6638
+ });
6639
+ this.logger.debug(`Conversation turn recorded for ${toolName}`, 'McpAdrAnalysisServer', {
6640
+ turnNumber: enriched.turnNumber,
6641
+ });
6642
+ }
6643
+ // Apply masking to final response
6644
+ return await this.applyOutputMasking(finalResponse);
6645
+ }
6646
+ catch (error) {
6647
+ this.logger.error('State reinforcement or conversation recording failed, returning original response', 'McpAdrAnalysisServer', error instanceof Error ? error : undefined);
6648
+ // Fallback to just masking if enrichment fails
6649
+ return await this.applyOutputMasking(response);
6650
+ }
6651
+ }
5939
6652
  /**
5940
6653
  * Read MCP resource with prompt-driven caching
5941
6654
  */
5942
6655
  async readResource(uri) {
5943
6656
  try {
6657
+ // Import resource router and templated resources (ensures routes are registered)
6658
+ const { resourceRouter } = await import('./resources/resource-router.js');
6659
+ // Import templated resources to register routes
6660
+ await import('./resources/adr-by-id-resource.js');
6661
+ await import('./resources/research-by-topic-resource.js');
6662
+ await import('./resources/todo-by-id-resource.js');
6663
+ await import('./resources/rule-by-id-resource.js');
6664
+ await import('./resources/technology-by-name-resource.js');
6665
+ await import('./resources/pattern-by-name-resource.js');
6666
+ await import('./resources/validated-pattern-by-platform-resource.js');
6667
+ await import('./resources/pattern-sources-by-platform-resource.js');
6668
+ await import('./resources/pattern-base-code-by-platform-resource.js');
6669
+ // Try routing first (handles templated resources)
6670
+ if (resourceRouter.canRoute(uri)) {
6671
+ const result = await resourceRouter.route(uri);
6672
+ return {
6673
+ contents: [
6674
+ {
6675
+ uri,
6676
+ mimeType: result.contentType,
6677
+ text: JSON.stringify(result.data, null, 2),
6678
+ },
6679
+ ],
6680
+ _meta: {
6681
+ lastModified: result.lastModified,
6682
+ etag: result.etag,
6683
+ cacheKey: result.cacheKey,
6684
+ },
6685
+ };
6686
+ }
6687
+ // Fall back to static resource handling
5944
6688
  // Parse URI to determine resource type and parameters
5945
6689
  const url = new globalThis.URL(uri);
5946
6690
  const resourceType = url.pathname.replace('/', '');
@@ -5997,6 +6741,222 @@ Please provide:
5997
6741
  ],
5998
6742
  };
5999
6743
  }
6744
+ case 'todo_list': {
6745
+ const { generateTodoListResource } = await import('./resources/todo-list-resource.js');
6746
+ const result = await generateTodoListResource();
6747
+ return {
6748
+ contents: [
6749
+ {
6750
+ uri,
6751
+ mimeType: result.contentType,
6752
+ text: JSON.stringify(result.data, null, 2),
6753
+ },
6754
+ ],
6755
+ _meta: {
6756
+ lastModified: result.lastModified,
6757
+ etag: result.etag,
6758
+ cacheKey: result.cacheKey,
6759
+ },
6760
+ };
6761
+ }
6762
+ case 'research_index': {
6763
+ const { generateResearchIndexResource } = await import('./resources/research-index-resource.js');
6764
+ const result = await generateResearchIndexResource();
6765
+ return {
6766
+ contents: [
6767
+ {
6768
+ uri,
6769
+ mimeType: result.contentType,
6770
+ text: JSON.stringify(result.data, null, 2),
6771
+ },
6772
+ ],
6773
+ _meta: {
6774
+ lastModified: result.lastModified,
6775
+ etag: result.etag,
6776
+ cacheKey: result.cacheKey,
6777
+ },
6778
+ };
6779
+ }
6780
+ case 'rule_catalog': {
6781
+ const { generateRuleCatalogResource } = await import('./resources/rule-catalog-resource.js');
6782
+ const result = await generateRuleCatalogResource();
6783
+ return {
6784
+ contents: [
6785
+ {
6786
+ uri,
6787
+ mimeType: result.contentType,
6788
+ text: JSON.stringify(result.data, null, 2),
6789
+ },
6790
+ ],
6791
+ _meta: {
6792
+ lastModified: result.lastModified,
6793
+ etag: result.etag,
6794
+ cacheKey: result.cacheKey,
6795
+ },
6796
+ };
6797
+ }
6798
+ case 'rule_generation': {
6799
+ const { generateRuleGenerationResource } = await import('./resources/rule-generation-resource.js');
6800
+ const result = await generateRuleGenerationResource(undefined, url.searchParams);
6801
+ return {
6802
+ contents: [
6803
+ {
6804
+ uri,
6805
+ mimeType: result.contentType,
6806
+ text: JSON.stringify(result.data, null, 2),
6807
+ },
6808
+ ],
6809
+ _meta: {
6810
+ lastModified: result.lastModified,
6811
+ etag: result.etag,
6812
+ cacheKey: result.cacheKey,
6813
+ },
6814
+ };
6815
+ }
6816
+ case 'project_status': {
6817
+ const { generateProjectStatusResource } = await import('./resources/project-status-resource.js');
6818
+ const result = await generateProjectStatusResource();
6819
+ return {
6820
+ contents: [
6821
+ {
6822
+ uri,
6823
+ mimeType: result.contentType,
6824
+ text: JSON.stringify(result.data, null, 2),
6825
+ },
6826
+ ],
6827
+ _meta: {
6828
+ lastModified: result.lastModified,
6829
+ etag: result.etag,
6830
+ cacheKey: result.cacheKey,
6831
+ },
6832
+ };
6833
+ }
6834
+ case 'deployment_status': {
6835
+ const { generateDeploymentStatusResource } = await import('./resources/deployment-status-resource.js');
6836
+ const result = await generateDeploymentStatusResource(undefined, url.searchParams);
6837
+ return {
6838
+ contents: [
6839
+ {
6840
+ uri,
6841
+ mimeType: result.contentType,
6842
+ text: JSON.stringify(result.data, null, 2),
6843
+ },
6844
+ ],
6845
+ _meta: {
6846
+ lastModified: result.lastModified,
6847
+ etag: result.etag,
6848
+ cacheKey: result.cacheKey,
6849
+ },
6850
+ };
6851
+ }
6852
+ case 'environment_analysis': {
6853
+ const { generateEnvironmentAnalysisResource } = await import('./resources/environment-analysis-resource.js');
6854
+ const result = await generateEnvironmentAnalysisResource(undefined, url.searchParams);
6855
+ return {
6856
+ contents: [
6857
+ {
6858
+ uri,
6859
+ mimeType: result.contentType,
6860
+ text: JSON.stringify(result.data, null, 2),
6861
+ },
6862
+ ],
6863
+ _meta: {
6864
+ lastModified: result.lastModified,
6865
+ etag: result.etag,
6866
+ cacheKey: result.cacheKey,
6867
+ },
6868
+ };
6869
+ }
6870
+ case 'memory_snapshots': {
6871
+ const { generateMemorySnapshotsResource } = await import('./resources/memory-snapshots-resource.js');
6872
+ const result = await generateMemorySnapshotsResource(undefined, url.searchParams);
6873
+ return {
6874
+ contents: [
6875
+ {
6876
+ uri,
6877
+ mimeType: result.contentType,
6878
+ text: JSON.stringify(result.data, null, 2),
6879
+ },
6880
+ ],
6881
+ _meta: {
6882
+ lastModified: result.lastModified,
6883
+ etag: result.etag,
6884
+ cacheKey: result.cacheKey,
6885
+ },
6886
+ };
6887
+ }
6888
+ case 'project_metrics': {
6889
+ const { generateProjectMetricsResource } = await import('./resources/project-metrics-resource.js');
6890
+ const result = await generateProjectMetricsResource();
6891
+ return {
6892
+ contents: [
6893
+ {
6894
+ uri,
6895
+ mimeType: result.contentType,
6896
+ text: JSON.stringify(result.data, null, 2),
6897
+ },
6898
+ ],
6899
+ _meta: {
6900
+ lastModified: result.lastModified,
6901
+ etag: result.etag,
6902
+ cacheKey: result.cacheKey,
6903
+ },
6904
+ };
6905
+ }
6906
+ case 'deployment_history': {
6907
+ const { generateDeploymentHistoryResource } = await import('./resources/deployment-history-resource.js');
6908
+ const result = await generateDeploymentHistoryResource(undefined, url.searchParams);
6909
+ return {
6910
+ contents: [
6911
+ {
6912
+ uri,
6913
+ mimeType: result.contentType,
6914
+ text: JSON.stringify(result.data, null, 2),
6915
+ },
6916
+ ],
6917
+ _meta: {
6918
+ lastModified: result.lastModified,
6919
+ etag: result.etag,
6920
+ cacheKey: result.cacheKey,
6921
+ },
6922
+ };
6923
+ }
6924
+ case 'code_quality': {
6925
+ const { generateCodeQualityResource } = await import('./resources/code-quality-resource.js');
6926
+ const result = await generateCodeQualityResource(undefined, url.searchParams);
6927
+ return {
6928
+ contents: [
6929
+ {
6930
+ uri,
6931
+ mimeType: result.contentType,
6932
+ text: JSON.stringify(result.data, null, 2),
6933
+ },
6934
+ ],
6935
+ _meta: {
6936
+ lastModified: result.lastModified,
6937
+ etag: result.etag,
6938
+ cacheKey: result.cacheKey,
6939
+ },
6940
+ };
6941
+ }
6942
+ case 'validated_patterns': {
6943
+ const { generateValidatedPatternsCatalogResource } = await import('./resources/validated-patterns-catalog-resource.js');
6944
+ const result = await generateValidatedPatternsCatalogResource();
6945
+ return {
6946
+ contents: [
6947
+ {
6948
+ uri,
6949
+ mimeType: result.contentType,
6950
+ text: JSON.stringify(result.data, null, 2),
6951
+ },
6952
+ ],
6953
+ _meta: {
6954
+ lastModified: result.lastModified,
6955
+ etag: result.etag,
6956
+ cacheKey: result.cacheKey,
6957
+ },
6958
+ };
6959
+ }
6000
6960
  default:
6001
6961
  throw new McpAdrError(`Unknown resource type: ${resourceType}`, 'UNKNOWN_RESOURCE');
6002
6962
  }
@@ -6014,6 +6974,22 @@ Please provide:
6014
6974
  async start() {
6015
6975
  // Validate configuration before starting
6016
6976
  await this.validateConfiguration();
6977
+ // Initialize memory entity manager
6978
+ await this.memoryEntityManager.initialize();
6979
+ this.logger.info('Memory Entity Manager initialized', 'McpAdrAnalysisServer');
6980
+ // Initialize conversation memory manager (Phase 3: Structured External Memory)
6981
+ await this.conversationMemoryManager.initialize();
6982
+ this.logger.info('Phase 3 (Structured External Memory) initialized', 'McpAdrAnalysisServer');
6983
+ // Generate initial server context file
6984
+ try {
6985
+ await this.contextGenerator.writeContextFile(this.kgManager, this.memoryEntityManager, this.conversationMemoryManager);
6986
+ this.logger.info('Server context file generated at .mcp-server-context.md', 'McpAdrAnalysisServer');
6987
+ }
6988
+ catch (error) {
6989
+ this.logger.warn('Failed to generate initial server context file', 'McpAdrAnalysisServer', {
6990
+ error: error instanceof Error ? error.message : String(error),
6991
+ });
6992
+ }
6017
6993
  const transport = new StdioServerTransport();
6018
6994
  await this.server.connect(transport);
6019
6995
  // Keep the process alive
@@ -6025,16 +7001,70 @@ Please provide:
6025
7001
  /**
6026
7002
  * File system tool implementations
6027
7003
  */
7004
+ /**
7005
+ * List accessible roots (MCP best practice)
7006
+ */
7007
+ async listRoots() {
7008
+ const roots = this.rootManager.listRoots();
7009
+ const rootsList = roots
7010
+ .map(r => `### ${r.name}\n\n**Path**: \`${r.path}\`\n\n**Description**: ${r.description}\n`)
7011
+ .join('\n');
7012
+ return {
7013
+ content: [
7014
+ {
7015
+ type: 'text',
7016
+ text: `# Available File System Roots\n\nThese are the directories that can be accessed by this MCP server.\n\n${rootsList}\nUse these paths with \`read_directory\` and \`read_file\` tools to explore and access files.`,
7017
+ },
7018
+ ],
7019
+ };
7020
+ }
7021
+ /**
7022
+ * Read directory contents (MCP best practice for autonomous file discovery)
7023
+ */
7024
+ async readDirectory(args) {
7025
+ const targetPath = args.path || this.config.projectPath;
7026
+ try {
7027
+ const path = await import('path');
7028
+ const resolvedPath = path.resolve(targetPath);
7029
+ // Security check: ensure path is within accessible roots
7030
+ if (!this.rootManager.isPathAllowed(resolvedPath)) {
7031
+ const roots = this.rootManager.listRoots();
7032
+ const rootList = roots.map(r => ` - ${r.name}: ${r.path}`).join('\n');
7033
+ throw new McpAdrError(`Access denied: Path '${targetPath}' is outside accessible roots.\n\nAccessible roots:\n${rootList}\n\nUse list_roots tool for more details.`, 'ACCESS_DENIED');
7034
+ }
7035
+ const { readdir } = await import('fs/promises');
7036
+ const entries = await readdir(resolvedPath, { withFileTypes: true });
7037
+ const files = entries.filter(e => e.isFile()).map(e => `📄 ${e.name}`);
7038
+ const dirs = entries.filter(e => e.isDirectory()).map(e => `📁 ${e.name}/`);
7039
+ const root = this.rootManager.getRootForPath(resolvedPath);
7040
+ const relPath = this.rootManager.getRelativePathFromRoot(resolvedPath);
7041
+ const filesList = files.length > 0 ? files.join('\n') : '(no files)';
7042
+ const dirsList = dirs.length > 0 ? dirs.join('\n') : '(no directories)';
7043
+ return {
7044
+ content: [
7045
+ {
7046
+ type: 'text',
7047
+ text: `# Directory: ${targetPath}\n\n**Root**: ${root?.name}\n**Relative Path**: ${relPath || '/'}\n**Full Path**: \`${resolvedPath}\`\n\n## Directories (${dirs.length})\n\n${dirsList}\n\n## Files (${files.length})\n\n${filesList}`,
7048
+ },
7049
+ ],
7050
+ };
7051
+ }
7052
+ catch (error) {
7053
+ throw new McpAdrError(`Failed to read directory: ${error instanceof Error ? error.message : String(error)}`, 'DIRECTORY_READ_ERROR');
7054
+ }
7055
+ }
6028
7056
  async readFile(args) {
6029
7057
  const { filePath } = args;
6030
7058
  try {
6031
7059
  const fs = await import('fs/promises');
6032
7060
  const path = await import('path');
6033
- // Resolve path relative to project path for security
6034
- const safePath = path.resolve(this.config.projectPath, filePath);
6035
- // Security check: ensure path is within project directory
6036
- if (!safePath.startsWith(this.config.projectPath)) {
6037
- throw new McpAdrError('Access denied: Path is outside project directory', 'ACCESS_DENIED');
7061
+ // Resolve path (handle both relative and absolute paths)
7062
+ const safePath = path.resolve(filePath);
7063
+ // Security check: ensure path is within accessible roots
7064
+ if (!this.rootManager.isPathAllowed(safePath)) {
7065
+ const roots = this.rootManager.listRoots();
7066
+ const rootList = roots.map(r => ` - ${r.name}: ${r.path}`).join('\n');
7067
+ throw new McpAdrError(`Access denied: Path '${filePath}' is outside accessible roots.\n\nAccessible roots:\n${rootList}\n\nUse list_roots tool for more details.`, 'ACCESS_DENIED');
6038
7068
  }
6039
7069
  const content = await fs.readFile(safePath, 'utf-8');
6040
7070
  return {
@@ -6108,40 +7138,6 @@ Please provide:
6108
7138
  throw new McpAdrError(`Failed to list directory: ${error instanceof Error ? error.message : String(error)}`, 'DIRECTORY_LIST_ERROR');
6109
7139
  }
6110
7140
  }
6111
- async manageTodoJson(_args) {
6112
- try {
6113
- // TODO management has been deprecated and moved to mcp-shrimp-task-manager
6114
- this.logger.warn('⚠️ manageTodoJson deprecated - use mcp-shrimp-task-manager instead');
6115
- return {
6116
- content: [
6117
- {
6118
- type: 'text',
6119
- text: `⚠️ **TODO Management Tool Deprecated**
6120
-
6121
- This tool (manageTodoJson) has been deprecated and is no longer functional.
6122
-
6123
- **Replacement:** Use the external \`mcp-shrimp-task-manager\` for task management:
6124
- - Task planning and breaking down
6125
- - Task tracking and status updates
6126
- - Task dependencies and priorities
6127
- - Task completion and verification
6128
-
6129
- **Migration:** The system has moved to a memory-centric architecture where task management is handled by external MCP servers rather than internal JSON files.
6130
-
6131
- **Error:** TodoJsonManager was removed - use mcp-shrimp-task-manager for task management`,
6132
- },
6133
- ],
6134
- isError: false,
6135
- };
6136
- }
6137
- catch (error) {
6138
- // If it's already a McpAdrError with good details, re-throw it as-is
6139
- if (error instanceof Error && error.name === 'McpAdrError') {
6140
- throw error;
6141
- }
6142
- throw new McpAdrError(`JSON TODO management failed: ${error instanceof Error ? error.message : String(error)}`, 'TODO_JSON_MANAGEMENT_ERROR');
6143
- }
6144
- }
6145
7141
  async generateDeploymentGuidance(args) {
6146
7142
  try {
6147
7143
  const { generateDeploymentGuidance } = await import('./tools/deployment-guidance-tool.js');
@@ -6220,6 +7216,15 @@ This tool has been deprecated and replaced with memory-centric health scoring.
6220
7216
  throw new McpAdrError(`Memory loading failed: ${error instanceof Error ? error.message : String(error)}`, 'MEMORY_LOADING_ERROR');
6221
7217
  }
6222
7218
  }
7219
+ async expandAnalysisSection(args) {
7220
+ try {
7221
+ const { expandAnalysisSection } = await import('./tools/expand-analysis-tool.js');
7222
+ return await expandAnalysisSection(args);
7223
+ }
7224
+ catch (error) {
7225
+ throw new McpAdrError(`Failed to expand analysis: ${error instanceof Error ? error.message : String(error)}`, 'EXPAND_ANALYSIS_ERROR');
7226
+ }
7227
+ }
6223
7228
  async interactiveAdrPlanning(args) {
6224
7229
  try {
6225
7230
  const { interactiveAdrPlanning } = await import('./tools/interactive-adr-planning-tool.js');
@@ -6241,9 +7246,91 @@ This tool has been deprecated and replaced with memory-centric health scoring.
6241
7246
  throw new McpAdrError(`Tool chain orchestration failed: ${error instanceof Error ? error.message : String(error)}`, 'TOOL_CHAIN_ORCHESTRATOR_ERROR');
6242
7247
  }
6243
7248
  }
7249
+ /**
7250
+ * Phase 3: Expand Memory Tool
7251
+ * Retrieves and expands stored content from tiered responses
7252
+ */
7253
+ async expandMemory(args) {
7254
+ try {
7255
+ const { expandMemory } = await import('./tools/conversation-memory-tool.js');
7256
+ return await expandMemory(args, this.conversationMemoryManager);
7257
+ }
7258
+ catch (error) {
7259
+ throw new McpAdrError(`Memory expansion failed: ${error instanceof Error ? error.message : String(error)}`, 'MEMORY_EXPANSION_ERROR');
7260
+ }
7261
+ }
7262
+ /**
7263
+ * Phase 3: Query Conversation History Tool
7264
+ * Searches and retrieves conversation sessions
7265
+ */
7266
+ async queryConversationHistory(args) {
7267
+ try {
7268
+ const { queryConversationHistory } = await import('./tools/conversation-memory-tool.js');
7269
+ return await queryConversationHistory(args, this.conversationMemoryManager);
7270
+ }
7271
+ catch (error) {
7272
+ throw new McpAdrError(`Conversation history query failed: ${error instanceof Error ? error.message : String(error)}`, 'CONVERSATION_QUERY_ERROR');
7273
+ }
7274
+ }
7275
+ /**
7276
+ * Phase 3: Get Conversation Snapshot Tool
7277
+ * Retrieves current conversation context
7278
+ */
7279
+ async getConversationSnapshot(args) {
7280
+ try {
7281
+ const { getConversationSnapshot } = await import('./tools/conversation-memory-tool.js');
7282
+ return await getConversationSnapshot(args, this.conversationMemoryManager);
7283
+ }
7284
+ catch (error) {
7285
+ throw new McpAdrError(`Conversation snapshot retrieval failed: ${error instanceof Error ? error.message : String(error)}`, 'SNAPSHOT_ERROR');
7286
+ }
7287
+ }
7288
+ /**
7289
+ * Phase 3: Get Memory Statistics Tool
7290
+ * Retrieves conversation memory statistics
7291
+ */
7292
+ async getMemoryStats() {
7293
+ try {
7294
+ const { getMemoryStats } = await import('./tools/conversation-memory-tool.js');
7295
+ return await getMemoryStats(this.conversationMemoryManager);
7296
+ }
7297
+ catch (error) {
7298
+ throw new McpAdrError(`Memory stats retrieval failed: ${error instanceof Error ? error.message : String(error)}`, 'MEMORY_STATS_ERROR');
7299
+ }
7300
+ }
7301
+ /**
7302
+ * Get Server Context Tool
7303
+ * Generates comprehensive server context file for LLM @ referencing
7304
+ */
7305
+ async getServerContext(args) {
7306
+ try {
7307
+ const { getServerContext } = await import('./tools/get-server-context-tool.js');
7308
+ return await getServerContext(args, this.kgManager, this.memoryEntityManager, this.conversationMemoryManager);
7309
+ }
7310
+ catch (error) {
7311
+ throw new McpAdrError(`Server context generation failed: ${error instanceof Error ? error.message : String(error)}`, 'SERVER_CONTEXT_ERROR');
7312
+ }
7313
+ }
6244
7314
  }
6245
7315
  /**
6246
- * Main execution
7316
+ * Main execution function for the MCP ADR Analysis Server
7317
+ *
7318
+ * @description Initializes and starts the MCP server with proper configuration,
7319
+ * error handling, and graceful shutdown. Handles command line arguments for
7320
+ * help, version, and test modes.
7321
+ *
7322
+ * @returns {Promise<void>} Resolves when server shuts down gracefully
7323
+ *
7324
+ * @throws {Error} When server initialization fails or configuration is invalid
7325
+ *
7326
+ * @example
7327
+ * ```typescript
7328
+ * // Start the server (typically called from CLI)
7329
+ * await main();
7330
+ * ```
7331
+ *
7332
+ * @since 1.0.0
7333
+ * @category Main
6247
7334
  */
6248
7335
  async function main() {
6249
7336
  const args = process.argv.slice(2);