mirror of
https://github.com/trycua/computer.git
synced 2026-05-08 08:09:43 -05:00
allow using host computer for mcp server with documentation
This commit is contained in:
@@ -1287,7 +1287,15 @@ class MacOSAutomationHandler(BaseAutomationHandler):
|
||||
if not isinstance(screenshot, Image.Image):
|
||||
return {"success": False, "error": "Failed to capture screenshot"}
|
||||
|
||||
# Resize image to reduce size (max width 1920, maintain aspect ratio)
|
||||
max_width = 1920
|
||||
if screenshot.width > max_width:
|
||||
ratio = max_width / screenshot.width
|
||||
new_height = int(screenshot.height * ratio)
|
||||
screenshot = screenshot.resize((max_width, new_height), Image.Resampling.LANCZOS)
|
||||
|
||||
buffered = BytesIO()
|
||||
# Use PNG format with optimization to reduce file size
|
||||
screenshot.save(buffered, format="PNG", optimize=True)
|
||||
buffered.seek(0)
|
||||
image_data = base64.b64encode(buffered.getvalue()).decode()
|
||||
|
||||
@@ -10,6 +10,7 @@ This module provides:
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import uuid
|
||||
import weakref
|
||||
@@ -57,7 +58,14 @@ class ComputerPool:
|
||||
logger.debug("Creating new computer instance")
|
||||
from computer import Computer
|
||||
|
||||
computer = Computer(verbosity=logging.INFO)
|
||||
# Check if we should use host computer server
|
||||
use_host = os.getenv("CUA_USE_HOST_COMPUTER_SERVER", "false").lower() in (
|
||||
"true",
|
||||
"1",
|
||||
"yes",
|
||||
)
|
||||
|
||||
computer = Computer(verbosity=logging.INFO, use_host_computer_server=use_host)
|
||||
await computer.run()
|
||||
self._in_use.add(computer)
|
||||
return computer
|
||||
|
||||
Reference in New Issue
Block a user