Take a screenshot of the user's screen and return it as an image. Use this tool anytime the user wants you to look at something they're doing.
()
| 14 | |
| 15 | @mcp.tool() |
| 16 | def take_screenshot() -> Image: |
| 17 | """Take a screenshot of the user's screen and return it as an image. Use |
| 18 | this tool anytime the user wants you to look at something they're doing. |
| 19 | """ |
| 20 | import pyautogui |
| 21 | |
| 22 | buffer = io.BytesIO() |
| 23 | |
| 24 | # if the file exceeds ~1MB, it will be rejected by Claude |
| 25 | screenshot = pyautogui.screenshot() |
| 26 | screenshot.convert("RGB").save(buffer, format="JPEG", quality=60, optimize=True) |
| 27 | return Image(data=buffer.getvalue(), format="jpeg") |