Spaces:
Sleeping
Sleeping
Download examples/screenshot.py from purecipher/xsecuremcp: direct link, hf CLI and curl.
- Browser
- Download file 761 Bytes
-
https://huggingface.co/spaces/purecipher/xsecuremcp/resolve/main/examples/screenshot.py
- Command line
-
hf download hf://spaces/purecipher/xsecuremcp/examples/screenshot.py
-
curl -L -o screenshot.py https://huggingface.co/spaces/purecipher/xsecuremcp/resolve/main/examples/screenshot.py
761 Bytes
| """ | |
| FastMCP Screenshot Example | |
| Give Claude a tool to capture and view screenshots. | |
| """ | |
| import io | |
| from fastmcp import FastMCP | |
| from fastmcp.utilities.types import Image | |
| # Create server | |
| mcp = FastMCP("Screenshot Demo", dependencies=["pyautogui", "Pillow"]) | |
| def take_screenshot() -> Image: | |
| """ | |
| 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. | |
| """ | |
| import pyautogui | |
| buffer = io.BytesIO() | |
| # if the file exceeds ~1MB, it will be rejected by Claude | |
| screenshot = pyautogui.screenshot() | |
| screenshot.convert("RGB").save(buffer, format="JPEG", quality=60, optimize=True) | |
| return Image(data=buffer.getvalue(), format="jpeg") | |