Merge pull request #371 from formulahendry/junhan/http-doc

docs: add error handling when it fails to start HTTP server
This commit is contained in:
Inna Harper 2025-06-30 15:28:21 +01:00 • committed by GitHub
commit 5e20ee1fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -590,8 +590,17 @@ app.delete('/mcp', async (req: Request, res: Response) => {
// Start the server
const PORT = 3000;
app.listen(PORT, () => {
console.log(`MCP Stateless Streamable HTTP Server listening on port ${PORT}`);
setupServer().then(() => {
app.listen(PORT, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`MCP Stateless Streamable HTTP Server listening on port ${PORT}`);
});
}).catch(error => {
console.error('Failed to set up the server:', error);
process.exit(1);
});
```