Image Tools Server¶
image_tools_server (doc_processing_std_tools.image_tools, MCP name image-tools) gives an agent
seven tools to crop, resize, zoom, rotate, annotate, convert and inspect images with Pillow. It needs
Pillow, which the docs and screenshot extras both install.
from doc_processing_std_tools import image_tools_server
The editing tools write a new file and return its path; they do not show the image to the model.
To let the model see the result, pass the path to read_image.
Tools¶
| Tool | Key parameters | Returns |
|---|---|---|
image_crop |
path, left, top, right, bottom, output_path, frame=0 |
Path of the cropped image (default <name>_cropped.<ext>) |
image_resize |
path, width, height, output_path, frame=0 |
Path of the resized image (default <name>_resized.<ext>). Give one dimension to keep the aspect ratio, or both for an exact size |
image_zoom |
path, region={"left", "top", "width", "height"}, zoom_factor=2.0, output_path, frame=0 |
Path of the enlarged region (default <name>_zoomed.<ext>) |
image_rotate |
path, angle (degrees, counter-clockwise), output_path, frame=0 |
Path of the rotated image (default <name>_rotated.<ext>); the canvas grows to fit |
image_annotate |
path, annotations (a JSON list), output_path, frame=0 |
Path of the annotated image (default <name>_annotated.<ext>) |
image_convert |
path, format (png, jpeg, webp, bmp, tiff), output_path, frame=0 |
Path of the converted image (default: same name with the new extension — .jpg for JPEG, .tif for TIFF) |
image_get_info |
path |
JSON: width, height, format, mode, n_frames, is_animated, file_size_bytes, file_size_human |
Annotation objects for image_annotate:
[
{"type": "rectangle", "x": 40, "y": 60, "width": 200, "height": 80, "color": "red"},
{"type": "text", "x": 40, "y": 30, "text": "Total", "font_size": 24, "color": "red"},
{"type": "circle", "cx": 300, "cy": 200, "radius": 25, "color": "blue"},
{"type": "arrow", "x1": 10, "y1": 10, "x2": 120, "y2": 90, "color": "green"}
]
How images are handled¶
- Orientation. Images are opened with their EXIF orientation applied, so coordinates match what
a viewer shows.
image_get_inforeports the corrected dimensions. - Quality and metadata. Saving keeps the ICC colour profile, EXIF data and DPI where the format allows. JPEG is written at quality 95 without chroma subsampling, WebP at quality 95.
- Format. The output format follows the output file's extension. Only
image_convertchanges the format. Converting to JPEG flattens transparency onto a white background. - Multi-frame images. For an animated GIF or a multi-page TIFF,
framepicks the frame (0-based); an out-of-range frame is an error. - Size cap. Images above about 256 million pixels are refused as likely decompression bombs.
Environment variables¶
| Variable | Default | Effect here |
|---|---|---|
DPTTOOLS_MAX_FILE_SIZE_MB |
50 |
Every tool refuses input files larger than this |
Examples¶
Tool calls are written as Python calls; the model sends the same arguments as JSON.
image_get_info(path="scan.jpg")
image_zoom(path="scan.jpg", region={"left": 800, "top": 1200, "width": 400, "height": 200}, zoom_factor=3)
image_resize(path="photo.png", width=1200, output_path="photo_small.png")
Pitfalls¶
- The default output path sits next to the input and is overwritten if it exists. Pass
output_pathto choose the location.image_convertto the format the file already has, without anoutput_path, writes over the input itself. - Coordinates are in pixels of the corrected image. Call
image_get_infofirst to learn the dimensions;image_croptakes the box's right and bottom edges, whileimage_zoomtakes a width and height. - Edits do not reach the model by themselves. Follow an edit with
read_imageon the returned path when the model needs to see it. Zooming into a region first is a cheap way to let the model read small print. - These tools do not scale for the model. They write files at the size you ask for. When the
model looks at a result through
read_image, that tool scales it to the model-safe limits (Images).