get_network_status
Retrieve network configuration, connectivity status, and diagnostics including interfaces, IP addresses, DNS settings, and VPN detection for troubleshooting and security analysis.
Instructions
Get network configuration and connectivity - interfaces, IPs, DNS, VPN status.
Complete network diagnostics including external connectivity and VPN detection. Essential for troubleshooting network issues and security analysis.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_network_status"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/sysinfo/server.py:95-111 (handler)The primary handler function for the 'get_network_status' tool. Decorated with @mcp.tool for automatic registration in the FastMCP server. It invokes get_network_info() from collectors, formats the output, and returns a ToolResult with text content.
@mcp.tool def get_network_status() -> ToolResult: """Get network configuration and connectivity - interfaces, IPs, DNS, VPN status. Complete network diagnostics including external connectivity and VPN detection. Essential for troubleshooting network issues and security analysis. """ info_sections = [] info_sections.append("# Network Status") info_sections.append(f"*Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n") try: info_sections.extend(get_network_info()) except Exception as e: info_sections.append(f"⚠️ **Network detection error**: {str(e)}") return text_response("\n".join(info_sections)) - src/sysinfo/collectors.py:442-487 (helper)The core helper function get_network_info() that implements the network status logic: enumerates network interfaces with psutil.net_if_addrs(), retrieves gateway/DNS info platform-specifically, fetches external IP via AWS checkip, detects VPN via interface names, and compiles markdown-formatted info list.
def get_network_info() -> List[str]: """Get network interface and connectivity information""" info = [] info.append("\n## 🌐 Network") # Network interfaces net_interfaces = psutil.net_if_addrs() net_stats = psutil.net_if_stats() for interface, addresses in net_interfaces.items(): if interface.startswith('lo') or interface.startswith('utun'): continue # Skip loopback and tunnels for main display stats = net_stats.get(interface) if stats and stats.isup: info.append(f"\n### {interface}") info.append(f"- **Status**: {'Up' if stats.isup else 'Down'}") for addr in addresses: if addr.family.name == 'AF_INET': # IPv4 info.append(f"- **IPv4**: {addr.address}") if addr.netmask: info.append(f" - **Netmask**: {addr.netmask}") elif addr.family.name == 'AF_INET6': # IPv6 if not addr.address.startswith('fe80'): # Skip link-local info.append(f"- **IPv6**: {addr.address}") # Gateway and DNS gateway = _get_default_gateway() if gateway: info.append(f"\n- **Default Gateway**: {gateway}") dns_servers = _get_dns_servers() if dns_servers: info.append(f"- **DNS Servers**: {', '.join(dns_servers[:3])}") # External IP external_ip = _get_external_ip() info.append(f"- **External IP**: {external_ip}") # VPN Detection vpn_status = _detect_vpn(net_interfaces, net_stats) info.append(f"- **VPN Status**: {vpn_status}") return info - src/sysinfo/server.py:95-111 (registration)The @mcp.tool decorator on get_network_status() handles tool registration in the FastMCP instance created earlier in the file.
@mcp.tool def get_network_status() -> ToolResult: """Get network configuration and connectivity - interfaces, IPs, DNS, VPN status. Complete network diagnostics including external connectivity and VPN detection. Essential for troubleshooting network issues and security analysis. """ info_sections = [] info_sections.append("# Network Status") info_sections.append(f"*Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n") try: info_sections.extend(get_network_info()) except Exception as e: info_sections.append(f"⚠️ **Network detection error**: {str(e)}") return text_response("\n".join(info_sections))