Skip to main content
Glama
dknell

System Information MCP Server

by dknell

get_cpu_info_tool

Retrieve CPU usage metrics and hardware information from the System Information MCP Server to monitor system performance and resource utilization.

Instructions

Retrieve CPU usage and information.

Args: interval: Measurement interval in seconds (default: 1.0) per_cpu: Include per-CPU core breakdown (default: false)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
intervalNo
per_cpuNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function for the get_cpu_info_tool, registered via @app.tool() decorator. Delegates execution to the get_cpu_info helper function with provided parameters.
    @app.tool()
    def get_cpu_info_tool(interval: float = 1.0, per_cpu: bool = False) -> Dict[str, Any]:
        """Retrieve CPU usage and information.
    
        Args:
            interval: Measurement interval in seconds (default: 1.0)
            per_cpu: Include per-CPU core breakdown (default: false)
        """
        return get_cpu_info(interval=interval, per_cpu=per_cpu)
  • Registration of the get_cpu_info_tool via FastMCP @app.tool() decorator.
    @app.tool()
  • Core helper function implementing the CPU information retrieval logic using psutil library. Includes parameter validation, CPU stats collection, frequency, load average, and optional per-CPU breakdown. Cached with 2-second TTL.
    @cache_result("cpu_info", ttl=2)
    def get_cpu_info(interval: float = 1.0, per_cpu: bool = False) -> Dict[str, Any]:
        """Retrieve CPU usage and information."""
        try:
            # Validate parameters
            if interval <= 0:
                raise ValueError("Interval must be a positive number")
    
            # Get CPU percentage (this call blocks for the interval)
            cpu_percent = psutil.cpu_percent(interval=interval)
    
            # Get per-CPU percentages if requested
            per_cpu_percent = None
            if per_cpu:
                per_cpu_percent = psutil.cpu_percent(interval=0, percpu=True)
    
            # Get CPU counts
            cpu_count_logical = psutil.cpu_count(logical=True) or 0
            cpu_count_physical = psutil.cpu_count(logical=False) or 0
    
            # Get CPU frequency
            try:
                cpu_freq = psutil.cpu_freq()
                cpu_freq_current = safe_float(cpu_freq.current if cpu_freq else 0)
                cpu_freq_max = safe_float(cpu_freq.max if cpu_freq else 0)
            except (AttributeError, OSError):
                cpu_freq_current = 0.0
                cpu_freq_max = 0.0
    
            # Get load average (Unix-like systems only)
            try:
                if hasattr(os, 'getloadavg'):
                    load_avg = os.getloadavg()
                    load_average = [round(avg, 2) for avg in load_avg]
                else:
                    load_average = [0.0, 0.0, 0.0]
            except (AttributeError, OSError):
                load_average = [0.0, 0.0, 0.0]
    
            result = {
                "cpu_percent": round(cpu_percent, 1),
                "cpu_count_logical": cpu_count_logical,
                "cpu_count_physical": cpu_count_physical,
                "cpu_freq_current": cpu_freq_current,
                "cpu_freq_max": cpu_freq_max,
                "load_average": load_average,
            }
    
            if per_cpu_percent is not None:
                result["per_cpu_percent"] = [round(p, 1) for p in per_cpu_percent]
    
            return result
    
        except Exception as e:
            logger.error(f"Error getting CPU info: {e}")
            raise
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool retrieves information (implying read-only), but doesn't disclose behavioral traits like whether it requires permissions, has rate limits, returns real-time vs. historical data, or error conditions. The description is minimal and misses key operational details for a system monitoring tool.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose followed by parameter details. Every sentence adds value, with no wasted words. The structure is clear, though it could benefit from slight formatting improvements for readability.

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

Completeness3/5

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

Given the tool's low complexity, 2 parameters, no annotations, but an output schema exists, the description is minimally adequate. It covers purpose and parameters but lacks behavioral context and usage guidelines. The output schema likely handles return values, so completeness is borderline but not fully helpful for an agent.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics for both parameters: 'interval' is explained as 'Measurement interval in seconds (default: 1.0)', and 'per_cpu' as 'Include per-CPU core breakdown (default: false)'. This clarifies usage beyond the bare schema, though it could note units or constraints more explicitly.

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

Purpose4/5

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

The description clearly states the tool's purpose with 'Retrieve CPU usage and information', specifying both the verb (retrieve) and resource (CPU usage/information). It distinguishes from siblings by focusing on CPU rather than disk, memory, network, etc., though it doesn't explicitly contrast with them. The purpose is specific but could be slightly more distinctive.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like get_memory_info_tool or get_system_uptime_tool, nor does it specify scenarios where CPU info is needed over other system metrics. Usage is implied by the purpose but lacks explicit context or exclusions.

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