INNER CODE UNIT · Python

el

CursorTouch/Android-MCP · src/android_mcp/__main__.py:298

    el=device(**kwargs)
    if not el.wait(timeout=timeout):
        return f'Element not found with selectors {kwargs} within {timeout}s'
    el.click()
    return f'Clicked element matching {kwargs}'

@mcp.tool(
    name="Snapshot",
    description="Get the state of the device. Optionally includes visual screenshot when use_vision=True. The use_annotation parameter (default True) can be set to False to get a clean screenshot without bounding boxes.",
    annotations=ToolAnnotations(title="Snapshot", readOnlyHint=True),
)
def state_tool(use_vision: bool = False, use_annotation: bool = True):
    require_device()
    mobile_state = mobile.get_state(
        use_vision=use_vision, use_annotation=use_annotation, as_bytes=True
    )
    return [mobile_state.tree_state.to_string()] + (
        [Image(data=mobile_state.screenshot, format="PNG")] if use_vision else []

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…