// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

import type { IncomingMessage } from 'node:http';

const LOCALHOST_ADDRESSES = new Set(['127.0.0.1', '::1', '::ffff:127.0.0.1']);

/**
 * Requests from localhost get relaxed auth requirements — the same
 * localhost-vs-network binding distinction proven useful in the reference
 * servers (looser auth only when bound to localhost, never over an exposed
 * network interface).
 */
export function isFromLocalhost(request: IncomingMessage): boolean {
  const address = request.socket.remoteAddress;
  return address !== undefined && LOCALHOST_ADDRESSES.has(address);
}
