Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ async function runServer(port: number | null) {
await transport.handlePostMessage(req, res);
});

app.listen(port, () => {
app.listen(port, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`Server running on http://localhost:${port}/sse`);
});
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/examples/server/demoInMemoryOAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ export const setupAuthServer = ({authServerUrl, mcpServerUrl, strictResource}: {

const auth_port = authServerUrl.port;
// Start the auth server
authApp.listen(auth_port, () => {
authApp.listen(auth_port, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`OAuth Authorization Server listening on port ${auth_port}`);
});

Expand Down
6 changes: 5 additions & 1 deletion src/examples/server/jsonResponseStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ app.get('/mcp', async (req: Request, res: Response) => {

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
app.listen(PORT, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`MCP Streamable HTTP Server listening on port ${PORT}`);
});

Expand Down
6 changes: 5 additions & 1 deletion src/examples/server/simpleSseServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ app.post('/messages', async (req: Request, res: Response) => {

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
app.listen(PORT, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`Simple SSE Server (deprecated protocol version 2024-11-05) listening on port ${PORT}`);
});

Expand Down
6 changes: 5 additions & 1 deletion src/examples/server/simpleStatelessStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ app.delete('/mcp', async (req: Request, res: Response) => {

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
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}`);
});

Expand Down
6 changes: 5 additions & 1 deletion src/examples/server/simpleStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,11 @@ if (useOAuth && authMiddleware) {
app.delete('/mcp', mcpDeleteHandler);
}

app.listen(MCP_PORT, () => {
app.listen(MCP_PORT, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`MCP Streamable HTTP Server listening on port ${MCP_PORT}`);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ app.post("/messages", async (req: Request, res: Response) => {

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
app.listen(PORT, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`Backwards compatible MCP server listening on port ${PORT}`);
console.log(`
==============================================
Expand Down
6 changes: 5 additions & 1 deletion src/examples/server/standaloneSseWithGetStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ app.get('/mcp', async (req: Request, res: Response) => {

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
app.listen(PORT, (error) => {
if (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
console.log(`Server listening on port ${PORT}`);
});

Expand Down