Skip to main content
Glama
batteryshark

System Information MCP Server

by batteryshark

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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))
  • 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
  • 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))

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/batteryshark/mcp-sysinfo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server