Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions mcpgateway/federation/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import asyncio
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
import ipaddress
import os
import socket
from typing import Dict, List, Optional
Expand Down Expand Up @@ -219,8 +220,10 @@ def _get_local_addresses(self) -> List[str]:
# Get all network interfaces
for iface in socket.getaddrinfo(socket.gethostname(), None):
addr = iface[4][0]
# Skip localhost
if not addr.startswith("127."):
ip_obj = ipaddress.ip_address(addr)
is_ipv4 = isinstance(ip_obj, ipaddress.IPv4Address)
# Skip localhost and non ipv4 addresses
if is_ipv4 and not addr.startswith("127."):
addresses.append(addr)
except Exception as e:
logger.warning(f"Failed to get local addresses: {e}")
Expand Down
Loading