Skip to content

Commit 5e20ee1

Browse files
authored
Merge pull request #371 from formulahendry/junhan/http-doc
docs: add error handling when it fails to start HTTP server
2 parents 0a1cfd9 + a02704c commit 5e20ee1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,17 @@ app.delete('/mcp', async (req: Request, res: Response) => {
590590
591591
// Start the server
592592
const PORT = 3000;
593-
app.listen(PORT, () => {
594-
console.log(`MCP Stateless Streamable HTTP Server listening on port ${PORT}`);
593+
setupServer().then(() => {
594+
app.listen(PORT, (error) => {
595+
if (error) {
596+
console.error('Failed to start server:', error);
597+
process.exit(1);
598+
}
599+
console.log(`MCP Stateless Streamable HTTP Server listening on port ${PORT}`);
600+
});
601+
}).catch(error => {
602+
console.error('Failed to set up the server:', error);
603+
process.exit(1);
595604
});
596605
597606
```

0 commit comments

Comments
 (0)