get_web_screenshots
Retrieve screenshots from web browsing sessions to review AI agent actions and page interactions during task execution.
Instructions
Retrieve screenshots captured during a web browsing session.
Each browsing session saves screenshots of the pages visited. Use this to
review what the AI agent saw and did during task execution.
Args:
session_id: Session ID returned from browse_web or check_web_task
Returns:
Dictionary containing:
- ok: Boolean indicating success
- screenshots: List of screenshot file paths
- session_id: The session identifier
- count: Number of screenshots found
- error: Error message (if session not found)
Example:
get_web_screenshots("20251017_143022_a1b2c3d4")
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
Implementation Reference
- server.py:90-143 (handler)The handler function for the 'get_web_screenshots' MCP tool. It is registered via the @mcp.tool() decorator. Lists PNG screenshots saved in the session-specific directory under SCREENSHOT_OUTPUT_DIR, returning paths relative to the parent directory.@mcp.tool() async def get_web_screenshots(session_id: str) -> dict[str, Any]: """ Retrieve screenshots captured during a web browsing session. Each browsing session saves screenshots of the pages visited. Use this to review what the AI agent saw and did during task execution. Args: session_id: Session ID returned from browse_web or check_web_task Returns: Dictionary containing: - ok: Boolean indicating success - screenshots: List of screenshot file paths - session_id: The session identifier - count: Number of screenshots found - error: Error message (if session not found) Example: get_web_screenshots("20251017_143022_a1b2c3d4") """ logger.info(f"Retrieving screenshot history for session: {session_id}") try: from browser_agent import SCREENSHOT_OUTPUT_DIR screenshot_dir = Path(SCREENSHOT_OUTPUT_DIR) / session_id if not screenshot_dir.exists(): return { "ok": False, "error": f"No screenshots found for session {session_id}" } screenshots = sorted([ str(p.relative_to(screenshot_dir.parent)) for p in screenshot_dir.glob("*.png") ]) return { "ok": True, "screenshots": screenshots, "session_id": session_id, "count": len(screenshots) } except Exception as e: logger.error(f"Error retrieving screenshots: {e}") return { "ok": False, "error": str(e) }
- browser_agent.py:33-33 (helper)Constant defining the base directory for storing screenshots, used by the get_web_screenshots tool to locate session screenshots.SCREENSHOT_OUTPUT_DIR = os.environ.get("SCREENSHOT_OUTPUT_DIR", _default_screenshot_dir)