@monoes/monomindcli 1.10.54 → 1.10.55

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 (441) hide show
  1. package/.claude/agents/optimization/benchmark-suite.md +2 -0
  2. package/.claude/agents/optimization/load-balancer.md +2 -0
  3. package/.claude/agents/optimization/performance-monitor.md +2 -0
  4. package/.claude/agents/optimization/resource-allocator.md +3 -1
  5. package/.claude/agents/optimization/topology-optimizer.md +2 -0
  6. package/.claude/commands/mastermind/_repeat.md +21 -0
  7. package/.claude/commands/mastermind/_taskfile.md +235 -0
  8. package/.claude/commands/mastermind/adr.md +11 -0
  9. package/.claude/commands/mastermind/approve.md +94 -0
  10. package/.claude/commands/mastermind/autodev.md +32 -0
  11. package/.claude/commands/mastermind/budget.md +7 -0
  12. package/.claude/commands/mastermind/code-review.md +317 -0
  13. package/.claude/commands/mastermind/createorg.md +40 -1
  14. package/.claude/commands/mastermind/createtask.md +383 -0
  15. package/.claude/commands/mastermind/debug.md +22 -0
  16. package/.claude/commands/mastermind/design.md +20 -0
  17. package/.claude/commands/mastermind/do.md +526 -0
  18. package/.claude/commands/mastermind/execute.md +20 -0
  19. package/.claude/commands/mastermind/finish.md +20 -0
  20. package/.claude/commands/mastermind/graph-status.md +7 -0
  21. package/.claude/commands/mastermind/help.md +118 -0
  22. package/.claude/commands/mastermind/ideate.md +261 -0
  23. package/.claude/commands/mastermind/improve.md +345 -0
  24. package/.claude/commands/mastermind/loops.md +7 -0
  25. package/.claude/commands/mastermind/master.md +186 -6
  26. package/.claude/commands/mastermind/memory.md +230 -0
  27. package/.claude/commands/mastermind/plan.md +26 -0
  28. package/.claude/commands/mastermind/receive-review.md +20 -0
  29. package/.claude/commands/mastermind/repeat.md +257 -0
  30. package/.claude/commands/mastermind/runorg.md +3 -0
  31. package/.claude/commands/mastermind/skill-builder.md +20 -0
  32. package/.claude/commands/mastermind/specialagents.md +125 -0
  33. package/.claude/commands/mastermind/swarm.md +161 -0
  34. package/.claude/commands/mastermind/taskdev.md +26 -0
  35. package/.claude/commands/mastermind/tdd.md +22 -0
  36. package/.claude/commands/mastermind/techport.md +4 -0
  37. package/.claude/commands/mastermind/understand.md +139 -0
  38. package/.claude/commands/mastermind/verify.md +22 -0
  39. package/.claude/commands/mastermind/worktree.md +20 -0
  40. package/.claude/helpers/handlers/graph-status-handler.cjs +2 -1
  41. package/.claude/helpers/hook-handler.cjs +19 -0
  42. package/.claude/helpers/skill-registry.json +23 -0
  43. package/.claude/helpers/statusline.cjs +1 -1
  44. package/.claude/skills/mastermind/approve.md +15 -7
  45. package/.claude/skills/mastermind/autodev.md +534 -0
  46. package/.claude/skills/mastermind/createorg.md +21 -5
  47. package/.claude/skills/mastermind/debug.md +232 -0
  48. package/.claude/skills/mastermind/design.md +187 -0
  49. package/.claude/skills/mastermind/execute.md +104 -0
  50. package/.claude/skills/mastermind/finish.md +251 -0
  51. package/.claude/skills/mastermind/plan.md +180 -0
  52. package/.claude/skills/mastermind/receive-review.md +213 -0
  53. package/.claude/skills/mastermind/runorg.md +23 -8
  54. package/.claude/skills/mastermind/skill-builder.md +274 -0
  55. package/.claude/skills/mastermind/taskdev.md +307 -0
  56. package/.claude/skills/mastermind/tdd.md +394 -0
  57. package/.claude/skills/mastermind/verify.md +196 -0
  58. package/.claude/skills/mastermind/worktree.md +160 -132
  59. package/README.md +320 -253
  60. package/dist/src/commands/analyze.d.ts.map +1 -1
  61. package/dist/src/commands/analyze.js +9 -2
  62. package/dist/src/commands/analyze.js.map +1 -1
  63. package/dist/src/commands/benchmark.js.map +1 -1
  64. package/dist/src/commands/completions.js +1 -1
  65. package/dist/src/commands/guidance.js +7 -7
  66. package/dist/src/commands/hooks.d.ts.map +1 -1
  67. package/dist/src/commands/hooks.js +16 -3
  68. package/dist/src/commands/hooks.js.map +1 -1
  69. package/dist/src/commands/index.d.ts +3 -2
  70. package/dist/src/commands/index.d.ts.map +1 -1
  71. package/dist/src/commands/index.js +7 -0
  72. package/dist/src/commands/index.js.map +1 -1
  73. package/dist/src/commands/init.d.ts.map +1 -1
  74. package/dist/src/commands/init.js +47 -13
  75. package/dist/src/commands/init.js.map +1 -1
  76. package/dist/src/commands/neural.d.ts.map +1 -1
  77. package/dist/src/commands/neural.js +100 -14
  78. package/dist/src/commands/neural.js.map +1 -1
  79. package/dist/src/commands/platforms.d.ts +11 -0
  80. package/dist/src/commands/platforms.d.ts.map +1 -0
  81. package/dist/src/commands/platforms.js +195 -0
  82. package/dist/src/commands/platforms.js.map +1 -0
  83. package/dist/src/commands/ruvector/backup.js.map +1 -1
  84. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  85. package/dist/src/commands/ruvector/init.js.map +1 -1
  86. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  87. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  88. package/dist/src/commands/ruvector/status.js.map +1 -1
  89. package/dist/src/commands/update.js +6 -6
  90. package/dist/src/init/executor.d.ts.map +1 -1
  91. package/dist/src/init/executor.js +28 -0
  92. package/dist/src/init/executor.js.map +1 -1
  93. package/dist/src/init/statusline-generator.js +1 -1
  94. package/dist/src/init/types.d.ts +1 -0
  95. package/dist/src/init/types.d.ts.map +1 -1
  96. package/dist/src/mcp-server.d.ts.map +1 -1
  97. package/dist/src/mcp-server.js +92 -0
  98. package/dist/src/mcp-server.js.map +1 -1
  99. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  100. package/dist/src/mcp-tools/hive-mind-tools.js +52 -0
  101. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  102. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  103. package/dist/src/mcp-tools/hooks-tools.js +106 -5
  104. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  105. package/dist/src/mcp-tools/index.d.ts +0 -5
  106. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  107. package/dist/src/mcp-tools/index.js +0 -5
  108. package/dist/src/mcp-tools/index.js.map +1 -1
  109. package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
  110. package/dist/src/mcp-tools/monograph-tools.js +507 -5587
  111. package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
  112. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  113. package/dist/src/mcp-tools/neural-tools.js +64 -4
  114. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  115. package/dist/src/mcp-tools/security-tools.js +4 -4
  116. package/dist/src/memory/intelligence.d.ts +2 -2
  117. package/dist/src/memory/intelligence.d.ts.map +1 -1
  118. package/dist/src/memory/intelligence.js +108 -3
  119. package/dist/src/memory/intelligence.js.map +1 -1
  120. package/dist/src/memory/memory-bridge.js +1 -1
  121. package/dist/src/memory/memory-bridge.js.map +1 -1
  122. package/dist/src/memory/sona-optimizer.d.ts +1 -10
  123. package/dist/src/memory/sona-optimizer.d.ts.map +1 -1
  124. package/dist/src/memory/sona-optimizer.js +0 -46
  125. package/dist/src/memory/sona-optimizer.js.map +1 -1
  126. package/dist/src/runtime/headless.js +3 -3
  127. package/dist/src/ruvector/diff-classifier.d.ts +0 -2
  128. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -1
  129. package/dist/src/ruvector/diff-classifier.js +2 -14
  130. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  131. package/dist/src/ruvector/index.d.ts +26 -9
  132. package/dist/src/ruvector/index.d.ts.map +1 -1
  133. package/dist/src/ruvector/index.js +3 -21
  134. package/dist/src/ruvector/index.js.map +1 -1
  135. package/dist/src/ruvector/ruvllm-wasm.js +2 -2
  136. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
  137. package/dist/src/types.d.ts +0 -15
  138. package/dist/src/types.d.ts.map +1 -1
  139. package/dist/src/types.js +0 -18
  140. package/dist/src/types.js.map +1 -1
  141. package/dist/src/ui/dashboard.html +8763 -9766
  142. package/dist/src/ui/orgs.html +1 -1
  143. package/dist/src/ui/server.mjs +504 -35
  144. package/dist/src/update/index.js +1 -1
  145. package/dist/src/update/validator.js +8 -8
  146. package/dist/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +2 -2
  148. package/.claude/agents/academic/academic-anthropologist.md +0 -126
  149. package/.claude/agents/academic/academic-geographer.md +0 -128
  150. package/.claude/agents/academic/academic-historian.md +0 -124
  151. package/.claude/agents/academic/academic-narratologist.md +0 -119
  152. package/.claude/agents/academic/academic-psychologist.md +0 -119
  153. package/.claude/agents/analysis/analyze-code-quality.md +0 -58
  154. package/.claude/agents/analysis/code-analyzer.md +0 -189
  155. package/.claude/agents/analysis/code-review/analyze-code-quality.md +0 -58
  156. package/.claude/agents/consensus/performance-benchmarker.md +0 -831
  157. package/.claude/agents/data/ml/data-ml-model.md +0 -76
  158. package/.claude/agents/development/dev-backend-api.md +0 -178
  159. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +0 -52
  160. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +0 -63
  161. package/.claude/agents/game-development/blender/blender-addon-engineer.md +0 -235
  162. package/.claude/agents/game-development/game-audio-engineer.md +0 -265
  163. package/.claude/agents/game-development/game-designer.md +0 -168
  164. package/.claude/agents/game-development/godot/godot-gameplay-scripter.md +0 -335
  165. package/.claude/agents/game-development/godot/godot-multiplayer-engineer.md +0 -298
  166. package/.claude/agents/game-development/godot/godot-shader-developer.md +0 -267
  167. package/.claude/agents/game-development/level-designer.md +0 -209
  168. package/.claude/agents/game-development/narrative-designer.md +0 -244
  169. package/.claude/agents/game-development/roblox-studio/roblox-avatar-creator.md +0 -298
  170. package/.claude/agents/game-development/roblox-studio/roblox-experience-designer.md +0 -306
  171. package/.claude/agents/game-development/roblox-studio/roblox-systems-scripter.md +0 -326
  172. package/.claude/agents/game-development/technical-artist.md +0 -230
  173. package/.claude/agents/game-development/unity/unity-architect.md +0 -272
  174. package/.claude/agents/game-development/unity/unity-editor-tool-developer.md +0 -311
  175. package/.claude/agents/game-development/unity/unity-multiplayer-engineer.md +0 -322
  176. package/.claude/agents/game-development/unity/unity-shader-graph-artist.md +0 -270
  177. package/.claude/agents/game-development/unreal-engine/unreal-multiplayer-architect.md +0 -314
  178. package/.claude/agents/game-development/unreal-engine/unreal-systems-engineer.md +0 -311
  179. package/.claude/agents/game-development/unreal-engine/unreal-technical-artist.md +0 -257
  180. package/.claude/agents/game-development/unreal-engine/unreal-world-builder.md +0 -274
  181. package/.claude/agents/github/release-swarm.md +0 -597
  182. package/.claude/agents/goal/agent.md +0 -804
  183. package/.claude/agents/goal/code-goal-planner.md +0 -445
  184. package/.claude/agents/marketing/marketing-ai-citation-strategist.md +0 -171
  185. package/.claude/agents/marketing/marketing-app-store-optimizer.md +0 -322
  186. package/.claude/agents/marketing/marketing-baidu-seo-specialist.md +0 -227
  187. package/.claude/agents/marketing/marketing-bilibili-content-strategist.md +0 -200
  188. package/.claude/agents/marketing/marketing-book-co-author.md +0 -111
  189. package/.claude/agents/marketing/marketing-carousel-growth-engine.md +0 -200
  190. package/.claude/agents/marketing/marketing-china-ecommerce-operator.md +0 -284
  191. package/.claude/agents/marketing/marketing-content-creator.md +0 -67
  192. package/.claude/agents/marketing/marketing-cross-border-ecommerce.md +0 -260
  193. package/.claude/agents/marketing/marketing-douyin-strategist.md +0 -150
  194. package/.claude/agents/marketing/marketing-growth-hacker.md +0 -54
  195. package/.claude/agents/marketing/marketing-instagram-curator.md +0 -114
  196. package/.claude/agents/marketing/marketing-kuaishou-strategist.md +0 -224
  197. package/.claude/agents/marketing/marketing-linkedin-content-creator.md +0 -215
  198. package/.claude/agents/marketing/marketing-livestream-commerce-coach.md +0 -306
  199. package/.claude/agents/marketing/marketing-podcast-strategist.md +0 -278
  200. package/.claude/agents/marketing/marketing-private-domain-operator.md +0 -309
  201. package/.claude/agents/marketing/marketing-reddit-community-builder.md +0 -124
  202. package/.claude/agents/marketing/marketing-seo-specialist.md +0 -279
  203. package/.claude/agents/marketing/marketing-short-video-editing-coach.md +0 -413
  204. package/.claude/agents/marketing/marketing-social-media-strategist.md +0 -125
  205. package/.claude/agents/marketing/marketing-tiktok-strategist.md +0 -126
  206. package/.claude/agents/marketing/marketing-twitter-engager.md +0 -127
  207. package/.claude/agents/marketing/marketing-wechat-official-account.md +0 -146
  208. package/.claude/agents/marketing/marketing-weibo-strategist.md +0 -241
  209. package/.claude/agents/marketing/marketing-xiaohongshu-specialist.md +0 -139
  210. package/.claude/agents/marketing/marketing-zhihu-strategist.md +0 -163
  211. package/.claude/agents/neural/safla-neural.md +0 -74
  212. package/.claude/agents/paid-media/paid-media-auditor.md +0 -71
  213. package/.claude/agents/paid-media/paid-media-creative-strategist.md +0 -71
  214. package/.claude/agents/paid-media/paid-media-paid-social-strategist.md +0 -71
  215. package/.claude/agents/paid-media/paid-media-ppc-strategist.md +0 -71
  216. package/.claude/agents/paid-media/paid-media-programmatic-buyer.md +0 -71
  217. package/.claude/agents/paid-media/paid-media-search-query-analyst.md +0 -71
  218. package/.claude/agents/paid-media/paid-media-tracking-specialist.md +0 -71
  219. package/.claude/agents/payments/agentic-payments.md +0 -126
  220. package/.claude/agents/product/product-behavioral-nudge-engine.md +0 -81
  221. package/.claude/agents/product/product-feedback-synthesizer.md +0 -119
  222. package/.claude/agents/product/product-manager.md +0 -469
  223. package/.claude/agents/product/product-sprint-prioritizer.md +0 -154
  224. package/.claude/agents/product/product-trend-researcher.md +0 -159
  225. package/.claude/agents/project-management/project-management-experiment-tracker.md +0 -199
  226. package/.claude/agents/project-management/project-management-jira-workflow-steward.md +0 -231
  227. package/.claude/agents/project-management/project-management-project-shepherd.md +0 -195
  228. package/.claude/agents/project-management/project-management-studio-operations.md +0 -201
  229. package/.claude/agents/project-management/project-management-studio-producer.md +0 -204
  230. package/.claude/agents/project-management/project-manager-senior.md +0 -136
  231. package/.claude/agents/reasoning/agent.md +0 -804
  232. package/.claude/agents/reasoning/goal-planner.md +0 -73
  233. package/.claude/agents/sales/sales-account-strategist.md +0 -228
  234. package/.claude/agents/sales/sales-coach.md +0 -272
  235. package/.claude/agents/sales/sales-deal-strategist.md +0 -181
  236. package/.claude/agents/sales/sales-discovery-coach.md +0 -226
  237. package/.claude/agents/sales/sales-engineer.md +0 -183
  238. package/.claude/agents/sales/sales-outbound-strategist.md +0 -202
  239. package/.claude/agents/sales/sales-pipeline-analyst.md +0 -268
  240. package/.claude/agents/sales/sales-proposal-strategist.md +0 -218
  241. package/.claude/agents/sona/sona-learning-optimizer.md +0 -65
  242. package/.claude/agents/spatial-computing/macos-spatial-metal-engineer.md +0 -338
  243. package/.claude/agents/spatial-computing/terminal-integration-specialist.md +0 -71
  244. package/.claude/agents/spatial-computing/visionos-spatial-engineer.md +0 -55
  245. package/.claude/agents/specialists/memory-specialist.md +0 -298
  246. package/.claude/agents/specialists/performance-engineer.md +0 -387
  247. package/.claude/agents/specialists/queen-coordinator.md +0 -67
  248. package/.claude/agents/specialists/security-architect.md +0 -154
  249. package/.claude/agents/specialized/accounts-payable-agent.md +0 -186
  250. package/.claude/agents/specialized/corporate-training-designer.md +0 -193
  251. package/.claude/agents/specialized/data-consolidation-agent.md +0 -61
  252. package/.claude/agents/specialized/government-digital-presales-consultant.md +0 -364
  253. package/.claude/agents/specialized/healthcare-marketing-compliance.md +0 -396
  254. package/.claude/agents/specialized/recruitment-specialist.md +0 -510
  255. package/.claude/agents/specialized/report-distribution-agent.md +0 -66
  256. package/.claude/agents/specialized/sales-data-extraction-agent.md +0 -68
  257. package/.claude/agents/specialized/specialized-french-consulting-market.md +0 -193
  258. package/.claude/agents/specialized/specialized-korean-business-navigator.md +0 -217
  259. package/.claude/agents/specialized/specialized-salesforce-architect.md +0 -181
  260. package/.claude/agents/specialized/study-abroad-advisor.md +0 -283
  261. package/.claude/agents/specialized/supply-chain-strategist.md +0 -583
  262. package/.claude/agents/sublinear/consensus-coordinator.md +0 -333
  263. package/.claude/agents/sublinear/matrix-optimizer.md +0 -180
  264. package/.claude/agents/sublinear/pagerank-analyzer.md +0 -295
  265. package/.claude/agents/sublinear/performance-optimizer.md +0 -363
  266. package/.claude/agents/sublinear/trading-predictor.md +0 -242
  267. package/.claude/agents/support/support-analytics-reporter.md +0 -366
  268. package/.claude/agents/support/support-executive-summary-generator.md +0 -213
  269. package/.claude/agents/support/support-finance-tracker.md +0 -443
  270. package/.claude/agents/support/support-infrastructure-maintainer.md +0 -619
  271. package/.claude/agents/support/support-legal-compliance-checker.md +0 -589
  272. package/.claude/agents/support/support-support-responder.md +0 -586
  273. package/.claude/agents/swarm/adaptive-coordinator.md +0 -364
  274. package/.claude/agents/swarm/hierarchical-coordinator.md +0 -318
  275. package/.claude/agents/templates/github-pr-manager.md +0 -155
  276. package/.claude/agents/templates/memory-coordinator.md +0 -163
  277. package/.claude/agents/templates/migration-plan.md +0 -724
  278. package/.claude/agents/templates/orchestrator-task.md +0 -120
  279. package/.claude/agents/templates/performance-analyzer.md +0 -179
  280. package/.claude/agents/templates/sparc-coordinator.md +0 -163
  281. package/.claude/agents/testing/testing-reality-checker.md +0 -237
  282. package/.claude/commands/analysis/token-efficiency.md +0 -42
  283. package/.claude/commands/optimization/README.md +0 -73
  284. package/.claude/commands/optimization/parallel-execution.md +0 -76
  285. package/.claude/commands/swarm/swarm-analysis.md +0 -62
  286. package/.claude/commands/swarm/swarm-background.md +0 -65
  287. package/.claude/commands/swarm/swarm-modes.md +0 -67
  288. package/.claude/commands/swarm/swarm-monitor.md +0 -54
  289. package/.claude/commands/swarm/swarm-status.md +0 -44
  290. package/.claude/commands/swarm/swarm-strategies.md +0 -76
  291. package/.claude/commands/training/model-update.md +0 -78
  292. package/.claude/commands/training/pattern-learn.md +0 -69
  293. package/.claude/commands/training/specialization.md +0 -92
  294. package/.claude/commands/verify/check.md +0 -106
  295. package/.claude/commands/verify/start.md +0 -105
  296. package/.claude/helpers/README.md +0 -105
  297. package/.claude/helpers/context-persistence-hook.mjs +0 -1988
  298. package/.claude/helpers/intelligence.cjs +0 -247
  299. package/.claude/helpers/learning-service.mjs +0 -1302
  300. package/.claude/helpers/memory-palace.cjs +0 -461
  301. package/.claude/helpers/memory.cjs +0 -84
  302. package/.claude/helpers/metrics-db.mjs +0 -488
  303. package/.claude/helpers/router.cjs +0 -559
  304. package/.claude/helpers/session.cjs +0 -126
  305. package/.claude/helpers/swarm-hooks.sh +0 -761
  306. package/.claude/helpers/toggle-statusline.cjs +0 -58
  307. package/.claude/helpers/token-tracker.cjs +0 -934
  308. package/.claude/skills/agentdb-advanced/SKILL.md +0 -549
  309. package/.claude/skills/agentdb-learning/SKILL.md +0 -544
  310. package/.claude/skills/agentdb-memory-patterns/SKILL.md +0 -337
  311. package/.claude/skills/agentdb-optimization/SKILL.md +0 -508
  312. package/.claude/skills/agentdb-vector-search/SKILL.md +0 -335
  313. package/.claude/skills/agentic-integration/SKILL.md +0 -265
  314. package/.claude/skills/cli-modernization/SKILL.md +0 -950
  315. package/.claude/skills/core-implementation/SKILL.md +0 -892
  316. package/.claude/skills/ddd-architecture/SKILL.md +0 -444
  317. package/.claude/skills/github-code-review/SKILL.md +0 -1147
  318. package/.claude/skills/github-multi-repo/SKILL.md +0 -912
  319. package/.claude/skills/github-project-management/SKILL.md +0 -1245
  320. package/.claude/skills/github-release-management/SKILL.md +0 -1118
  321. package/.claude/skills/github-workflow-automation/SKILL.md +0 -1107
  322. package/.claude/skills/mcp-optimization/SKILL.md +0 -837
  323. package/.claude/skills/memory-unification/SKILL.md +0 -196
  324. package/.claude/skills/performance-optimization/SKILL.md +0 -416
  325. package/.claude/skills/reasoningbank-agentdb/SKILL.md +0 -444
  326. package/.claude/skills/reasoningbank-intelligence/SKILL.md +0 -199
  327. package/.claude/skills/security-hardening/SKILL.md +0 -101
  328. package/.claude/skills/stream-chain/SKILL.md +0 -560
  329. package/.claude/skills/swarm-coordination/SKILL.md +0 -451
  330. package/bundled-graph/dist/src/analyze.d.ts +0 -32
  331. package/bundled-graph/dist/src/analyze.d.ts.map +0 -1
  332. package/bundled-graph/dist/src/analyze.js +0 -297
  333. package/bundled-graph/dist/src/analyze.js.map +0 -1
  334. package/bundled-graph/dist/src/build.d.ts +0 -8
  335. package/bundled-graph/dist/src/build.d.ts.map +0 -1
  336. package/bundled-graph/dist/src/build.js.map +0 -1
  337. package/bundled-graph/dist/src/cache.d.ts +0 -12
  338. package/bundled-graph/dist/src/cache.d.ts.map +0 -1
  339. package/bundled-graph/dist/src/cache.js +0 -43
  340. package/bundled-graph/dist/src/cache.js.map +0 -1
  341. package/bundled-graph/dist/src/cluster.d.ts +0 -5
  342. package/bundled-graph/dist/src/cluster.d.ts.map +0 -1
  343. package/bundled-graph/dist/src/cluster.js.map +0 -1
  344. package/bundled-graph/dist/src/detect.d.ts +0 -21
  345. package/bundled-graph/dist/src/detect.d.ts.map +0 -1
  346. package/bundled-graph/dist/src/detect.js +0 -195
  347. package/bundled-graph/dist/src/detect.js.map +0 -1
  348. package/bundled-graph/dist/src/export.d.ts +0 -21
  349. package/bundled-graph/dist/src/export.d.ts.map +0 -1
  350. package/bundled-graph/dist/src/export.js +0 -68
  351. package/bundled-graph/dist/src/export.js.map +0 -1
  352. package/bundled-graph/dist/src/extract/index.d.ts +0 -20
  353. package/bundled-graph/dist/src/extract/index.d.ts.map +0 -1
  354. package/bundled-graph/dist/src/extract/index.js +0 -158
  355. package/bundled-graph/dist/src/extract/index.js.map +0 -1
  356. package/bundled-graph/dist/src/extract/languages/c.d.ts +0 -3
  357. package/bundled-graph/dist/src/extract/languages/c.d.ts.map +0 -1
  358. package/bundled-graph/dist/src/extract/languages/c.js +0 -88
  359. package/bundled-graph/dist/src/extract/languages/c.js.map +0 -1
  360. package/bundled-graph/dist/src/extract/languages/cpp.d.ts +0 -3
  361. package/bundled-graph/dist/src/extract/languages/cpp.d.ts.map +0 -1
  362. package/bundled-graph/dist/src/extract/languages/cpp.js +0 -121
  363. package/bundled-graph/dist/src/extract/languages/cpp.js.map +0 -1
  364. package/bundled-graph/dist/src/extract/languages/csharp.d.ts +0 -3
  365. package/bundled-graph/dist/src/extract/languages/csharp.d.ts.map +0 -1
  366. package/bundled-graph/dist/src/extract/languages/csharp.js +0 -121
  367. package/bundled-graph/dist/src/extract/languages/csharp.js.map +0 -1
  368. package/bundled-graph/dist/src/extract/languages/go.d.ts +0 -3
  369. package/bundled-graph/dist/src/extract/languages/go.d.ts.map +0 -1
  370. package/bundled-graph/dist/src/extract/languages/go.js +0 -181
  371. package/bundled-graph/dist/src/extract/languages/go.js.map +0 -1
  372. package/bundled-graph/dist/src/extract/languages/java.d.ts +0 -3
  373. package/bundled-graph/dist/src/extract/languages/java.d.ts.map +0 -1
  374. package/bundled-graph/dist/src/extract/languages/java.js +0 -117
  375. package/bundled-graph/dist/src/extract/languages/java.js.map +0 -1
  376. package/bundled-graph/dist/src/extract/languages/kotlin.d.ts +0 -3
  377. package/bundled-graph/dist/src/extract/languages/kotlin.d.ts.map +0 -1
  378. package/bundled-graph/dist/src/extract/languages/kotlin.js +0 -112
  379. package/bundled-graph/dist/src/extract/languages/kotlin.js.map +0 -1
  380. package/bundled-graph/dist/src/extract/languages/php.d.ts +0 -3
  381. package/bundled-graph/dist/src/extract/languages/php.d.ts.map +0 -1
  382. package/bundled-graph/dist/src/extract/languages/php.js +0 -130
  383. package/bundled-graph/dist/src/extract/languages/php.js.map +0 -1
  384. package/bundled-graph/dist/src/extract/languages/python.d.ts +0 -3
  385. package/bundled-graph/dist/src/extract/languages/python.d.ts.map +0 -1
  386. package/bundled-graph/dist/src/extract/languages/python.js +0 -230
  387. package/bundled-graph/dist/src/extract/languages/python.js.map +0 -1
  388. package/bundled-graph/dist/src/extract/languages/ruby.d.ts +0 -3
  389. package/bundled-graph/dist/src/extract/languages/ruby.d.ts.map +0 -1
  390. package/bundled-graph/dist/src/extract/languages/ruby.js +0 -120
  391. package/bundled-graph/dist/src/extract/languages/ruby.js.map +0 -1
  392. package/bundled-graph/dist/src/extract/languages/rust.d.ts +0 -3
  393. package/bundled-graph/dist/src/extract/languages/rust.d.ts.map +0 -1
  394. package/bundled-graph/dist/src/extract/languages/rust.js +0 -195
  395. package/bundled-graph/dist/src/extract/languages/rust.js.map +0 -1
  396. package/bundled-graph/dist/src/extract/languages/scala.d.ts +0 -3
  397. package/bundled-graph/dist/src/extract/languages/scala.d.ts.map +0 -1
  398. package/bundled-graph/dist/src/extract/languages/scala.js +0 -110
  399. package/bundled-graph/dist/src/extract/languages/scala.js.map +0 -1
  400. package/bundled-graph/dist/src/extract/languages/swift.d.ts +0 -3
  401. package/bundled-graph/dist/src/extract/languages/swift.d.ts.map +0 -1
  402. package/bundled-graph/dist/src/extract/languages/swift.js +0 -122
  403. package/bundled-graph/dist/src/extract/languages/swift.js.map +0 -1
  404. package/bundled-graph/dist/src/extract/languages/typescript.d.ts +0 -3
  405. package/bundled-graph/dist/src/extract/languages/typescript.d.ts.map +0 -1
  406. package/bundled-graph/dist/src/extract/languages/typescript.js +0 -295
  407. package/bundled-graph/dist/src/extract/languages/typescript.js.map +0 -1
  408. package/bundled-graph/dist/src/extract/semantic.d.ts +0 -38
  409. package/bundled-graph/dist/src/extract/semantic.d.ts.map +0 -1
  410. package/bundled-graph/dist/src/extract/semantic.js +0 -242
  411. package/bundled-graph/dist/src/extract/semantic.js.map +0 -1
  412. package/bundled-graph/dist/src/extract/tree-sitter-runner.d.ts +0 -48
  413. package/bundled-graph/dist/src/extract/tree-sitter-runner.d.ts.map +0 -1
  414. package/bundled-graph/dist/src/extract/tree-sitter-runner.js +0 -137
  415. package/bundled-graph/dist/src/extract/tree-sitter-runner.js.map +0 -1
  416. package/bundled-graph/dist/src/extract/types.d.ts +0 -7
  417. package/bundled-graph/dist/src/extract/types.d.ts.map +0 -1
  418. package/bundled-graph/dist/src/extract/types.js +0 -2
  419. package/bundled-graph/dist/src/extract/types.js.map +0 -1
  420. package/bundled-graph/dist/src/index.d.ts +0 -28
  421. package/bundled-graph/dist/src/index.d.ts.map +0 -1
  422. package/bundled-graph/dist/src/index.js +0 -26
  423. package/bundled-graph/dist/src/index.js.map +0 -1
  424. package/bundled-graph/dist/src/pipeline.d.ts +0 -27
  425. package/bundled-graph/dist/src/pipeline.d.ts.map +0 -1
  426. package/bundled-graph/dist/src/pipeline.js +0 -269
  427. package/bundled-graph/dist/src/pipeline.js.map +0 -1
  428. package/bundled-graph/dist/src/report.d.ts +0 -26
  429. package/bundled-graph/dist/src/report.d.ts.map +0 -1
  430. package/bundled-graph/dist/src/report.js +0 -214
  431. package/bundled-graph/dist/src/report.js.map +0 -1
  432. package/bundled-graph/dist/src/types.d.ts +0 -124
  433. package/bundled-graph/dist/src/types.d.ts.map +0 -1
  434. package/bundled-graph/dist/src/types.js +0 -2
  435. package/bundled-graph/dist/src/types.js.map +0 -1
  436. package/bundled-graph/dist/src/visualize.d.ts +0 -4
  437. package/bundled-graph/dist/src/visualize.d.ts.map +0 -1
  438. package/bundled-graph/dist/src/visualize.js +0 -574
  439. package/bundled-graph/dist/src/visualize.js.map +0 -1
  440. package/bundled-graph/dist/tsconfig.tsbuildinfo +0 -1
  441. package/dist/src/ui/dashboard-v2.html +0 -5316
@@ -1,837 +0,0 @@
1
- ---
2
- name: mcp-optimization
3
- description: "MCP server optimization and transport layer enhancement for monomind. Implements connection pooling, load balancing, tool registry optimization, and performance monitoring for sub-100ms response times."
4
- triggers:
5
- - MCP server slow
6
- - MCP latency
7
- - tool lookup latency
8
- - connection pooling
9
- - MCP startup time
10
- - optimize transport layer
11
- - sub-100ms MCP
12
- ---
13
-
14
- # MCP Optimization
15
-
16
- ## What This Skill Does
17
-
18
- Optimizes monomind MCP (Model Context Protocol) server implementation with advanced transport layer optimizations, connection pooling, load balancing, and comprehensive performance monitoring to achieve sub-100ms response times.
19
-
20
- ## Quick Start
21
-
22
- ```bash
23
- # Initialize MCP optimization analysis
24
- Task("MCP architecture", "Analyze current MCP server performance and bottlenecks", "mcp-specialist")
25
-
26
- # Optimization implementation (parallel)
27
- Task("Connection pooling", "Implement MCP connection pooling and reuse", "mcp-specialist")
28
- Task("Load balancing", "Add dynamic load balancing for MCP tools", "mcp-specialist")
29
- Task("Transport optimization", "Optimize transport layer performance", "mcp-specialist")
30
- ```
31
-
32
- ## MCP Performance Architecture
33
-
34
- ### Current State Analysis
35
-
36
- ```
37
- Current MCP Issues:
38
- ├── Cold Start Latency: ~1.8s MCP server init
39
- ├── Connection Overhead: New connection per request
40
- ├── Tool Registry: Linear search O(n) for 213+ tools
41
- ├── Transport Layer: No connection reuse
42
- └── Memory Usage: No cleanup of idle connections
43
-
44
- Target Performance:
45
- ├── Startup Time: <400ms (4.5x improvement)
46
- ├── Tool Lookup: <5ms (O(1) hash table)
47
- ├── Connection Reuse: 90%+ connection pool hits
48
- ├── Response Time: <100ms p95
49
- └── Memory Efficiency: 50% reduction
50
- ```
51
-
52
- ### MCP Server Architecture
53
-
54
- ```typescript
55
- // src/core/mcp/mcp-server.ts
56
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
57
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
58
-
59
- interface OptimizedMCPConfig {
60
- // Connection pooling
61
- maxConnections: number;
62
- idleTimeoutMs: number;
63
- connectionReuseEnabled: boolean;
64
-
65
- // Tool registry
66
- toolCacheEnabled: boolean;
67
- toolIndexType: "hash" | "trie";
68
-
69
- // Performance
70
- requestTimeoutMs: number;
71
- batchingEnabled: boolean;
72
- compressionEnabled: boolean;
73
-
74
- // Monitoring
75
- metricsEnabled: boolean;
76
- healthCheckIntervalMs: number;
77
- }
78
-
79
- export class OptimizedMCPServer {
80
- private server: Server;
81
- private connectionPool: ConnectionPool;
82
- private toolRegistry: FastToolRegistry;
83
- private loadBalancer: MCPLoadBalancer;
84
- private metrics: MCPMetrics;
85
-
86
- constructor(config: OptimizedMCPConfig) {
87
- this.server = new Server(
88
- {
89
- name: "monomind-v1",
90
- version: "3.0.0",
91
- },
92
- {
93
- capabilities: {
94
- tools: { listChanged: true },
95
- resources: { subscribe: true, listChanged: true },
96
- prompts: { listChanged: true },
97
- },
98
- },
99
- );
100
-
101
- this.connectionPool = new ConnectionPool(config);
102
- this.toolRegistry = new FastToolRegistry(config.toolIndexType);
103
- this.loadBalancer = new MCPLoadBalancer();
104
- this.metrics = new MCPMetrics(config.metricsEnabled);
105
- }
106
-
107
- async start(): Promise<void> {
108
- // Pre-warm connection pool
109
- await this.connectionPool.preWarm();
110
-
111
- // Pre-build tool index
112
- await this.toolRegistry.buildIndex();
113
-
114
- // Setup request handlers with optimizations
115
- this.setupOptimizedHandlers();
116
-
117
- // Start health monitoring
118
- this.startHealthMonitoring();
119
-
120
- // Start server
121
- const transport = new StdioServerTransport();
122
- await this.server.connect(transport);
123
-
124
- this.metrics.recordStartup();
125
- }
126
- }
127
- ```
128
-
129
- ## Connection Pool Implementation
130
-
131
- ### Advanced Connection Pooling
132
-
133
- ```typescript
134
- // src/core/mcp/connection-pool.ts
135
- interface PooledConnection {
136
- id: string;
137
- connection: MCPConnection;
138
- lastUsed: number;
139
- usageCount: number;
140
- isHealthy: boolean;
141
- }
142
-
143
- export class ConnectionPool {
144
- private pool: Map<string, PooledConnection> = new Map();
145
- private readonly config: ConnectionPoolConfig;
146
- private healthChecker: HealthChecker;
147
-
148
- constructor(config: ConnectionPoolConfig) {
149
- this.config = {
150
- maxConnections: 50,
151
- minConnections: 5,
152
- idleTimeoutMs: 300000, // 5 minutes
153
- maxUsageCount: 1000,
154
- healthCheckIntervalMs: 30000,
155
- ...config,
156
- };
157
-
158
- this.healthChecker = new HealthChecker(this.config.healthCheckIntervalMs);
159
- }
160
-
161
- async getConnection(endpoint: string): Promise<MCPConnection> {
162
- const start = performance.now();
163
-
164
- // Try to get from pool first
165
- const pooled = this.findAvailableConnection(endpoint);
166
- if (pooled) {
167
- pooled.lastUsed = Date.now();
168
- pooled.usageCount++;
169
-
170
- this.recordMetric("pool_hit", performance.now() - start);
171
- return pooled.connection;
172
- }
173
-
174
- // Check pool capacity
175
- if (this.pool.size >= this.config.maxConnections) {
176
- await this.evictLeastUsedConnection();
177
- }
178
-
179
- // Create new connection
180
- const connection = await this.createConnection(endpoint);
181
- const pooledConn: PooledConnection = {
182
- id: this.generateConnectionId(),
183
- connection,
184
- lastUsed: Date.now(),
185
- usageCount: 1,
186
- isHealthy: true,
187
- };
188
-
189
- this.pool.set(pooledConn.id, pooledConn);
190
- this.recordMetric("pool_miss", performance.now() - start);
191
-
192
- return connection;
193
- }
194
-
195
- async releaseConnection(connection: MCPConnection): Promise<void> {
196
- // Mark connection as available for reuse
197
- const pooled = this.findConnectionById(connection.id);
198
- if (pooled) {
199
- // Check if connection should be retired
200
- if (pooled.usageCount >= this.config.maxUsageCount) {
201
- await this.removeConnection(pooled.id);
202
- }
203
- }
204
- }
205
-
206
- async preWarm(): Promise<void> {
207
- const connections: Promise<MCPConnection>[] = [];
208
-
209
- for (let i = 0; i < this.config.minConnections; i++) {
210
- connections.push(this.createConnection("default"));
211
- }
212
-
213
- await Promise.all(connections);
214
- }
215
-
216
- private async evictLeastUsedConnection(): Promise<void> {
217
- let oldestConn: PooledConnection | null = null;
218
- let oldestTime = Date.now();
219
-
220
- for (const conn of this.pool.values()) {
221
- if (conn.lastUsed < oldestTime) {
222
- oldestTime = conn.lastUsed;
223
- oldestConn = conn;
224
- }
225
- }
226
-
227
- if (oldestConn) {
228
- await this.removeConnection(oldestConn.id);
229
- }
230
- }
231
-
232
- private findAvailableConnection(endpoint: string): PooledConnection | null {
233
- for (const conn of this.pool.values()) {
234
- if (
235
- conn.isHealthy &&
236
- conn.connection.endpoint === endpoint &&
237
- Date.now() - conn.lastUsed < this.config.idleTimeoutMs
238
- ) {
239
- return conn;
240
- }
241
- }
242
- return null;
243
- }
244
- }
245
- ```
246
-
247
- ## Fast Tool Registry
248
-
249
- ### O(1) Tool Lookup Implementation
250
-
251
- ```typescript
252
- // src/core/mcp/fast-tool-registry.ts
253
- interface ToolIndexEntry {
254
- name: string;
255
- handler: ToolHandler;
256
- metadata: ToolMetadata;
257
- usageCount: number;
258
- avgLatencyMs: number;
259
- }
260
-
261
- export class FastToolRegistry {
262
- private toolIndex: Map<string, ToolIndexEntry> = new Map();
263
- private categoryIndex: Map<string, string[]> = new Map();
264
- private fuzzyMatcher: FuzzyMatcher;
265
- private cache: LRUCache<string, ToolIndexEntry>;
266
-
267
- constructor(indexType: "hash" | "trie" = "hash") {
268
- this.fuzzyMatcher = new FuzzyMatcher();
269
- this.cache = new LRUCache<string, ToolIndexEntry>(1000); // Cache 1000 most used tools
270
- }
271
-
272
- async buildIndex(): Promise<void> {
273
- const start = performance.now();
274
-
275
- // Load all available tools
276
- const tools = await this.loadAllTools();
277
-
278
- // Build hash index for O(1) lookup
279
- for (const tool of tools) {
280
- const entry: ToolIndexEntry = {
281
- name: tool.name,
282
- handler: tool.handler,
283
- metadata: tool.metadata,
284
- usageCount: 0,
285
- avgLatencyMs: 0,
286
- };
287
-
288
- this.toolIndex.set(tool.name, entry);
289
-
290
- // Build category index
291
- const category = tool.metadata.category || "general";
292
- if (!this.categoryIndex.has(category)) {
293
- this.categoryIndex.set(category, []);
294
- }
295
- this.categoryIndex.get(category)!.push(tool.name);
296
- }
297
-
298
- // Build fuzzy search index
299
- await this.fuzzyMatcher.buildIndex(tools.map((t) => t.name));
300
-
301
- console.log(
302
- `Tool index built in ${(performance.now() - start).toFixed(2)}ms for ${tools.length} tools`,
303
- );
304
- }
305
-
306
- findTool(name: string): ToolIndexEntry | null {
307
- // Try cache first
308
- const cached = this.cache.get(name);
309
- if (cached) return cached;
310
-
311
- // Try exact match
312
- const exact = this.toolIndex.get(name);
313
- if (exact) {
314
- this.cache.set(name, exact);
315
- return exact;
316
- }
317
-
318
- // Try fuzzy match
319
- const fuzzyMatches = this.fuzzyMatcher.search(name, 1);
320
- if (fuzzyMatches.length > 0) {
321
- const match = this.toolIndex.get(fuzzyMatches[0]);
322
- if (match) {
323
- this.cache.set(name, match);
324
- return match;
325
- }
326
- }
327
-
328
- return null;
329
- }
330
-
331
- findToolsByCategory(category: string): ToolIndexEntry[] {
332
- const toolNames = this.categoryIndex.get(category) || [];
333
- return toolNames
334
- .map((name) => this.toolIndex.get(name))
335
- .filter((entry) => entry !== undefined) as ToolIndexEntry[];
336
- }
337
-
338
- getMostUsedTools(limit: number = 10): ToolIndexEntry[] {
339
- return Array.from(this.toolIndex.values())
340
- .sort((a, b) => b.usageCount - a.usageCount)
341
- .slice(0, limit);
342
- }
343
-
344
- recordToolUsage(toolName: string, latencyMs: number): void {
345
- const entry = this.toolIndex.get(toolName);
346
- if (entry) {
347
- entry.usageCount++;
348
- // Moving average for latency
349
- entry.avgLatencyMs = (entry.avgLatencyMs + latencyMs) / 2;
350
- }
351
- }
352
- }
353
- ```
354
-
355
- ## Load Balancing & Request Distribution
356
-
357
- ### Intelligent Load Balancer
358
-
359
- ```typescript
360
- // src/core/mcp/load-balancer.ts
361
- interface ServerInstance {
362
- id: string;
363
- endpoint: string;
364
- load: number;
365
- responseTime: number;
366
- isHealthy: boolean;
367
- maxConnections: number;
368
- currentConnections: number;
369
- }
370
-
371
- export class MCPLoadBalancer {
372
- private servers: Map<string, ServerInstance> = new Map();
373
- private routingStrategy: RoutingStrategy = "least-connections";
374
-
375
- addServer(server: ServerInstance): void {
376
- this.servers.set(server.id, server);
377
- }
378
-
379
- selectServer(toolCategory?: string): ServerInstance | null {
380
- const healthyServers = Array.from(this.servers.values()).filter(
381
- (server) => server.isHealthy,
382
- );
383
-
384
- if (healthyServers.length === 0) return null;
385
-
386
- switch (this.routingStrategy) {
387
- case "round-robin":
388
- return this.roundRobinSelection(healthyServers);
389
-
390
- case "least-connections":
391
- return this.leastConnectionsSelection(healthyServers);
392
-
393
- case "response-time":
394
- return this.responseTimeSelection(healthyServers);
395
-
396
- case "weighted":
397
- return this.weightedSelection(healthyServers, toolCategory);
398
-
399
- default:
400
- return healthyServers[0];
401
- }
402
- }
403
-
404
- private leastConnectionsSelection(servers: ServerInstance[]): ServerInstance {
405
- return servers.reduce((least, current) =>
406
- current.currentConnections < least.currentConnections ? current : least,
407
- );
408
- }
409
-
410
- private responseTimeSelection(servers: ServerInstance[]): ServerInstance {
411
- return servers.reduce((fastest, current) =>
412
- current.responseTime < fastest.responseTime ? current : fastest,
413
- );
414
- }
415
-
416
- private weightedSelection(
417
- servers: ServerInstance[],
418
- category?: string,
419
- ): ServerInstance {
420
- // Prefer servers with lower load and better response time
421
- const scored = servers.map((server) => ({
422
- server,
423
- score: this.calculateServerScore(server, category),
424
- }));
425
-
426
- scored.sort((a, b) => b.score - a.score);
427
- return scored[0].server;
428
- }
429
-
430
- private calculateServerScore(
431
- server: ServerInstance,
432
- category?: string,
433
- ): number {
434
- const loadFactor = 1 - server.currentConnections / server.maxConnections;
435
- const responseFactor = 1 / (server.responseTime + 1);
436
- const categoryBonus = this.getCategoryBonus(server, category);
437
-
438
- return loadFactor * 0.4 + responseFactor * 0.4 + categoryBonus * 0.2;
439
- }
440
-
441
- updateServerMetrics(
442
- serverId: string,
443
- metrics: Partial<ServerInstance>,
444
- ): void {
445
- const server = this.servers.get(serverId);
446
- if (server) {
447
- Object.assign(server, metrics);
448
- }
449
- }
450
- }
451
- ```
452
-
453
- ## Transport Layer Optimization
454
-
455
- ### High-Performance Transport
456
-
457
- ```typescript
458
- // src/core/mcp/optimized-transport.ts
459
- export class OptimizedTransport {
460
- private compression: boolean = true;
461
- private batching: boolean = true;
462
- private batchBuffer: MCPMessage[] = [];
463
- private batchTimeout: NodeJS.Timeout | null = null;
464
-
465
- constructor(private config: TransportConfig) {}
466
-
467
- async send(message: MCPMessage): Promise<void> {
468
- if (this.batching && this.canBatch(message)) {
469
- this.addToBatch(message);
470
- return;
471
- }
472
-
473
- await this.sendImmediate(message);
474
- }
475
-
476
- private async sendImmediate(message: MCPMessage): Promise<void> {
477
- const start = performance.now();
478
-
479
- // Compress if enabled
480
- const payload = this.compression ? await this.compress(message) : message;
481
-
482
- // Send through transport
483
- await this.transport.send(payload);
484
-
485
- // Record metrics
486
- this.recordLatency(performance.now() - start);
487
- }
488
-
489
- private addToBatch(message: MCPMessage): void {
490
- this.batchBuffer.push(message);
491
-
492
- // Start batch timeout if not already running
493
- if (!this.batchTimeout) {
494
- this.batchTimeout = setTimeout(
495
- () => this.flushBatch(),
496
- this.config.batchTimeoutMs || 10,
497
- );
498
- }
499
-
500
- // Flush if batch is full
501
- if (this.batchBuffer.length >= this.config.maxBatchSize) {
502
- this.flushBatch();
503
- }
504
- }
505
-
506
- private async flushBatch(): Promise<void> {
507
- if (this.batchBuffer.length === 0) return;
508
-
509
- const batch = this.batchBuffer.splice(0);
510
- this.batchTimeout = null;
511
-
512
- // Send as single batched message
513
- await this.sendImmediate({
514
- type: "batch",
515
- messages: batch,
516
- });
517
- }
518
-
519
- private canBatch(message: MCPMessage): boolean {
520
- // Don't batch urgent messages or responses
521
- return (
522
- message.type !== "response" &&
523
- message.priority !== "high" &&
524
- message.type !== "error"
525
- );
526
- }
527
-
528
- private async compress(data: any): Promise<Buffer> {
529
- // Use async zlib.gzip() in production to avoid blocking the event loop
530
- return compressAsync(Buffer.from(JSON.stringify(data)));
531
- }
532
- }
533
-
534
- function compressAsync(data: Buffer): Promise<Buffer> {
535
- return new Promise((resolve, reject) =>
536
- zlib.gzip(data, (err, result) => (err ? reject(err) : resolve(result))),
537
- );
538
- }
539
- ```
540
-
541
- ## Performance Monitoring
542
-
543
- ### Real-time MCP Metrics
544
-
545
- ```typescript
546
- // src/core/mcp/metrics.ts
547
- interface MCPMetrics {
548
- requestCount: number;
549
- errorCount: number;
550
- avgResponseTime: number;
551
- p95ResponseTime: number;
552
- connectionPoolHits: number;
553
- connectionPoolMisses: number;
554
- toolLookupTime: number;
555
- startupTime: number;
556
- }
557
-
558
- export class MCPMetricsCollector {
559
- private metrics: MCPMetrics;
560
- private responseTimeBuffer: number[] = [];
561
- private readonly bufferSize = 1000;
562
-
563
- constructor() {
564
- this.metrics = this.createInitialMetrics();
565
- }
566
-
567
- recordRequest(latencyMs: number): void {
568
- this.metrics.requestCount++;
569
- this.updateResponseTimes(latencyMs);
570
- }
571
-
572
- recordError(): void {
573
- this.metrics.errorCount++;
574
- }
575
-
576
- recordConnectionPoolHit(): void {
577
- this.metrics.connectionPoolHits++;
578
- }
579
-
580
- recordConnectionPoolMiss(): void {
581
- this.metrics.connectionPoolMisses++;
582
- }
583
-
584
- recordToolLookup(latencyMs: number): void {
585
- this.metrics.toolLookupTime = this.updateMovingAverage(
586
- this.metrics.toolLookupTime,
587
- latencyMs,
588
- );
589
- }
590
-
591
- recordStartup(latencyMs: number): void {
592
- this.metrics.startupTime = latencyMs;
593
- }
594
-
595
- getMetrics(): MCPMetrics {
596
- return { ...this.metrics };
597
- }
598
-
599
- getHealthStatus(): HealthStatus {
600
- const errorRate = this.metrics.errorCount / this.metrics.requestCount;
601
- const poolHitRate =
602
- this.metrics.connectionPoolHits /
603
- (this.metrics.connectionPoolHits + this.metrics.connectionPoolMisses);
604
-
605
- return {
606
- status: this.determineHealthStatus(errorRate, poolHitRate),
607
- errorRate,
608
- poolHitRate,
609
- avgResponseTime: this.metrics.avgResponseTime,
610
- p95ResponseTime: this.metrics.p95ResponseTime,
611
- };
612
- }
613
-
614
- private updateResponseTimes(latency: number): void {
615
- this.responseTimeBuffer.push(latency);
616
-
617
- if (this.responseTimeBuffer.length > this.bufferSize) {
618
- this.responseTimeBuffer.shift();
619
- }
620
-
621
- this.metrics.avgResponseTime = this.calculateAverage(
622
- this.responseTimeBuffer,
623
- );
624
- this.metrics.p95ResponseTime = this.calculatePercentile(
625
- this.responseTimeBuffer,
626
- 95,
627
- );
628
- }
629
-
630
- private calculatePercentile(arr: number[], percentile: number): number {
631
- const sorted = arr.slice().sort((a, b) => a - b);
632
- const index = Math.ceil((percentile / 100) * sorted.length) - 1;
633
- return sorted[index] || 0;
634
- }
635
-
636
- private determineHealthStatus(
637
- errorRate: number,
638
- poolHitRate: number,
639
- ): "healthy" | "warning" | "critical" {
640
- if (errorRate > 0.1 || poolHitRate < 0.5) return "critical";
641
- if (errorRate > 0.05 || poolHitRate < 0.7) return "warning";
642
- return "healthy";
643
- }
644
- }
645
- ```
646
-
647
- ## Tool Registry Optimization
648
-
649
- ### Pre-compiled Tool Index
650
-
651
- ```typescript
652
- // src/core/mcp/tool-precompiler.ts
653
- export class ToolPrecompiler {
654
- async precompileTools(): Promise<CompiledToolRegistry> {
655
- const tools = await this.loadAllTools();
656
-
657
- // Create optimized lookup structures
658
- const nameIndex = new Map<string, Tool>();
659
- const categoryIndex = new Map<string, Tool[]>();
660
- const fuzzyIndex = new Map<string, string[]>();
661
-
662
- for (const tool of tools) {
663
- // Exact name index
664
- nameIndex.set(tool.name, tool);
665
-
666
- // Category index
667
- const category = tool.metadata.category || "general";
668
- if (!categoryIndex.has(category)) {
669
- categoryIndex.set(category, []);
670
- }
671
- categoryIndex.get(category)!.push(tool);
672
-
673
- // Pre-compute fuzzy variations
674
- const variations = this.generateFuzzyVariations(tool.name);
675
- for (const variation of variations) {
676
- if (!fuzzyIndex.has(variation)) {
677
- fuzzyIndex.set(variation, []);
678
- }
679
- fuzzyIndex.get(variation)!.push(tool.name);
680
- }
681
- }
682
-
683
- return {
684
- nameIndex,
685
- categoryIndex,
686
- fuzzyIndex,
687
- totalTools: tools.length,
688
- compiledAt: new Date(),
689
- };
690
- }
691
-
692
- private generateFuzzyVariations(name: string): string[] {
693
- const variations: string[] = [];
694
-
695
- // Common typos and abbreviations
696
- variations.push(name.toLowerCase());
697
- variations.push(name.replace(/[-_]/g, ""));
698
- variations.push(name.replace(/[aeiou]/gi, "")); // Consonants only
699
-
700
- // Add more fuzzy matching logic as needed
701
-
702
- return variations;
703
- }
704
- }
705
- ```
706
-
707
- ## Advanced Caching Strategy
708
-
709
- ### Multi-Level Caching
710
-
711
- ```typescript
712
- // src/core/mcp/multi-level-cache.ts
713
- export class MultiLevelCache {
714
- private l1Cache: Map<string, any> = new Map(); // In-memory, fastest
715
- private l2Cache: LRUCache<string, any>; // LRU cache, larger capacity
716
- private l3Cache: DiskCache; // Persistent disk cache
717
-
718
- constructor(config: CacheConfig) {
719
- this.l2Cache = new LRUCache<string, any>({
720
- max: config.l2MaxEntries || 10000,
721
- ttl: config.l2TTL || 300000, // 5 minutes
722
- });
723
-
724
- this.l3Cache = new DiskCache(config.l3Path || "./.cache/mcp");
725
- }
726
-
727
- async get(key: string): Promise<any | null> {
728
- // Try L1 cache first (fastest)
729
- // LRU pattern: delete and re-insert on access so the key moves to the end
730
- // of insertion order; the Map's first key is always the least-recently-used.
731
- if (this.l1Cache.has(key)) {
732
- const value = this.l1Cache.get(key);
733
- this.l1Cache.delete(key);
734
- this.l1Cache.set(key, value);
735
- return value;
736
- }
737
-
738
- // Try L2 cache
739
- const l2Value = this.l2Cache.get(key);
740
- if (l2Value) {
741
- // Promote to L1
742
- this.l1Cache.set(key, l2Value);
743
- return l2Value;
744
- }
745
-
746
- // Try L3 cache (disk)
747
- const l3Value = await this.l3Cache.get(key);
748
- if (l3Value) {
749
- // Promote to L2 and L1
750
- this.l2Cache.set(key, l3Value);
751
- this.l1Cache.set(key, l3Value);
752
- return l3Value;
753
- }
754
-
755
- return null;
756
- }
757
-
758
- async set(key: string, value: any, options?: CacheOptions): Promise<void> {
759
- // Set in all levels
760
- this.l1Cache.set(key, value);
761
- this.l2Cache.set(key, value);
762
-
763
- if (options?.persistent) {
764
- await this.l3Cache.set(key, value);
765
- }
766
-
767
- // Manage L1 cache size with LRU eviction:
768
- // Map iterates in insertion order, so re-inserting a key on access moves it
769
- // to the end. The first key is therefore always the least-recently-used one.
770
- if (this.l1Cache.size > 1000) {
771
- const lruKey = this.l1Cache.keys().next().value;
772
- this.l1Cache.delete(lruKey);
773
- }
774
- }
775
- }
776
- ```
777
-
778
- ## Success Metrics
779
-
780
- ### Performance Targets
781
-
782
- - [ ] **Startup Time**: <400ms MCP server initialization (4.5x improvement)
783
- - [ ] **Response Time**: <100ms p95 for tool execution
784
- - [ ] **Tool Lookup**: <5ms average lookup time
785
- - [ ] **Connection Pool**: >90% hit rate
786
- - [ ] **Memory Usage**: 50% reduction in idle memory
787
- - [ ] **Error Rate**: <1% failed requests
788
- - [ ] **Throughput**: >1000 requests/second
789
-
790
- ### Monitoring Dashboards
791
-
792
- ```typescript
793
- const mcpDashboard = {
794
- metrics: [
795
- "Request latency (p50, p95, p99)",
796
- "Error rate by tool category",
797
- "Connection pool utilization",
798
- "Tool lookup performance",
799
- "Memory usage trends",
800
- "Cache hit rates (L1, L2, L3)",
801
- ],
802
-
803
- alerts: [
804
- "Response time >200ms for 5 minutes",
805
- "Error rate >5% for 1 minute",
806
- "Pool hit rate <70% for 10 minutes",
807
- "Memory usage >500MB for 5 minutes",
808
- ],
809
- };
810
- ```
811
-
812
- ## Related Skills
813
-
814
- - `core-implementation` - Core domain integration with MCP
815
- - `performance-optimization` - Overall performance optimization
816
- - `swarm-coordination` - MCP integration with swarm coordination
817
- - `memory-unification` - Memory sharing via MCP tools
818
-
819
- ## Usage Examples
820
-
821
- ### Complete MCP Optimization
822
-
823
- ```bash
824
- # Full MCP server optimization
825
- Task("MCP optimization implementation",
826
- "Implement all MCP performance optimizations with monitoring",
827
- "mcp-specialist")
828
- ```
829
-
830
- ### Specific Optimization
831
-
832
- ```bash
833
- # Connection pool optimization
834
- Task("MCP connection pooling",
835
- "Implement advanced connection pooling with health monitoring",
836
- "mcp-specialist")
837
- ```