Skip to main content
Glama
senseisven

MCP Remote macOS Control Server

by senseisven

remote_macos_get_screen

Capture screenshots from remote macOS computers using VNC connection. Enables remote desktop monitoring and visual access to Mac systems.

Instructions

Connect to a remote MacOs machine and get a screenshot of the remote desktop. Uses environment variables for connection details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'remote_macos_get_screen' tool. It uses environment variables for VNC connection details, calls capture_vnc_screen to get the screen image, encodes it as base64 PNG, and returns it as ImageContent along with dimensions.
    async def handle_remote_macos_get_screen(arguments: dict[str, Any]) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Connect to a remote MacOs machine and get a screenshot of the remote desktop."""
        # Use environment variables
        host = MACOS_HOST
        port = MACOS_PORT
        password = MACOS_PASSWORD
        username = MACOS_USERNAME
        encryption = VNC_ENCRYPTION
    
        # Capture screen using helper method
        success, screen_data, error_message, dimensions = await capture_vnc_screen(
            host=host, port=port, password=password, username=username, encryption=encryption
        )
    
        if not success:
            return [types.TextContent(type="text", text=error_message)]
    
        # Encode image in base64
        base64_data = base64.b64encode(screen_data).decode('utf-8')
    
        # Return image content with dimensions
        width, height = dimensions
        return [
            types.ImageContent(
                type="image",
                data=base64_data,
                mimeType="image/png",
                alt_text=f"Screenshot from remote MacOs machine at {host}:{port}"
            ),
            types.TextContent(
                type="text",
                text=f"Image dimensions: {width}x{height}"
            )
        ]
  • The tool schema definition in the list_tools() function, specifying name, description, and empty input schema (no parameters required).
        name="remote_macos_get_screen",
        description="Connect to a remote MacOs machine and get a screenshot of the remote desktop. Uses environment variables for connection details.",
        inputSchema={
            "type": "object",
            "properties": {}
        },
    ),
  • Tool dispatch/registration in the call_tool() handler: checks tool name and delegates to the specific handler function.
    if name == "remote_macos_get_screen":
        return await handle_remote_macos_get_screen(arguments)
  • Core helper function called by the handler to establish VNC connection using VNCClient, capture the screen, resize to 1366x768, and return PNG bytes or error.
    async def capture_vnc_screen(host: str, port: int, password: str, username: Optional[str] = None,
                                 encryption: str = "prefer_on") -> Tuple[bool, Optional[bytes], Optional[str], Optional[Tuple[int, int]]]:
        """Capture a screenshot from a remote MacOs machine.
    
        Args:
            host: remote MacOs machine hostname or IP address
            port: remote MacOs machine port
            password: remote MacOs machine password
            username: remote MacOs machine username (optional)
            encryption: Encryption preference (default: "prefer_on")
    
        Returns:
            Tuple containing:
            - success: True if the operation was successful
            - screen_data: PNG image data if successful, None otherwise
            - error_message: Error message if unsuccessful, None otherwise
            - dimensions: Tuple of (width, height) if successful, None otherwise
        """
        logger.debug(f"Connecting to remote MacOs machine at {host}:{port} with encryption: {encryption}")
    
        # Initialize VNC client
        vnc = VNCClient(host=host, port=port, password=password, username=username, encryption=encryption)
    
        try:
            # Connect to remote MacOs machine
            success, error_message = vnc.connect()
            if not success:
                detailed_error = f"Failed to connect to remote MacOs machine at {host}:{port}. {error_message}\n"
                detailed_error += "This VNC client only supports Apple Authentication (protocol 30). "
                detailed_error += "Please ensure the remote MacOs machine supports this protocol. "
                detailed_error += "For macOS, enable Screen Sharing in System Preferences > Sharing."
                return False, None, detailed_error, None
    
            # Capture screen
            screen_data = vnc.capture_screen()
    
            if not screen_data:
                return False, None, f"Failed to capture screenshot from remote MacOs machine at {host}:{port}", None
    
            # Save original dimensions for reference
            original_dims = (vnc.width, vnc.height)
    
            # Scale the image to FWXGA resolution (1366x768)
            target_width, target_height = 1366, 768
    
            try:
                # Convert bytes to PIL Image
                image_data = io.BytesIO(screen_data)
                img = Image.open(image_data)
    
                # Resize the image to the target resolution
                scaled_img = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
    
                # Convert back to bytes
                output_buffer = io.BytesIO()
                scaled_img.save(output_buffer, format='PNG')
                output_buffer.seek(0)
                scaled_screen_data = output_buffer.getvalue()
    
                logger.info(f"Scaled image from {original_dims[0]}x{original_dims[1]} to {target_width}x{target_height}")
    
                # Return success with scaled screen data and target dimensions
                return True, scaled_screen_data, None, (target_width, target_height)
    
            except Exception as e:
                logger.warning(f"Failed to scale image: {str(e)}. Returning original image.")
                # Return the original image if scaling fails
                return True, screen_data, None, original_dims
    
        finally:
            # Close VNC connection
            vnc.close()
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 connection details via environment variables, which is useful context, but doesn't describe what happens during connection (e.g., authentication needs, potential timeouts, rate limits, or what the screenshot output looks like). For a tool with zero annotation coverage, this leaves significant gaps.

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 two sentences with zero waste: the first states the purpose clearly, and the second adds essential context about environment variables. It's appropriately sized and front-loaded with the core functionality.

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

Completeness3/5

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

Given the tool's complexity (remote connection and screenshot capture), no annotations, no output schema, and 0 parameters, the description is minimally adequate. It covers the purpose and connection method but lacks details on behavioral aspects like error handling, output format, or prerequisites, leaving room for improvement.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so the schema fully documents the lack of parameters. The description adds value by explaining that connection details come from environment variables, which clarifies why no parameters are needed. This compensates appropriately for the parameter-less design.

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 specific action ('Connect to a remote MacOs machine and get a screenshot') and distinguishes it from sibling tools that perform mouse operations, application opening, or key sending. It identifies both the verb and resource precisely.

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 implies usage context by specifying it's for remote MacOS machines and uses environment variables for connection, but doesn't explicitly state when to use this versus alternatives or any exclusions. It provides clear context but lacks explicit guidance on alternatives.

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/senseisven/mcp_macos'

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