README - replace code snippets with examples (#1136)
This commit is contained in:
parent
49991fd2c7
commit
9bf5160eea
1 changed files with 585 additions and 169 deletions
15
examples/snippets/servers/images.py
Normal file
15
examples/snippets/servers/images.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"""Example showing image handling with FastMCP."""
|
||||
|
||||
from PIL import Image as PILImage
|
||||
|
||||
from mcp.server.fastmcp import FastMCP, Image
|
||||
|
||||
mcp = FastMCP("Image Example")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def create_thumbnail(image_path: str) -> Image:
|
||||
"""Create a thumbnail from an image"""
|
||||
img = PILImage.open(image_path)
|
||||
img.thumbnail((100, 100))
|
||||
return Image(data=img.tobytes(), format="png")
|
||||
Loading…
Reference in a new issue