Skip to main content
Glama

remote_macos_send_keys

Send keyboard input to remote macOS systems for automated control, including text, special keys, and key combinations.

Instructions

Send keyboard input to a remote MacOs machine. Uses environment variables for connection details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textNoText to send as keystrokes
special_keyNoSpecial key to send (e.g., 'enter', 'backspace', 'tab', 'escape', etc.)
key_combinationNoKey combination to send (e.g., 'ctrl+c', 'cmd+q', 'ctrl+alt+delete', etc.)

Implementation Reference

  • The primary handler function that executes the remote_macos_send_keys tool. It connects to the remote MacOS via VNC, parses arguments for text, special_key, or key_combination, and sends the appropriate key events using the VNCClient.
    def handle_remote_macos_send_keys(arguments: dict[str, Any]) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Send keyboard input to a remote MacOs machine."""
        # Use environment variables
        host = MACOS_HOST
        port = MACOS_PORT
        password = MACOS_PASSWORD
        username = MACOS_USERNAME
        encryption = VNC_ENCRYPTION
    
        # Get required parameters from arguments
        text = arguments.get("text")
        special_key = arguments.get("special_key")
        key_combination = arguments.get("key_combination")
    
        if not text and not special_key and not key_combination:
            raise ValueError("Either text, special_key, or key_combination must be provided")
    
        # Initialize VNC client
        vnc = VNCClient(host=host, port=port, password=password, username=username, encryption=encryption)
    
        # Connect to remote MacOs machine
        success, error_message = vnc.connect()
        if not success:
            error_msg = f"Failed to connect to remote MacOs machine at {host}:{port}. {error_message}"
            return [types.TextContent(type="text", text=error_msg)]
    
        try:
            result_message = []
    
            # Map of special key names to X11 keysyms
            special_keys = {
                "enter": 0xff0d,
                "return": 0xff0d,
                "backspace": 0xff08,
                "tab": 0xff09,
                "escape": 0xff1b,
                "esc": 0xff1b,
                "delete": 0xffff,
                "del": 0xffff,
                "home": 0xff50,
                "end": 0xff57,
                "page_up": 0xff55,
                "page_down": 0xff56,
                "left": 0xff51,
                "up": 0xff52,
                "right": 0xff53,
                "down": 0xff54,
                "f1": 0xffbe,
                "f2": 0xffbf,
                "f3": 0xffc0,
                "f4": 0xffc1,
                "f5": 0xffc2,
                "f6": 0xffc3,
                "f7": 0xffc4,
                "f8": 0xffc5,
                "f9": 0xffc6,
                "f10": 0xffc7,
                "f11": 0xffc8,
                "f12": 0xffc9,
                "space": 0x20,
            }
    
            # Map of modifier key names to X11 keysyms
            modifier_keys = {
                "ctrl": 0xffe3,    # Control_L
                "control": 0xffe3,  # Control_L
                "shift": 0xffe1,   # Shift_L
                "alt": 0xffe9,     # Alt_L
                "option": 0xffe9,  # Alt_L (Mac convention)
                "cmd": 0xffeb,     # Command_L (Mac convention)
                "command": 0xffeb,  # Command_L (Mac convention)
                "win": 0xffeb,     # Command_L
                "super": 0xffeb,   # Command_L
                "fn": 0xffed,      # Function key
                "meta": 0xffeb,    # Command_L (Mac convention)
            }
    
            # Map for letter keys (a-z)
            letter_keys = {chr(i): i for i in range(ord('a'), ord('z') + 1)}
    
            # Map for number keys (0-9)
            number_keys = {str(i): ord(str(i)) for i in range(10)}
    
            # Process special key
            if special_key:
                if special_key.lower() in special_keys:
                    key = special_keys[special_key.lower()]
                    if vnc.send_key_event(key, True) and vnc.send_key_event(key, False):
                        result_message.append(f"Sent special key: {special_key}")
                    else:
                        result_message.append(f"Failed to send special key: {special_key}")
                else:
                    result_message.append(f"Unknown special key: {special_key}")
                    result_message.append(f"Supported special keys: {', '.join(special_keys.keys())}")
    
            # Process text
            if text:
                if vnc.send_text(text):
                    result_message.append(f"Sent text: '{text}'")
                else:
                    result_message.append(f"Failed to send text: '{text}'")
    
            # Process key combination
            if key_combination:
                keys = []
                for part in key_combination.lower().split('+'):
                    part = part.strip()
                    if part in modifier_keys:
                        keys.append(modifier_keys[part])
                    elif part in special_keys:
                        keys.append(special_keys[part])
                    elif part in letter_keys:
                        keys.append(letter_keys[part])
                    elif part in number_keys:
                        keys.append(number_keys[part])
                    elif len(part) == 1:
                        # For any other single character keys
                        keys.append(ord(part))
                    else:
                        result_message.append(f"Unknown key in combination: {part}")
                        break
    
                if len(keys) == len(key_combination.split('+')):
                    if vnc.send_key_combination(keys):
                        result_message.append(f"Sent key combination: {key_combination}")
                    else:
                        result_message.append(f"Failed to send key combination: {key_combination}")
    
            return [types.TextContent(type="text", text="\n".join(result_message))]
        finally:
            vnc.close()
  • The tool schema definition in list_tools(), specifying the input parameters and their descriptions for validation.
    types.Tool(
        name="remote_macos_send_keys",
        description="Send keyboard input to a remote MacOs machine. Uses environment variables for connection details.",
        inputSchema={
            "type": "object",
            "properties": {
                "text": {"type": "string", "description": "Text to send as keystrokes"},
                "special_key": {"type": "string", "description": "Special key to send (e.g., 'enter', 'backspace', 'tab', 'escape', etc.)"},
                "key_combination": {"type": "string", "description": "Key combination to send (e.g., 'ctrl+c', 'cmd+q', 'ctrl+alt+delete', etc.)"}
            },
            "required": []
        },
    ),
  • Registration and dispatch logic in the handle_call_tool function, which routes tool calls with name 'remote_macos_send_keys' to the handler function.
    elif name == "remote_macos_send_keys":
        return handle_remote_macos_send_keys(arguments)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions using environment variables for connection details, which adds some context about authentication/configuration needs. However, it lacks critical behavioral information such as error handling, latency considerations, whether it's read-only or destructive, or any rate limits—essential for a remote control tool.

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 with two sentences that directly convey the core functionality and a key implementation detail. Every word earns its place, and it is front-loaded with the primary purpose. There is no unnecessary elaboration or redundancy.

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 the complexity of a remote control tool with no annotations and no output schema, the description is incomplete. It fails to explain return values, error conditions, or behavioral traits like whether it's safe or destructive. The environment variable mention is helpful but insufficient for full contextual understanding, especially compared to richer 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?

Schema description coverage is 100%, with clear descriptions for each parameter (text, special_key, key_combination). The description adds no additional parameter semantics beyond what the schema provides, such as examples of valid inputs or interactions between parameters. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 verb ('send keyboard input') and resource ('to a remote MacOs machine'), making the purpose immediately understandable. It distinguishes itself from sibling tools like mouse operations or screen capture by focusing on keyboard input. However, it doesn't explicitly differentiate from potential keyboard-related siblings that might exist elsewhere.

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 mentions environment variables for connection details, which hints at prerequisites, but offers no explicit usage context, exclusion criteria, or comparison with sibling tools like remote_macos_open_application that might involve keyboard input indirectly.

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/baryhuang/mcp-remote-macos-use'

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