We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ahao0150/debug-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
port-manager.ts•1.56 kB
/**
* Port Manager - Singleton for managing HTTP server port information
*
* This module manages the dynamically assigned port for the HTTP server.
* The port is automatically assigned by the system when using port 0,
* and this manager stores and provides access to the actual port number.
*/
class PortManager {
private port: number | null = null;
private host: string = 'localhost';
/**
* Set the port number
*/
setPort(port: number): void {
this.port = port;
}
/**
* Get the current port number
* @returns The port number or null if not set
*/
getPort(): number | null {
return this.port;
}
/**
* Set the host address
*/
setHost(host: string): void {
this.host = host;
}
/**
* Get the current host address
*/
getHost(): string {
return this.host;
}
/**
* Get the complete server URL
* @returns The server URL or default URL if port is not set
*/
getServerUrl(): string {
if (this.port === null) {
// Fallback to default if port not set yet
return `http://${this.host}:3000/api/log`;
}
return `http://${this.host}:${this.port}/api/log`;
}
/**
* Get the base server URL (without /api/log)
*/
getBaseUrl(): string {
if (this.port === null) {
return `http://${this.host}:3000`;
}
return `http://${this.host}:${this.port}`;
}
/**
* Check if port is set
*/
isPortSet(): boolean {
return this.port !== null;
}
}
// Export singleton instance
export const portManager = new PortManager();