fix(mcp-server): add graceful shutdown to prevent zombie processes (#477)

* fix(mcp-server): add graceful shutdown to prevent zombie processes

Add lifecycle handlers to properly exit the MCP server when the parent
application closes:

- Listen for stdin close/end events (primary method for all platforms)
- Handle SIGINT/SIGTERM signals
- Handle stdout broken pipe errors
- Export shutdown() function from http-server to clean up resources

* chore(mcp-server): bump version to 0.1.11
This commit is contained in:
Dayuan Jiang
2025-12-31 18:38:20 +09:00
committed by GitHub
parent 03ac9a79de
commit 7bdc1fe612
3 changed files with 33 additions and 2 deletions

View File

@@ -127,7 +127,12 @@ function cleanupExpiredSessions(): void {
}
}
setInterval(cleanupExpiredSessions, 5 * 60 * 1000)
const cleanupIntervalId = setInterval(cleanupExpiredSessions, 5 * 60 * 1000)
export function shutdown(): void {
clearInterval(cleanupIntervalId)
stopHttpServer()
}
export function getServerPort(): number {
return serverPort