1b74b06753
Cut comment and docstring volume roughly in half across src, tests, examples, and docs_src: removed comments that restate the adjacent code, leftover development narration, section banners, and self-evident Args/Returns blocks, and compressed the remaining docstrings to a Google-style summary line plus only the detail that earns its place. Kept (and tightened) the load-bearing content: Raises sections, deprecation and version-availability notes, spec/RFC/issue references, why-comments for non-obvious decisions, and all coverage pragmas. The generated mcp_types.v* wire modules are untouched.
24 lines
704 B
Python
24 lines
704 B
Python
"""Give Claude a tool to capture and view screenshots."""
|
|
|
|
import io
|
|
|
|
from mcp.server.mcpserver import MCPServer
|
|
from mcp.server.mcpserver.utilities.types import Image
|
|
|
|
mcp = MCPServer("Screenshot Demo")
|
|
|
|
|
|
@mcp.tool()
|
|
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")
|