Embed files in a PDF
pdf_add_attachmentEmbed XML, CSV, or other files in a PDF as attachments from local paths, https URLs, or data URIs while preserving existing content and returning the updated PDF.
Instructions
Embed one or more files (for example an XML or CSV data file) in a PDF as attachments. Each entry in files has a source (a local path, an https:// URL or a data: URI with base64) and optional name, mime_type, description (at most 1,000 characters) and relationship (Alternative, Data, Source, Supplement or Unspecified, default Unspecified; the PDF/A-3 AFRelationship value). A local path must end in .xml, .csv, .json, .txt, .md, .html, .xlsx, .pdf, .png, .jpg or .jpeg and lie inside the allowed directories (PDFOPS_ROOT, default the working directory). name is 1-255 characters and at most 255 UTF-8 bytes with no / or backslash or control characters, and defaults to the file name of a path or the last part of an https:// URL path (a data: URI needs a name). mime_type looks like text/xml, with no parameters and no #. At most 10 files and 3 MB in total per call, and at most 200 attachments in the finished PDF. A PDF whose list of embedded files has over 2,000 entries (name_tree_too_large) or an unreadable existing name (attachments_too_complex) is refused. A name already used by an attachment in the PDF (as a key or as an entry's /UF or /F), or twice in the call, is refused. Existing content, including any existing attachments, is kept. Each file keeps its full name; the lookup key for qpdf --show-attachment is plain ASCII and is returned in the result as keys. Unknown keys are rejected. The whole file is saved again, so an existing digital signature on the PDF stops validating. Returns the result written to output_path, or inline as an application/pdf resource when output_path is omitted (results over 7 MB are never returned inline: pass output_path); an existing file at output_path is overwritten. The source is never modified.
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_path": "<pdf_path>",
"files": "<files>"
},
"name": "pdf_add_attachment"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | Files to embed. Nothing is added unless every entry is valid. | |
| password | No | Password to open the input, only needed for a user-password PDF (owner-locked files with an empty user password open without it). | |
| pdf_path | Yes | 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. | |
| output_path | No | 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. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | No | One entry per added file, in order: the ASCII key for qpdf --show-attachment (qpdf --list-attachments shows it) | |
| bytes | Yes | Size of the produced PDF in bytes | |
| output_path | No | Absolute path written, when output_path was supplied | |
| resource_uri | No | pdfops:// uri of the inline application/pdf resource, when output_path was omitted |