Fix a lifecycle bug with server everything in stdio mode (#2848)

This commit is contained in:
Nick Pape
2025-11-25 15:50:31 -06:00
committed by GitHub
parent 8e0c890337
commit 76dcff0617

View File

@@ -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();
});
}