From 136509d5423aa3ef1018428d132512a6ccb90b6e Mon Sep 17 00:00:00 2001 From: Issue Hunter Date: Sun, 12 Apr 2026 14:54:07 +0000 Subject: [PATCH] fix: Error: listen EADDRINUSE: address already in use :::8080 --- scripts/start-server.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/start-server.ts b/scripts/start-server.ts index ad3292c..5a64718 100644 --- a/scripts/start-server.ts +++ b/scripts/start-server.ts @@ -83,12 +83,16 @@ export async function startServer(args: string[] = process.argv.slice(2)) { app.get('/mcp', handleSessionRequest); app.delete('/mcp', handleSessionRequest); - const PORT = 8080 - - app.listen(PORT, () => { - console.error(`MCP Web Server running at http://localhost:${PORT}`); - console.error(`- Health Check: http://localhost:${PORT}/health`); - console.error(`- MCP Endpoint: http://localhost:${PORT}/mcp`); + const PORT = parseInt(process.env.PORT ?? '8080', 10) + + await new Promise((resolve, reject) => { + const server = app.listen(PORT, () => { + console.error(`MCP Web Server running at http://localhost:${PORT}`); + console.error(`- Health Check: http://localhost:${PORT}/health`); + console.error(`- MCP Endpoint: http://localhost:${PORT}/mcp`); + resolve(); + }); + server.on('error', reject); }); return proxy.getServer()