improved structure and implementation
This commit is contained in:
12 files changed
+300
-154
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
|
||||
export function registerSigIntHandler(transports: Map<string, StdioServerTransport | StreamableHTTPServerTransport>) {
|
||||
process.on('SIGINT', async () => {
|
||||
for (const sessionID of transports.keys()) {
|
||||
await transports.get(sessionID)?.close();
|
||||
transports.delete(sessionID);
|
||||
}
|
||||
|
||||
console.error('Server shut down.');
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user