Skip to main content
Glama
batteryshark

System Information MCP Server

by batteryshark

get_running_processes

Retrieve running processes with resource usage and executable paths to analyze performance, troubleshoot resource issues, and conduct security audits.

Instructions

Get list of running processes with resource usage and executable paths.

Shows top processes by CPU/memory usage with PIDs, names, and executable paths. Essential for performance analysis, troubleshooting resource issues, and security auditing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for get_running_processes. Wraps the collector function, formats output as ToolResult with markdown sections.
    @mcp.tool def get_running_processes() -> ToolResult: """Get list of running processes with resource usage and executable paths. Shows top processes by CPU/memory usage with PIDs, names, and executable paths. Essential for performance analysis, troubleshooting resource issues, and security auditing. """ info_sections = [] info_sections.append("# Running Processes") info_sections.append(f"*Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n") try: from .collectors import get_running_processes as get_processes_data info_sections.extend(get_processes_data()) except Exception as e: info_sections.append(f"⚠️ **Process detection error**: {str(e)}") return text_response("\n".join(info_sections))
  • Core helper function that iterates over processes using psutil, collects CPU/memory usage, sorts top processes, and formats as markdown table with summary.
    def get_running_processes() -> List[str]: """Get list of running processes with resource usage""" info = [] info.append("## ⚙️ Running Processes") try: # Get all processes and sort by CPU usage processes = [] for proc in psutil.process_iter(['pid', 'name', 'cpu_percent', 'memory_percent', 'exe', 'cmdline']): try: pinfo = proc.info if pinfo['name'] and pinfo['name'] != '': # Get CPU percent (this call triggers measurement) cpu_percent = proc.cpu_percent() pinfo['cpu_percent'] = cpu_percent processes.append(pinfo) except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): continue # Sort by CPU usage, then memory usage processes.sort(key=lambda x: (x.get('cpu_percent', 0), x.get('memory_percent', 0)), reverse=True) # Display top 20 processes info.append(f"\n### Top Processes (by CPU/Memory usage)") info.append("| PID | Name | CPU% | Memory% | Path |") info.append("|-----|------|------|---------|------|") count = 0 for proc in processes: if count >= 20: break pid = proc.get('pid', 'N/A') name = proc.get('name', 'Unknown')[:20] # Truncate long names cpu = proc.get('cpu_percent', 0) memory = proc.get('memory_percent', 0) # Get executable path exe_path = proc.get('exe', '') if not exe_path and proc.get('cmdline'): # Fallback to first command line argument cmdline = proc.get('cmdline', []) if cmdline: exe_path = cmdline[0] # Truncate path for display if exe_path: if len(exe_path) > 40: exe_path = "..." + exe_path[-37:] else: exe_path = "N/A" # Only show processes with some activity or important system processes if cpu > 0.1 or memory > 0.5 or name.lower() in ['kernel_task', 'systemd', 'init', 'launchd']: info.append(f"| {pid} | {name} | {cpu:.1f}% | {memory:.1f}% | {exe_path} |") count += 1 # Add process summary total_processes = len(processes) active_processes = len([p for p in processes if p.get('cpu_percent', 0) > 0]) info.append(f"\n**Summary**: {total_processes} total processes, {active_processes} active") except Exception as e: info.append(f"⚠️ **Error collecting process information**: {str(e)}") return info

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