Skip to main content
Glama

get_serial_port

Get the serial port address (ptty path or TCP address/port) of a UTM VM for 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

  • Core implementation of get_serial_port: validates VM name, executes AppleScript to query UTM for the first serial port's interface/address/port, and returns structured dict with available flag.
    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,
        }
  • Return value schema: available (bool), id (int), interface (string: 'ptty' or 'tcp'), address (string: path or IP), port (int).
    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,
    }
  • MCP tool registration using @mcp.tool() decorator on get_serial_port function, which delegates to applescript.get_serial_port.
    @mcp.tool()
    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)
  • _validate_vm_name helper used to sanitize the VM name input before AppleScript execution.
    def _validate_vm_name(name: str) -> str:
        if not name or not _VM_NAME_RE.match(name):
            raise ValueError(f"Invalid VM name: {name!r} — only word characters, spaces, hyphens, and dots allowed")
        return name
  • _parse_int helper used to parse integer values from AppleScript output (used for serial port id and port number).
    def _parse_int(value: str) -> int:
        """Parse an integer from AppleScript output, handling floats."""
        try:
            return int(float(value))
        except (ValueError, TypeError):
            return 0
Behavior3/5

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

With no annotations, the description does not explicitly state that the operation is read-only, though the name 'get' implies it. The description adds some value by detailing the return path, but does not disclose potential side effects or permissions needed.

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 brief, well-structured, and front-loaded with the primary purpose. Every sentence adds value, and the parameter listing is placed after the main explanation. No wasted words.

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?

Despite lacking an output schema, the description explains the return format and port applicability. It covers the essential context for a simple tool with one parameter, but could be enhanced with error handling or prerequisite info.

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?

The only parameter 'name' is described simply as 'VM name' in the description, which adds minimal additional meaning over the schema's empty description. With 0% schema coverage, the description should provide richer context (e.g., examples, constraints), but it does not.

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 that the tool gets the serial port address of a VM, specifying the return format (ptty for Apple VF, TCP address/port for QEMU). This distinguishes it from sibling tools like get_vm_ip and others.

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

Usage Guidelines4/5

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

The description explains the tool is for 'direct console access without SSH,' providing clear context for when to use it. It does not explicitly mention when not to use it or list alternatives, but the use case is well-defined.

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