Labsco
peterparker57 logo

Screenshot MCP Server

β˜… 3

from peterparker57

Capture Windows screenshots from AI assistants in WSL, with options for specific monitors or windows.

πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

This repo is in Read Only mode and has been replaced

Use the WSLSnapIt-MCP repo instead (works better, more features!)

Screenshot MCP Server

A Model Context Protocol (MCP) server that enables AI assistants running in WSL to capture Windows screenshots with advanced features like monitor selection and window-specific capture.

Features

  • πŸ“Έ Full Desktop Capture - Capture all monitors (default behavior)
  • πŸ–₯️ Monitor Selection - Capture specific monitors (primary, 1, 2, etc.)
  • πŸͺŸ Window Capture - Capture specific windows by title match with DPI awareness
  • πŸš€ Process Capture - Capture windows by process name (e.g., notepad.exe)
  • πŸ“‚ Custom Save Locations - Save to any folder using WSL or Windows paths
  • πŸ”„ Automatic Path Conversion - Converts WSL paths to Windows paths
  • πŸ“ Organized Storage - Screenshots saved to workspace/screenshots/ by default
  • 🎯 DPI Aware - Proper scaling for high-DPI displays
  • πŸ–ΌοΈ Full Window Capture - Includes window shadows and borders without clipping

API Reference

The MCP server provides a single tool:

take_screenshot

Parameters:

  • filename (optional): Name for the screenshot file (default: "screenshot.png")
  • monitor (optional): Which monitor to capture
    • "all" - Capture all monitors (default)
    • "primary" - Capture primary monitor only
    • 1, 2, etc. - Capture specific monitor by index
  • windowTitle (optional): Capture a specific window by its title (partial match supported)
  • processName (optional): Capture a specific window by process name (e.g., "notepad.exe" or "notepad")
  • folder (optional): Custom folder path to save the screenshot
    • Supports WSL paths: /mnt/c/Users/...
    • Supports Windows paths: C:\Users\...
    • Supports relative paths: ../images
    • Default: workspace/screenshots/

Returns:

  • Success message with the file path
  • Error message if capture fails

Notes:

  • If both windowTitle and processName are provided, windowTitle takes precedence
  • Custom folders are created automatically if they don't exist
  • Path formats are automatically converted between WSL and Windows as needed

Technical Details

Architecture

  • MCP Server: Node.js with @modelcontextprotocol/sdk
  • Screenshot Capture: PowerShell with .NET Windows Forms
  • Communication: Executes PowerShell commands from WSL
  • Encoding: Base64 encoding for reliable command execution

Window Capture Features

  • DPI Awareness: Automatically handles high-DPI displays for crisp captures
  • Window Padding: Adds 10px padding to capture window shadows and borders
  • Render Wait: Waits 200ms after focusing window to ensure complete rendering
  • Bounds Checking: Prevents negative coordinates when windows are near screen edges
  • Process Matching: Intelligent process name matching (strips .exe extension automatically)

How It Works

  1. MCP server receives screenshot request from Claude
  2. Determines save location (custom folder or default)
  3. Converts paths between WSL and Windows formats as needed
  4. Constructs appropriate PowerShell script based on parameters
  5. Encodes script in base64 to avoid escaping issues
  6. Executes PowerShell command from WSL
  7. PowerShell captures screenshot using Windows Forms APIs
  8. Image is saved to the specified location

Error Handling

  • Filters PowerShell CLIXML output (verbose logging, not errors)
  • Validates monitor indices
  • Provides clear error messages for missing windows or processes
  • Lists available windows when capture fails
  • Automatically creates directories if needed
  • Handles both WSL and Windows path formats

Recent Updates

v1.2.0

  • Added custom folder support with the folder parameter
  • Supports both WSL paths (/mnt/...) and Windows paths (C:\...)
  • Automatic path conversion between WSL and Windows formats
  • Creates custom directories automatically if they don't exist
  • Maintains backward compatibility with default screenshots folder

v1.1.0

  • Added process name capture support
  • Can now capture windows by process name (e.g., "notepad.exe")
  • Intelligent .exe extension handling
  • Enhanced error messages showing available windows

v1.0.1

  • Fixed window capture clipping issues
  • Added DPI awareness for high-DPI displays
  • Added padding to capture window shadows
  • Improved window rendering wait time
  • Added bounds checking for edge cases

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Acknowledgments