Skip to main content
Glama
dknell

System Information MCP Server

by dknell

get_process_list_tool

Retrieve and analyze running processes with sorting and filtering options to monitor system performance and identify resource usage patterns.

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

  • MCP tool handler for get_process_list_tool, decorated with @app.tool() which registers the tool and defines input schema via type hints and docstring.
    @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 logic for retrieving, filtering, sorting, and formatting the process list using psutil.
    @cache_result("process_list", ttl=2)
    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
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Retrieve' implies a read operation, it doesn't specify whether this requires special permissions, has rate limits, returns real-time or cached data, or what format the output takes. The description mentions parameters but doesn't explain behavioral implications like what happens when limit is exceeded or how filtering works.

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 with the core purpose in the first sentence. The parameter documentation is organized clearly with bullet-like formatting. Every sentence adds value, though the structure could be slightly more polished with complete sentences for parameter descriptions.

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 moderate complexity (3 parameters, system monitoring function) and the presence of an output schema, the description covers the basics adequately. However, with no annotations and incomplete behavioral context, there are gaps in understanding permissions, performance characteristics, and error conditions that would help an agent use this tool effectively.

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 compensates well by explaining all three parameters: limit (maximum number, default), sort_by (criteria with examples, default), and filter_name (pattern filtering). It adds meaningful context beyond the bare schema, though it could provide more detail about pattern syntax or sorting behavior.

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 verb ('Retrieve') and resource ('list of running processes'), making the purpose immediately understandable. It distinguishes from siblings by focusing specifically on processes rather than CPU, disk, memory, network, uptime, or temperature information. However, it doesn't explicitly contrast with sibling tools in the text itself.

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. There's no mention of sibling tools, no indication of when this tool is appropriate versus other system monitoring tools, and no discussion of prerequisites or constraints. The agent must infer usage from the tool name alone.

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