API & MCP

Everything a person can do on PDF Compressor, a program or AI agent can do with the same inputs and get the identical result.

HTTP API

  • POST https://pdfcompressor.usefulweb.site/api/v1/calculate – run PDF Compressor
  • GET https://pdfcompressor.usefulweb.site/api/v1/tool – inputs, output schema, examples
  • OpenAPI 3.1: /openapi.json · /openapi.yaml
  • Errors: application/problem+json; 422 includes per-field errors.

PDF Compressor

Re-writes a PDF with Ghostscript using the screen, e-book, printer or prepress preset, or your own image resolution and JPEG quality. Shows the size before and after, can compare up to three presets side by side, and renders page 1 before and after so you can judge the quality. If the result is not smaller, you get the original back.

Inputs of PDF Compressor
FieldTypeDefaultDescription
file (required)file—PDF. Max 100 MB.
presetselect (screen, ebook, printer, prepress, custom)"ebook"Compression level
comparebooleanfalseCompare up to three levels (slower). Also runs the next levels so you can download and compare each.
imageDpiinteger120Image resolution (custom)
jpegQualityinteger70JPEG quality (custom)
grayscalebooleanfalseConvert to grayscale
passwordtext—PDF password (only if the file is protected). Used only to open the file for this conversion; it is written to a private temporary file, never to a command line, and deleted with the job.

Example request

Text-only PDF with the e-book preset

curl -X POST https://pdfcompressor.usefulweb.site/api/v1/calculate -H 'content-type: application/json' -d '{"preset":"ebook","file":{"filename":"report.pdf","contentType":"application/pdf","contentBase64":"JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUiA1IDAgUl0gL0NvdW50IDIgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA3IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAxOTMgPj4Kc3RyZWFtCkJUIC9GMSAyNCBUZiA3MiA3NDIgVGQgKFF1YXJ0ZXJseSByZXBvcnQpIFRqIEVUCkJUIC9GMSAxNCBUZiA3MiA3MTIgVGQgKFJldmVudWUgZ3JldyAxMiBwZXJjZW50LikgVGogRVQKQlQgL0YxIDE0IFRmIDcyIDY4MiBUZCAoVGhpcyBzYW1wbGUgaGFzIG9ubHkgdGV4dCwgc28gdGhlcmUgaXMgbGl0dGxlIHRvIGNvbXByZXNzLikgVGogRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNTk1IDg0Ml0gL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNyAwIFIgPj4gPj4gL0NvbnRlbnRzIDYgMCBSID4+CmVuZG9iago2IDAgb2JqCjw8IC9MZW5ndGggMzkgPj4Kc3RyZWFtCkJUIC9GMSAyNCBUZiA3MiA3NDIgVGQgKFBhZ2UgdHdvKSBUaiBFVAplbmRzdHJlYW0KZW5kb2JqCjcgMCBvYmoKPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cGUgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhIC9FbmNvZGluZyAvV2luQW5zaUVuY29kaW5nID4+CmVuZG9iagp4cmVmCjAgOAowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMTUgMDAwMDAgbiAKMDAwMDAwMDA2NCAwMDAwMCBuIAowMDAwMDAwMTI3IDAwMDAwIG4gCjAwMDAwMDAyNTMgMDAwMDAgbiAKMDAwMDAwMDQ5NyAwMDAwMCBuIAowMDAwMDAwNjIzIDAwMDAwIG4gCjAwMDAwMDA3MTIgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA4IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgo4MDkKJSVFT0YK"}}'

Every result contains

inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.

MCP (Model Context Protocol)

  • Streamable HTTP endpoint: https://pdfcompressor.usefulweb.site/mcp – protocol revisions 2026-07-28 (stateless) and 2025-11-25 / 2025-06-18 / 2025-03-26 (initialize handshake).
  • Tools: pdf_compressor
  • Local stdio connector: node src/mcp-stdio.ts --tool=pdf-compressor
{
  "mcpServers": {
    "pdf-compressor": { "type": "http", "url": "https://pdfcompressor.usefulweb.site/mcp" }
  }
}