HTTP Server Auto-Start & Time Parser Improvements
This release introduces a comprehensive HTTP server management system with automatic startup capabilities, proactive health checking in session-start hooks, and fixes the time parser to support "last N periods" expressions.
Key Features
HTTP Server Auto-Start System
- Smart Service Management (
scripts/service/http_server_manager.sh)- 376 lines of robust service management code
- Orphaned process detection and cleanup (handles stale PIDs from crashes/force kills)
- Version mismatch detection (alerts when installed version differs from running version)
- Config change detection (monitors .env file modification timestamps)
- Hybrid storage initialization wait (10-second timeout)
- Health check with retry logic (3 attempts with 2s intervals)
- Commands:
status,start,stop,restart,auto-start,logs - Shell integration support (add to ~/.zshrc for automatic startup)
Session-Start Hook Health Check
- Proactive HTTP Server Monitoring (
~/.claude/hooks/core/session-start.js)- Displays clear warning when HTTP server is unreachable
- Provides actionable fix instructions
- Detects connection errors: ECONNREFUSED, fetch failed, network errors, timeout
- Non-blocking check (warns but doesn't block Claude Code session)
Bug Fixes
Time Parser "Last N Periods" Support
- Fixed Issue #266 - Time expressions not working
- Added regex pattern for "last N days/weeks/months/years"
- Implemented
get_last_n_periods_range(n, period)function - Pattern positioning: Checked BEFORE
last_periodpattern for specificity - Properly handles:
- "last 3 days" → From 3 days ago 00:00:00 to now
- "last 2 weeks" → From 2 weeks ago Monday 00:00:00 to now
- "last 1 month" → From 1 month ago first day 00:00:00 to now
- "last 5 years" → From 5 years ago Jan 1 00:00:00 to now
- Backward compatible with existing "last week", "last month" patterns
Configuration Changes
Hook Configuration Time Windows
- Reverted to "last 3 days" (now works with parser fix)
- Applied to
recentTimeWindowandfallbackTimeWindow - Previously limited to "yesterday" due to parser bug
- Now leverages full 3-day context window for better memory recall
- Applied to
Technical Details
HTTP Server Manager Architecture
- PID tracking via
/tmp/mcp_memory_http.pid(shared location for orphan detection) - Config fingerprinting via MD5 hash of
.envfile - Version extraction from installed package
- Log rotation support (tails last 50 lines)
- SIGTERM graceful shutdown (10s timeout before SIGKILL)
- Auto-start function for shell integration (idempotent, safe for rc files)
Time Parser Improvements
- Regex pattern:
r'last\s+(\d+)\s+(days?|weeks?|months?|years?)' - Handles singular/plural forms (day/days, week/weeks, etc.)
- Week boundaries: Monday 00:00:00 (ISO 8601 standard)
- Month boundaries: First day 00:00:00 (calendar month alignment)
- Fallback behavior: Interprets unknown periods as days
Testing Coverage
- HTTP server manager: status/start/stop/restart/auto-start commands
- Orphaned process cleanup: detection and cleanup of stale PIDs
- Version mismatch: detection when installed vs running version differs
- Config change detection: restart trigger on .env modification
- Time parser: "last 3 days", "last 2 weeks", "last 1 month", "last 5 years"
- Backward compatibility: "last week", "last month" still work
Upgrade Notes
- Drop-in replacement, no configuration changes required
- Recommended: Add HTTP server auto-start to your shell rc file:
# Add to ~/.zshrc or ~/.bashrc eval "$(bash /path/to/scripts/service/http_server_manager.sh auto-start)"
- Time expressions like "last 3 days" now work correctly in memory queries
Files Modified
scripts/service/http_server_manager.sh(NEW) - 376 linessrc/mcp_memory_service/utils/time_parser.py- Added pattern, function, and integration~/.claude/hooks/core/session-start.js- Added health check warning (lines 657-674)~/.claude/hooks/config.json- Reverted to "last 3 days"
See CHANGELOG.md for complete version history.