claude-mpm 5.1.9__py3-none-any.whl → 5.4.14__py3-none-any.whl

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.

Potentially problematic release.


This version of claude-mpm might be problematic. Click here for more details.

Files changed (162) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/__init__.py +4 -0
  3. claude_mpm/agents/PM_INSTRUCTIONS.md +85 -0
  4. claude_mpm/agents/agent_loader.py +13 -44
  5. claude_mpm/agents/templates/circuit-breakers.md +138 -1
  6. claude_mpm/cli/__main__.py +4 -0
  7. claude_mpm/cli/commands/agent_state_manager.py +8 -17
  8. claude_mpm/cli/commands/auto_configure.py +210 -25
  9. claude_mpm/cli/commands/config.py +88 -2
  10. claude_mpm/cli/commands/configure.py +1097 -158
  11. claude_mpm/cli/commands/configure_agent_display.py +15 -6
  12. claude_mpm/cli/commands/mpm_init/core.py +160 -46
  13. claude_mpm/cli/commands/mpm_init/knowledge_extractor.py +481 -0
  14. claude_mpm/cli/commands/mpm_init/prompts.py +280 -0
  15. claude_mpm/cli/commands/skills.py +21 -2
  16. claude_mpm/cli/commands/summarize.py +413 -0
  17. claude_mpm/cli/executor.py +11 -3
  18. claude_mpm/cli/parsers/base_parser.py +5 -0
  19. claude_mpm/cli/parsers/config_parser.py +153 -83
  20. claude_mpm/cli/parsers/skills_parser.py +3 -2
  21. claude_mpm/cli/startup.py +333 -89
  22. claude_mpm/commands/mpm-config.md +266 -0
  23. claude_mpm/commands/{mpm-ticket-organize.md → mpm-organize.md} +4 -5
  24. claude_mpm/config/agent_sources.py +27 -0
  25. claude_mpm/core/framework/formatters/content_formatter.py +3 -13
  26. claude_mpm/core/framework/loaders/agent_loader.py +8 -5
  27. claude_mpm/core/framework_loader.py +4 -2
  28. claude_mpm/core/logger.py +13 -0
  29. claude_mpm/core/socketio_pool.py +3 -3
  30. claude_mpm/core/unified_agent_registry.py +5 -15
  31. claude_mpm/hooks/claude_hooks/correlation_manager.py +60 -0
  32. claude_mpm/hooks/claude_hooks/event_handlers.py +206 -78
  33. claude_mpm/hooks/claude_hooks/hook_handler.py +6 -0
  34. claude_mpm/hooks/claude_hooks/installer.py +33 -10
  35. claude_mpm/hooks/claude_hooks/memory_integration.py +26 -9
  36. claude_mpm/hooks/claude_hooks/response_tracking.py +2 -3
  37. claude_mpm/hooks/claude_hooks/services/connection_manager.py +4 -0
  38. claude_mpm/hooks/memory_integration_hook.py +46 -1
  39. claude_mpm/init.py +0 -19
  40. claude_mpm/scripts/claude-hook-handler.sh +58 -18
  41. claude_mpm/scripts/launch_monitor.py +93 -13
  42. claude_mpm/services/agents/agent_recommendation_service.py +278 -0
  43. claude_mpm/services/agents/agent_review_service.py +280 -0
  44. claude_mpm/services/agents/deployment/agent_discovery_service.py +2 -3
  45. claude_mpm/services/agents/deployment/agent_template_builder.py +4 -2
  46. claude_mpm/services/agents/deployment/multi_source_deployment_service.py +78 -9
  47. claude_mpm/services/agents/deployment/remote_agent_discovery_service.py +335 -53
  48. claude_mpm/services/agents/git_source_manager.py +34 -0
  49. claude_mpm/services/agents/loading/base_agent_manager.py +1 -13
  50. claude_mpm/services/agents/sources/git_source_sync_service.py +8 -1
  51. claude_mpm/services/agents/toolchain_detector.py +10 -6
  52. claude_mpm/services/analysis/__init__.py +11 -1
  53. claude_mpm/services/analysis/clone_detector.py +1030 -0
  54. claude_mpm/services/command_deployment_service.py +71 -10
  55. claude_mpm/services/event_bus/config.py +3 -1
  56. claude_mpm/services/git/git_operations_service.py +93 -8
  57. claude_mpm/services/monitor/daemon.py +9 -2
  58. claude_mpm/services/monitor/daemon_manager.py +39 -3
  59. claude_mpm/services/monitor/server.py +225 -19
  60. claude_mpm/services/self_upgrade_service.py +120 -12
  61. claude_mpm/services/skills/__init__.py +3 -0
  62. claude_mpm/services/skills/git_skill_source_manager.py +32 -2
  63. claude_mpm/services/skills/selective_skill_deployer.py +230 -0
  64. claude_mpm/services/skills/skill_to_agent_mapper.py +406 -0
  65. claude_mpm/services/skills_deployer.py +64 -3
  66. claude_mpm/services/socketio/event_normalizer.py +15 -1
  67. claude_mpm/services/socketio/server/core.py +160 -21
  68. claude_mpm/services/version_control/git_operations.py +103 -0
  69. claude_mpm/utils/agent_filters.py +17 -44
  70. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/METADATA +47 -84
  71. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/RECORD +76 -150
  72. claude_mpm-5.4.14.dist-info/entry_points.txt +5 -0
  73. claude_mpm-5.4.14.dist-info/licenses/LICENSE +94 -0
  74. claude_mpm-5.4.14.dist-info/licenses/LICENSE-FAQ.md +153 -0
  75. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +0 -292
  76. claude_mpm/agents/BASE_DOCUMENTATION.md +0 -53
  77. claude_mpm/agents/BASE_ENGINEER.md +0 -658
  78. claude_mpm/agents/BASE_OPS.md +0 -219
  79. claude_mpm/agents/BASE_PM.md +0 -480
  80. claude_mpm/agents/BASE_PROMPT_ENGINEER.md +0 -787
  81. claude_mpm/agents/BASE_QA.md +0 -167
  82. claude_mpm/agents/BASE_RESEARCH.md +0 -53
  83. claude_mpm/agents/base_agent.json +0 -31
  84. claude_mpm/agents/base_agent_loader.py +0 -601
  85. claude_mpm/cli/ticket_cli.py +0 -35
  86. claude_mpm/commands/mpm-config-view.md +0 -150
  87. claude_mpm/dashboard/analysis_runner.py +0 -455
  88. claude_mpm/dashboard/index.html +0 -13
  89. claude_mpm/dashboard/open_dashboard.py +0 -66
  90. claude_mpm/dashboard/static/css/activity.css +0 -1958
  91. claude_mpm/dashboard/static/css/connection-status.css +0 -370
  92. claude_mpm/dashboard/static/css/dashboard.css +0 -4701
  93. claude_mpm/dashboard/static/js/components/activity-tree.js +0 -1871
  94. claude_mpm/dashboard/static/js/components/agent-hierarchy.js +0 -777
  95. claude_mpm/dashboard/static/js/components/agent-inference.js +0 -956
  96. claude_mpm/dashboard/static/js/components/build-tracker.js +0 -333
  97. claude_mpm/dashboard/static/js/components/code-simple.js +0 -857
  98. claude_mpm/dashboard/static/js/components/connection-debug.js +0 -654
  99. claude_mpm/dashboard/static/js/components/diff-viewer.js +0 -891
  100. claude_mpm/dashboard/static/js/components/event-processor.js +0 -542
  101. claude_mpm/dashboard/static/js/components/event-viewer.js +0 -1155
  102. claude_mpm/dashboard/static/js/components/export-manager.js +0 -368
  103. claude_mpm/dashboard/static/js/components/file-change-tracker.js +0 -443
  104. claude_mpm/dashboard/static/js/components/file-change-viewer.js +0 -690
  105. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +0 -724
  106. claude_mpm/dashboard/static/js/components/file-viewer.js +0 -580
  107. claude_mpm/dashboard/static/js/components/hud-library-loader.js +0 -211
  108. claude_mpm/dashboard/static/js/components/hud-manager.js +0 -671
  109. claude_mpm/dashboard/static/js/components/hud-visualizer.js +0 -1718
  110. claude_mpm/dashboard/static/js/components/module-viewer.js +0 -2764
  111. claude_mpm/dashboard/static/js/components/session-manager.js +0 -579
  112. claude_mpm/dashboard/static/js/components/socket-manager.js +0 -368
  113. claude_mpm/dashboard/static/js/components/ui-state-manager.js +0 -749
  114. claude_mpm/dashboard/static/js/components/unified-data-viewer.js +0 -1824
  115. claude_mpm/dashboard/static/js/components/working-directory.js +0 -920
  116. claude_mpm/dashboard/static/js/connection-manager.js +0 -536
  117. claude_mpm/dashboard/static/js/dashboard.js +0 -1914
  118. claude_mpm/dashboard/static/js/extension-error-handler.js +0 -164
  119. claude_mpm/dashboard/static/js/socket-client.js +0 -1474
  120. claude_mpm/dashboard/static/js/tab-isolation-fix.js +0 -185
  121. claude_mpm/dashboard/static/socket.io.min.js +0 -7
  122. claude_mpm/dashboard/static/socket.io.v4.8.1.backup.js +0 -7
  123. claude_mpm/dashboard/templates/code_simple.html +0 -153
  124. claude_mpm/dashboard/templates/index.html +0 -606
  125. claude_mpm/dashboard/test_dashboard.html +0 -372
  126. claude_mpm/scripts/mcp_server.py +0 -75
  127. claude_mpm/scripts/mcp_wrapper.py +0 -39
  128. claude_mpm/services/mcp_gateway/__init__.py +0 -159
  129. claude_mpm/services/mcp_gateway/auto_configure.py +0 -369
  130. claude_mpm/services/mcp_gateway/config/__init__.py +0 -17
  131. claude_mpm/services/mcp_gateway/config/config_loader.py +0 -296
  132. claude_mpm/services/mcp_gateway/config/config_schema.py +0 -243
  133. claude_mpm/services/mcp_gateway/config/configuration.py +0 -429
  134. claude_mpm/services/mcp_gateway/core/__init__.py +0 -43
  135. claude_mpm/services/mcp_gateway/core/base.py +0 -312
  136. claude_mpm/services/mcp_gateway/core/exceptions.py +0 -253
  137. claude_mpm/services/mcp_gateway/core/interfaces.py +0 -443
  138. claude_mpm/services/mcp_gateway/core/process_pool.py +0 -977
  139. claude_mpm/services/mcp_gateway/core/singleton_manager.py +0 -315
  140. claude_mpm/services/mcp_gateway/core/startup_verification.py +0 -316
  141. claude_mpm/services/mcp_gateway/main.py +0 -589
  142. claude_mpm/services/mcp_gateway/registry/__init__.py +0 -12
  143. claude_mpm/services/mcp_gateway/registry/service_registry.py +0 -412
  144. claude_mpm/services/mcp_gateway/registry/tool_registry.py +0 -489
  145. claude_mpm/services/mcp_gateway/server/__init__.py +0 -15
  146. claude_mpm/services/mcp_gateway/server/mcp_gateway.py +0 -414
  147. claude_mpm/services/mcp_gateway/server/stdio_handler.py +0 -372
  148. claude_mpm/services/mcp_gateway/server/stdio_server.py +0 -712
  149. claude_mpm/services/mcp_gateway/tools/__init__.py +0 -36
  150. claude_mpm/services/mcp_gateway/tools/base_adapter.py +0 -485
  151. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +0 -789
  152. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +0 -654
  153. claude_mpm/services/mcp_gateway/tools/health_check_tool.py +0 -456
  154. claude_mpm/services/mcp_gateway/tools/hello_world.py +0 -551
  155. claude_mpm/services/mcp_gateway/tools/kuzu_memory_service.py +0 -555
  156. claude_mpm/services/mcp_gateway/utils/__init__.py +0 -14
  157. claude_mpm/services/mcp_gateway/utils/package_version_checker.py +0 -160
  158. claude_mpm/services/mcp_gateway/utils/update_preferences.py +0 -170
  159. claude_mpm-5.1.9.dist-info/entry_points.txt +0 -10
  160. claude_mpm-5.1.9.dist-info/licenses/LICENSE +0 -21
  161. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/WHEEL +0 -0
  162. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/top_level.txt +0 -0
@@ -1,555 +0,0 @@
1
- """
2
- Kuzu-Memory MCP Service Integration
3
- ====================================
4
-
5
- Provides MCP tool wrappers for kuzu-memory knowledge graph operations,
6
- enabling the PM agent to store and retrieve memories programmatically.
7
-
8
- WHY: The PM agent needs structured tools to manage conversation memories,
9
- allowing it to build up project knowledge over time.
10
-
11
- DESIGN DECISIONS:
12
- - Extends ExternalMCPService for consistent integration patterns
13
- - Provides high-level tools that abstract kuzu-memory complexity
14
- - Includes context enrichment for better memory retrieval
15
- - Supports tagging for organized knowledge management
16
- - kuzu-memory>=1.1.5 is now a REQUIRED dependency (moved from optional in v4.8.6)
17
- """
18
-
19
- import json
20
- import subprocess
21
- from pathlib import Path
22
- from typing import Any, Dict, List, Optional
23
-
24
- from claude_mpm.services.mcp_gateway.core.interfaces import (
25
- MCPToolDefinition,
26
- MCPToolInvocation,
27
- MCPToolResult,
28
- )
29
- from claude_mpm.services.mcp_gateway.tools.base_adapter import BaseToolAdapter
30
-
31
-
32
- class KuzuMemoryService(BaseToolAdapter):
33
- """
34
- MCP service wrapper for kuzu-memory knowledge graph.
35
-
36
- Provides tools for:
37
- - Storing memories with tags
38
- - Retrieving relevant memories
39
- - Searching memories by query
40
- - Getting enriched context for topics
41
- """
42
-
43
- def __init__(self):
44
- """Initialize kuzu-memory MCP service."""
45
- # Define the tool
46
- definition = MCPToolDefinition(
47
- name="kuzu_memory",
48
- description="Knowledge graph memory system for persistent context",
49
- input_schema={
50
- "type": "object",
51
- "properties": {
52
- "action": {
53
- "type": "string",
54
- "enum": ["store", "recall", "search", "context"],
55
- "description": "The memory operation to perform",
56
- },
57
- "content": {
58
- "type": "string",
59
- "description": "Content for store operation",
60
- },
61
- "query": {
62
- "type": "string",
63
- "description": "Query for recall/search/context operations",
64
- },
65
- "tags": {
66
- "type": "array",
67
- "items": {"type": "string"},
68
- "description": "Tags for filtering or categorization",
69
- },
70
- "limit": {
71
- "type": "integer",
72
- "default": 5,
73
- "description": "Maximum number of results",
74
- },
75
- },
76
- "required": ["action"],
77
- },
78
- )
79
- super().__init__(definition)
80
-
81
- self.service_name = "kuzu-memory"
82
- self.package_name = "kuzu-memory"
83
- # Use the current project directory as kuzu-memory works with project-specific databases
84
- self.project_path = Path.cwd()
85
- self._is_installed = False
86
- self.kuzu_cmd = None
87
-
88
- async def _check_installation(self) -> bool:
89
- """Check if kuzu-memory is installed via pipx."""
90
- # Check pipx installation first
91
- pipx_path = (
92
- Path.home()
93
- / ".local"
94
- / "pipx"
95
- / "venvs"
96
- / "kuzu-memory"
97
- / "bin"
98
- / "kuzu-memory"
99
- )
100
- if pipx_path.exists():
101
- self.kuzu_cmd = str(pipx_path)
102
- return True
103
-
104
- # Check system PATH
105
- import shutil
106
-
107
- kuzu_cmd = shutil.which("kuzu-memory")
108
- if kuzu_cmd:
109
- self.kuzu_cmd = kuzu_cmd
110
- return True
111
-
112
- return False
113
-
114
- async def _install_package(self) -> bool:
115
- """
116
- Install kuzu-memory using pipx (preferred over pip).
117
-
118
- NOTE: As of v4.8.6, kuzu-memory is a required dependency and should be
119
- installed via pip along with claude-mpm. This method is kept for backward
120
- compatibility and edge cases where the package may be missing.
121
- """
122
- try:
123
- # Check if pipx is available
124
- import shutil
125
-
126
- if not shutil.which("pipx"):
127
- self.log_warning(
128
- "pipx not found. Install it first: python -m pip install --user pipx"
129
- )
130
- self.log_info(
131
- "Alternatively, kuzu-memory should be installed via pip with claude-mpm dependencies"
132
- )
133
- return False
134
-
135
- self.log_info("Installing kuzu-memory via pipx...")
136
- result = subprocess.run(
137
- ["pipx", "install", "kuzu-memory"],
138
- capture_output=True,
139
- text=True,
140
- timeout=60,
141
- check=False,
142
- )
143
-
144
- if result.returncode == 0:
145
- self.log_info("Successfully installed kuzu-memory via pipx")
146
- return await self._check_installation()
147
-
148
- self.log_error(f"Failed to install kuzu-memory: {result.stderr}")
149
- return False
150
-
151
- except Exception as e:
152
- self.log_error(f"Error installing kuzu-memory: {e}")
153
- return False
154
-
155
- async def initialize(self) -> bool:
156
- """
157
- Initialize the kuzu-memory service.
158
-
159
- NOTE: As of v4.8.6, kuzu-memory is a required dependency. This method
160
- checks for installation and provides helpful messages if missing.
161
- """
162
- try:
163
- # Check if package is installed
164
- self._is_installed = await self._check_installation()
165
-
166
- if not self._is_installed:
167
- self.log_warning(
168
- f"{self.package_name} not found in PATH. "
169
- f"Since v4.8.6, it's a required dependency."
170
- )
171
- self.log_info("Attempting installation via pipx as fallback...")
172
- await self._install_package()
173
- self._is_installed = await self._check_installation()
174
-
175
- if not self._is_installed:
176
- self.log_error(
177
- f"Failed to initialize {self.package_name}. "
178
- f"Please install manually: pip install kuzu-memory>=1.1.5"
179
- )
180
- return False
181
-
182
- self.log_info(f"{self.package_name} is available and ready")
183
- self._initialized = True
184
- return True
185
-
186
- except Exception as e:
187
- self.log_error(f"Failed to initialize {self.service_name}: {e}")
188
- return False
189
-
190
- async def invoke(self, invocation: MCPToolInvocation) -> MCPToolResult:
191
- """
192
- Invoke kuzu-memory tool based on the invocation request.
193
-
194
- Routes to appropriate method based on action parameter.
195
- """
196
- params = invocation.parameters
197
- action = params.get("action")
198
-
199
- try:
200
- if action == "store":
201
- result = await self.store_memory(
202
- params.get("content"),
203
- params.get("tags"),
204
- {}, # metadata
205
- )
206
- elif action == "recall":
207
- result = await self.recall_memories(
208
- params.get("query"), params.get("limit", 5), params.get("tags")
209
- )
210
- elif action == "search":
211
- result = await self.search_memories(
212
- params.get("query", ""),
213
- "both", # search_type
214
- params.get("limit", 10),
215
- )
216
- elif action == "context":
217
- result = await self.get_context(
218
- params.get("query", ""),
219
- 2,
220
- True, # depth # include_related
221
- )
222
- else:
223
- return MCPToolResult(success=False, error=f"Unknown action: {action}")
224
-
225
- return MCPToolResult(
226
- success=result.get("success", False),
227
- data=result,
228
- error=result.get("error"),
229
- )
230
-
231
- except Exception as e:
232
- return MCPToolResult(success=False, error=str(e))
233
-
234
- def validate_parameters(self, parameters: Dict[str, Any]) -> bool:
235
- """Validate tool parameters - basic implementation."""
236
- return True # Validation is handled in individual methods
237
-
238
- async def shutdown(self) -> None:
239
- """Shutdown the service."""
240
- # No resources to clean up
241
-
242
- async def store_memory(
243
- self,
244
- content: str,
245
- tags: Optional[List[str]] = None,
246
- metadata: Optional[Dict[str, Any]] = None,
247
- ) -> Dict[str, Any]:
248
- """
249
- Store a memory in the knowledge graph.
250
-
251
- Args:
252
- content: Memory content to store
253
- tags: Optional tags for categorization
254
- metadata: Optional metadata
255
-
256
- Returns:
257
- Result of the storage operation
258
- """
259
- if not self._is_installed:
260
- return {
261
- "success": False,
262
- "error": "kuzu-memory not installed",
263
- }
264
-
265
- try:
266
- # Use remember command for storing memories
267
- # kuzu-memory works with project-specific databases in the current working directory
268
- cmd = [self.kuzu_cmd, "remember", content]
269
-
270
- # Execute command in project directory
271
- result = subprocess.run(
272
- cmd,
273
- capture_output=True,
274
- text=True,
275
- timeout=10,
276
- cwd=str(self.project_path),
277
- check=False,
278
- )
279
-
280
- if result.returncode == 0:
281
- return {
282
- "success": True,
283
- "message": "Memory stored successfully",
284
- "content": content[:100],
285
- "tags": tags or [],
286
- }
287
-
288
- return {
289
- "success": False,
290
- "error": result.stderr or "Failed to store memory",
291
- }
292
-
293
- except Exception as e:
294
- self.logger.error(f"Error storing memory: {e}")
295
- return {
296
- "success": False,
297
- "error": str(e),
298
- }
299
-
300
- async def recall_memories(
301
- self,
302
- query: str,
303
- limit: int = 5,
304
- tags: Optional[List[str]] = None,
305
- ) -> Dict[str, Any]:
306
- """
307
- Recall memories relevant to a query.
308
-
309
- Args:
310
- query: Query to find relevant memories
311
- limit: Maximum number of memories
312
- tags: Optional tag filter
313
-
314
- Returns:
315
- Retrieved memories
316
- """
317
- if not self._is_installed:
318
- return {
319
- "success": False,
320
- "error": "kuzu-memory not installed",
321
- "memories": [],
322
- }
323
-
324
- try:
325
- # Use recall command for retrieving memories
326
- # kuzu-memory works with project-specific databases in the current working directory
327
- cmd = [
328
- self.kuzu_cmd,
329
- "recall",
330
- query,
331
- "--format",
332
- "json",
333
- "--max-memories",
334
- str(limit),
335
- ]
336
-
337
- # Execute command in project directory
338
- result = subprocess.run(
339
- cmd,
340
- capture_output=True,
341
- text=True,
342
- timeout=10,
343
- cwd=str(self.project_path),
344
- check=False,
345
- )
346
-
347
- if result.returncode == 0 and result.stdout:
348
- memories = json.loads(result.stdout)
349
- return {
350
- "success": True,
351
- "query": query,
352
- "count": len(memories),
353
- "memories": memories,
354
- }
355
-
356
- return {
357
- "success": True,
358
- "query": query,
359
- "count": 0,
360
- "memories": [],
361
- }
362
-
363
- except Exception as e:
364
- self.logger.error(f"Error recalling memories: {e}")
365
- return {
366
- "success": False,
367
- "error": str(e),
368
- "memories": [],
369
- }
370
-
371
- async def search_memories(
372
- self,
373
- search_term: str,
374
- search_type: str = "both",
375
- limit: int = 10,
376
- ) -> Dict[str, Any]:
377
- """
378
- Search memories by using recall with the search term.
379
-
380
- Args:
381
- search_term: Term to search for
382
- search_type: Type of search (not used, kept for compatibility)
383
- limit: Maximum number of results
384
-
385
- Returns:
386
- Search results
387
- """
388
- if not self._is_installed:
389
- return {
390
- "success": False,
391
- "error": "kuzu-memory not installed",
392
- "results": [],
393
- }
394
-
395
- try:
396
- # Use recall for searching (kuzu-memory doesn't have a separate search command)
397
- cmd = [
398
- self.kuzu_cmd,
399
- "recall",
400
- search_term,
401
- "--format",
402
- "json",
403
- "--max-memories",
404
- str(limit),
405
- ]
406
-
407
- # Execute command in project directory
408
- result = subprocess.run(
409
- cmd,
410
- capture_output=True,
411
- text=True,
412
- timeout=10,
413
- cwd=str(self.project_path),
414
- check=False,
415
- )
416
-
417
- if result.returncode == 0 and result.stdout:
418
- # Parse the output
419
- results = []
420
- if "No relevant memories found" not in result.stdout:
421
- # Try to extract memories from output
422
- lines = result.stdout.strip().split("\n")
423
- for line in lines:
424
- if line.strip() and not line.startswith("🔍"):
425
- results.append({"content": line.strip()})
426
-
427
- return {
428
- "success": True,
429
- "search_term": search_term,
430
- "count": len(results),
431
- "results": results[:limit],
432
- }
433
-
434
- return {
435
- "success": True,
436
- "search_term": search_term,
437
- "count": 0,
438
- "results": [],
439
- }
440
-
441
- except Exception as e:
442
- self.log_error(f"Error searching memories: {e}")
443
- return {
444
- "success": False,
445
- "error": str(e),
446
- "results": [],
447
- }
448
-
449
- async def get_context(
450
- self,
451
- topic: str,
452
- depth: int = 2,
453
- include_related: bool = True,
454
- ) -> Dict[str, Any]:
455
- """
456
- Get enriched context for a topic using the enhance command.
457
-
458
- Args:
459
- topic: Topic to get context for
460
- depth: Maximum memories to include
461
- include_related: Not used, kept for compatibility
462
-
463
- Returns:
464
- Enriched context for the topic
465
- """
466
- if not self._is_installed:
467
- return {
468
- "success": False,
469
- "error": "kuzu-memory not installed",
470
- "context": {},
471
- }
472
-
473
- try:
474
- # Use enhance command for context enrichment
475
- cmd = [
476
- self.kuzu_cmd,
477
- "enhance",
478
- topic,
479
- "--max-memories",
480
- str(depth * 3),
481
- "--format",
482
- "plain", # Get just the context
483
- ]
484
-
485
- # Execute command in project directory
486
- result = subprocess.run(
487
- cmd,
488
- capture_output=True,
489
- text=True,
490
- timeout=15,
491
- cwd=str(self.project_path),
492
- check=False,
493
- )
494
-
495
- if result.returncode == 0 and result.stdout:
496
- return {
497
- "success": True,
498
- "topic": topic,
499
- "context": result.stdout.strip(),
500
- "memories": [], # Enhanced context is already processed
501
- }
502
-
503
- # Fallback to recall if enhance fails
504
- self.log_debug("Enhance command failed, falling back to recall")
505
- return await self.recall_memories(topic, limit=depth * 3)
506
-
507
- except Exception as e:
508
- self.log_error(f"Error getting context: {e}")
509
- # Fallback to basic recall
510
- return await self.recall_memories(topic, limit=depth * 3)
511
-
512
-
513
- # Tool function wrappers for MCP Gateway
514
- async def store_memory(
515
- content: str,
516
- tags: Optional[List[str]] = None,
517
- metadata: Optional[Dict[str, Any]] = None,
518
- ) -> Dict[str, Any]:
519
- """Store a memory using the kuzu-memory service."""
520
- service = KuzuMemoryService()
521
- await service.initialize()
522
- return await service.store_memory(content, tags, metadata)
523
-
524
-
525
- async def recall_memories(
526
- query: str,
527
- limit: int = 5,
528
- tags: Optional[List[str]] = None,
529
- ) -> Dict[str, Any]:
530
- """Recall memories relevant to a query."""
531
- service = KuzuMemoryService()
532
- await service.initialize()
533
- return await service.recall_memories(query, limit, tags)
534
-
535
-
536
- async def search_memories(
537
- search_term: str,
538
- search_type: str = "both",
539
- limit: int = 10,
540
- ) -> Dict[str, Any]:
541
- """Search memories by content or tags."""
542
- service = KuzuMemoryService()
543
- await service.initialize()
544
- return await service.search_memories(search_term, search_type, limit)
545
-
546
-
547
- async def get_context(
548
- topic: str,
549
- depth: int = 2,
550
- include_related: bool = True,
551
- ) -> Dict[str, Any]:
552
- """Get enriched context for a topic."""
553
- service = KuzuMemoryService()
554
- await service.initialize()
555
- return await service.get_context(topic, depth, include_related)
@@ -1,14 +0,0 @@
1
- """
2
- MCP Gateway Utilities
3
- ======================
4
-
5
- Utility modules for the MCP Gateway service.
6
- """
7
-
8
- from .package_version_checker import PackageVersionChecker
9
- from .update_preferences import UpdatePreferences
10
-
11
- __all__ = [
12
- "PackageVersionChecker",
13
- "UpdatePreferences",
14
- ]