Skip to content

feat(snap-happy): Add Windows/WSL2 support and MCP tool annotations#54

Open
bryankthompson wants to merge 1 commit intobadlogic:mainfrom
bryankthompson:feat/windows-wsl2-support-and-annotations
Open

feat(snap-happy): Add Windows/WSL2 support and MCP tool annotations#54
bryankthompson wants to merge 1 commit intobadlogic:mainfrom
bryankthompson:feat/windows-wsl2-support-and-annotations

Conversation

@bryankthompson
Copy link

Summary

This PR adds comprehensive Windows and WSL2 support to snap-happy, along with MCP tool annotations and screenshot optimization options.

Changes

Windows/WSL2 Support

  • WSL2 detection via WSL_DISTRO_NAME environment variable
  • Automatic path conversion from WSL paths (/mnt/c/) to Windows paths (C:\)
  • Window-specific capture on Windows using PrintWindow Win32 API via PowerShell
  • ListWindows on Windows - enumerates visible windows with handles using PowerShell
  • PowerShell temp script handling with proper cleanup in finally blocks
  • Debug logging on stderr for troubleshooting

Screenshot Optimization Options (TakeScreenshot)

  • maxWidth/maxHeight - Resize screenshots (default: 1920x1080)
  • format - Output format (png or jpeg)
  • quality - JPEG compression quality (1-100)
  • returnPath - Return file path instead of base64 data

MCP Tool Annotations

Tool title readOnlyHint destructiveHint idempotentHint openWorldHint
GetLastScreenshot "Get Last Screenshot" true - - false
TakeScreenshot "Take Screenshot" false false false false
ListWindows "List Windows" true - - false

Files Changed

  • apps/snap-happy/src/screenshot.ts - Windows/WSL2 implementation
  • apps/snap-happy/src/tools.ts - Tool annotations and new parameters
  • apps/snap-happy/src/index.ts - Handler updates for new options

Testing

Tested on Windows 11 via WSL2 (Ubuntu). Both full-screen and window-specific captures work correctly.

Related

🤖 Generated with Claude Code

## Windows/WSL2 Support
- Add WSL2 detection via WSL_DISTRO_NAME environment variable
- Implement automatic path conversion from WSL (/mnt/c/) to Windows (C:\)
- Add window-specific capture on Windows using PrintWindow Win32 API
- Implement ListWindows on Windows via PowerShell
- Add PowerShell temp script handling with proper cleanup
- Add debug logging for troubleshooting

## Screenshot Optimization Options
- Add maxWidth/maxHeight parameters for resizing (default: 1920x1080)
- Add format option (png/jpeg)
- Add quality option for JPEG compression (1-100)
- Add returnPath option to return file path instead of base64

## MCP Tool Annotations
- Add annotations to GetLastScreenshot (readOnlyHint: true)
- Add annotations to TakeScreenshot (destructiveHint: false, idempotentHint: false)
- Add annotations to ListWindows (readOnlyHint: true)
- All tools have openWorldHint: false (local system only)

## Documentation Updates
- Update tool descriptions to mention Windows support
- Update parameter descriptions for new options

Reference implementation: https://github.com/triepod-ai/snap-happy-mcp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants