Skip to main content
Glama
0xhackerfren

Frida Game Hacking MCP

by 0xhackerfren

screenshot_window

Capture screenshots of specific game windows for analysis in game hacking and reverse engineering workflows. Save images as PNG files or get base64 data for further processing.

Instructions

Take a screenshot of a specific window.

Args:
    target: Window title (string) or HWND handle (integer)
    save_path: Optional path to save the screenshot (PNG). If empty, returns base64.

Returns:
    Screenshot info with base64 data or saved file path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYes
save_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'screenshot_window' tool. It captures a screenshot of a specified window using Windows API (win32gui, win32ui) and PIL for image processing, supporting both base64 output and file saving.
    @mcp.tool()
    def screenshot_window(target: Union[str, int], save_path: str = "") -> Dict[str, Any]:
        """
        Take a screenshot of a specific window.
        
        Args:
            target: Window title (string) or HWND handle (integer)
            save_path: Optional path to save the screenshot (PNG). If empty, returns base64.
        
        Returns:
            Screenshot info with base64 data or saved file path.
        """
        if not SCREENSHOT_AVAILABLE:
            return {"error": "Screenshot support not available. Install: pip install pywin32 pillow"}
        
        try:
            # Find the window
            hwnd = None
            if isinstance(target, int):
                hwnd = target
            else:
                def find_window(h, _):
                    nonlocal hwnd
                    if win32gui.IsWindowVisible(h):
                        title = win32gui.GetWindowText(h)
                        if title and target.lower() in title.lower():
                            hwnd = h
                            return False
                    return True
                win32gui.EnumWindows(find_window, None)
            
            if not hwnd:
                return {"error": f"Window not found: {target}"}
            
            # Get window dimensions
            rect = win32gui.GetWindowRect(hwnd)
            width = rect[2] - rect[0]
            height = rect[3] - rect[1]
            
            if width <= 0 or height <= 0:
                return {"error": "Window has invalid dimensions"}
            
            # Capture the window
            hwnd_dc = win32gui.GetWindowDC(hwnd)
            mfc_dc = win32ui.CreateDCFromHandle(hwnd_dc)
            save_dc = mfc_dc.CreateCompatibleDC()
            
            bitmap = win32ui.CreateBitmap()
            bitmap.CreateCompatibleBitmap(mfc_dc, width, height)
            save_dc.SelectObject(bitmap)
            
            # Try PrintWindow first (works for most windows)
            result = ctypes.windll.user32.PrintWindow(hwnd, save_dc.GetSafeHdc(), 2)
            
            if result == 0:
                # Fallback to BitBlt
                save_dc.BitBlt((0, 0), (width, height), mfc_dc, (0, 0), win32con.SRCCOPY)
            
            # Convert to PIL Image
            bmp_info = bitmap.GetInfo()
            bmp_str = bitmap.GetBitmapBits(True)
            
            img = Image.frombuffer(
                'RGB',
                (bmp_info['bmWidth'], bmp_info['bmHeight']),
                bmp_str, 'raw', 'BGRX', 0, 1
            )
            
            # Cleanup
            win32gui.DeleteObject(bitmap.GetHandle())
            save_dc.DeleteDC()
            mfc_dc.DeleteDC()
            win32gui.ReleaseDC(hwnd, hwnd_dc)
            
            # Save or return base64
            if save_path:
                img.save(save_path, 'PNG')
                return {
                    "success": True,
                    "path": save_path,
                    "width": width,
                    "height": height,
                    "window_title": win32gui.GetWindowText(hwnd)
                }
            else:
                buffer = io.BytesIO()
                img.save(buffer, format='PNG')
                img_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
                
                return {
                    "success": True,
                    "width": width,
                    "height": height,
                    "window_title": win32gui.GetWindowText(hwnd),
                    "image_base64": img_base64,
                    "format": "png"
                }
        
        except Exception as e:
            return {"error": f"Screenshot failed: {str(e)}"}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool captures screenshots, accepts window titles or handles, and outputs base64 or file paths. However, it misses important details like permissions needed, whether it requires window focus, error conditions, or performance implications.

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 front-loaded with the core purpose, followed by well-structured sections for Args and Returns. Every sentence earns its place by providing essential information without redundancy. The formatting with clear headings enhances readability.

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

Completeness4/5

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

Given the tool's moderate complexity, no annotations, and the presence of an output schema (which handles return values), the description is reasonably complete. It covers purpose, parameters, and output behavior adequately, though could benefit from more behavioral context like error handling or prerequisites.

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 description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'target' can be a window title string or HWND handle integer, and clarifies that 'save_path' being empty triggers base64 return. This compensates well for the schema's lack of descriptions.

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 ('Take a screenshot') and resource ('of a specific window'), distinguishing it from sibling tools like 'screenshot_screen' which captures the entire screen. The verb+resource combination is precise and unambiguous.

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 for capturing window-specific screenshots, with the 'save_path' parameter guidance suggesting when to use base64 vs file output. However, it lacks explicit guidance on when to choose this tool over alternatives like 'screenshot_screen' or other window-related tools in the sibling list.

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/0xhackerfren/frida-game-hacking-mcp'

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