MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / take_screenshot

Function take_screenshot

examples/mcpserver/screenshot.py:16–27  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

14
15@mcp.tool()
16def 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")

Callers

nothing calls this directly

Calls 2

ImageClass · 0.90
saveMethod · 0.80

Tested by

no test coverage detected