-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from jlowin/dependencies
Support Python dependencies in Server
- Loading branch information
Showing
6 changed files
with
244 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
# /// script | ||
# dependencies = ["fastmcp", "pyautogui", "Pillow"] | ||
# /// | ||
|
||
""" | ||
FastMCP Screenshot Example | ||
Give Claude a tool to capture and view screenshots. | ||
""" | ||
|
||
import io | ||
|
||
from fastmcp import FastMCP, Image | ||
|
||
|
||
# Create server | ||
mcp = FastMCP("Screenshot Demo") | ||
mcp = FastMCP("Screenshot Demo", dependencies=["pyautogui", "Pillow"]) | ||
|
||
|
||
@mcp.tool() | ||
def take_screenshot() -> Image: | ||
"""Take a screenshot of the user's screen and return it as an 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 | ||
|
||
screenshot = pyautogui.screenshot() | ||
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.