Bug Fixes
-
Fix PPID mismatch on WSL2/Linux — MCP redirects restored (#347)
Claude Code spawns hooks via
bash -c "node ...". On WSL2/Linux (dash as/bin/sh), the intermediate shell does NOT exec-optimize, soprocess.ppidin the hook points to a transient bash PID — not Claude Code. The PPID-keyed sentinel file was never found, causing all MCP redirects to be silently bypassed. Context window floods.What changed
hooks/core/mcp-ready.mjs: Replaced PPID-keyed sentinel lookup with directory-scan + PID liveness probe. Scans/tmp/context-mode-mcp-ready-*, probes each PID withkill(pid, 0). Works regardless of spawn topology.src/server.ts: Sentinel now usesprocess.pid(notprocess.ppid) in filename. Hardcoded/tmpon Unix to avoid TMPDIR mismatch.- Stale cleanup: Dead sentinels from crashed servers are automatically deleted during scan.
- 11 test files updated to match new sentinel path pattern.
Platforms affected
- WSL2/Linux: Fixed — dash/sh doesn't exec-optimize, PPID always mismatched
- macOS: Already worked (bash/zsh exec-optimize), now works via scan too
- Windows: Already worked (cmd.exe), now uses
os.tmpdir()for scan
Related
- Closes #347
- Thanks @se7enango for the detailed reproduction and process tree evidence