Skip to main content
Glama
Heht571
by Heht571

get_os_details

Retrieve operating system details from remote servers to monitor system information and configuration for server management tasks.

Instructions

获取操作系统详细信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostnameYes
usernameYes
passwordNo
portNo
timeoutNo

Implementation Reference

  • Primary handler implementation for the 'get_os_details' tool. Uses SSH to fetch and parse comprehensive OS information including distro, version, kernel, architecture, uptime, boot time, and virtualization detection.
    def get_os_details(
        hostname: str,
        username: str,
        password: str = "",
        port: int = 22,
        timeout: int = 30
    ) -> dict:
        """获取操作系统详细信息"""
        result = {"status": "unknown", "os_info": {}, "error": ""}
    
        try:
            with SSHManager(hostname, username, password, port, timeout) as ssh:
                # 收集各种系统信息
                commands = {
                    "hostname": "hostname",
                    "os_release": "cat /etc/os-release || cat /etc/redhat-release || cat /etc/debian_version || uname -a",
                    "kernel": "uname -r",
                    "architecture": "uname -m",
                    "uptime": "uptime -p",
                    "last_boot": "who -b"
                }
    
                os_info = {}
                for key, command in commands.items():
                    stdin, stdout, stderr = ssh.exec_command(command, timeout=timeout)
                    output = stdout.read().decode().strip()
                    os_info[key] = output
    
                # 解析OS分发版和版本
                distro = "Unknown"
                version = "Unknown"
    
                if "NAME=" in os_info["os_release"]:
                    distro_match = re.search(r'NAME="?(.*?)"?', os_info["os_release"], re.MULTILINE)
                    if distro_match:
                        distro = distro_match.group(1)
    
                    version_match = re.search(r'VERSION="?(.*?)"?', os_info["os_release"], re.MULTILINE)
                    if version_match:
                        version = version_match.group(1)
                    else:
                        version_id_match = re.search(r'VERSION_ID="?(.*?)"?', os_info["os_release"], re.MULTILINE)
                        if version_id_match:
                            version = version_id_match.group(1)
    
                os_info["distro"] = distro
                os_info["version"] = version
    
                # 检查是否为虚拟机
                vm_check_command = "systemd-detect-virt || dmesg | grep -i virtual || dmidecode | grep -i vmware || dmidecode | grep -i virtualbox || echo 'Unknown'"
                stdin, stdout, stderr = ssh.exec_command(vm_check_command, timeout=timeout)
                vm_output = stdout.read().decode().strip()
    
                os_info["virtualization"] = "Unknown"
                if vm_output != "Unknown":
                    for vm_type in ["kvm", "vmware", "virtualbox", "xen", "docker", "lxc", "openvz", "parallels"]:
                        if vm_type.lower() in vm_output.lower():
                            os_info["virtualization"] = vm_type
                            break
    
                result["os_info"] = os_info
                result["status"] = "success"
    
        except Exception as e:
            result["status"] = "error"
            result["error"] = str(e)
    
        return result
  • Simplified handler for 'get_os_details' in the SSE variant. Collects raw outputs from OS info commands via SSH without additional parsing.
    def get_os_details(
        hostname: str,
        username: str,
        password: str = "",
        port: int = 22,
        timeout: int = 30
    ) -> dict:
        """获取操作系统详细信息"""
        result = {"status": "unknown", "os_info": {}, "error": ""}
    
        try:
            with SSHManager(hostname, username, password, port, timeout) as ssh:
                # 收集各种系统信息
                commands = {
                    "hostname": "hostname",
                    "os_release": "cat /etc/os-release || cat /etc/redhat-release || cat /etc/debian_version || uname -a",
                    "kernel": "uname -r",
                    "architecture": "uname -m",
                    "uptime": "uptime -p",
                    "last_boot": "who -b"
                }
    
                os_info = {}
                for key, command in commands.items():
                    stdin, stdout, stderr = ssh.exec_command(command, timeout=timeout)
                    output = stdout.read().decode().strip()
                    os_info[key] = output
    
                result["os_info"] = os_info
                result["status"] = "success"
    
        except Exception as e:
            result["status"] = "error"
            result["error"] = str(e)
    
        return result
  • Tool registration block in main.py where get_os_details is included in the tools_dict and registered to the MCP instance using mcp.tool() decorator.
    tools_dict = {
        'get_memory_info': get_memory_info,
        'remote_server_inspection': remote_server_inspection,
        'get_system_load': get_system_load,
        'monitor_processes': monitor_processes,
        'check_service_status': check_service_status,
        'get_os_details': get_os_details,
        'check_ssh_risk_logins': check_ssh_risk_logins,
        'check_firewall_config': check_firewall_config,
        'security_vulnerability_scan': security_vulnerability_scan,
        'backup_critical_files': backup_critical_files,
        'inspect_network': inspect_network,
        'analyze_logs': analyze_logs,
        'list_docker_containers': list_docker_containers,
        'list_docker_images': list_docker_images,
        'list_docker_volumes': list_docker_volumes,
        'get_container_logs': get_container_logs,
        'monitor_container_stats': monitor_container_stats,
        'check_docker_health': check_docker_health
    }
    
    # 使用装饰器动态注册所有工具
    for name, func in tools_dict.items():
        mcp.tool()(func)
    
    # 特殊处理list_available_tools,因为它需要mcp实例
    @mcp.tool()
    def _list_available_tools():
        return list_available_tools(mcp)
    
    return mcp
  • Parameter schema definition for the get_os_details tool used in tool descriptions or validation.
    {"name": "get_os_details", "description": "获取操作系统详细信息", "parameters": [
        {"name": "hostname", "type": "str", "default": None},
        {"name": "username", "type": "str", "default": None},
        {"name": "password", "type": "str", "default": ""},
        {"name": "port", "type": "int", "default": 22},
        {"name": "timeout", "type": "int", "default": 30}
    ]}
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description only states what the tool does ('获取操作系统详细信息') without mentioning that it requires remote authentication (hostname, username, password), operates over SSH (port 22 default), has timeout behavior, or what kind of OS details are returned. For a tool with 5 parameters including authentication credentials, this is inadequate behavioral transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is maximally concise at a single phrase ('获取操作系统详细信息'). While this represents under-specification rather than ideal conciseness, it contains no redundant or unnecessary information. Every word contributes to stating the basic purpose, earning its place in the minimal description.

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

Completeness1/5

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

For a tool with 5 parameters (including authentication credentials), no annotations, no output schema, and 0% schema description coverage, the description is completely inadequate. It doesn't explain what OS details are returned, how authentication works, what the timeout means, or any behavioral characteristics. The description fails to provide the minimal context needed for an agent to understand this tool's operation.

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

Parameters1/5

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

With 0% schema description coverage for 5 parameters, the description provides no information about any parameters. The schema shows this tool requires hostname and username authentication with optional password, port, and timeout settings, but the description doesn't mention these requirements or their purposes. The description fails to compensate for the complete lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取操作系统详细信息' (Get operating system details) states the basic purpose but is vague about scope and specificity. It doesn't distinguish this tool from siblings like 'get_system_load' or 'get_memory_info' that also retrieve system information. The description restates the tool name concept without clarifying what specific OS details are obtained.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/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. With siblings like 'get_system_load', 'get_memory_info', and 'remote_server_inspection' that also retrieve system information, there's no indication of what makes this tool distinct or when it should be preferred over other options. No context about prerequisites or typical use cases is provided.

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/Heht571/ops-mcp-server'

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