Skip to main content
Glama

capture_full_screen

Capture the entire screen as a screenshot with Auto-Snap MCP. Save the image to a specified path and receive a JSON response with results and file details for easy integration.

Instructions

Capture screenshot of the entire screen. Args: output_path: Optional path to save the screenshot Returns: JSON string with capture results and file path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_pathNo

Implementation Reference

  • MCP tool handler function that registers and executes the capture_full_screen tool. Delegates to CrossPlatformWindowManager and formats response as JSON.
    @mcp.tool() async def capture_full_screen(output_path: Optional[str] = None) -> str: """ Capture screenshot of the entire screen. Args: output_path: Optional path to save the screenshot Returns: JSON string with capture results and file path. """ try: wm = get_window_manager() captured_path = wm.capture_full_screen(output_path) result = { "status": "success", "output_path": captured_path, "file_exists": Path(captured_path).exists(), "file_size_mb": round(Path(captured_path).stat().st_size / (1024 * 1024), 2) } return json.dumps(result, indent=2) except Exception as e: logger.error(f"Failed to capture full screen: {e}") return json.dumps({ "status": "error", "error": str(e), "output_path": output_path })
  • Core implementation of full screen capture in WindowsWindowManager using PowerShell to grab screen via System.Drawing and save via temp file copy from WSL.
    def capture_full_screen(self, output_path: Optional[str] = None) -> str: """ Capture full screen screenshot using PowerShell from WSL2. """ if not self.powershell_available: raise Exception("PowerShell not available - cannot capture full screen") logger.info("Capturing full screen using PowerShell...") try: # PowerShell script to capture full screen ps_script = ''' Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # Get primary screen dimensions $primaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen $bounds = $primaryScreen.Bounds $width = $bounds.Width $height = $bounds.Height Write-Verbose "Screen dimensions: ${width}x${height}" # Capture full screen $bitmap = New-Object System.Drawing.Bitmap($width, $height) $graphics = [System.Drawing.Graphics]::FromImage($bitmap) $graphics.CopyFromScreen(0, 0, 0, 0, [System.Drawing.Size]::new($width, $height)) $graphics.Dispose() # Save to temporary file in Windows temp directory $tempPath = [System.IO.Path]::GetTempFileName() + ".png" $bitmap.Save($tempPath, [System.Drawing.Imaging.ImageFormat]::Png) $bitmap.Dispose() Write-Output $tempPath ''' result = subprocess.run( ['powershell.exe', '-Command', ps_script], capture_output=True, text=True, check=True, timeout=30 # 30 second timeout for full screen capture ) temp_windows_path = result.stdout.strip() if not temp_windows_path: raise Exception("PowerShell did not return temp file path") # Convert Windows path to WSL path wsl_temp_path = self._windows_path_to_wsl(temp_windows_path) if output_path is None: timestamp = int(time.time()) output_path = f"fullscreen_{timestamp}.png" # Copy from Windows temp to desired location subprocess.run(['cp', wsl_temp_path, output_path], check=True) # Clean up Windows temp file subprocess.run( ['powershell.exe', '-Command', f'Remove-Item "{temp_windows_path}" -Force'], check=False # Don't fail if cleanup fails ) logger.info(f"Full screen captured: {output_path}") return output_path except subprocess.TimeoutExpired: logger.error("PowerShell full screen capture timed out after 30 seconds") raise Exception("Full screen capture timeout") except subprocess.CalledProcessError as e: logger.error(f"Failed to capture full screen: {e}") raise except Exception as e: logger.error(f"Full screen capture failed: {e}") raise
  • CrossPlatformWindowManager method that delegates full screen capture to the platform-specific manager or falls back to pyscreenshot.ImageGrab.grab().
    def capture_full_screen(self, output_path: Optional[str] = None) -> str: """Capture full screen screenshot.""" if hasattr(self.manager, 'capture_full_screen'): return self.manager.capture_full_screen(output_path) else: # Fallback using pyscreenshot try: screenshot = ImageGrab.grab() if output_path is None: timestamp = int(time.time()) output_path = f"screenshot_{timestamp}.png" screenshot.save(output_path) logger.info(f"Full screen captured: {output_path}") return output_path except Exception as e: logger.error(f"Failed to capture full screen: {e}") raise
  • Linux-specific full screen capture implementation in WindowCapture using pyscreenshot.ImageGrab.grab().
    def capture_full_screen(self, output_path: Optional[str] = None) -> str: """ Capture full screen screenshot. """ try: screenshot = ImageGrab.grab() if output_path is None: timestamp = int(time.time()) output_path = f"screenshot_{timestamp}.png" screenshot.save(output_path) logger.info(f"Full screen captured: {output_path}") return output_path except Exception as e: logger.error(f"Failed to capture full screen: {e}") raise

Other Tools

Related 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/PovedaAqui/auto-snap-mcp'

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