Skip to main content
Glama

Compress a PDF

compress_pdf
Idempotent

Shrink a PDF by redrawing pages as JPEGs at a chosen quality; returns before/after sizes. Use for scans and photos; text-heavy files can grow.

Instructions

Makes a PDF smaller by redrawing every page as a JPEG image at the chosen quality, and returns the size before and after. Best for scans and photo-heavy files; for documents that are mostly text it usually makes the file larger, which the result then says. The text is no longer selectable afterwards: run recognize_text on the result to make it searchable again. To get separate image files instead, use pdf_to_images. The original is not changed, and an existing output file is only replaced with overwrite: true. Encrypted PDFs cannot be compressed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path of the PDF.
outputYesAbsolute path of the new PDF. If the file exists, the call fails unless overwrite is true.
qualityNolow: 96 dpi, smallest; medium: 144 dpi (default); high: 200 dpi.
passwordNoPassword, if the PDF is encrypted. Without it an encrypted PDF cannot be opened; with it, it can be read, but tools that write a new PDF cannot save it.
overwriteNoAllow replacing an existing file (default false).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.9
    • changedInput schema / properties / output / description
      Previous value: -"Absolute path of the PDF to write."New value: +"Absolute path of the new PDF. If the file exists, the call fails unless overwrite is true."
    • changedInput schema / properties / password / description
      Previous value: -"Password, if the PDF is encrypted."New value: +"Password, if the PDF is encrypted. Without it an encrypted PDF cannot be opened; with it, it can be read, but tools that write a new PDF cannot save it."
  2. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only declare the safety profile (readOnly=false, destructive=false, idempotent=true); the description goes well beyond them by disclosing the lossy side effect (text is no longer selectable), the non-mutation of the original, the conditional replacement of the output file via overwrite, and the encrypted-input failure mode. It is consistent with the annotations rather than contradicting them.

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

Conciseness5/5

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

Effectively concise for the amount of load-bearing information: mechanism first, then suitability, then the lossy consequence and its remedy, then the sibling alternative, then file-safety semantics, then the encryption limitation. No sentence is redundant with the schema or annotations.

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

Completeness5/5

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

There is no output schema, so the description compensates by stating what is returned ('the size before and after'). Combined with the side-effect, safety, and precondition disclosures, an agent has everything needed to call this correctly on the first try.

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

Parameters3/5

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

Schema description coverage is 100%, so path, output, quality, password and overwrite are already documented with dpi values and defaults. The description reinforces overwrite and quality behavior but adds no new parameter syntax or constraints beyond the schema, so the baseline of 3 applies.

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?

States a specific verb+resource (compress a PDF) plus the exact mechanism ('redrawing every page as a JPEG image at the chosen quality'), which tells an agent how the output differs from the input. It also names the sibling pdf_to_images as the alternative for a different output shape, so it is distinguishable without opening any schema.

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

Usage Guidelines5/5

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

Explicit when-to-use ('Best for scans and photo-heavy files'), when-not ('for documents that are mostly text it usually makes the file larger'), the follow-up step ('run recognize_text on the result'), the alternative tool for a different goal (pdf_to_images), and a hard precondition (encrypted PDFs cannot be compressed). Nothing is left to inference.

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