forked from modelcontextprotocol/servers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdio.ts
More file actions
31 lines (23 loc) · 747 Bytes
/
stdio.ts
File metadata and controls
31 lines (23 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { createServer } from "./everything.js";
console.error('Starting default (STDIO) server...');
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 server.close();
});
}
main().catch((error) => {
console.error("Server error:", error);
process.exit(1);
});