diff --git a/src/everything/stdio.ts b/src/everything/stdio.ts index e443a983b..102af4f10 100644 --- a/src/everything/stdio.ts +++ b/src/everything/stdio.ts @@ -9,14 +9,18 @@ async function main() { const transport = new StdioServerTransport(); const {server, cleanup, startNotificationIntervals} = createServer(); + // Cleanup when client disconnects + server.onclose = async () => { + await cleanup(); + process.exit(0); + }; + await server.connect(transport); startNotificationIntervals(); // Cleanup on exit process.on("SIGINT", async () => { - await cleanup(); - await server.close(); - process.exit(0); + await server.close(); }); }