mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-02-19 11:54:58 -05:00
Fix a lifecycle bug with server everything in stdio mode (#2848)
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user