mcp-adr-analysis-server 2.1.9 → 2.1.19

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 (408) hide show
  1. package/README.md +55 -8
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/src/index.d.ts +78 -2
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +1793 -577
  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/templates/domain-knowledge-templates.d.ts.map +1 -1
  111. package/dist/src/templates/domain-knowledge-templates.js +49 -49
  112. package/dist/src/templates/domain-knowledge-templates.js.map +1 -1
  113. package/dist/src/tools/adr-bootstrap-validation-tool.d.ts.map +1 -1
  114. package/dist/src/tools/adr-bootstrap-validation-tool.js +214 -4
  115. package/dist/src/tools/adr-bootstrap-validation-tool.js.map +1 -1
  116. package/dist/src/tools/adr-suggestion-tool.d.ts +2 -2
  117. package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
  118. package/dist/src/tools/adr-suggestion-tool.js +129 -12
  119. package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
  120. package/dist/src/tools/adr-validation-tool.d.ts +98 -0
  121. package/dist/src/tools/adr-validation-tool.d.ts.map +1 -0
  122. package/dist/src/tools/adr-validation-tool.js +372 -0
  123. package/dist/src/tools/adr-validation-tool.js.map +1 -0
  124. package/dist/src/tools/bootstrap-validation-loop-tool.d.ts +262 -0
  125. package/dist/src/tools/bootstrap-validation-loop-tool.d.ts.map +1 -0
  126. package/dist/src/tools/bootstrap-validation-loop-tool.js +1934 -0
  127. package/dist/src/tools/bootstrap-validation-loop-tool.js.map +1 -0
  128. package/dist/src/tools/conversation-memory-tool.d.ts +48 -0
  129. package/dist/src/tools/conversation-memory-tool.d.ts.map +1 -0
  130. package/dist/src/tools/conversation-memory-tool.js +254 -0
  131. package/dist/src/tools/conversation-memory-tool.js.map +1 -0
  132. package/dist/src/tools/deployment-analysis-tool.d.ts.map +1 -1
  133. package/dist/src/tools/deployment-analysis-tool.js +82 -6
  134. package/dist/src/tools/deployment-analysis-tool.js.map +1 -1
  135. package/dist/src/tools/deployment-guidance-tool.d.ts.map +1 -1
  136. package/dist/src/tools/deployment-guidance-tool.js +126 -25
  137. package/dist/src/tools/deployment-guidance-tool.js.map +1 -1
  138. package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
  139. package/dist/src/tools/deployment-readiness-tool.js +166 -5
  140. package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
  141. package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -1
  142. package/dist/src/tools/environment-analysis-tool.js +36 -1
  143. package/dist/src/tools/environment-analysis-tool.js.map +1 -1
  144. package/dist/src/tools/expand-analysis-tool.d.ts +23 -0
  145. package/dist/src/tools/expand-analysis-tool.d.ts.map +1 -0
  146. package/dist/src/tools/expand-analysis-tool.js +107 -0
  147. package/dist/src/tools/expand-analysis-tool.js.map +1 -0
  148. package/dist/src/tools/get-server-context-tool.d.ts +67 -0
  149. package/dist/src/tools/get-server-context-tool.d.ts.map +1 -0
  150. package/dist/src/tools/get-server-context-tool.js +75 -0
  151. package/dist/src/tools/get-server-context-tool.js.map +1 -0
  152. package/dist/src/tools/interactive-adr-planning-tool.d.ts.map +1 -1
  153. package/dist/src/tools/interactive-adr-planning-tool.js +82 -9
  154. package/dist/src/tools/interactive-adr-planning-tool.js.map +1 -1
  155. package/dist/src/tools/llm-cloud-management-tool.d.ts +62 -0
  156. package/dist/src/tools/llm-cloud-management-tool.d.ts.map +1 -0
  157. package/dist/src/tools/llm-cloud-management-tool.js +202 -0
  158. package/dist/src/tools/llm-cloud-management-tool.js.map +1 -0
  159. package/dist/src/tools/llm-database-management-tool.d.ts +62 -0
  160. package/dist/src/tools/llm-database-management-tool.d.ts.map +1 -0
  161. package/dist/src/tools/llm-database-management-tool.js +203 -0
  162. package/dist/src/tools/llm-database-management-tool.js.map +1 -0
  163. package/dist/src/tools/llm-web-search-tool.d.ts +59 -0
  164. package/dist/src/tools/llm-web-search-tool.d.ts.map +1 -0
  165. package/dist/src/tools/llm-web-search-tool.js +165 -0
  166. package/dist/src/tools/llm-web-search-tool.js.map +1 -0
  167. package/dist/src/tools/mcp-planning-tool.d.ts.map +1 -1
  168. package/dist/src/tools/mcp-planning-tool.js +10 -3
  169. package/dist/src/tools/mcp-planning-tool.js.map +1 -1
  170. package/dist/src/tools/memory-loading-tool.d.ts.map +1 -1
  171. package/dist/src/tools/memory-loading-tool.js +4 -2
  172. package/dist/src/tools/memory-loading-tool.js.map +1 -1
  173. package/dist/src/tools/perform-research-tool.d.ts +61 -0
  174. package/dist/src/tools/perform-research-tool.d.ts.map +1 -0
  175. package/dist/src/tools/perform-research-tool.js +324 -0
  176. package/dist/src/tools/perform-research-tool.js.map +1 -0
  177. package/dist/src/tools/research-question-tool.d.ts.map +1 -1
  178. package/dist/src/tools/research-question-tool.js +11 -9
  179. package/dist/src/tools/research-question-tool.js.map +1 -1
  180. package/dist/src/tools/review-existing-adrs-tool.d.ts.map +1 -1
  181. package/dist/src/tools/review-existing-adrs-tool.js +42 -3
  182. package/dist/src/tools/review-existing-adrs-tool.js.map +1 -1
  183. package/dist/src/tools/tool-chain-orchestrator.d.ts +15 -94
  184. package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
  185. package/dist/src/tools/tool-chain-orchestrator.js +2 -2
  186. package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
  187. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +25 -120
  188. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
  189. package/dist/src/tools/troubleshoot-guided-workflow-tool.js +91 -2
  190. package/dist/src/tools/troubleshoot-guided-workflow-tool.js.map +1 -1
  191. package/dist/src/types/ape-framework.d.ts +50 -283
  192. package/dist/src/types/ape-framework.d.ts.map +1 -1
  193. package/dist/src/types/conversation-context.d.ts.map +1 -1
  194. package/dist/src/types/conversation-context.js +12 -12
  195. package/dist/src/types/conversation-context.js.map +1 -1
  196. package/dist/src/types/conversation-memory.d.ts +184 -0
  197. package/dist/src/types/conversation-memory.d.ts.map +1 -0
  198. package/dist/src/types/conversation-memory.js +8 -0
  199. package/dist/src/types/conversation-memory.js.map +1 -0
  200. package/dist/src/types/index.d.ts +112 -339
  201. package/dist/src/types/index.d.ts.map +1 -1
  202. package/dist/src/types/knowledge-generation.d.ts +96 -401
  203. package/dist/src/types/knowledge-generation.d.ts.map +1 -1
  204. package/dist/src/types/knowledge-graph-schemas.d.ts +77 -715
  205. package/dist/src/types/knowledge-graph-schemas.d.ts.map +1 -1
  206. package/dist/src/types/knowledge-graph-schemas.js +8 -8
  207. package/dist/src/types/knowledge-graph-schemas.js.map +1 -1
  208. package/dist/src/types/memory-entities.d.ts +1230 -6164
  209. package/dist/src/types/memory-entities.d.ts.map +1 -1
  210. package/dist/src/types/memory-entities.js +8 -8
  211. package/dist/src/types/memory-entities.js.map +1 -1
  212. package/dist/src/types/reflexion-framework.d.ts +35 -264
  213. package/dist/src/types/reflexion-framework.d.ts.map +1 -1
  214. package/dist/src/types/reflexion-framework.js +1 -1
  215. package/dist/src/types/reflexion-framework.js.map +1 -1
  216. package/dist/src/types/state-reinforcement.d.ts +87 -0
  217. package/dist/src/types/state-reinforcement.d.ts.map +1 -0
  218. package/dist/src/types/state-reinforcement.js +5 -0
  219. package/dist/src/types/state-reinforcement.js.map +1 -0
  220. package/dist/src/types/tiered-response.d.ts +61 -0
  221. package/dist/src/types/tiered-response.d.ts.map +1 -0
  222. package/dist/src/types/tiered-response.js +8 -0
  223. package/dist/src/types/tiered-response.js.map +1 -0
  224. package/dist/src/types/tool-context.d.ts +50 -0
  225. package/dist/src/types/tool-context.d.ts.map +1 -0
  226. package/dist/src/types/tool-context.js +20 -0
  227. package/dist/src/types/tool-context.js.map +1 -0
  228. package/dist/src/utils/adr-action-analyzer.d.ts +23 -0
  229. package/dist/src/utils/adr-action-analyzer.d.ts.map +1 -0
  230. package/dist/src/utils/adr-action-analyzer.js +323 -0
  231. package/dist/src/utils/adr-action-analyzer.js.map +1 -0
  232. package/dist/src/utils/adr-context-detector.d.ts +33 -0
  233. package/dist/src/utils/adr-context-detector.d.ts.map +1 -0
  234. package/dist/src/utils/adr-context-detector.js +279 -0
  235. package/dist/src/utils/adr-context-detector.js.map +1 -0
  236. package/dist/src/utils/adr-discovery.d.ts +28 -2
  237. package/dist/src/utils/adr-discovery.d.ts.map +1 -1
  238. package/dist/src/utils/adr-discovery.js +91 -7
  239. package/dist/src/utils/adr-discovery.js.map +1 -1
  240. package/dist/src/utils/adr-knowledge-initializer.d.ts +54 -0
  241. package/dist/src/utils/adr-knowledge-initializer.d.ts.map +1 -0
  242. package/dist/src/utils/adr-knowledge-initializer.js +240 -0
  243. package/dist/src/utils/adr-knowledge-initializer.js.map +1 -0
  244. package/dist/src/utils/adr-timeline-extractor.d.ts +21 -0
  245. package/dist/src/utils/adr-timeline-extractor.d.ts.map +1 -0
  246. package/dist/src/utils/adr-timeline-extractor.js +294 -0
  247. package/dist/src/utils/adr-timeline-extractor.js.map +1 -0
  248. package/dist/src/utils/adr-timeline-types.d.ts +234 -0
  249. package/dist/src/utils/adr-timeline-types.d.ts.map +1 -0
  250. package/dist/src/utils/adr-timeline-types.js +7 -0
  251. package/dist/src/utils/adr-timeline-types.js.map +1 -0
  252. package/dist/src/utils/ai-executor.d.ts +36 -0
  253. package/dist/src/utils/ai-executor.d.ts.map +1 -1
  254. package/dist/src/utils/ai-executor.js +39 -3
  255. package/dist/src/utils/ai-executor.js.map +1 -1
  256. package/dist/src/utils/apply-cot-enhancement.d.ts.map +1 -1
  257. package/dist/src/utils/apply-cot-enhancement.js +15 -15
  258. package/dist/src/utils/apply-cot-enhancement.js.map +1 -1
  259. package/dist/src/utils/automatic-prompt-engineering.d.ts.map +1 -1
  260. package/dist/src/utils/automatic-prompt-engineering.js +68 -58
  261. package/dist/src/utils/automatic-prompt-engineering.js.map +1 -1
  262. package/dist/src/utils/conditional-request.d.ts +105 -0
  263. package/dist/src/utils/conditional-request.d.ts.map +1 -0
  264. package/dist/src/utils/conditional-request.js +186 -0
  265. package/dist/src/utils/conditional-request.js.map +1 -0
  266. package/dist/src/utils/config.d.ts +72 -18
  267. package/dist/src/utils/config.d.ts.map +1 -1
  268. package/dist/src/utils/config.js +75 -0
  269. package/dist/src/utils/config.js.map +1 -1
  270. package/dist/src/utils/context-document-manager.d.ts +112 -0
  271. package/dist/src/utils/context-document-manager.d.ts.map +1 -0
  272. package/dist/src/utils/context-document-manager.js +351 -0
  273. package/dist/src/utils/context-document-manager.js.map +1 -0
  274. package/dist/src/utils/conversation-memory-manager.d.ts +86 -0
  275. package/dist/src/utils/conversation-memory-manager.d.ts.map +1 -0
  276. package/dist/src/utils/conversation-memory-manager.js +443 -0
  277. package/dist/src/utils/conversation-memory-manager.js.map +1 -0
  278. package/dist/src/utils/dag-executor.d.ts +106 -0
  279. package/dist/src/utils/dag-executor.d.ts.map +1 -0
  280. package/dist/src/utils/dag-executor.js +420 -0
  281. package/dist/src/utils/dag-executor.js.map +1 -0
  282. package/dist/src/utils/deployment-analysis.d.ts.map +1 -1
  283. package/dist/src/utils/deployment-analysis.js +17 -9
  284. package/dist/src/utils/deployment-analysis.js.map +1 -1
  285. package/dist/src/utils/deployment-type-registry.d.ts +52 -0
  286. package/dist/src/utils/deployment-type-registry.d.ts.map +1 -0
  287. package/dist/src/utils/deployment-type-registry.js +543 -0
  288. package/dist/src/utils/deployment-type-registry.js.map +1 -0
  289. package/dist/src/utils/dynamic-deployment-intelligence.d.ts +117 -0
  290. package/dist/src/utils/dynamic-deployment-intelligence.d.ts.map +1 -0
  291. package/dist/src/utils/dynamic-deployment-intelligence.js +445 -0
  292. package/dist/src/utils/dynamic-deployment-intelligence.js.map +1 -0
  293. package/dist/src/utils/environment-analysis.d.ts.map +1 -1
  294. package/dist/src/utils/environment-analysis.js +63 -44
  295. package/dist/src/utils/environment-analysis.js.map +1 -1
  296. package/dist/src/utils/environment-capability-registry.d.ts +101 -0
  297. package/dist/src/utils/environment-capability-registry.d.ts.map +1 -0
  298. package/dist/src/utils/environment-capability-registry.js +489 -0
  299. package/dist/src/utils/environment-capability-registry.js.map +1 -0
  300. package/dist/src/utils/index.d.ts +3 -3
  301. package/dist/src/utils/index.d.ts.map +1 -1
  302. package/dist/src/utils/index.js +3 -3
  303. package/dist/src/utils/index.js.map +1 -1
  304. package/dist/src/utils/knowledge-generation.d.ts.map +1 -1
  305. package/dist/src/utils/knowledge-generation.js +61 -35
  306. package/dist/src/utils/knowledge-generation.js.map +1 -1
  307. package/dist/src/utils/knowledge-graph-manager.d.ts +19 -0
  308. package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
  309. package/dist/src/utils/knowledge-graph-manager.js +165 -1
  310. package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
  311. package/dist/src/utils/llm-artifact-detector.d.ts.map +1 -1
  312. package/dist/src/utils/llm-artifact-detector.js +28 -24
  313. package/dist/src/utils/llm-artifact-detector.js.map +1 -1
  314. package/dist/src/utils/mermaid-diagrams.d.ts +101 -0
  315. package/dist/src/utils/mermaid-diagrams.d.ts.map +1 -0
  316. package/dist/src/utils/mermaid-diagrams.js +445 -0
  317. package/dist/src/utils/mermaid-diagrams.js.map +1 -0
  318. package/dist/src/utils/monitoring.d.ts +249 -0
  319. package/dist/src/utils/monitoring.d.ts.map +1 -0
  320. package/dist/src/utils/monitoring.js +513 -0
  321. package/dist/src/utils/monitoring.js.map +1 -0
  322. package/dist/src/utils/pattern-contribution-helper.d.ts +60 -0
  323. package/dist/src/utils/pattern-contribution-helper.d.ts.map +1 -0
  324. package/dist/src/utils/pattern-contribution-helper.js +308 -0
  325. package/dist/src/utils/pattern-contribution-helper.js.map +1 -0
  326. package/dist/src/utils/pattern-loader.d.ts +183 -0
  327. package/dist/src/utils/pattern-loader.d.ts.map +1 -0
  328. package/dist/src/utils/pattern-loader.js +200 -0
  329. package/dist/src/utils/pattern-loader.js.map +1 -0
  330. package/dist/src/utils/pattern-research-utility.d.ts +107 -0
  331. package/dist/src/utils/pattern-research-utility.d.ts.map +1 -0
  332. package/dist/src/utils/pattern-research-utility.js +360 -0
  333. package/dist/src/utils/pattern-research-utility.js.map +1 -0
  334. package/dist/src/utils/pattern-to-dag-converter.d.ts +62 -0
  335. package/dist/src/utils/pattern-to-dag-converter.d.ts.map +1 -0
  336. package/dist/src/utils/pattern-to-dag-converter.js +265 -0
  337. package/dist/src/utils/pattern-to-dag-converter.js.map +1 -0
  338. package/dist/src/utils/platform-detector.d.ts +86 -0
  339. package/dist/src/utils/platform-detector.d.ts.map +1 -0
  340. package/dist/src/utils/platform-detector.js +509 -0
  341. package/dist/src/utils/platform-detector.js.map +1 -0
  342. package/dist/src/utils/prompt-composition.d.ts.map +1 -1
  343. package/dist/src/utils/prompt-composition.js +1 -4
  344. package/dist/src/utils/prompt-composition.js.map +1 -1
  345. package/dist/src/utils/reflexion.d.ts.map +1 -1
  346. package/dist/src/utils/reflexion.js +51 -42
  347. package/dist/src/utils/reflexion.js.map +1 -1
  348. package/dist/src/utils/research-integration.d.ts.map +1 -1
  349. package/dist/src/utils/research-integration.js +8 -2
  350. package/dist/src/utils/research-integration.js.map +1 -1
  351. package/dist/src/utils/research-orchestrator.d.ts +209 -0
  352. package/dist/src/utils/research-orchestrator.d.ts.map +1 -0
  353. package/dist/src/utils/research-orchestrator.js +863 -0
  354. package/dist/src/utils/research-orchestrator.js.map +1 -0
  355. package/dist/src/utils/research-questions.d.ts.map +1 -1
  356. package/dist/src/utils/research-questions.js +4 -1
  357. package/dist/src/utils/research-questions.js.map +1 -1
  358. package/dist/src/utils/resource-extractor.d.ts +57 -0
  359. package/dist/src/utils/resource-extractor.d.ts.map +1 -0
  360. package/dist/src/utils/resource-extractor.js +323 -0
  361. package/dist/src/utils/resource-extractor.js.map +1 -0
  362. package/dist/src/utils/resource-versioning.d.ts +124 -0
  363. package/dist/src/utils/resource-versioning.d.ts.map +1 -0
  364. package/dist/src/utils/resource-versioning.js +272 -0
  365. package/dist/src/utils/resource-versioning.js.map +1 -0
  366. package/dist/src/utils/root-manager.d.ts +118 -0
  367. package/dist/src/utils/root-manager.d.ts.map +1 -0
  368. package/dist/src/utils/root-manager.js +154 -0
  369. package/dist/src/utils/root-manager.js.map +1 -0
  370. package/dist/src/utils/rule-generation.d.ts.map +1 -1
  371. package/dist/src/utils/rule-generation.js +4 -1
  372. package/dist/src/utils/rule-generation.js.map +1 -1
  373. package/dist/src/utils/server-context-generator.d.ts +47 -0
  374. package/dist/src/utils/server-context-generator.d.ts.map +1 -0
  375. package/dist/src/utils/server-context-generator.js +666 -0
  376. package/dist/src/utils/server-context-generator.js.map +1 -0
  377. package/dist/src/utils/state-reinforcement-manager.d.ts +60 -0
  378. package/dist/src/utils/state-reinforcement-manager.d.ts.map +1 -0
  379. package/dist/src/utils/state-reinforcement-manager.js +200 -0
  380. package/dist/src/utils/state-reinforcement-manager.js.map +1 -0
  381. package/dist/src/utils/system-card-manager.d.ts +194 -0
  382. package/dist/src/utils/system-card-manager.d.ts.map +1 -0
  383. package/dist/src/utils/system-card-manager.js +336 -0
  384. package/dist/src/utils/system-card-manager.js.map +1 -0
  385. package/dist/src/utils/tiered-response-manager.d.ts +40 -0
  386. package/dist/src/utils/tiered-response-manager.d.ts.map +1 -0
  387. package/dist/src/utils/tiered-response-manager.js +243 -0
  388. package/dist/src/utils/tiered-response-manager.js.map +1 -0
  389. package/dist/src/utils/tree-sitter-analyzer.d.ts.map +1 -1
  390. package/dist/src/utils/tree-sitter-analyzer.js +83 -11
  391. package/dist/src/utils/tree-sitter-analyzer.js.map +1 -1
  392. package/dist/src/utils/validated-pattern-definitions.d.ts +219 -0
  393. package/dist/src/utils/validated-pattern-definitions.d.ts.map +1 -0
  394. package/dist/src/utils/validated-pattern-definitions.js +1511 -0
  395. package/dist/src/utils/validated-pattern-definitions.js.map +1 -0
  396. package/package.json +21 -12
  397. package/dist/src/prompts/todo-prompts.d.ts +0 -49
  398. package/dist/src/prompts/todo-prompts.d.ts.map +0 -1
  399. package/dist/src/prompts/todo-prompts.js +0 -824
  400. package/dist/src/prompts/todo-prompts.js.map +0 -1
  401. package/dist/src/types/todo-json-schemas.d.ts +0 -17
  402. package/dist/src/types/todo-json-schemas.d.ts.map +0 -1
  403. package/dist/src/types/todo-json-schemas.js +0 -9
  404. package/dist/src/types/todo-json-schemas.js.map +0 -1
  405. package/dist/src/utils/todo-file-watcher.d.ts +0 -14
  406. package/dist/src/utils/todo-file-watcher.d.ts.map +0 -1
  407. package/dist/src/utils/todo-file-watcher.js +0 -25
  408. 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: {
@@ -792,6 +878,69 @@ export class McpAdrAnalysisServer {
792
878
  },
793
879
  },
794
880
  },
881
+ {
882
+ name: 'validate_adr',
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.',
884
+ inputSchema: {
885
+ type: 'object',
886
+ properties: {
887
+ adrPath: {
888
+ type: 'string',
889
+ description: 'Path to the ADR file to validate (relative or absolute)',
890
+ },
891
+ projectPath: {
892
+ type: 'string',
893
+ description: 'Path to the project directory',
894
+ default: '.',
895
+ },
896
+ adrDirectory: {
897
+ type: 'string',
898
+ description: 'Directory containing ADR files',
899
+ default: 'docs/adrs',
900
+ },
901
+ includeEnvironmentCheck: {
902
+ type: 'boolean',
903
+ description: 'Include live environment verification in validation',
904
+ default: true,
905
+ },
906
+ confidenceThreshold: {
907
+ type: 'number',
908
+ description: 'Minimum research confidence threshold (0-1)',
909
+ default: 0.6,
910
+ },
911
+ },
912
+ required: ['adrPath'],
913
+ },
914
+ },
915
+ {
916
+ name: 'validate_all_adrs',
917
+ description: 'Validate all ADRs in a directory against actual infrastructure reality',
918
+ inputSchema: {
919
+ type: 'object',
920
+ properties: {
921
+ projectPath: {
922
+ type: 'string',
923
+ description: 'Path to the project directory',
924
+ default: '.',
925
+ },
926
+ adrDirectory: {
927
+ type: 'string',
928
+ description: 'Directory containing ADR files',
929
+ default: 'docs/adrs',
930
+ },
931
+ includeEnvironmentCheck: {
932
+ type: 'boolean',
933
+ description: 'Include live environment verification in validation',
934
+ default: true,
935
+ },
936
+ minConfidence: {
937
+ type: 'number',
938
+ description: 'Minimum research confidence for validation (0-1)',
939
+ default: 0.6,
940
+ },
941
+ },
942
+ },
943
+ },
795
944
  {
796
945
  name: 'incorporate_research',
797
946
  description: 'Incorporate research findings into architectural decisions',
@@ -1204,95 +1353,255 @@ export class McpAdrAnalysisServer {
1204
1353
  },
1205
1354
  },
1206
1355
  {
1207
- name: 'analyze_deployment_progress',
1208
- description: 'Analyze deployment progress and verify completion with outcome rules',
1356
+ name: 'perform_research',
1357
+ description: 'Perform research using cascading sources: project files → knowledge graph → environment resources → web search (fallback)',
1209
1358
  inputSchema: {
1210
1359
  type: 'object',
1211
1360
  properties: {
1212
- analysisType: {
1361
+ question: {
1213
1362
  type: 'string',
1214
- enum: ['tasks', 'cicd', 'progress', 'completion', 'comprehensive'],
1215
- description: 'Type of deployment analysis to perform',
1216
- default: 'comprehensive',
1363
+ description: 'The research question to answer',
1364
+ },
1365
+ projectPath: {
1366
+ type: 'string',
1367
+ description: 'Path to project directory',
1368
+ default: '.',
1217
1369
  },
1218
1370
  adrDirectory: {
1219
1371
  type: 'string',
1220
1372
  description: 'Directory containing ADR files',
1221
1373
  default: 'docs/adrs',
1222
1374
  },
1223
- todoPath: {
1224
- type: 'string',
1225
- description: 'Path to TODO.md file for task identification',
1226
- default: 'TODO.md',
1375
+ confidenceThreshold: {
1376
+ type: 'number',
1377
+ description: 'Minimum confidence threshold (0-1) before suggesting web search',
1378
+ default: 0.6,
1379
+ minimum: 0,
1380
+ maximum: 1,
1227
1381
  },
1228
- cicdLogs: {
1229
- type: 'string',
1230
- description: 'CI/CD pipeline logs for analysis',
1382
+ performWebSearch: {
1383
+ type: 'boolean',
1384
+ description: 'Enable web search recommendations when confidence is low',
1385
+ default: true,
1231
1386
  },
1232
- pipelineConfig: {
1387
+ },
1388
+ required: ['question'],
1389
+ },
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: {
1233
1398
  type: 'string',
1234
- description: 'CI/CD pipeline configuration',
1399
+ description: 'The search query to execute',
1235
1400
  },
1236
- deploymentTasks: {
1237
- type: 'array',
1238
- items: {
1239
- type: 'object',
1240
- properties: {
1241
- taskId: { type: 'string' },
1242
- taskName: { type: 'string' },
1243
- status: { type: 'string' },
1244
- progress: { type: 'number' },
1245
- category: { type: 'string' },
1246
- priority: { type: 'string' },
1247
- verificationCriteria: { type: 'array', items: { type: 'string' } },
1248
- expectedOutcome: { type: 'string' },
1249
- },
1250
- },
1251
- description: 'Deployment tasks for progress calculation',
1401
+ maxResults: {
1402
+ type: 'number',
1403
+ description: 'Maximum results to return',
1404
+ default: 5,
1405
+ minimum: 1,
1406
+ maximum: 20,
1252
1407
  },
1253
- outcomeRules: {
1254
- type: 'array',
1255
- items: {
1256
- type: 'object',
1257
- properties: {
1258
- ruleId: { type: 'string' },
1259
- description: { type: 'string' },
1260
- criteria: { type: 'array', items: { type: 'string' } },
1261
- verificationMethod: { type: 'string' },
1262
- },
1263
- },
1264
- description: 'Outcome rules for completion verification',
1408
+ includeContent: {
1409
+ type: 'boolean',
1410
+ description: 'Include full content in results',
1411
+ default: true,
1265
1412
  },
1266
- actualOutcomes: {
1267
- type: 'array',
1268
- items: {
1269
- type: 'object',
1270
- properties: {
1271
- taskId: { type: 'string' },
1272
- outcome: { type: 'string' },
1273
- evidence: { type: 'array', items: { type: 'string' } },
1274
- timestamp: { type: 'string' },
1275
- },
1276
- },
1277
- description: 'Actual deployment outcomes',
1413
+ llmInstructions: {
1414
+ type: 'string',
1415
+ description: 'LLM instructions for search optimization',
1278
1416
  },
1279
- cicdStatus: {
1280
- type: 'object',
1281
- description: 'CI/CD pipeline status data',
1417
+ projectPath: {
1418
+ type: 'string',
1419
+ description: 'Path to project directory',
1420
+ default: '.',
1282
1421
  },
1283
- environmentStatus: {
1284
- type: 'object',
1285
- description: 'Environment status data',
1422
+ adrDirectory: {
1423
+ type: 'string',
1424
+ description: 'Directory containing ADR files',
1425
+ default: 'docs/adrs',
1286
1426
  },
1287
1427
  },
1428
+ required: ['query'],
1288
1429
  },
1289
1430
  },
1290
1431
  {
1291
- name: 'check_ai_execution_status',
1292
- description: 'Check AI execution configuration and status for debugging prompt-only mode issues',
1432
+ name: 'llm_cloud_management',
1433
+ description: 'LLM-managed cloud provider operations with research-driven approach',
1293
1434
  inputSchema: {
1294
1435
  type: 'object',
1295
- properties: {},
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
+ },
1515
+ {
1516
+ name: 'analyze_deployment_progress',
1517
+ description: 'Analyze deployment progress and verify completion with outcome rules',
1518
+ inputSchema: {
1519
+ type: 'object',
1520
+ properties: {
1521
+ analysisType: {
1522
+ type: 'string',
1523
+ enum: ['tasks', 'cicd', 'progress', 'completion', 'comprehensive'],
1524
+ description: 'Type of deployment analysis to perform',
1525
+ default: 'comprehensive',
1526
+ },
1527
+ adrDirectory: {
1528
+ type: 'string',
1529
+ description: 'Directory containing ADR files',
1530
+ default: 'docs/adrs',
1531
+ },
1532
+ todoPath: {
1533
+ type: 'string',
1534
+ description: 'Path to TODO.md file for task identification',
1535
+ default: 'TODO.md',
1536
+ },
1537
+ cicdLogs: {
1538
+ type: 'string',
1539
+ description: 'CI/CD pipeline logs for analysis',
1540
+ },
1541
+ pipelineConfig: {
1542
+ type: 'string',
1543
+ description: 'CI/CD pipeline configuration',
1544
+ },
1545
+ deploymentTasks: {
1546
+ type: 'array',
1547
+ items: {
1548
+ type: 'object',
1549
+ properties: {
1550
+ taskId: { type: 'string' },
1551
+ taskName: { type: 'string' },
1552
+ status: { type: 'string' },
1553
+ progress: { type: 'number' },
1554
+ category: { type: 'string' },
1555
+ priority: { type: 'string' },
1556
+ verificationCriteria: { type: 'array', items: { type: 'string' } },
1557
+ expectedOutcome: { type: 'string' },
1558
+ },
1559
+ },
1560
+ description: 'Deployment tasks for progress calculation',
1561
+ },
1562
+ outcomeRules: {
1563
+ type: 'array',
1564
+ items: {
1565
+ type: 'object',
1566
+ properties: {
1567
+ ruleId: { type: 'string' },
1568
+ description: { type: 'string' },
1569
+ criteria: { type: 'array', items: { type: 'string' } },
1570
+ verificationMethod: { type: 'string' },
1571
+ },
1572
+ },
1573
+ description: 'Outcome rules for completion verification',
1574
+ },
1575
+ actualOutcomes: {
1576
+ type: 'array',
1577
+ items: {
1578
+ type: 'object',
1579
+ properties: {
1580
+ taskId: { type: 'string' },
1581
+ outcome: { type: 'string' },
1582
+ evidence: { type: 'array', items: { type: 'string' } },
1583
+ timestamp: { type: 'string' },
1584
+ },
1585
+ },
1586
+ description: 'Actual deployment outcomes',
1587
+ },
1588
+ cicdStatus: {
1589
+ type: 'object',
1590
+ description: 'CI/CD pipeline status data',
1591
+ },
1592
+ environmentStatus: {
1593
+ type: 'object',
1594
+ description: 'Environment status data',
1595
+ },
1596
+ },
1597
+ },
1598
+ },
1599
+ {
1600
+ name: 'check_ai_execution_status',
1601
+ description: 'Check AI execution configuration and status for debugging prompt-only mode issues',
1602
+ inputSchema: {
1603
+ type: 'object',
1604
+ properties: {},
1296
1605
  required: [],
1297
1606
  },
1298
1607
  },
@@ -1402,18 +1711,44 @@ export class McpAdrAnalysisServer {
1402
1711
  required: ['developmentPhase'],
1403
1712
  },
1404
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
+ },
1405
1736
  {
1406
1737
  name: 'read_file',
1407
1738
  description: 'Read contents of a file',
1408
1739
  inputSchema: {
1409
1740
  type: 'object',
1410
1741
  properties: {
1411
- path: {
1742
+ filePath: {
1412
1743
  type: 'string',
1413
1744
  description: 'Path to the file to read',
1414
1745
  },
1746
+ path: {
1747
+ type: 'string',
1748
+ description: 'Path to the file to read (alias for filePath)',
1749
+ },
1415
1750
  },
1416
- required: ['path'],
1751
+ required: [],
1417
1752
  },
1418
1753
  },
1419
1754
  {
@@ -1448,200 +1783,6 @@ export class McpAdrAnalysisServer {
1448
1783
  required: ['path'],
1449
1784
  },
1450
1785
  },
1451
- {
1452
- name: 'manage_todo_json',
1453
- description: 'JSON-first TODO management with consistent LLM interactions, automatic scoring sync, and knowledge graph integration',
1454
- inputSchema: {
1455
- type: 'object',
1456
- properties: {
1457
- operation: {
1458
- type: 'string',
1459
- enum: [
1460
- 'create_task',
1461
- 'update_task',
1462
- 'bulk_update',
1463
- 'get_tasks',
1464
- 'get_analytics',
1465
- 'import_adr_tasks',
1466
- 'sync_knowledge_graph',
1467
- 'sync_to_markdown',
1468
- 'import_from_markdown',
1469
- ],
1470
- description: 'Operation to perform on TODO JSON backend',
1471
- },
1472
- projectPath: {
1473
- type: 'string',
1474
- description: 'Project root path (uses configured PROJECT_PATH if not provided)',
1475
- },
1476
- taskId: {
1477
- type: 'string',
1478
- description: 'Task ID for update operations',
1479
- },
1480
- title: {
1481
- type: 'string',
1482
- description: 'Task title for create operations',
1483
- },
1484
- description: {
1485
- type: 'string',
1486
- description: 'Task description',
1487
- },
1488
- priority: {
1489
- type: 'string',
1490
- enum: ['low', 'medium', 'high', 'critical'],
1491
- default: 'medium',
1492
- description: 'Task priority level',
1493
- },
1494
- assignee: {
1495
- type: 'string',
1496
- description: 'Task assignee',
1497
- },
1498
- dueDate: {
1499
- type: 'string',
1500
- description: 'Due date (ISO string format)',
1501
- },
1502
- category: {
1503
- type: 'string',
1504
- description: 'Task category',
1505
- },
1506
- tags: {
1507
- type: 'array',
1508
- items: { type: 'string' },
1509
- description: 'Task tags',
1510
- },
1511
- dependencies: {
1512
- type: 'array',
1513
- items: { type: 'string' },
1514
- description: 'Task dependencies (task IDs)',
1515
- },
1516
- intentId: {
1517
- type: 'string',
1518
- description: 'Link to knowledge graph intent',
1519
- },
1520
- linkedAdrs: {
1521
- type: 'array',
1522
- items: { type: 'string' },
1523
- description: 'Related ADR files',
1524
- },
1525
- autoComplete: {
1526
- type: 'boolean',
1527
- default: false,
1528
- description: 'Auto-complete when criteria are met',
1529
- },
1530
- completionCriteria: {
1531
- type: 'string',
1532
- description: 'Auto-completion rules',
1533
- },
1534
- updates: {
1535
- type: 'object',
1536
- properties: {
1537
- title: { type: 'string' },
1538
- description: { type: 'string' },
1539
- status: {
1540
- type: 'string',
1541
- enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'],
1542
- },
1543
- priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1544
- assignee: { type: 'string' },
1545
- dueDate: { type: 'string' },
1546
- progressPercentage: { type: 'number', minimum: 0, maximum: 100 },
1547
- notes: { type: 'string' },
1548
- tags: { type: 'array', items: { type: 'string' } },
1549
- },
1550
- description: 'Fields to update for update operations',
1551
- },
1552
- reason: {
1553
- type: 'string',
1554
- description: 'Reason for update (for changelog)',
1555
- },
1556
- filters: {
1557
- type: 'object',
1558
- properties: {
1559
- status: {
1560
- type: 'string',
1561
- enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'],
1562
- },
1563
- priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1564
- assignee: { type: 'string' },
1565
- category: { type: 'string' },
1566
- hasDeadline: { type: 'boolean' },
1567
- overdue: { type: 'boolean' },
1568
- tags: { type: 'array', items: { type: 'string' } },
1569
- },
1570
- description: 'Filter criteria for get_tasks operation',
1571
- },
1572
- sortBy: {
1573
- type: 'string',
1574
- enum: ['priority', 'dueDate', 'createdAt', 'updatedAt'],
1575
- default: 'priority',
1576
- description: 'Sort field for get_tasks operation',
1577
- },
1578
- sortOrder: {
1579
- type: 'string',
1580
- enum: ['asc', 'desc'],
1581
- default: 'desc',
1582
- description: 'Sort order for get_tasks operation',
1583
- },
1584
- limit: {
1585
- type: 'number',
1586
- description: 'Maximum number of tasks to return',
1587
- },
1588
- timeframe: {
1589
- type: 'string',
1590
- enum: ['day', 'week', 'month', 'all'],
1591
- default: 'week',
1592
- description: 'Analysis timeframe for analytics',
1593
- },
1594
- includeVelocity: {
1595
- type: 'boolean',
1596
- default: true,
1597
- description: 'Include velocity metrics in analytics',
1598
- },
1599
- includeScoring: {
1600
- type: 'boolean',
1601
- default: true,
1602
- description: 'Include scoring metrics in analytics',
1603
- },
1604
- adrDirectory: {
1605
- type: 'string',
1606
- default: 'docs/adrs',
1607
- description: 'ADR directory path for imports',
1608
- },
1609
- preserveExisting: {
1610
- type: 'boolean',
1611
- default: true,
1612
- description: 'Keep existing tasks during imports',
1613
- },
1614
- autoLinkDependencies: {
1615
- type: 'boolean',
1616
- default: true,
1617
- description: 'Auto-detect task dependencies',
1618
- },
1619
- direction: {
1620
- type: 'string',
1621
- enum: ['to_kg', 'from_kg', 'bidirectional'],
1622
- default: 'bidirectional',
1623
- description: 'Knowledge graph sync direction',
1624
- },
1625
- force: {
1626
- type: 'boolean',
1627
- default: false,
1628
- description: 'Force operation even if conflicts exist',
1629
- },
1630
- mergeStrategy: {
1631
- type: 'string',
1632
- enum: ['overwrite', 'merge', 'preserve_json'],
1633
- default: 'merge',
1634
- description: 'Merge strategy for imports',
1635
- },
1636
- backupExisting: {
1637
- type: 'boolean',
1638
- default: true,
1639
- description: 'Create backup before destructive operations',
1640
- },
1641
- },
1642
- required: ['operation'],
1643
- },
1644
- },
1645
1786
  {
1646
1787
  name: 'generate_deployment_guidance',
1647
1788
  description: 'Generate deployment guidance and instructions from ADRs with environment-specific configurations',
@@ -2137,7 +2278,6 @@ export class McpAdrAnalysisServer {
2137
2278
  items: {
2138
2279
  type: 'string',
2139
2280
  enum: [
2140
- 'manage_todo_json',
2141
2281
  'smart_git_push',
2142
2282
  'compare_adr_progress',
2143
2283
  'analyze_content_security',
@@ -2460,7 +2600,7 @@ export class McpAdrAnalysisServer {
2460
2600
  },
2461
2601
  {
2462
2602
  name: 'interactive_adr_planning',
2463
- 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.',
2464
2604
  inputSchema: {
2465
2605
  type: 'object',
2466
2606
  properties: {
@@ -2652,75 +2792,263 @@ export class McpAdrAnalysisServer {
2652
2792
  description: 'Maximum depth for relationship traversal (find_related action)',
2653
2793
  default: 2,
2654
2794
  },
2655
- forceReload: {
2795
+ forceReload: {
2796
+ type: 'boolean',
2797
+ description: 'Force reload of ADRs (load_adrs action)',
2798
+ default: false,
2799
+ },
2800
+ },
2801
+ },
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
+ },
2827
+ {
2828
+ name: 'tool_chain_orchestrator',
2829
+ description: 'AI-powered dynamic tool sequencing - intelligently analyze user requests and generate structured tool execution plans',
2830
+ inputSchema: {
2831
+ type: 'object',
2832
+ properties: {
2833
+ userRequest: {
2834
+ type: 'string',
2835
+ description: 'User request to analyze and create tool execution plan for',
2836
+ },
2837
+ availableTools: {
2838
+ type: 'array',
2839
+ items: { type: 'string' },
2840
+ description: 'List of available MCP tools to orchestrate',
2841
+ },
2842
+ executionMode: {
2843
+ type: 'string',
2844
+ enum: ['plan_only', 'plan_and_execute', 'validate_plan'],
2845
+ description: 'Orchestration mode',
2846
+ default: 'plan_only',
2847
+ },
2848
+ maxSteps: {
2849
+ type: 'number',
2850
+ description: 'Maximum number of steps in the execution plan',
2851
+ default: 10,
2852
+ },
2853
+ allowParallel: {
2854
+ type: 'boolean',
2855
+ description: 'Allow parallel execution of independent steps',
2856
+ default: true,
2857
+ },
2858
+ contextHints: {
2859
+ type: 'array',
2860
+ items: { type: 'string' },
2861
+ description: 'Additional context hints for better plan generation',
2862
+ },
2863
+ },
2864
+ required: ['userRequest'],
2865
+ },
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: {
2656
2882
  type: 'boolean',
2657
- description: 'Force reload of ADRs (load_adrs action)',
2658
- default: false,
2883
+ description: 'Include related conversation context and knowledge graph state',
2884
+ default: true,
2659
2885
  },
2660
2886
  },
2887
+ required: ['expandableId'],
2661
2888
  },
2662
2889
  },
2663
2890
  {
2664
- name: 'tool_chain_orchestrator',
2665
- description: 'AI-powered dynamic tool sequencing - intelligently analyze user requests and generate structured tool execution plans',
2891
+ name: 'query_conversation_history',
2892
+ description: 'Phase 3: Search and retrieve conversation sessions based on filters',
2666
2893
  inputSchema: {
2667
2894
  type: 'object',
2668
2895
  properties: {
2669
- userRequest: {
2896
+ projectPath: {
2670
2897
  type: 'string',
2671
- description: 'User request to analyze and create tool execution plan for',
2898
+ description: 'Filter by project path',
2672
2899
  },
2673
- availableTools: {
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: {
2674
2909
  type: 'array',
2675
2910
  items: { type: 'string' },
2676
- description: 'List of available MCP tools to orchestrate',
2911
+ description: 'Filter by tools used in the session',
2677
2912
  },
2678
- executionMode: {
2913
+ keyword: {
2679
2914
  type: 'string',
2680
- enum: ['plan_only', 'plan_and_execute', 'validate_plan'],
2681
- description: 'Orchestration mode',
2682
- default: 'plan_only',
2915
+ description: 'Search keyword in conversation turns',
2683
2916
  },
2684
- maxSteps: {
2917
+ limit: {
2685
2918
  type: 'number',
2686
- description: 'Maximum number of steps in the execution plan',
2919
+ description: 'Maximum number of sessions to return',
2687
2920
  default: 10,
2688
2921
  },
2689
- allowParallel: {
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: {
2690
2954
  type: 'boolean',
2691
- description: 'Allow parallel execution of independent steps',
2955
+ description: 'Whether to write the context to .mcp-server-context.md file',
2692
2956
  default: true,
2693
2957
  },
2694
- contextHints: {
2695
- type: 'array',
2696
- items: { type: 'string' },
2697
- description: 'Additional context hints for better plan generation',
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,
2698
2971
  },
2699
2972
  },
2700
- required: ['userRequest'],
2701
2973
  },
2702
2974
  },
2703
2975
  ],
2704
2976
  };
2705
2977
  });
2706
- // 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
+ */
2707
3020
  this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
2708
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
+ };
2709
3040
  try {
2710
3041
  let response;
2711
3042
  const safeArgs = args || {};
2712
3043
  switch (name) {
2713
3044
  case 'analyze_project_ecosystem':
2714
- response = await this.analyzeProjectEcosystem(safeArgs);
3045
+ response = await this.analyzeProjectEcosystem(safeArgs, context);
2715
3046
  break;
2716
3047
  case 'get_architectural_context':
2717
3048
  response = await this.getArchitecturalContext(safeArgs);
2718
3049
  break;
2719
3050
  case 'generate_adrs_from_prd':
2720
- response = await this.generateAdrsFromPrd(safeArgs);
2721
- break;
2722
- case 'generate_adr_todo':
2723
- response = await this.generateAdrTodo(safeArgs);
3051
+ response = await this.generateAdrsFromPrd(safeArgs, context);
2724
3052
  break;
2725
3053
  case 'compare_adr_progress':
2726
3054
  response = await this.compareAdrProgress(safeArgs);
@@ -2755,12 +3083,24 @@ export class McpAdrAnalysisServer {
2755
3083
  case 'generate_adr_bootstrap':
2756
3084
  response = await this.generateAdrBootstrap(safeArgs);
2757
3085
  break;
3086
+ case 'bootstrap_validation_loop':
3087
+ response = await this.bootstrapValidationLoop(safeArgs);
3088
+ break;
2758
3089
  case 'discover_existing_adrs':
2759
- 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);
2760
3094
  break;
2761
3095
  case 'review_existing_adrs':
2762
3096
  response = await this.reviewExistingAdrs(safeArgs);
2763
3097
  break;
3098
+ case 'validate_adr':
3099
+ response = await this.validateAdr(safeArgs);
3100
+ break;
3101
+ case 'validate_all_adrs':
3102
+ response = await this.validateAllAdrs(safeArgs);
3103
+ break;
2764
3104
  case 'incorporate_research':
2765
3105
  response = await this.incorporateResearch(safeArgs);
2766
3106
  break;
@@ -2785,6 +3125,18 @@ export class McpAdrAnalysisServer {
2785
3125
  case 'generate_research_questions':
2786
3126
  response = await this.generateResearchQuestions(safeArgs);
2787
3127
  break;
3128
+ case 'perform_research':
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);
3139
+ break;
2788
3140
  case 'analyze_deployment_progress':
2789
3141
  response = await this.analyzeDeploymentProgress(safeArgs);
2790
3142
  break;
@@ -2797,18 +3149,26 @@ export class McpAdrAnalysisServer {
2797
3149
  case 'get_development_guidance':
2798
3150
  response = await this.getDevelopmentGuidance(safeArgs);
2799
3151
  break;
2800
- case 'read_file':
2801
- 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);
2802
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
+ }
2803
3166
  case 'write_file':
2804
3167
  response = await this.writeFile(safeArgs);
2805
3168
  break;
2806
3169
  case 'list_directory':
2807
3170
  response = await this.listDirectory(safeArgs);
2808
3171
  break;
2809
- case 'manage_todo_json':
2810
- response = await this.manageTodoJson(safeArgs);
2811
- break;
2812
3172
  case 'generate_deployment_guidance':
2813
3173
  response = await this.generateDeploymentGuidance(safeArgs);
2814
3174
  break;
@@ -2830,19 +3190,38 @@ export class McpAdrAnalysisServer {
2830
3190
  case 'memory_loading':
2831
3191
  response = await this.memoryLoading(safeArgs);
2832
3192
  break;
3193
+ case 'expand_analysis_section':
3194
+ response = await this.expandAnalysisSection(safeArgs);
3195
+ break;
2833
3196
  case 'interactive_adr_planning':
2834
3197
  response = await this.interactiveAdrPlanning(safeArgs);
2835
3198
  break;
2836
3199
  case 'tool_chain_orchestrator':
2837
3200
  response = await this.toolChainOrchestrator(safeArgs);
2838
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;
2839
3217
  default:
2840
3218
  throw new McpAdrError(`Unknown tool: ${name}`, 'UNKNOWN_TOOL');
2841
3219
  }
2842
- // Apply content masking to response
2843
3220
  // Track tool execution in knowledge graph
2844
3221
  await this.trackToolExecution(name, args, response, true);
2845
- 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);
2846
3225
  }
2847
3226
  catch (error) {
2848
3227
  // Track failed execution
@@ -2853,32 +3232,213 @@ export class McpAdrAnalysisServer {
2853
3232
  throw new McpAdrError(`Tool execution failed: ${error instanceof Error ? error.message : String(error)}`, 'TOOL_EXECUTION_ERROR');
2854
3233
  }
2855
3234
  });
2856
- // 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
+ */
2857
3260
  this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
2858
3261
  return {
2859
3262
  resources: [
3263
+ // Existing resources (refactored to return data)
2860
3264
  {
2861
3265
  uri: 'adr://architectural_knowledge_graph',
2862
3266
  name: 'Architectural Knowledge Graph',
2863
- description: 'Complete architectural knowledge graph of the project',
3267
+ description: 'Complete architectural knowledge graph with technologies, patterns, and relationships',
2864
3268
  mimeType: 'application/json',
2865
3269
  },
2866
3270
  {
2867
3271
  uri: 'adr://analysis_report',
2868
3272
  name: 'Analysis Report',
2869
- description: 'Comprehensive project analysis report',
3273
+ description: 'Comprehensive project analysis report with metrics and recommendations',
2870
3274
  mimeType: 'application/json',
2871
3275
  },
2872
3276
  {
2873
3277
  uri: 'adr://adr_list',
2874
3278
  name: 'ADR List',
2875
- description: 'List of all Architectural Decision Records',
3279
+ description: 'List of all Architectural Decision Records with status and metadata',
3280
+ mimeType: 'application/json',
3281
+ },
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',
2876
3411
  mimeType: 'application/json',
2877
3412
  },
2878
3413
  ],
2879
3414
  };
2880
3415
  });
2881
- // Resource reading handler
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
+ */
2882
3442
  this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
2883
3443
  const { uri } = request.params;
2884
3444
  try {
@@ -2892,7 +3452,31 @@ export class McpAdrAnalysisServer {
2892
3452
  throw new McpAdrError(`Resource reading failed: ${error instanceof Error ? error.message : String(error)}`, 'RESOURCE_ERROR');
2893
3453
  }
2894
3454
  });
2895
- // Prompts handler
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
+ */
2896
3480
  this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
2897
3481
  const { allPrompts } = await import('./prompts/index.js');
2898
3482
  return {
@@ -2903,7 +3487,47 @@ export class McpAdrAnalysisServer {
2903
3487
  })),
2904
3488
  };
2905
3489
  });
2906
- // Prompt execution handler
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
+ */
2907
3531
  this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
2908
3532
  const { name, arguments: args } = request.params;
2909
3533
  try {
@@ -3071,18 +3695,17 @@ Verify these environment variables are set in your MCP configuration:
3071
3695
  5. **suggest_adrs** - Auto-suggest ADRs from implicit decisions
3072
3696
  6. **generate_adr_from_decision** - Create ADRs from specific decisions
3073
3697
  7. **discover_existing_adrs** - Intelligent ADR discovery and analysis
3074
- 8. **generate_adr_todo** - Create actionable task lists from ADRs
3075
3698
 
3076
3699
  ### 🔍 **Research & Documentation Tools** (AI-Powered ✅)
3077
- 9. **generate_research_questions** - Create context-aware research questions
3078
- 10. **incorporate_research** - Integrate research findings into decisions
3079
- 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
3080
3703
 
3081
3704
  ### 🛡️ **Security & Compliance Tools** (AI-Powered ✅)
3082
- 12. **generate_content_masking** - Intelligent content masking and protection
3083
- 13. **configure_custom_patterns** - Customize security and masking settings
3084
- 14. **apply_basic_content_masking** - Basic content masking (fallback)
3085
- 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
3086
3709
 
3087
3710
  ### 🏗️ **Rule & Governance Tools** (AI-Powered ✅)
3088
3711
  16. **generate_rules** - Extract architectural rules from ADRs
@@ -3140,13 +3763,13 @@ Define how to measure success:
3140
3763
  1. analyze_project_ecosystem → 2. get_architectural_context → 3. suggest_adrs → 4. generate_adr_from_decision
3141
3764
 
3142
3765
  ### **Existing Project Analysis**
3143
- 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
3144
3767
 
3145
3768
  ### **Security Audit**
3146
3769
  1. analyze_content_security → 2. generate_content_masking → 3. configure_custom_patterns → 4. validate_content_masking
3147
3770
 
3148
3771
  ### **PRD to Implementation**
3149
- 1. generate_adrs_from_prd → 2. generate_adr_todo → 3. analyze_deployment_progress
3772
+ 1. generate_adrs_from_prd → 2. analyze_deployment_progress
3150
3773
 
3151
3774
  ### **Legacy Modernization**
3152
3775
  1. analyze_project_ecosystem → 2. get_architectural_context → 3. suggest_adrs → 4. generate_rules → 5. validate_rules
@@ -3194,7 +3817,7 @@ ${executionResult.content}
3194
3817
  ## Quick Reference: Available Tools
3195
3818
 
3196
3819
  **Core Analysis**: analyze_project_ecosystem, get_architectural_context, generate_adrs_from_prd, analyze_content_security
3197
- **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
3198
3821
  **Security**: generate_content_masking, configure_custom_patterns, validate_content_masking
3199
3822
  **Governance**: generate_rules, validate_rules, create_rule_set
3200
3823
  **Environment**: analyze_environment, analyze_deployment_progress
@@ -3237,7 +3860,10 @@ This guidance is tailored to your specific context and goals for maximum effecti
3237
3860
  const { getAdrDirectoryPath } = await import('./utils/config.js');
3238
3861
  const { discoverAdrsInDirectory } = await import('./utils/adr-discovery.js');
3239
3862
  const absoluteAdrPath = getAdrDirectoryPath(this.config);
3240
- 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
+ });
3241
3867
  // Filter ADRs to only those specified for implementation
3242
3868
  const targetAdrs = discoveryResult.adrs.filter(adr => adrsToImplement.some((target) => adr.title.toLowerCase().includes(target.toLowerCase()) ||
3243
3869
  adr.filename.toLowerCase().includes(target.toLowerCase())));
@@ -3432,7 +4058,6 @@ This development guidance works seamlessly with other MCP tools:
3432
4058
  - **analyze_content_security** → Security validation during development
3433
4059
 
3434
4060
  ### **Documentation Tools**
3435
- - **generate_adr_todo** → Create implementation task lists
3436
4061
  - **discover_existing_adrs** → Reference existing architectural decisions
3437
4062
 
3438
4063
  ## Next Steps: From Architecture to Code
@@ -3463,7 +4088,8 @@ This guidance ensures your development work is **architecturally aligned**, **qu
3463
4088
  throw new McpAdrError(`Failed to generate development guidance: ${error instanceof Error ? error.message : String(error)}`, 'DEVELOPMENT_ERROR');
3464
4089
  }
3465
4090
  }
3466
- async analyzeProjectEcosystem(args) {
4091
+ async analyzeProjectEcosystem(args, context) {
4092
+ const ctx = context || createNoOpContext();
3467
4093
  // Use configured project path if not provided in args
3468
4094
  const projectPath = args.projectPath || this.config.projectPath;
3469
4095
  const { includePatterns, enhancedMode = true, knowledgeEnhancement = true, learningEnabled = true, technologyFocus = [], analysisDepth = 'comprehensive', includeEnvironment = true, recursiveDepth = 'comprehensive', analysisScope = [],
@@ -3473,9 +4099,38 @@ This guidance ensures your development work is **architecturally aligned**, **qu
3473
4099
  this.logger.info(`Analysis configuration - Depth: ${analysisDepth}, Recursive: ${recursiveDepth}, Environment: ${includeEnvironment}`);
3474
4100
  this.logger.info(`Enhancement features - Knowledge: ${knowledgeEnhancement}, Learning: ${learningEnabled}`);
3475
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);
3476
4104
  try {
4105
+ ctx.info('📊 Phase 1: Analyzing project structure');
4106
+ ctx.report_progress(10, 100);
3477
4107
  // Import utilities dynamically to avoid circular dependencies
3478
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
+ }
3479
4134
  // Import advanced prompting utilities if enhanced mode is enabled
3480
4135
  let generateArchitecturalKnowledge = null;
3481
4136
  let executeWithReflexion = null;
@@ -3494,6 +4149,8 @@ This guidance ensures your development work is **architecturally aligned**, **qu
3494
4149
  }
3495
4150
  }
3496
4151
  // Step 1: Generate technology-specific knowledge if enabled
4152
+ ctx.info('🧠 Phase 2: Generating architectural knowledge');
4153
+ ctx.report_progress(25, 100);
3497
4154
  let knowledgeContext = '';
3498
4155
  if (enhancedMode && knowledgeEnhancement && generateArchitecturalKnowledge) {
3499
4156
  try {
@@ -3544,8 +4201,12 @@ ${memoryResult.prompt}
3544
4201
  }
3545
4202
  }
3546
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);
3547
4206
  const baseProjectAnalysisPrompt = await analyzeProjectStructure(projectPath);
3548
4207
  // Step 4: Generate environment analysis if enabled
4208
+ ctx.info('🔧 Phase 4: Analyzing environment and infrastructure');
4209
+ ctx.report_progress(55, 100);
3549
4210
  let environmentAnalysisContext = '';
3550
4211
  if (includeEnvironment) {
3551
4212
  try {
@@ -3579,6 +4240,8 @@ ${environmentResult.content[0].text}
3579
4240
  }
3580
4241
  }
3581
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);
3582
4245
  let enhancedAnalysisPrompt = baseProjectAnalysisPrompt.prompt + environmentAnalysisContext;
3583
4246
  if (enhancedMode && learningEnabled && executeWithReflexion && createToolReflexionConfig) {
3584
4247
  try {
@@ -3615,6 +4278,8 @@ ${environmentResult.content[0].text}
3615
4278
  baseProjectAnalysisPrompt.prompt + knowledgeContext + environmentAnalysisContext;
3616
4279
  }
3617
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);
3618
4283
  const { executeEcosystemAnalysisPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
3619
4284
  const executionResult = await executeEcosystemAnalysisPrompt(enhancedAnalysisPrompt, baseProjectAnalysisPrompt.instructions, {
3620
4285
  temperature: 0.1,
@@ -3640,6 +4305,8 @@ ${environmentResult.content[0].text}
3640
4305
  this.logger.warn('Failed to record project structure to knowledge graph:', kgError);
3641
4306
  // Don't fail the entire analysis if KG recording fails
3642
4307
  }
4308
+ ctx.info('✅ Ecosystem analysis completed successfully');
4309
+ ctx.report_progress(100, 100);
3643
4310
  // Return appropriate response based on execution result
3644
4311
  if (executionResult.isAIGenerated) {
3645
4312
  // AI execution successful - return actual analysis results
@@ -4029,16 +4696,24 @@ This **outcome-focused approach** ensures architectural work delivers **measurab
4029
4696
  throw new McpAdrError(`Failed to get architectural context: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
4030
4697
  }
4031
4698
  }
4032
- async generateAdrsFromPrd(args) {
4699
+ async generateAdrsFromPrd(args, context) {
4700
+ const ctx = context || createNoOpContext();
4033
4701
  const { prdPath, enhancedMode = true, promptOptimization = true, knowledgeEnhancement = true, prdType = 'general', } = args;
4034
4702
  const outputDirectory = args['outputDirectory'] || this.config.adrDirectory;
4035
4703
  this.logger.info(`Generating enhanced ADRs from PRD: ${prdPath} to ${outputDirectory}`);
4036
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);
4037
4707
  try {
4708
+ ctx.info('📂 Phase 1: Validating PRD file');
4709
+ ctx.report_progress(10, 100);
4038
4710
  const { readFileContentCompat: readFileContent, fileExistsCompat: fileExists } = await import('./utils/file-system.js');
4039
4711
  // Import advanced prompting utilities if enhanced mode is enabled
4712
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4040
4713
  let generateArchitecturalKnowledge = null;
4714
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4041
4715
  let optimizePromptWithAPE = null;
4716
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4042
4717
  let createToolAPEConfig = null;
4043
4718
  if (enhancedMode) {
4044
4719
  if (knowledgeEnhancement) {
@@ -4055,7 +4730,11 @@ This **outcome-focused approach** ensures architectural work delivers **measurab
4055
4730
  const fileExistsPrompt = await fileExists(prdPath);
4056
4731
  // Generate file content reading prompt
4057
4732
  const fileContentPrompt = await readFileContent(prdPath);
4733
+ ctx.info('📚 Phase 2: Reading PRD content');
4734
+ ctx.report_progress(25, 100);
4058
4735
  // Step 1: Generate domain-specific knowledge if enabled
4736
+ ctx.info('🧠 Phase 3: Generating domain knowledge');
4737
+ ctx.report_progress(40, 100);
4059
4738
  let knowledgeContext = '';
4060
4739
  if (enhancedMode && knowledgeEnhancement && generateArchitecturalKnowledge) {
4061
4740
  try {
@@ -4086,8 +4765,12 @@ ${knowledgeResult.prompt}
4086
4765
  }
4087
4766
  }
4088
4767
  // Step 2: Create base ADR generation prompt
4768
+ ctx.info('📋 Phase 4: Creating base ADR prompts');
4769
+ ctx.report_progress(60, 100);
4089
4770
  const baseAdrPrompt = this.createBaseAdrPrompt(prdPath, outputDirectory, knowledgeContext);
4090
4771
  // Step 3: Apply APE optimization if enabled
4772
+ ctx.info('⚡ Phase 5: Optimizing prompts with APE');
4773
+ ctx.report_progress(75, 100);
4091
4774
  let finalAdrPrompt = baseAdrPrompt;
4092
4775
  if (enhancedMode && promptOptimization && optimizePromptWithAPE && createToolAPEConfig) {
4093
4776
  try {
@@ -4166,6 +4849,8 @@ For each generated ADR, create a file creation prompt using the following patter
4166
4849
  - Confirm all decisions are traceable back to PRD requirements with domain context
4167
4850
  `;
4168
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);
4169
4854
  const { executeADRGenerationPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
4170
4855
  const executionResult = await executeADRGenerationPrompt(adrPrompt, 'Generate comprehensive ADRs from PRD analysis with enhanced domain knowledge and optimization', {
4171
4856
  temperature: 0.1,
@@ -4174,6 +4859,8 @@ For each generated ADR, create a file creation prompt using the following patter
4174
4859
  Generate well-structured ADRs that follow best practices and include all necessary sections.
4175
4860
  Focus on extracting architectural decisions from the PRD and creating actionable ADRs with clear reasoning.`,
4176
4861
  });
4862
+ ctx.info('✅ ADR generation completed successfully');
4863
+ ctx.report_progress(100, 100);
4177
4864
  if (executionResult.isAIGenerated) {
4178
4865
  // AI execution successful - return actual ADR generation results
4179
4866
  return formatMCPResponse({
@@ -4299,109 +4986,6 @@ The enhanced process maintains full traceability from PRD requirements to genera
4299
4986
  throw new McpAdrError(`Failed to generate ADR prompts from PRD: ${error instanceof Error ? error.message : String(error)}`, 'PROMPT_GENERATION_ERROR');
4300
4987
  }
4301
4988
  }
4302
- async generateAdrTodo(args) {
4303
- const { scope = 'all', phase = 'both', linkAdrs = true, includeRules = true, ruleSource = 'both', preserveExisting = true, forceSyncToMarkdown = false, intentId, createJsonBackup = true, } = args;
4304
- const { getAdrDirectoryPath } = await import('./utils/config.js');
4305
- const path = await import('path');
4306
- // Use absolute ADR path relative to project
4307
- const absoluteAdrPath = args['adrDirectory']
4308
- ? path.resolve(this.config.projectPath, args['adrDirectory'])
4309
- : getAdrDirectoryPath(this.config);
4310
- // Keep relative path for display purposes
4311
- const adrDirectory = args['adrDirectory'] || this.config.adrDirectory;
4312
- this.logger.info(`Generating JSON-first TODO for ADRs in: ${absoluteAdrPath} (phase: ${phase})`);
4313
- try {
4314
- // Always use JSON-first TODO system
4315
- this.logger.info('Using JSON-first TODO system for ADR task generation');
4316
- // TODO management has been deprecated and moved to mcp-shrimp-task-manager
4317
- this.logger.warn('⚠️ TODO management has been deprecated - use mcp-shrimp-task-manager instead');
4318
- // Optional: Create backup if requested and JSON exists
4319
- if (createJsonBackup) {
4320
- try {
4321
- this.logger.info('Backup feature deprecated - use mcp-shrimp-task-manager for task management');
4322
- }
4323
- catch {
4324
- // Continue if backup fails - might be first time setup
4325
- this.logger.debug('No existing JSON data to backup');
4326
- }
4327
- }
4328
- // Import ADR tasks into JSON system has been deprecated
4329
- const importResult = {
4330
- content: [
4331
- {
4332
- type: 'text',
4333
- text: `⚠️ **TODO Management Deprecated**
4334
-
4335
- This feature has been moved to mcp-shrimp-task-manager.
4336
-
4337
- **Replacement:** Use the external \`mcp-shrimp-task-manager\` for:
4338
- - Task planning and breaking down from ADRs
4339
- - Task tracking and status updates
4340
- - Task dependencies and priorities
4341
- - Task completion and verification
4342
-
4343
- **Migration:** The system now uses memory-centric architecture where task management is handled by external MCP servers.`,
4344
- },
4345
- ],
4346
- };
4347
- return {
4348
- content: [
4349
- {
4350
- type: 'text',
4351
- text: `# ✅ JSON-First TODO Generated from ADRs
4352
-
4353
- ## 🏗️ JSON-First TODO System Active
4354
- ✅ **todo-data.json** - JSON-first TODO backend created/updated
4355
- ✅ **TODO.md** - Markdown frontend ${forceSyncToMarkdown ? 'synchronized' : 'available for sync'}
4356
-
4357
- ## Configuration Applied
4358
- - **ADR Directory**: ${adrDirectory}
4359
- - **Scope**: ${scope}
4360
- - **TDD Phase**: ${phase}
4361
- - **ADR Dependency Linking**: ${linkAdrs ? 'Enabled' : 'Disabled'}
4362
- - **Rules Integration**: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}
4363
- - **Preserve Existing**: ${preserveExisting}
4364
- - **Force Markdown Sync**: ${forceSyncToMarkdown ? 'Enabled' : 'Disabled'}
4365
- - **Intent Linking**: ${intentId ? `Linked to ${intentId}` : 'None'}
4366
- - **JSON Backup**: ${createJsonBackup ? 'Created' : 'Skipped'}
4367
-
4368
- ## JSON-First Architecture Benefits
4369
- ✅ **Structured Data**: JSON backend ensures consistent LLM interactions
4370
- ✅ **Automatic Sync**: JSON-to-markdown conversion maintains TODO.md compatibility
4371
- ✅ **Enhanced Metadata**: Full task lifecycle with dependencies, assignees, priorities
4372
- ✅ **Complete Integration**: Native support for scoring, git automation, and knowledge graph
4373
- ✅ **Backup Protection**: Automatic data preservation during updates
4374
- ✅ **No Manual Setup**: All cache files auto-generated, tests can immediately validate
4375
-
4376
- ${importResult.content?.[0]?.text || 'TODO management feature has been deprecated'}
4377
-
4378
- ## Available Operations (use manage_todo_v2 tool)
4379
- 1. **View Tasks**: \`get_tasks\` operation with filtering and sorting
4380
- 2. **Update Status**: \`update_task\` operation with status, progress, notes
4381
- 3. **Bulk Updates**: \`bulk_update\` operation for multiple tasks
4382
- 4. **Analytics**: \`get_analytics\` operation for progress metrics
4383
- 5. **Sync Control**: \`sync_to_markdown\` and \`sync_knowledge_graph\` operations
4384
-
4385
- ## Validation & Progress Tracking
4386
- - **Progress Check**: Use \`compare_adr_progress\` to validate implementation vs ADRs
4387
- - **Git Integration**: Use \`smart_git_push\` for automatic task status updates
4388
- - **Scoring**: Integrated with smart scoring for release readiness assessment
4389
-
4390
- ## TDD Workflow Integration
4391
- - **Phase 1**: Mock test generation tasks created
4392
- - **Phase 2**: Production implementation tasks linked to tests
4393
- - **Dependencies**: ADR relationships mapped to task dependencies
4394
- - **Validation**: Architectural rules integrated into task criteria
4395
-
4396
- *All TODO data is now managed in JSON format with automatic markdown sync*`,
4397
- },
4398
- ],
4399
- };
4400
- }
4401
- catch (error) {
4402
- throw new McpAdrError(`Failed to generate ADR todo: ${error instanceof Error ? error.message : String(error)}`, 'GENERATION_ERROR');
4403
- }
4404
- }
4405
4989
  async compareAdrProgress(args) {
4406
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;
4407
4991
  const { getAdrDirectoryPath } = await import('./utils/config.js');
@@ -4458,7 +5042,10 @@ ${importResult.content?.[0]?.text || 'TODO management feature has been deprecate
4458
5042
  let discoveryResult = null;
4459
5043
  if (validationType === 'full' || validationType === 'adr-only') {
4460
5044
  const { discoverAdrsInDirectory } = await import('./utils/adr-discovery.js');
4461
- discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, true, projectPath);
5045
+ discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, projectPath, {
5046
+ includeContent: true,
5047
+ includeTimeline: false,
5048
+ });
4462
5049
  }
4463
5050
  const analysis = await this.performLocalAdrProgressAnalysis({
4464
5051
  todoContent,
@@ -4643,14 +5230,17 @@ ${importResult.content?.[0]?.text || 'TODO management feature has been deprecate
4643
5230
 
4644
5231
  ## Environment Context
4645
5232
  - **Target Environment**: ${environment}
4646
- - **Security Level**: ${environmentConfig.securityLevel || 'Not specified'}
4647
- - **Required Files**: ${environmentConfig.requiredFiles?.length || 0} files
4648
- - **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
4649
5236
 
4650
5237
  ## ADR Discovery Results
4651
5238
  ${totalAdrs > 0
4652
5239
  ? `Found ${totalAdrs} ADRs:\n${discoveredAdrs
4653
- .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
+ })
4654
5244
  .join('\n')}`
4655
5245
  : 'No ADRs found in the specified directory.'}
4656
5246
 
@@ -4716,23 +5306,9 @@ ${environmentValidation
4716
5306
 
4717
5307
  ## Next Steps
4718
5308
  1. Address high-priority alignment issues identified above
4719
- 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'}
4720
5310
  3. ${includeFileChecks ? 'Verify implementation of completed tasks' : 'Enable file checks for detailed implementation verification'}
4721
5311
  4. ${includeRuleValidation ? 'Resolve architectural rule compliance violations' : 'Enable rule validation for compliance checking'}
4722
-
4723
- ## Integration Commands
4724
-
4725
- To regenerate TODO after fixes:
4726
- \`\`\`json
4727
- {
4728
- "tool": "generate_adr_todo",
4729
- "args": {
4730
- "adrDirectory": "${adrDirectory}",
4731
- "phase": "both",
4732
- "linkAdrs": true,
4733
- "includeRules": ${includeRuleValidation}
4734
- }
4735
- }
4736
5312
  \`\`\`
4737
5313
 
4738
5314
  To re-run this validation with strict mode:
@@ -4792,17 +5368,20 @@ To re-run this validation with strict mode:
4792
5368
  const misaligned = [];
4793
5369
  const missing = [];
4794
5370
  // Simple keyword matching for alignment detection
4795
- const adrKeywords = adrs.flatMap(adr => [
4796
- adr.title.toLowerCase(),
4797
- ...(adr.decision || '')
4798
- .toLowerCase()
4799
- .split(/\s+/)
4800
- .filter((w) => w.length > 4),
4801
- ...(adr.context || '')
4802
- .toLowerCase()
4803
- .split(/\s+/)
4804
- .filter((w) => w.length > 4),
4805
- ]);
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
+ });
4806
5385
  // Environment-specific keywords that should be prioritized
4807
5386
  const envKeywords = [];
4808
5387
  if (environment && environmentConfig) {
@@ -4818,7 +5397,8 @@ To re-run this validation with strict mode:
4818
5397
  }
4819
5398
  for (const task of tasks) {
4820
5399
  const taskLower = task.title.toLowerCase();
4821
- 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));
4822
5402
  // Environment-aware alignment scoring
4823
5403
  const hasEnvKeywordMatch = envKeywords.some(keyword => taskLower.includes(keyword));
4824
5404
  if (hasKeywordMatch || hasEnvKeywordMatch) {
@@ -4830,8 +5410,9 @@ To re-run this validation with strict mode:
4830
5410
  }
4831
5411
  // Identify potential missing tasks based on ADR content
4832
5412
  for (const adr of adrs) {
4833
- if (adr.status === 'accepted' && adr.decision) {
4834
- 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+/);
4835
5416
  const implementationWords = [
4836
5417
  'implement',
4837
5418
  'create',
@@ -4842,25 +5423,28 @@ To re-run this validation with strict mode:
4842
5423
  'configure',
4843
5424
  ];
4844
5425
  if (implementationWords.some(word => decisionWords.includes(word))) {
4845
- 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));
4846
5429
  if (!hasCorrespondingTask) {
4847
- missing.push(`Implement ${adr.title}`);
5430
+ missing.push(`Implement ${adrTitle}`);
4848
5431
  }
4849
5432
  }
4850
5433
  }
4851
5434
  }
4852
5435
  // Environment-specific missing tasks
4853
5436
  if (environment && environmentConfig) {
4854
- if (environmentConfig.requiredFiles) {
4855
- for (const file of environmentConfig.requiredFiles) {
5437
+ const envConfig = environmentConfig;
5438
+ if (envConfig['requiredFiles']) {
5439
+ for (const file of envConfig['requiredFiles']) {
4856
5440
  const hasFileTask = tasks.some(task => task.title.toLowerCase().includes(file.toLowerCase()));
4857
5441
  if (!hasFileTask) {
4858
5442
  missing.push(`Create ${file} for ${environment} environment`);
4859
5443
  }
4860
5444
  }
4861
5445
  }
4862
- if (environmentConfig.requiredServices) {
4863
- for (const service of environmentConfig.requiredServices) {
5446
+ if (envConfig['requiredServices']) {
5447
+ for (const service of envConfig['requiredServices']) {
4864
5448
  const hasServiceTask = tasks.some(task => task.title.toLowerCase().includes(service.toLowerCase()));
4865
5449
  if (!hasServiceTask) {
4866
5450
  missing.push(`Setup ${service} service for ${environment}`);
@@ -5544,14 +6128,130 @@ Please provide:
5544
6128
  const { default: generateAdrBootstrapScripts } = await import('./tools/adr-bootstrap-validation-tool.js');
5545
6129
  return await generateAdrBootstrapScripts(args);
5546
6130
  }
5547
- async discoverExistingAdrs(args) {
5548
- const { discoverExistingAdrs } = await import('./tools/adr-suggestion-tool.js');
5549
- 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
+ }
5550
6239
  }
5551
6240
  async reviewExistingAdrs(args) {
5552
6241
  const { reviewExistingAdrs } = await import('./tools/review-existing-adrs-tool.js');
5553
6242
  return await reviewExistingAdrs(args);
5554
6243
  }
6244
+ /**
6245
+ * ADR validation tool implementations
6246
+ */
6247
+ async validateAdr(args) {
6248
+ const { validateAdr } = await import('./tools/adr-validation-tool.js');
6249
+ return await validateAdr(args);
6250
+ }
6251
+ async validateAllAdrs(args) {
6252
+ const { validateAllAdrs } = await import('./tools/adr-validation-tool.js');
6253
+ return await validateAllAdrs(args);
6254
+ }
5555
6255
  /**
5556
6256
  * Research integration tool implementations
5557
6257
  */
@@ -5596,6 +6296,73 @@ Please provide:
5596
6296
  const { generateResearchQuestions } = await import('./tools/research-question-tool.js');
5597
6297
  return await generateResearchQuestions(args);
5598
6298
  }
6299
+ /**
6300
+ * Perform research tool implementation
6301
+ */
6302
+ async performResearch(args, context) {
6303
+ const ctx = context || createNoOpContext();
6304
+ if (!('question' in args) || typeof args['question'] !== 'string') {
6305
+ throw new McpAdrError('Missing required parameter: question', 'INVALID_ARGUMENTS');
6306
+ }
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
+ );
6365
+ }
5599
6366
  /**
5600
6367
  * Deployment analysis tool implementation
5601
6368
  */
@@ -5807,11 +6574,117 @@ Please provide:
5807
6574
  return response;
5808
6575
  }
5809
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
+ }
5810
6652
  /**
5811
6653
  * Read MCP resource with prompt-driven caching
5812
6654
  */
5813
6655
  async readResource(uri) {
5814
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
5815
6688
  // Parse URI to determine resource type and parameters
5816
6689
  const url = new globalThis.URL(uri);
5817
6690
  const resourceType = url.pathname.replace('/', '');
@@ -5868,6 +6741,222 @@ Please provide:
5868
6741
  ],
5869
6742
  };
5870
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
+ }
5871
6960
  default:
5872
6961
  throw new McpAdrError(`Unknown resource type: ${resourceType}`, 'UNKNOWN_RESOURCE');
5873
6962
  }
@@ -5885,6 +6974,22 @@ Please provide:
5885
6974
  async start() {
5886
6975
  // Validate configuration before starting
5887
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
+ }
5888
6993
  const transport = new StdioServerTransport();
5889
6994
  await this.server.connect(transport);
5890
6995
  // Keep the process alive
@@ -5896,16 +7001,70 @@ Please provide:
5896
7001
  /**
5897
7002
  * File system tool implementations
5898
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
+ }
5899
7056
  async readFile(args) {
5900
7057
  const { filePath } = args;
5901
7058
  try {
5902
7059
  const fs = await import('fs/promises');
5903
7060
  const path = await import('path');
5904
- // Resolve path relative to project path for security
5905
- const safePath = path.resolve(this.config.projectPath, filePath);
5906
- // Security check: ensure path is within project directory
5907
- if (!safePath.startsWith(this.config.projectPath)) {
5908
- 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');
5909
7068
  }
5910
7069
  const content = await fs.readFile(safePath, 'utf-8');
5911
7070
  return {
@@ -5979,40 +7138,6 @@ Please provide:
5979
7138
  throw new McpAdrError(`Failed to list directory: ${error instanceof Error ? error.message : String(error)}`, 'DIRECTORY_LIST_ERROR');
5980
7139
  }
5981
7140
  }
5982
- async manageTodoJson(_args) {
5983
- try {
5984
- // TODO management has been deprecated and moved to mcp-shrimp-task-manager
5985
- this.logger.warn('⚠️ manageTodoJson deprecated - use mcp-shrimp-task-manager instead');
5986
- return {
5987
- content: [
5988
- {
5989
- type: 'text',
5990
- text: `⚠️ **TODO Management Tool Deprecated**
5991
-
5992
- This tool (manageTodoJson) has been deprecated and is no longer functional.
5993
-
5994
- **Replacement:** Use the external \`mcp-shrimp-task-manager\` for task management:
5995
- - Task planning and breaking down
5996
- - Task tracking and status updates
5997
- - Task dependencies and priorities
5998
- - Task completion and verification
5999
-
6000
- **Migration:** The system has moved to a memory-centric architecture where task management is handled by external MCP servers rather than internal JSON files.
6001
-
6002
- **Error:** TodoJsonManager was removed - use mcp-shrimp-task-manager for task management`,
6003
- },
6004
- ],
6005
- isError: false,
6006
- };
6007
- }
6008
- catch (error) {
6009
- // If it's already a McpAdrError with good details, re-throw it as-is
6010
- if (error instanceof Error && error.name === 'McpAdrError') {
6011
- throw error;
6012
- }
6013
- throw new McpAdrError(`JSON TODO management failed: ${error instanceof Error ? error.message : String(error)}`, 'TODO_JSON_MANAGEMENT_ERROR');
6014
- }
6015
- }
6016
7141
  async generateDeploymentGuidance(args) {
6017
7142
  try {
6018
7143
  const { generateDeploymentGuidance } = await import('./tools/deployment-guidance-tool.js');
@@ -6091,6 +7216,15 @@ This tool has been deprecated and replaced with memory-centric health scoring.
6091
7216
  throw new McpAdrError(`Memory loading failed: ${error instanceof Error ? error.message : String(error)}`, 'MEMORY_LOADING_ERROR');
6092
7217
  }
6093
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
+ }
6094
7228
  async interactiveAdrPlanning(args) {
6095
7229
  try {
6096
7230
  const { interactiveAdrPlanning } = await import('./tools/interactive-adr-planning-tool.js');
@@ -6112,9 +7246,91 @@ This tool has been deprecated and replaced with memory-centric health scoring.
6112
7246
  throw new McpAdrError(`Tool chain orchestration failed: ${error instanceof Error ? error.message : String(error)}`, 'TOOL_CHAIN_ORCHESTRATOR_ERROR');
6113
7247
  }
6114
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
+ }
6115
7314
  }
6116
7315
  /**
6117
- * 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
6118
7334
  */
6119
7335
  async function main() {
6120
7336
  const args = process.argv.slice(2);