fix: Configure HTTP server to listen on 0.0.0.0:8080

This commit is contained in:
Barry Yip 2025-05-15 01:41:58 +08:00
parent 7da435c107
commit 0f0b957d54
2 changed files with 5 additions and 5 deletions

View File

@ -48,7 +48,7 @@ const config = {
if (portIndex !== -1 && portIndex + 1 < process.argv.length) {
return parseInt(process.argv[portIndex + 1]);
}
// Default port
// Default port for MCP
return 8080;
})()
};
@ -90,7 +90,7 @@ const autoLogin = async () => {
const initializeTransport = () => {
switch (config.TRANSPORT.toLowerCase()) {
case 'http':
info(`Initializing HTTP transport on port ${config.HTTP_PORT}`);
info(`Initializing HTTP transport on 0.0.0.0:${config.HTTP_PORT}`);
return new StreamableHttpTransport(config.HTTP_PORT);
case 'stdio':
info('Initializing stdio transport');

View File

@ -56,7 +56,7 @@ export class StreamableHttpTransport implements MCPTransport {
private transport: StreamableHTTPServerTransport | null = null;
private toolContext: ReturnType<typeof createToolContext> | null = null;
constructor(private port: number = 3000) {
constructor(private port: number = 8080) {
this.app = express();
this.app.use(express.json());
this.setupEndpoints();
@ -343,8 +343,8 @@ export class StreamableHttpTransport implements MCPTransport {
info('Transport connected');
return new Promise((resolve) => {
this.httpServer = this.app.listen(this.port, () => {
info(`MCP Server listening on port ${this.port}`);
this.httpServer = this.app.listen(this.port, '0.0.0.0', () => {
info(`MCP Server listening on 0.0.0.0:${this.port}`);
resolve();
});
});