INNER CODE UNIT · JavaScript
portValue
aeonfun/opendia · opendia-mcp/server.js:35
function portValue(name) {
const raw = argValue(name);
if (raw === null) return null;
if (!/^\d+$/.test(raw) || raw < 1 || raw > 65535) {
usageError(`${name}=${raw} is not a valid port (expected an integer 1-65535)`);
}
return Number(raw);
}
// `POST /sse` hands whatever it receives to handleMCPRequest, which drives the
// browser through the extension. Keep that surface on loopback by default; the
// extension reaches it at localhost and `ngrok http` connects from this machine
// too, so neither needs an off-host bind. --http-host= widens it deliberately.
const HTTP_HOST = argValue('--http-host') ?? '127.0.0.1';
function isLoopbackHost(host) {
return host === '127.0.0.1' || host === '::1' || host === 'localhost';
}