-
-
Notifications
You must be signed in to change notification settings - Fork 108
Issue Templates
The awareness hooks installer (claude-hooks/install_hooks.py
) currently violates the DRY principle by maintaining a separate MCP server configuration instead of leveraging the existing Claude Code MCP setup. This creates several issues:
-
Configuration Duplication: Hooks maintain separate
serverCommand
config in~/.claude/hooks/config.json
while Claude Code already has the memory server configured viaclaude mcp add memory
-
No MCP Awareness: The installer doesn't detect or validate existing Claude Code MCP configurations, leading to:
- Duplicate server processes
- Configuration drift between Claude Code and hooks
- Inconsistent backend configurations (Cloudflare vs SQLite vs ChromaDB)
-
Complex Maintenance: Updates require changing multiple configuration files instead of maintaining a single source of truth
-
Poor User Experience: Users must manually ensure hooks configuration matches their Claude Code MCP setup
Claude Code MCP Configuration:
$ claude mcp get memory
memory:
Scope: Local config (private to you in this project)
Status: ✓ Connected
Type: stdio
Command: uv run python -m mcp_memory_service.server
Environment: [Cloudflare backend configuration]
Hooks Configuration (Separate):
{
"memoryService": {
"mcp": {
"serverCommand": ["uv", "run", "python", "-m", "mcp_memory_service.server"],
"serverWorkingDir": "C:\\REPOSITORIES\\mcp-memory-service"
}
}
}
This results in two separate memory service processes with potentially different backend configurations.
Enhance install_hooks.py
to detect existing Claude Code MCP configurations:
def detect_claude_mcp_configuration(self) -> Optional[Dict]:
"""Detect existing Claude Code MCP memory server configuration."""
try:
# Parse `claude mcp get memory` output
result = subprocess.run(['claude', 'mcp', 'get', 'memory'],
capture_output=True, text=True)
if result.returncode == 0:
return self.parse_mcp_output(result.stdout)
except Exception:
pass
return None
def validate_mcp_prerequisites(self) -> Tuple[bool, List[str]]:
"""Validate that MCP memory service is properly configured."""
issues = []
# Check if memory server exists in Claude Code
# Verify server responds to health checks
# Validate backend configuration consistency
return len(issues) == 0, issues
Generate hooks configuration based on detected MCP setup:
def generate_hooks_config(self, detected_mcp: Optional[Dict]) -> Dict:
"""Generate hooks config based on detected MCP setup."""
if detected_mcp:
# Use existing MCP server reference (DRY approach)
return {
"memoryService": {
"protocol": "mcp",
"preferredProtocol": "mcp",
"mcp": {
"useExistingServer": True,
"serverName": "memory", # Reference existing Claude Code server
"fallbackToHttp": True
}
}
}
else:
# Fallback to independent setup
return self.generate_legacy_config()
Update utilities/memory-client.js
to support existing server connections:
class MemoryClient {
async connectToExistingMCP(serverName) {
// Connect to existing Claude Code MCP server
// Avoid spawning duplicate processes
// Use shared connection mechanism
}
}
🔍 Detecting existing MCP configuration...
✅ Found memory server: uv run python -m mcp_memory_service.server
✅ Backend: Cloudflare (healthy)
✅ Connection: Local stdio
📋 Installation Options:
[1] Use existing MCP setup (recommended) - DRY principle ✨
[2] Create independent hooks setup - legacy fallback
Choose option [1]:
- DRY Principle: Single source of truth for MCP configuration
- Reduced Complexity: No duplicate server processes
- Better Performance: Single memory service instance
- Easier Maintenance: Updates only require changing Claude Code MCP config
- Better UX: Automatic detection and configuration
- Fewer Bugs: Eliminates configuration drift issues
- Fresh installation with no existing MCP
- Installation with existing Cloudflare backend
- Installation with existing SQLite backend
- Installation with existing ChromaDB backend
- Configuration migration from legacy setup
- Fallback when MCP detection fails
- Support existing hooks configurations
- Provide migration path from
serverCommand
toserverName
approach - Graceful fallback when detection fails
The installer should validate:
- Claude Code CLI availability (
claude --help
) - Memory server existence (
claude mcp get memory
) - Server health and backend configuration
- Environment consistency
- Update README.md with MCP prerequisites section
- Create wiki page: "MCP Configuration Best Practices"
- Add troubleshooting guide for configuration conflicts
enhancement
architecture
DRY-principle
configuration
claude-code-integration
High - This affects user experience, system architecture, and maintenance overhead.