claude-mpm 3.9.7__py3-none-any.whl → 3.9.9__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.
Files changed (54) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/base_agent.json +1 -1
  3. claude_mpm/agents/templates/ticketing.json +1 -1
  4. claude_mpm/cli/__init__.py +3 -1
  5. claude_mpm/cli/commands/__init__.py +3 -1
  6. claude_mpm/cli/commands/cleanup.py +21 -1
  7. claude_mpm/cli/commands/mcp.py +821 -0
  8. claude_mpm/cli/parser.py +148 -1
  9. claude_mpm/config/memory_guardian_config.py +325 -0
  10. claude_mpm/constants.py +13 -0
  11. claude_mpm/hooks/claude_hooks/hook_handler.py +76 -19
  12. claude_mpm/models/state_models.py +433 -0
  13. claude_mpm/services/__init__.py +28 -0
  14. claude_mpm/services/communication/__init__.py +2 -2
  15. claude_mpm/services/communication/socketio.py +18 -16
  16. claude_mpm/services/infrastructure/__init__.py +4 -1
  17. claude_mpm/services/infrastructure/logging.py +3 -3
  18. claude_mpm/services/infrastructure/memory_guardian.py +770 -0
  19. claude_mpm/services/mcp_gateway/__init__.py +138 -0
  20. claude_mpm/services/mcp_gateway/config/__init__.py +17 -0
  21. claude_mpm/services/mcp_gateway/config/config_loader.py +232 -0
  22. claude_mpm/services/mcp_gateway/config/config_schema.py +234 -0
  23. claude_mpm/services/mcp_gateway/config/configuration.py +371 -0
  24. claude_mpm/services/mcp_gateway/core/__init__.py +51 -0
  25. claude_mpm/services/mcp_gateway/core/base.py +315 -0
  26. claude_mpm/services/mcp_gateway/core/exceptions.py +239 -0
  27. claude_mpm/services/mcp_gateway/core/interfaces.py +476 -0
  28. claude_mpm/services/mcp_gateway/main.py +326 -0
  29. claude_mpm/services/mcp_gateway/registry/__init__.py +12 -0
  30. claude_mpm/services/mcp_gateway/registry/service_registry.py +397 -0
  31. claude_mpm/services/mcp_gateway/registry/tool_registry.py +477 -0
  32. claude_mpm/services/mcp_gateway/server/__init__.py +15 -0
  33. claude_mpm/services/mcp_gateway/server/mcp_server.py +430 -0
  34. claude_mpm/services/mcp_gateway/server/mcp_server_simple.py +444 -0
  35. claude_mpm/services/mcp_gateway/server/stdio_handler.py +373 -0
  36. claude_mpm/services/mcp_gateway/tools/__init__.py +22 -0
  37. claude_mpm/services/mcp_gateway/tools/base_adapter.py +497 -0
  38. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +729 -0
  39. claude_mpm/services/mcp_gateway/tools/hello_world.py +551 -0
  40. claude_mpm/utils/file_utils.py +293 -0
  41. claude_mpm/utils/platform_memory.py +524 -0
  42. claude_mpm/utils/subprocess_utils.py +305 -0
  43. {claude_mpm-3.9.7.dist-info → claude_mpm-3.9.9.dist-info}/METADATA +4 -1
  44. {claude_mpm-3.9.7.dist-info → claude_mpm-3.9.9.dist-info}/RECORD +49 -26
  45. claude_mpm/agents/templates/.claude-mpm/memories/README.md +0 -36
  46. claude_mpm/agents/templates/.claude-mpm/memories/engineer_agent.md +0 -39
  47. claude_mpm/agents/templates/.claude-mpm/memories/qa_agent.md +0 -38
  48. claude_mpm/agents/templates/.claude-mpm/memories/research_agent.md +0 -39
  49. claude_mpm/agents/templates/.claude-mpm/memories/version_control_agent.md +0 -38
  50. /claude_mpm/agents/templates/{research_memory_efficient.json → backup/research_memory_efficient.json} +0 -0
  51. {claude_mpm-3.9.7.dist-info → claude_mpm-3.9.9.dist-info}/WHEEL +0 -0
  52. {claude_mpm-3.9.7.dist-info → claude_mpm-3.9.9.dist-info}/entry_points.txt +0 -0
  53. {claude_mpm-3.9.7.dist-info → claude_mpm-3.9.9.dist-info}/licenses/LICENSE +0 -0
  54. {claude_mpm-3.9.7.dist-info → claude_mpm-3.9.9.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,476 @@
1
+ """
2
+ MCP Gateway Interface Definitions
3
+ ==================================
4
+
5
+ This module defines the core interfaces for the MCP Gateway service,
6
+ establishing contracts for dependency injection and service orchestration.
7
+
8
+ Part of ISS-0034: Infrastructure Setup - MCP Gateway Project Foundation
9
+ """
10
+
11
+ from abc import ABC, abstractmethod
12
+ from typing import Any, Dict, List, Optional, Callable, Union
13
+ from dataclasses import dataclass
14
+ from datetime import datetime
15
+ from pathlib import Path
16
+ import asyncio
17
+
18
+
19
+ # Tool-related data structures
20
+ @dataclass
21
+ class MCPToolDefinition:
22
+ """Definition of an MCP tool."""
23
+ name: str
24
+ description: str
25
+ input_schema: Dict[str, Any]
26
+ output_schema: Optional[Dict[str, Any]] = None
27
+ version: str = "1.0.0"
28
+ metadata: Optional[Dict[str, Any]] = None
29
+
30
+
31
+ @dataclass
32
+ class MCPToolInvocation:
33
+ """Represents a tool invocation request."""
34
+ tool_name: str
35
+ parameters: Dict[str, Any]
36
+ context: Optional[Dict[str, Any]] = None
37
+ timeout: Optional[float] = None
38
+ request_id: Optional[str] = None
39
+
40
+
41
+ @dataclass
42
+ class MCPToolResult:
43
+ """Result from a tool invocation."""
44
+ success: bool
45
+ data: Optional[Any] = None
46
+ error: Optional[str] = None
47
+ metadata: Optional[Dict[str, Any]] = None
48
+ execution_time: Optional[float] = None
49
+
50
+
51
+ # Core MCP interfaces
52
+ class IMCPConfiguration(ABC):
53
+ """
54
+ Interface for MCP configuration management.
55
+
56
+ Handles loading, validation, and access to MCP Gateway configuration.
57
+ """
58
+
59
+ @abstractmethod
60
+ def load_config(self, config_path: Path) -> bool:
61
+ """
62
+ Load configuration from a file.
63
+
64
+ Args:
65
+ config_path: Path to configuration file
66
+
67
+ Returns:
68
+ True if configuration loaded successfully
69
+ """
70
+ pass
71
+
72
+ @abstractmethod
73
+ def get(self, key: str, default: Any = None) -> Any:
74
+ """
75
+ Get configuration value by key.
76
+
77
+ Args:
78
+ key: Configuration key (supports dot notation)
79
+ default: Default value if key not found
80
+
81
+ Returns:
82
+ Configuration value or default
83
+ """
84
+ pass
85
+
86
+ @abstractmethod
87
+ def set(self, key: str, value: Any) -> None:
88
+ """
89
+ Set configuration value.
90
+
91
+ Args:
92
+ key: Configuration key (supports dot notation)
93
+ value: Configuration value
94
+ """
95
+ pass
96
+
97
+ @abstractmethod
98
+ def validate(self) -> bool:
99
+ """
100
+ Validate the current configuration.
101
+
102
+ Returns:
103
+ True if configuration is valid
104
+ """
105
+ pass
106
+
107
+ @abstractmethod
108
+ def get_server_config(self) -> Dict[str, Any]:
109
+ """
110
+ Get MCP server configuration.
111
+
112
+ Returns:
113
+ Server configuration dictionary
114
+ """
115
+ pass
116
+
117
+ @abstractmethod
118
+ def get_tools_config(self) -> Dict[str, Any]:
119
+ """
120
+ Get tools configuration.
121
+
122
+ Returns:
123
+ Tools configuration dictionary
124
+ """
125
+ pass
126
+
127
+
128
+ class IMCPToolAdapter(ABC):
129
+ """
130
+ Interface for MCP tool adapters.
131
+
132
+ Tool adapters wrap external tools to make them MCP-compatible.
133
+ """
134
+
135
+ @abstractmethod
136
+ def get_definition(self) -> MCPToolDefinition:
137
+ """
138
+ Get the tool definition.
139
+
140
+ Returns:
141
+ Tool definition with schema and metadata
142
+ """
143
+ pass
144
+
145
+ @abstractmethod
146
+ async def invoke(self, invocation: MCPToolInvocation) -> MCPToolResult:
147
+ """
148
+ Invoke the tool with given parameters.
149
+
150
+ Args:
151
+ invocation: Tool invocation request
152
+
153
+ Returns:
154
+ Tool execution result
155
+ """
156
+ pass
157
+
158
+ @abstractmethod
159
+ def validate_parameters(self, parameters: Dict[str, Any]) -> bool:
160
+ """
161
+ Validate tool parameters against schema.
162
+
163
+ Args:
164
+ parameters: Parameters to validate
165
+
166
+ Returns:
167
+ True if parameters are valid
168
+ """
169
+ pass
170
+
171
+ @abstractmethod
172
+ async def initialize(self) -> bool:
173
+ """
174
+ Initialize the tool adapter.
175
+
176
+ Returns:
177
+ True if initialization successful
178
+ """
179
+ pass
180
+
181
+ @abstractmethod
182
+ async def shutdown(self) -> None:
183
+ """
184
+ Shutdown the tool adapter and clean up resources.
185
+ """
186
+ pass
187
+
188
+
189
+ class IMCPToolRegistry(ABC):
190
+ """
191
+ Interface for MCP tool registry.
192
+
193
+ Manages registration, discovery, and invocation of MCP tools.
194
+ """
195
+
196
+ @abstractmethod
197
+ def register_tool(self, adapter: IMCPToolAdapter) -> bool:
198
+ """
199
+ Register a tool adapter.
200
+
201
+ Args:
202
+ adapter: Tool adapter to register
203
+
204
+ Returns:
205
+ True if registration successful
206
+ """
207
+ pass
208
+
209
+ @abstractmethod
210
+ def unregister_tool(self, tool_name: str) -> bool:
211
+ """
212
+ Unregister a tool by name.
213
+
214
+ Args:
215
+ tool_name: Name of tool to unregister
216
+
217
+ Returns:
218
+ True if unregistration successful
219
+ """
220
+ pass
221
+
222
+ @abstractmethod
223
+ def get_tool(self, tool_name: str) -> Optional[IMCPToolAdapter]:
224
+ """
225
+ Get a tool adapter by name.
226
+
227
+ Args:
228
+ tool_name: Name of the tool
229
+
230
+ Returns:
231
+ Tool adapter if found, None otherwise
232
+ """
233
+ pass
234
+
235
+ @abstractmethod
236
+ def list_tools(self) -> List[MCPToolDefinition]:
237
+ """
238
+ List all registered tools.
239
+
240
+ Returns:
241
+ List of tool definitions
242
+ """
243
+ pass
244
+
245
+ @abstractmethod
246
+ async def invoke_tool(self, invocation: MCPToolInvocation) -> MCPToolResult:
247
+ """
248
+ Invoke a tool through the registry.
249
+
250
+ Args:
251
+ invocation: Tool invocation request
252
+
253
+ Returns:
254
+ Tool execution result
255
+ """
256
+ pass
257
+
258
+ @abstractmethod
259
+ def search_tools(self, query: str) -> List[MCPToolDefinition]:
260
+ """
261
+ Search for tools by query.
262
+
263
+ Args:
264
+ query: Search query
265
+
266
+ Returns:
267
+ List of matching tool definitions
268
+ """
269
+ pass
270
+
271
+
272
+ class IMCPCommunication(ABC):
273
+ """
274
+ Interface for MCP communication handling.
275
+
276
+ Manages stdio-based communication with MCP clients.
277
+ """
278
+
279
+ @abstractmethod
280
+ async def send_message(self, message: Dict[str, Any]) -> None:
281
+ """
282
+ Send a message to the MCP client.
283
+
284
+ Args:
285
+ message: Message to send
286
+ """
287
+ pass
288
+
289
+ @abstractmethod
290
+ async def receive_message(self) -> Optional[Dict[str, Any]]:
291
+ """
292
+ Receive a message from the MCP client.
293
+
294
+ Returns:
295
+ Received message or None if no message available
296
+ """
297
+ pass
298
+
299
+ @abstractmethod
300
+ async def send_response(self, request_id: str, result: Any) -> None:
301
+ """
302
+ Send a response to a request.
303
+
304
+ Args:
305
+ request_id: ID of the request being responded to
306
+ result: Result data
307
+ """
308
+ pass
309
+
310
+ @abstractmethod
311
+ async def send_error(self, request_id: str, error: str, code: int = -1) -> None:
312
+ """
313
+ Send an error response.
314
+
315
+ Args:
316
+ request_id: ID of the request that caused the error
317
+ error: Error message
318
+ code: Error code
319
+ """
320
+ pass
321
+
322
+ @abstractmethod
323
+ def is_connected(self) -> bool:
324
+ """
325
+ Check if communication channel is connected.
326
+
327
+ Returns:
328
+ True if connected
329
+ """
330
+ pass
331
+
332
+
333
+ class IMCPLifecycle(ABC):
334
+ """
335
+ Interface for MCP service lifecycle management.
336
+
337
+ Manages initialization, startup, shutdown, and health monitoring.
338
+ """
339
+
340
+ @abstractmethod
341
+ async def initialize(self) -> bool:
342
+ """
343
+ Initialize the MCP service.
344
+
345
+ Returns:
346
+ True if initialization successful
347
+ """
348
+ pass
349
+
350
+ @abstractmethod
351
+ async def start(self) -> bool:
352
+ """
353
+ Start the MCP service.
354
+
355
+ Returns:
356
+ True if startup successful
357
+ """
358
+ pass
359
+
360
+ @abstractmethod
361
+ async def stop(self) -> None:
362
+ """
363
+ Stop the MCP service gracefully.
364
+ """
365
+ pass
366
+
367
+ @abstractmethod
368
+ async def restart(self) -> bool:
369
+ """
370
+ Restart the MCP service.
371
+
372
+ Returns:
373
+ True if restart successful
374
+ """
375
+ pass
376
+
377
+ @abstractmethod
378
+ def get_state(self) -> str:
379
+ """
380
+ Get current service state.
381
+
382
+ Returns:
383
+ Service state (e.g., "initialized", "running", "stopped")
384
+ """
385
+ pass
386
+
387
+ @abstractmethod
388
+ def is_healthy(self) -> bool:
389
+ """
390
+ Check if service is healthy.
391
+
392
+ Returns:
393
+ True if service is healthy
394
+ """
395
+ pass
396
+
397
+ @abstractmethod
398
+ def get_health_status(self) -> Dict[str, Any]:
399
+ """
400
+ Get detailed health status.
401
+
402
+ Returns:
403
+ Health status information
404
+ """
405
+ pass
406
+
407
+
408
+ class IMCPServer(IMCPLifecycle):
409
+ """
410
+ Main interface for MCP server implementation.
411
+
412
+ Orchestrates tool registry, communication, and request handling.
413
+ """
414
+
415
+ @abstractmethod
416
+ def set_tool_registry(self, registry: IMCPToolRegistry) -> None:
417
+ """
418
+ Set the tool registry for the server.
419
+
420
+ Args:
421
+ registry: Tool registry to use
422
+ """
423
+ pass
424
+
425
+ @abstractmethod
426
+ def set_communication(self, communication: IMCPCommunication) -> None:
427
+ """
428
+ Set the communication handler.
429
+
430
+ Args:
431
+ communication: Communication handler to use
432
+ """
433
+ pass
434
+
435
+ @abstractmethod
436
+ async def handle_request(self, request: Dict[str, Any]) -> Dict[str, Any]:
437
+ """
438
+ Handle an MCP request.
439
+
440
+ Args:
441
+ request: MCP request message
442
+
443
+ Returns:
444
+ Response message
445
+ """
446
+ pass
447
+
448
+ @abstractmethod
449
+ async def run(self) -> None:
450
+ """
451
+ Run the MCP server main loop.
452
+
453
+ This method should handle incoming requests and manage the server lifecycle.
454
+ """
455
+ pass
456
+
457
+ @abstractmethod
458
+ def register_handler(self, method: str, handler: Callable) -> None:
459
+ """
460
+ Register a custom request handler.
461
+
462
+ Args:
463
+ method: Method name to handle
464
+ handler: Handler function
465
+ """
466
+ pass
467
+
468
+ @abstractmethod
469
+ def get_capabilities(self) -> Dict[str, Any]:
470
+ """
471
+ Get server capabilities.
472
+
473
+ Returns:
474
+ Dictionary of server capabilities
475
+ """
476
+ pass