list_common_commands
Retrieve a curated list of commonly used Unix commands from the system, helping users access key tools and functionalities quickly for efficient Unix operations.
Instructions
List common Unix commands available on the system.
Returns: A list of common Unix commands
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- unix_manual_server.py:248-309 (handler)The handler function decorated with @mcp.tool(), which lists common Unix commands from /bin, /usr/bin, /usr/local/bin, filters executables, removes duplicates, sorts, and categorizes them into File Operations, Text Processing, System Information, and Networking, returning a formatted string.@mcp.tool() def list_common_commands() -> str: """ List common Unix commands available on the system. Returns: A list of common Unix commands """ logger.info("Listing common commands") # Define common directories in PATH that contain commands common_dirs = ['/bin', '/usr/bin', '/usr/local/bin'] logger.debug(f"Searching in directories: {common_dirs}") commands = [] for directory in common_dirs: if os.path.exists(directory) and os.path.isdir(directory): logger.debug(f"Scanning directory: {directory}") # List only executable files try: for file in os.listdir(directory): file_path = os.path.join(directory, file) if os.path.isfile(file_path) and os.access(file_path, os.X_OK): commands.append(file) except Exception as e: logger.error(f"Error listing directory {directory}: {str(e)}") # Remove duplicates and sort commands = sorted(set(commands)) logger.info(f"Found {len(commands)} unique commands") # Return a formatted string with command categories result = "Common Unix commands available on this system:\n\n" # File operations file_cmds = [cmd for cmd in commands if cmd in ['ls', 'cp', 'mv', 'rm', 'mkdir', 'touch', 'chmod', 'chown', 'find', 'grep']] if file_cmds: logger.debug(f"File operation commands found: {len(file_cmds)}") result += "File Operations:\n" + ", ".join(file_cmds) + "\n\n" # Text processing text_cmds = [cmd for cmd in commands if cmd in ['cat', 'less', 'more', 'head', 'tail', 'grep', 'sed', 'awk', 'sort', 'uniq', 'wc']] if text_cmds: logger.debug(f"Text processing commands found: {len(text_cmds)}") result += "Text Processing:\n" + ", ".join(text_cmds) + "\n\n" # System information sys_cmds = [cmd for cmd in commands if cmd in ['ps', 'top', 'htop', 'df', 'du', 'free', 'uname', 'uptime', 'who', 'whoami']] if sys_cmds: logger.debug(f"System info commands found: {len(sys_cmds)}") result += "System Information:\n" + ", ".join(sys_cmds) + "\n\n" # Network tools net_cmds = [cmd for cmd in commands if cmd in ['ping', 'netstat', 'ifconfig', 'ip', 'ssh', 'scp', 'curl', 'wget']] if net_cmds: logger.debug(f"Networking commands found: {len(net_cmds)}") result += "Networking:\n" + ", ".join(net_cmds) + "\n\n" # Show total count result += f"Total commands found: {len(commands)}\n" result += "Use get_command_documentation() to learn more about any command." return result