Skip to main content
Glama

Optimise images

optimize_images
Idempotent

Optimise images like an expert, deciding per image. Default policy "auto" writes WebP, which every current browser supports: lossy for photos, lossless or palette for screenshots and graphics, whichever is smallest at the visual target.

Instructions

Optimise images like an expert, deciding per image. Default policy "auto" writes WebP, which every current browser supports: lossy for photos, lossless or palette for screenshots and graphics, whichever is smallest at the visual target. policy "avif" also tries AVIF (smaller, needs Safari 16.4+); "picture" adds a JPEG/PNG fallback; "keep" keeps the source format. Resizing fits each image's own aspect ratio and never upscales; widths makes srcset sizes; crop makes exact shapes. Writes NEW files to "/optimized/" (or outputDir), never touching originals; re-runs skip unchanged files. Works up to 45s, then returns status "running" with a jobId: call get_job to wait for the rest. Use dryRun: true to preview decisions without encoding. Allowed directories: (none configured).

Input Schema

NameRequiredDescriptionDefault
cropNoExact output shape (e.g. 400x400 thumbnails). attention keeps faces/salient areas; entropy keeps the busiest area.
filesNoPer-file settings that override the top-level ones, e.g. [{ path: "hero.jpg", resize: { maxWidth: 1920 }, priority: true }].
limitNoItems per page in the result.
pathsNoFiles, folders or globs to optimise with the top-level settings.
dryRunNoReturn the per-image plan (class, candidates, sizes, output paths) without encoding anything.
offsetNoFirst item of the page to return (use nextOffset from the previous result).
policyNoauto (default): WebP (lossy, lossless or palette, whichever is smallest at the target); works in every current browser. avif: AVIF or WebP, whichever is smaller (often 20–30% smaller photos; AVIF needs Safari 16.4+). keep: same format as the source. picture: AVIF/WebP plus a JPEG/PNG fallback for <picture>.
resizeNoFit inside this box, keeping the aspect ratio. Never upscales.
targetNoVisual-quality target (SSIMULACRA 2). Presets for photos: small=65, balanced=75 (default), high=85, lossless-look=90; screenshots, graphics and icons get +10 (faint UI lines need it). Or an exact number 30–100 for every image.
widthsNoResponsive widths for srcset. "auto" = 640/960/1280/1920/2560 up to the image's own width. Files get a -<w>w suffix.
urlBaseNoURL prefix for generated markup, e.g. "/images/optimized".
metadataNostrip (default): remove EXIF/GPS/XMP after auto-rotating. all: keep metadata.
priorityNoMarkup only: above-the-fold image (loading="eager", fetchpriority="high").
outputDirNoDefault: an "optimized" folder inside each input folder, mirroring its structure.
response_formatNodetailed adds per-output scores, qualities and HTML markup.concise

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=false and idempotentHint=true, but the description adds substantive context beyond them: new files are written to "<input folder>/optimized/" with originals untouched, re-runs skip unchanged files, there is a 45s execution ceiling after which a jobId is returned, and the allowed-directories line flags that no directories are currently configured. These are exactly the operational constraints an agent needs before invoking a write tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense and front-loaded, leading with the default policy before enumerating variants and then the write/timeout behavior. It is on the long side and partially mirrors schema text (policies, resize semantics), but each sentence carries operational information rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 15-parameter, nested-schema, no-output-schema tool, the description covers the essentials: output location, idempotency, timeout/job handoff, dry-run preview, and the fact that no directories are configured. Minor gaps remain – urlBase, response_format, pagination (limit/offset), and metadata handling are left entirely to the schema, which does document them adequately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3; the description earns an extra point by explaining how the parameters interact rather than restating them – per-image decisions, resizing respecting each image's own aspect ratio with no upscaling, widths producing srcset sizes, crop producing exact shapes. The policy tradeoffs are also given in prose with browser-compatibility context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ("Optimise images") plus a scope qualifier ("deciding per image"), then enumerates the policies it chooses among. An agent can immediately separate it from analyze_images (read-only analysis) and get_job (job polling), which the description names explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It clearly states the default behavior (policy "auto"), when to pick alternatives ("avif" for smaller files with Safari 16.4+, "picture" for fallback markup, "keep" to preserve format), and when to use dryRun ("to preview decisions without encoding"). It also routes to get_job when the run exceeds 45s. It does not explicitly say when to prefer this over analyze_images, so it falls short of a full 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.