Skip to main content
Glama
dknell

System Information MCP Server

by dknell

get_network_info_tool

Retrieve network interface details and performance statistics to monitor network status.

Instructions

Retrieve network interface information and statistics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registration of the 'get_network_info_tool' MCP tool via FastMCP @app.tool() decorator. Delegates to get_network_info() in tools.py.
    @app.tool()
    def get_network_info_tool() -> Dict[str, Any]:
        """Retrieve network interface information and statistics."""
        return get_network_info()
  • Core handler that uses psutil to retrieve network interface addresses, statistics (is_up, speed, mtu), and I/O counters (bytes/packets sent/received, errors, drops). Results are cached with a 5-second TTL.
    @cache_result("network_info", ttl=5)
    def get_network_info() -> Dict[str, Any]:
        """Retrieve network interface information and statistics."""
        try:
            interfaces = []
    
            # Get network interfaces
            net_if_addrs = psutil.net_if_addrs()
            net_if_stats = psutil.net_if_stats()
    
            for interface_name, addresses in net_if_addrs.items():
                interface_info: Dict[str, Any] = {
                    "name": interface_name,
                    "addresses": [],
                    "is_up": False,
                    "speed": 0,
                    "mtu": 0,
                }
    
                # Get interface statistics
                if interface_name in net_if_stats:
                    stats = net_if_stats[interface_name]
                    interface_info.update(
                        {"is_up": stats.isup, "speed": stats.speed, "mtu": stats.mtu}
                    )
    
                # Get addresses
                for addr in addresses:
                    addr_info = {"family": str(addr.family), "address": addr.address}
                    if addr.netmask:
                        addr_info["netmask"] = addr.netmask
                    interface_info["addresses"].append(addr_info)
    
                interfaces.append(interface_info)
    
            # Get network I/O statistics
            try:
                net_io = psutil.net_io_counters()
                if net_io:
                    io_stats = {
                        "bytes_sent": net_io.bytes_sent,
                        "bytes_recv": net_io.bytes_recv,
                        "packets_sent": net_io.packets_sent,
                        "packets_recv": net_io.packets_recv,
                        "errin": net_io.errin,
                        "errout": net_io.errout,
                        "dropin": net_io.dropin,
                        "dropout": net_io.dropout,
                    }
                else:
                    io_stats = {
                        "bytes_sent": 0,
                        "bytes_recv": 0,
                        "packets_sent": 0,
                        "packets_recv": 0,
                        "errin": 0,
                        "errout": 0,
                        "dropin": 0,
                        "dropout": 0,
                    }
            except Exception as e:
                logger.warning(f"Could not get network I/O stats: {e}")
                io_stats = {
                    "bytes_sent": 0,
                    "bytes_recv": 0,
                    "packets_sent": 0,
                    "packets_recv": 0,
                    "errin": 0,
                    "errout": 0,
                    "dropin": 0,
                    "dropout": 0,
                }
    
            return {"interfaces": interfaces, "stats": io_stats}
    
        except Exception as e:
            logger.error(f"Error getting network info: {e}")
            raise
  • Caching decorator applied to get_network_info with a 5-second TTL. Caches results by key to avoid redundant psutil calls.
    def cache_result(cache_key: str, ttl: Optional[int] = None) -> Any:
        """Decorator to cache function results with TTL."""
        if ttl is None:
            ttl = config.cache_ttl
    
        def decorator(func: Callable[..., T]) -> Callable[..., T]:
            @wraps(func)
            async def async_wrapper(*args: Any, **kwargs: Any) -> T:
                current_time = time.time()
    
                # Check if we have cached result
                if cache_key in _cache:
                    cache_entry = _cache[cache_key]
                    if current_time - cache_entry["timestamp"] < ttl:
                        logger.debug(f"Cache hit for {cache_key}")
                        return cache_entry["data"]
    
                # Get fresh data
                logger.debug(f"Cache miss for {cache_key}, fetching fresh data")
                if asyncio.iscoroutinefunction(func):
                    result = await func(*args, **kwargs)
                else:
                    result = func(*args, **kwargs)
    
                # Cache the result
                _cache[cache_key] = {"data": result, "timestamp": current_time}
    
                return result
    
            @wraps(func)
            def sync_wrapper(*args: Any, **kwargs: Any) -> T:
                current_time = time.time()
    
                # Check if we have cached result
                if cache_key in _cache:
                    cache_entry = _cache[cache_key]
                    if current_time - cache_entry["timestamp"] < ttl:
                        logger.debug(f"Cache hit for {cache_key}")
                        return cache_entry["data"]
    
                # Get fresh data
                logger.debug(f"Cache miss for {cache_key}, fetching fresh data")
                result = func(*args, **kwargs)
    
                # Cache the result
                _cache[cache_key] = {"data": result, "timestamp": current_time}
    
                return result
    
            # Return appropriate wrapper based on whether function is async
            return async_wrapper if asyncio.iscoroutinefunction(func) else sync_wrapper
    
        return decorator
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided; description carries full burden. It states retrieval without indicating permissions, side effects, or specifics of output. Adequate for a simple read-only tool but could be more detailed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence of 5 words conveys the purpose without waste. Front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with no parameters and an output schema, the description covers the essential purpose. No missing context given the complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has zero parameters, and schema coverage is 100%. Per guidelines, 0 params yields baseline 4. Description adds no parameter info, which is acceptable.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Retrieve network interface information and statistics', specifying the verb (retrieve) and resource (network interface info/statistics). It distinguishes itself from sibling tools that focus on CPU, disk, memory, etc.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use or not use, but usage is implied as a standard info retrieval tool. Sibling tools cover other system resources, so no direct alternative is needed. Lacks exclusions or context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/dknell/mcp-system-info'

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