Skip to main content
Glama
dknell

System Information MCP Server

by dknell

get_process_list_tool

Retrieve a list of running processes, sorted by CPU or memory usage, with optional name filtering.

Instructions

Retrieve list of running processes.

Args: limit: Maximum number of processes to return (default: 50) sort_by: Sort criteria - cpu, memory, name, pid (default: cpu) filter_name: Filter processes by name pattern

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
sort_byNocpu
filter_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Tool handler (MCP registration) for get_process_list_tool. Uses @app.tool() decorator to register the tool with FastMCP, accepts limit, sort_by, and filter_name parameters, and delegates to get_process_list().
    @app.tool()
    def get_process_list_tool(
        limit: int = 50, sort_by: str = "cpu", filter_name: Optional[str] = None
    ) -> Dict[str, Any]:
        """Retrieve list of running processes.
    
        Args:
            limit: Maximum number of processes to return (default: 50)
            sort_by: Sort criteria - cpu, memory, name, pid (default: cpu)
            filter_name: Filter processes by name pattern
        """
        return get_process_list(limit=limit, sort_by=sort_by, filter_name=filter_name)
  • Core implementation of get_process_list(). Uses psutil to iterate over processes, supports filtering by name, sorting by cpu/memory/name/pid, and limiting results. Returns process details like pid, name, username, status, CPU/memory usage, memory RSS, creation time, and command line.
    def get_process_list(
        limit: int = 50, sort_by: str = "cpu", filter_name: Optional[str] = None
    ) -> Dict[str, Any]:
        """Retrieve list of running processes."""
        try:
            # Validate parameters
            if limit <= 0:
                raise ValueError("Limit must be a positive number")
    
            limit = min(limit, config.max_processes)
    
            valid_sort_keys = ["cpu", "memory", "name", "pid"]
            if sort_by not in valid_sort_keys:
                raise ValueError(f"sort_by must be one of: {valid_sort_keys}")
    
            processes = []
    
            # Get all processes
            for proc in psutil.process_iter(
                [
                    "pid",
                    "name",
                    "username",
                    "status",
                    "cpu_percent",
                    "memory_percent",
                    "memory_info",
                    "create_time",
                    "cmdline",
                ]
            ):
                try:
                    proc_info = proc.info
    
                    # Filter by name if specified
                    if filter_name and filter_name.lower() not in proc_info["name"].lower():
                        continue
    
                    # Get memory RSS
                    memory_rss = 0
                    if proc_info.get("memory_info"):
                        memory_rss = proc_info["memory_info"].rss
    
                    # Filter and format command line
                    cmdline = filter_sensitive_cmdline(proc_info.get("cmdline") or [])
    
                    process_data = {
                        "pid": proc_info["pid"],
                        "name": proc_info["name"] or "Unknown",
                        "username": proc_info.get("username", "Unknown"),
                        "status": proc_info.get("status", "unknown"),
                        "cpu_percent": round(
                            safe_float(proc_info.get("cpu_percent", 0)), 1
                        ),
                        "memory_percent": round(
                            safe_float(proc_info.get("memory_percent", 0)), 1
                        ),
                        "memory_rss": memory_rss,
                        "memory_rss_mb": bytes_to_mb(memory_rss),
                        "create_time": timestamp_to_iso(proc_info.get("create_time", 0)),
                        "cmdline": cmdline,
                    }
    
                    processes.append(process_data)
    
                except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                    # Process may have terminated or we don't have permission
                    continue
    
            # Sort processes
            reverse_sort = True  # Most metrics should be sorted in descending order
            if sort_by == "cpu":
                processes.sort(key=lambda p: p["cpu_percent"], reverse=reverse_sort)
            elif sort_by == "memory":
                processes.sort(key=lambda p: p["memory_percent"], reverse=reverse_sort)
            elif sort_by == "name":
                processes.sort(key=lambda p: p["name"].lower(), reverse=False)
            elif sort_by == "pid":
                processes.sort(key=lambda p: p["pid"], reverse=False)
    
            # Apply limit
            limited_processes = processes[:limit]
    
            return {"processes": limited_processes, "total_processes": len(processes)}
    
        except Exception as e:
            logger.error(f"Error getting process list: {e}")
            raise
  • ServerConfig dataclass defines max_processes (default 100, configurable via SYSINFO_MAX_PROCESSES env var) which acts as a hard limit on the number of processes returned by get_process_list.
    """Server configuration with environment variable support."""
    
    name: str = "system-info-server"
    version: str = "1.0.0"
    description: str = "System information MCP server"
    cache_ttl: int = int(os.getenv("SYSINFO_CACHE_TTL", "5"))
    max_processes: int = int(os.getenv("SYSINFO_MAX_PROCESSES", "100"))
    enable_temperatures: bool = (
        os.getenv("SYSINFO_ENABLE_TEMP", "true").lower() == "true"
    )
    log_level: str = os.getenv("SYSINFO_LOG_LEVEL", "INFO")
    
    # Transport configuration
    transport: Literal["stdio", "sse", "streamable-http"] = os.getenv("SYSINFO_TRANSPORT", "stdio")  # type: ignore
    port: int = int(os.getenv("SYSINFO_PORT", "8001"))
    host: str = os.getenv("SYSINFO_HOST", "localhost")
    mount_path: str = os.getenv("SYSINFO_MOUNT_PATH", "/mcp")
  • Import of get_process_list from .tools module, which is the underlying function used by the registered tool handler.
    from .tools import (
        get_cpu_info,
        get_memory_info,
        get_disk_info,
        get_network_info,
        get_process_list,
        get_system_uptime,
Behavior2/5

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

No annotations are provided, and the description fails to disclose behavioral traits such as permission requirements, rate limits, or whether the list is a snapshot. It implies a read operation but offers no explicit confirmation.

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?

The description is concise, front-loaded with the main purpose, and parameter documentation follows cleanly. Every sentence is necessary and no words are wasted.

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?

While an output schema exists (reducing need for return value descriptions), the description lacks context about the tool's scope (e.g., all processes vs. user-specific) and any limitations, leaving some gaps in completeness.

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?

With 0% schema description coverage, the description effectively adds meaning for all three parameters: limit (max number), sort_by (criteria and defaults), and filter_name (pattern). This compensates for the missing schema descriptions.

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?

The description clearly states 'Retrieve list of running processes' with a specific verb ('retrieve') and resource ('list of running processes'), distinguishing it from sibling tools like get_cpu_info_tool.

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 (e.g., other info tools), nor any exclusions or prerequisites. It only lists parameters without usage 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