Skip to main content
Glama

Merge PDFs

pdf_merge
DestructiveIdempotent

Combine two or more PDFs into one document in the given order, then save it to a path or return it inline. Source files stay unchanged and an existing output file is overwritten.

Instructions

Merge two or more PDFs into one, in the order given, and save or return the result. Source files are read only and never modified; an existing file at output_path is overwritten. Returns the merged PDF written to output_path, or inline as an application/pdf resource when output_path is omitted. This tool only concatenates whole documents: it does not reorder, rotate or delete pages within them (pdf_extract_pages, pdf_rotate and pdf_delete_pages do), does not fill forms (pdf_fill does) and does not build documents from data (pdf_invoice does). An unreadable or rejected input fails with an error and writes no file, so a partial merge is never left behind.

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": {
      "pdf_paths": "<pdf_paths>"
    },
    "name": "pdf_merge"
  }
}

Input Schema

NameRequiredDescriptionDefault
passwordNoPassword to open the input, only needed for a user-password PDF (owner-locked files with an empty user password open without it). Applies to every input.
pdf_pathsYesIn order, each a PDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. A URL or data URI works when this server runs remotely (Smithery, hosted gateways), where local paths do not exist.
output_pathNoPath of a .pdf file to write the result to, inside the allowed directories (PDFOPS_ROOT, default the working directory); an existing file there is overwritten. Without it (as when running remotely) the PDF is returned inline as an application/pdf resource for the client to save.

Output Schema

NameRequiredDescriptionDefault
bytesYesSize of the produced PDF in bytes
output_pathNoAbsolute path written, when output_path was supplied
resource_uriNopdfops:// uri of the inline application/pdf resource, when output_path was omitted

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.6.0
    • changedInput schema / properties / output_path / description
      Previous value: -"Path of a .pdf file to write the result to, inside the allowed directories (PDFOPS_ROOT, default the working directory); an existing file there is overwritten. Omit when running remotely: the PDF is then returned inline as an application/pdf resource for the client to save."New value: +"Path of a .pdf file to write the result to, inside the allowed directories (PDFOPS_ROOT, default the working directory); an existing file there is overwritten. Without it (as when running remotely) the PDF is returned inline as an application/pdf resource for the client to save."
    • changedInput schema / properties / pdf_paths / description
      Previous value: -"In order, each a PDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. Use a URL or data URI when this server runs remotely (Smithery, hosted gateways) where local paths do not exist."New value: +"In order, each a PDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. A URL or data URI works when this server runs remotely (Smithery, hosted gateways), where local paths do not exist."
  2. Changed7 schema fields changedv0.5.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedInput schema / properties / output_path / description
      Previous value: -"Absolute path to write the result. Omit when running remotely: the PDF is then returned inline as an application/pdf resource for the client to save."New value: +"Path of a .pdf file to write the result to, inside the allowed directories (PDFOPS_ROOT, default the working directory); an existing file there is overwritten. Omit when running remotely: the PDF is then returned inline as an application/pdf resource for the client to save."
    • addedInput schema / properties / password
      Added value: +{
      +  "description": "Password to open the input, only needed for a user-password PDF (owner-locked files with an empty user password open without it). Applies to every input.",
      +  "type": "string"
      +}
    • changedInput schema / properties / pdf_paths / description
      Previous value: -"In order, each a PDF source: an absolute file path, an https:// URL, or a data:application/pdf;base64,… URI. Use a URL or data URI when this server runs remotely (Smithery, hosted gateways) where local paths do not exist."New value: +"In order, each a PDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. Use a URL or data URI when this server runs remotely (Smithery, hosted gateways) where local paths do not exist."
    • addedInput schema / properties / pdf_paths / maxItems
      Added value: +20
    • addedOutput schema / properties / bytes / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / bytes / minimum
      Added value: +-9007199254740991
  3. Changed4 schema fields changedv0.3.2
    • changedInput schema / properties / output_path / description
      Previous value: -"Absolute path to write the merged PDF"New value: +"Absolute path to write the result. Omit when running remotely: the PDF is then returned inline as an application/pdf resource for the client to save."
    • changedInput schema / properties / pdf_paths / description
      Previous value: -"Absolute paths of the PDFs to merge, in order"New value: +"In order, each a PDF source: an absolute file path, an https:// URL, or a data:application/pdf;base64,… URI. Use a URL or data URI when this server runs remotely (Smithery, hosted gateways) where local paths do not exist."
    • changedInput schema / required
      Previous value: -[
      -  "pdf_paths",
      -  "output_path"
      -]New value: +[
      +  "pdf_paths"
      +]
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "bytes": {
      +      "description": "Size of the produced PDF in bytes",
      +      "type": "integer"
      +    },
      +    "output_path": {
      +      "description": "Absolute path written, when output_path was supplied",
      +      "type": "string"
      +    },
      +    "resource_uri": {
      +      "description": "pdfops:// uri of the inline application/pdf resource, when output_path was omitted",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "bytes"
      +  ],
      +  "type": "object"
      +}
  4. First observedv0.2.0

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the destructiveHint=true annotation it explains precisely what is destroyed (an existing file at output_path) and what is not (source files are read-only). It also discloses failure atomicity — an unreadable or rejected input writes no file, so no partial merge is left behind — which is behavior no annotation conveys.

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?

It is front-loaded with the action and return modes, then the exclusions, then failure semantics — a logical order with no filler. The middle sentence is long and packs five negative clauses; it is information-dense but slightly harder to scan than it could be.

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?

For a three-parameter tool with full schema coverage, an output schema, and no nested objects, nothing material is missing: source locations, overwrite risk, return path, atomicity and sibling routing are all covered. Return values need not be explained further given the output schema.

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 100%, so pdf_paths, output_path and password are already fully documented, including source types, overwrite behavior and the password scope. The description only echoes order and overwrite semantics already present in the schema, adding no new syntax or constraint detail beyond the 2-20 item bounds stated there.

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 first sentence gives a specific verb and resource ("Merge two or more PDFs into one, in the order given") plus the output modes (save or return). It then draws explicit boundaries against pdf_extract_pages, pdf_rotate, pdf_delete_pages, pdf_fill and pdf_invoice, so an agent can distinguish it from siblings without opening a 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?

It states both the negative cases (no reordering/rotating/deleting inside documents, no form filling, no document generation) and names the sibling tool that handles each. The condition selecting this tool over those is unambiguous: concatenate whole documents only.

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