Files
claude-mem/src/servers
michelhelsdingen cd31eaf572 feat: parent heartbeat for MCP server orphan prevention (#992)
* feat: add parent heartbeat to MCP server to prevent orphaned processes

MCP server now monitors its parent process every 30s. When the parent
dies (ppid changes to 1 on Unix), the server self-exits to prevent
orphaned node processes that accumulate over time.

- Checks ppid every 30s after server start
- Compares against initial ppid (handles reparenting)
- Timer uses unref() to not keep process alive artificially
- Unix-only (ppid=1 detection doesn't apply on Windows)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

* fix: make cleanup() synchronous for consistent shutdown behavior

cleanup() only does synchronous work (clearInterval + process.exit),
so remove async to avoid inconsistent behavior when called from
setInterval callback vs signal handler vs awaited context.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Happy <yesreply@happy.engineering>
2026-02-16 00:31:23 -05:00
..