mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-19 08:33:23 +02:00
* In src/everything/sse.ts and streamableHttp.ts
- Replace console.log with console.error throughout * In src/everything/sse.ts - remove the process.exit() in the server.onclose handler so reconnections are possible
This commit is contained in:
@@ -11,24 +11,23 @@ const { server, cleanup } = createServer();
|
||||
let transport: SSEServerTransport;
|
||||
|
||||
app.get("/sse", async (req, res) => {
|
||||
console.log("Received connection");
|
||||
console.error("Received connection");
|
||||
transport = new SSEServerTransport("/message", res);
|
||||
await server.connect(transport);
|
||||
|
||||
server.onclose = async () => {
|
||||
await cleanup();
|
||||
await server.close();
|
||||
process.exit(0);
|
||||
};
|
||||
});
|
||||
|
||||
app.post("/message", async (req, res) => {
|
||||
console.log("Received message");
|
||||
console.error("Received message");
|
||||
|
||||
await transport.handlePostMessage(req, res);
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 3001;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
console.error(`Server is running on port ${PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user