Skip to main content
Glama
Paperboy

Paperboy

Official
by sudostash

optimize_pdf

DestructiveIdempotent

Shrink PDF files by linearizing for web view, recompressing streams, and lowering image DPI or targeting a size limit while keeping text and drawings sharp.

Instructions

Shrink a PDF: linearize ("fast web view"), recompress object streams and, if asked, lower the resolution of its pictures (max_image_dpi), or keep lowering it until the file fits a size (target_size_mb, down to 72 dpi). Text and drawings stay sharp, except in scans, where the text is itself a picture and can become hard to read at low resolutions. Pictures whose placement can't be worked out, masks, palettes and CMYK are left as they are. Lowering resolution needs the owner password if the PDF forbids changes. Signed PDFs are refused.

Any password argument can be "ask": the user then types it on a local page, so it never passes through the chat.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "input_path": "<input_path>"
    },
    "name": "optimize_pdf"
  }
}

Input Schema

NameRequiredDescriptionDefault
compressNo
passwordNo
linearizeNo
overwriteNo
input_pathYes
output_pathNo
max_image_dpiNoLower the resolution of pictures drawn sharper than this many dots per inch (150 suits screens, 300 print). Lossy; leave out to keep pictures as they are.
target_size_mbNoKeep lowering picture resolution and JPEG quality until the file is at most this many MB (1 MB = 1,000,000 bytes). Lossy. The smallest result is saved even if the target can't be met; check target_met.

Output Schema

NameRequiredDescriptionDefault
pagesYes
outputYes
image_dpiYes
linearizedYes
size_afterYes
target_metYes
saved_bytesYes
size_beforeYes
images_resampledYes
target_size_bytesYes
password_protectedYes
user_password_changedYes
permissions_restrictedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.1.1
    • addedInput schema / properties / max_image_dpi
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maximum": 1200,
      +      "minimum": 36,
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Lower the resolution of pictures drawn sharper than this many dots per inch (150 suits screens, 300 print). Lossy; leave out to keep pictures as they are.",
      +  "title": "Max Image Dpi"
      +}
    • addedInput schema / properties / target_size_mb
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maximum": 100000,
      +      "minimum": 0.01,
      +      "type": "number"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Keep lowering picture resolution and JPEG quality until the file is at most this many MB (1 MB = 1,000,000 bytes). Lossy. The smallest result is saved even if the target can't be met; check target_met.",
      +  "title": "Target Size Mb"
      +}
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "image_dpi": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "title": "Image Dpi"
      +    },
      +    "images_resampled": {
      +      "title": "Images Resampled",
      +      "type": "integer"
      +    },
      +    "linearized": {
      +      "title": "Linearized",
      +      "type": "boolean"
      +    },
      +    "output": {
      +      "title": "Output",
      +      "type": "string"
      +    },
      +    "pages": {
      +      "title": "Pages",
      +      "type": "integer"
      +    },
      +    "password_protected": {
      +      "title": "Password Protected",
      +      "type": "boolean"
      +    },
      +    "permissions_restricted": {
      +      "title": "Permissions Restricted",
      +      "type": "boolean"
      +    },
      +    "saved_bytes": {
      +      "title": "Saved Bytes",
      +      "type": "integer"
      +    },
      +    "size_after": {
      +      "title": "Size After",
      +      "type": "integer"
      +    },
      +    "size_before": {
      +      "title": "Size Before",
      +      "type": "integer"
      +    },
      +    "target_met": {
      +      "anyOf": [
      +        {
      +          "type": "boolean"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "title": "Target Met"
      +    },
      +    "target_size_bytes": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "title": "Target Size Bytes"
      +    },
      +    "user_password_changed": {
      +      "title": "User Password Changed",
      +      "type": "boolean"
      +    }
      +  },
      +  "required": [
      +    "password_protected",
      +    "permissions_restricted",
      +    "user_password_changed",
      +    "output",
      +    "pages",
      +    "size_before",
      +    "size_after",
      +    "saved_bytes",
      +    "linearized",
      +    "images_resampled",
      +    "image_dpi",
      +    "target_size_bytes",
      +    "target_met"
      +  ],
      +  "title": "OptimizeResult",
      +  "type": "object"
      +}
  2. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/5

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

Annotations already flag destructiveHint=true and idempotent=true; the description adds substantial context beyond that: which PDF elements are left untouched (masks, palettes, CMYK, unplaceable images), the readability risk for scanned text at low DPI, the owner-password requirement, and refusal of signed files. The "ask" password mechanism also discloses a security-relevant execution path the annotations say nothing about.

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 core action is front-loaded and every clause carries content (scope, lossy caveats, exceptions, password handling). It is dense to the point of reading as a wall of text, but nothing is filler and no sentence merely restates the name.

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 destructive 8-parameter mutation tool it covers effects, exceptions, credential needs, and points to the target_met output field rather than re-describing the return schema. The remaining hole is overwrite semantics, which matters given destructiveHint=true and a null default.

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 coverage is only 25%, so the description must carry weight; it does explain compress, linearize ("fast web view"), password including the "ask" sentinel, and reinforces the two sizing parameters. However, overwrite and output_path get no treatment at all, leaving a destructive tool's overwrite behavior and destination defaults ambiguous.

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 and resource ("Shrink a PDF") then enumerates the exact operations: linearize, recompress object streams, and optionally downscale images. No sibling in the catalog performs size reduction, and the definition makes the tool's scope unambiguous.

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?

Explains the two operating modes tied to parameters: a fixed resolution cap via max_image_dpi, or iterating down to target_size_mb ("down to 72 dpi"). It also states prerequisites (owner password needed to downscale a change-protected PDF) and an exclusion (signed PDFs are refused), but gives no explicit routing against sibling tools.

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