Skip to main content
Glama
tizee

Unix Manual Server

by tizee

check_command_exists

Verify if a Unix command is available on your system before attempting to use it, preventing errors and ensuring compatibility.

Instructions

Check if a command exists on the system.

Args: command: The command to check

Returns: Information about whether the command exists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes

Implementation Reference

  • The @mcp.tool()-decorated function implementing the 'check_command_exists' MCP tool handler. It checks if the specified command exists on the system by finding its path using get_command_path, validates the command name, and attempts to retrieve version information using --version, -V, or version subcommands.
    @mcp.tool()
    def check_command_exists(command: str) -> str:
        """
        Check if a command exists on the system.
    
        Args:
            command: The command to check
    
        Returns:
            Information about whether the command exists
        """
        logger.info(f"Checking if command exists: '{command}'")
        command_name = command.strip().split()[0]
        logger.debug(f"Extracted command name: {command_name}")
    
        if not re.match(r'^[a-zA-Z0-9_\.-]+$', command_name):
            logger.warning(f"Invalid command name: '{command_name}'")
            return f"Invalid command name: '{command_name}'"
    
        command_path = get_command_path(command_name)
        if command_path:
            logger.info(f"Command '{command_name}' exists at {command_path}")
    
            # Try --version
            logger.debug(f"Trying --version for {command_name}")
            version_result = safe_execute([command_path, "--version"], timeout=5)
            if version_result and version_result.returncode < 2 and version_result.stdout.strip():
                logger.debug(f"Got version info using --version for {command_name}")
                return f"Command '{command_name}' exists at {command_path}.\nVersion information: {version_result.stdout.strip()}"
    
            # Try -V (some commands use this for version)
            logger.debug(f"Trying -V for {command_name}")
            version_result = safe_execute([command_path, "-V"], timeout=5)
            if version_result and version_result.returncode < 2 and version_result.stdout.strip():
                logger.debug(f"Got version info using -V for {command_name}")
                return f"Command '{command_name}' exists at {command_path}.\nVersion information: {version_result.stdout.strip()}"
    
            # Try version
            logger.debug(f"Trying version subcommand for {command_name}")
            version_result = safe_execute([command_path, "version"], timeout=5)
            if version_result and version_result.returncode < 2 and version_result.stdout.strip():
                logger.debug(f"Got version info using version subcommand for {command_name}")
                return f"Command '{command_name}' exists at {command_path}.\nVersion information: {version_result.stdout.strip()}"
    
            return f"Command '{command_name}' exists on this system at {command_path}."
        else:
            logger.warning(f"Command '{command_name}' does not exist or is not in the PATH")
            return f"Command '{command_name}' does not exist or is not in the PATH."
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool checks for command existence but doesn't explain how it performs this check (e.g., system path search, specific OS behavior), what 'exists' means (e.g., executable in PATH), or any limitations (e.g., platform dependencies). This is inadequate for a tool with zero annotation coverage.

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 concise and well-structured with clear sections for Args and Returns. However, the 'Returns' section is vague ('Information about whether the command exists'), which slightly reduces efficiency. Overall, it's appropriately sized with minimal fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on behavior, parameter usage, and return format, making it inadequate for an agent to reliably invoke this tool. More context is needed to compensate for the missing structured data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds minimal value: it names the parameter ('command') and states it's 'The command to check,' but doesn't clarify format (e.g., string without arguments, case sensitivity) or examples. This is insufficient given the low schema coverage and single parameter.

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 tool's purpose: 'Check if a command exists on the system.' This is a specific verb ('Check') and resource ('command'), making it understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_command_documentation' or 'list_common_commands', which prevents a perfect score.

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. It doesn't mention sibling tools or specify scenarios where checking command existence is appropriate versus retrieving documentation or listing commands. This leaves the agent without contextual usage direction.

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

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