mobile_take_screenshot
Capture the current Android device screen to obtain a visual representation for analysis and interaction purposes.
Instructions
Take a screenshot of the current Android screen.
Returns an image object that can be viewed by the LLM.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:270-287 (handler)The handler function for the 'mobile_take_screenshot' tool. It checks if the device is initialized, takes a screenshot using uiautomator2, saves it as PNG bytes in a BytesIO buffer, and returns it as an Image object from fastmcp.utilities.types.@mcp.tool() def mobile_take_screenshot() -> Image: """Take a screenshot of the current Android screen. Returns an image object that can be viewed by the LLM. """ if device is None: return "Error: Device not initialized. Please call mobile_init() first to establish connection with Android device." try: screenshot = device.screenshot() buf = io.BytesIO() screenshot.save(buf, format="PNG") img_bytes = buf.getvalue() return Image(data=img_bytes, format="png") except Exception as e: return f"Error taking screenshot: {str(e)}"
- main.py:270-270 (registration)The @mcp.tool() decorator registers the mobile_take_screenshot function as an MCP tool.@mcp.tool()