Skip to main content
Glama

get_serial_port

Get the serial port address of a VM to enable direct console access without SSH.

Instructions

Get the serial port address of a VM.

Returns the ptty path (for Apple VF) or TCP address/port (for QEMU) that can be used for direct console access without SSH.

Args: name: VM name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The actual implementation of get_serial_port. It runs an AppleScript to fetch the first serial port's interface, address (ptty path or TCP), and port from UTM via osascript, returning a dict with availability, id, interface, address, and port.
    def get_serial_port(name: str) -> dict:
        """Get the first serial port's interface and address (ptty path or TCP info)."""
        _validate_vm_name(name)
        script = f'''
        tell application "UTM"
            set vm to virtual machine named "{_esc(name)}"
            set ports to serial ports of vm
            if (count of ports) > 0 then
                set p to item 1 of ports
                set pId to id of p
                set pIface to interface of p as text
                set pAddr to address of p
                set pPort to port of p
                return pId & "||" & pIface & "||" & pAddr & "||" & pPort
            else
                return "none"
            end if
        end tell
        '''
        raw = _run(script)
        if raw == "none":
            return {"available": False}
        parts = raw.split("||")
        return {
            "available": True,
            "id": _parse_int(parts[0]) if len(parts) > 0 else 0,
            "interface": parts[1] if len(parts) > 1 else "",
            "address": parts[2] if len(parts) > 2 else "",
            "port": _parse_int(parts[3]) if len(parts) > 3 else 0,
        }
  • The MCP tool definition for get_serial_port. Decorated with @mcp.tool(), it delegates to utm.get_serial_port(name) (the applescript module).
    def get_serial_port(name: str) -> dict:
        """Get the serial port address of a VM.
    
        Returns the ptty path (for Apple VF) or TCP address/port (for QEMU)
        that can be used for direct console access without SSH.
    
        Args:
            name: VM name
        """
        return utm.get_serial_port(name)
  • Registration of the get_serial_port tool via the @mcp.tool() decorator on the get_serial_port function in server.py.
    def get_serial_port(name: str) -> dict:
        """Get the serial port address of a VM.
    
        Returns the ptty path (for Apple VF) or TCP address/port (for QEMU)
        that can be used for direct console access without SSH.
    
        Args:
            name: VM name
        """
        return utm.get_serial_port(name)
  • Return schema: dict with 'available' (bool), 'id' (int), 'interface' (str), 'address' (str), 'port' (int). Input is a single 'name' (str) parameter.
    return {
        "available": True,
        "id": _parse_int(parts[0]) if len(parts) > 0 else 0,
        "interface": parts[1] if len(parts) > 1 else "",
        "address": parts[2] if len(parts) > 2 else "",
        "port": _parse_int(parts[3]) if len(parts) > 3 else 0,
    }
  • _parse_int helper used by get_serial_port to parse AppleScript integer/float values from the split result.
    def _parse_int(value: str) -> int:
Behavior3/5

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

With no annotations, the description carries full burden. It discloses the variable return format (ptty vs TCP) based on VM type, but does not mention side effects, prerequisites (e.g., VM must exist), or error scenarios. The read-only nature is implied but not stated.

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 extremely concise: two sentences that front-load the purpose and return types, followed by a single-line parameter definition. No extraneous information.

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

Completeness4/5

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

Given the simplicity of the tool (one parameter, no output schema), the description covers the essential: what it returns, platform variations, and use case. However, it omits prerequisites like VM state and does not explicitly differentiate from similar sibling tools.

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

Parameters3/5

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

The schema has 0% description coverage, so the description must compensate. It clarifies that 'name' refers to the VM name, but provides no additional context like format, expected values, or relationship to other tools.

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

Purpose5/5

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

The description clearly states the resource ('serial port address of a VM') and the action ('get'), and distinguishes the return type by platform (Apple VF vs QEMU). It is specific and helps the agent understand the tool's exact purpose.

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

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for direct console access without SSH, but it does not explicitly state when to use this tool over alternatives like get_vm_ip. No when-not conditions or exclusion criteria are 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/neverprepared/mcp-utm'

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