Skip to main content
Glama
tizee

Unix Manual Server

by tizee

list_common_commands

Discover available Unix commands to quickly find documentation and usage information within the chat interface.

Instructions

List common Unix commands available on the system.

Returns: A list of common Unix commands

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_common_commands' tool. It scans common Unix directories (/bin, /usr/bin, /usr/local/bin) for executable files, collects unique commands, categorizes them into File Operations, Text Processing, System Information, and Networking, and returns a formatted string listing them. Registered via @mcp.tool() decorator.
    @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

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/tizee/mcp-unix-manual'

If you have feedback or need assistance with the MCP directory API, please join our Discord server