merge-pdfs
Combine multiple PDF files into a single document with configurable metadata and compliance options.
Instructions
Combine multiple PDF files into a single document.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputMethod | Yes | Input method | |
| files | Yes | Array of URLs or base64-encoded PDFs | |
| metadata | No | Metadata for merged PDF | |
| pdfa | No | PDF/A compliance | |
| pdfua | No | PDF/UA compliance | |
| requestSource | No | Request source |
Implementation Reference
- src/index.ts:596-618 (handler)The handler function for the 'merge-pdfs' tool. It proxies the request to an external API at NWS_API_BASE/api/v1/merge-pdfs using the provided input parameters, handles authentication with DUMPLING_API_KEY, and returns the JSON response.async ({ inputMethod, files, metadata, pdfa, pdfua, requestSource }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/merge-pdfs`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ inputMethod, files, metadata, pdfa, pdfua, requestSource, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/index.ts:577-595 (schema)Zod schema defining the input parameters for the 'merge-pdfs' tool: inputMethod (url or base64), files (array of strings), optional metadata object, pdfa compliance option, pdfua boolean, and requestSource.{ inputMethod: z.enum(["url", "base64"]).describe("Input method"), files: z.array(z.string()).describe("Array of URLs or base64-encoded PDFs"), metadata: z .object({ Title: z.string().optional(), Author: z.string().optional(), Subject: z.string().optional(), Keywords: z.string().optional(), }) .optional() .describe("Metadata for merged PDF"), pdfa: z .enum(["PDF/A-1b", "PDF/A-2b", "PDF/A-3b"]) .optional() .describe("PDF/A compliance"), pdfua: z.boolean().optional().describe("PDF/UA compliance"), requestSource: z.string().optional().describe("Request source"), },
- src/index.ts:574-619 (registration)The server.tool call that registers the 'merge-pdfs' tool with its name, description, input schema, and handler function.server.tool( "merge-pdfs", "Combine multiple PDF files into a single document.", { inputMethod: z.enum(["url", "base64"]).describe("Input method"), files: z.array(z.string()).describe("Array of URLs or base64-encoded PDFs"), metadata: z .object({ Title: z.string().optional(), Author: z.string().optional(), Subject: z.string().optional(), Keywords: z.string().optional(), }) .optional() .describe("Metadata for merged PDF"), pdfa: z .enum(["PDF/A-1b", "PDF/A-2b", "PDF/A-3b"]) .optional() .describe("PDF/A compliance"), pdfua: z.boolean().optional().describe("PDF/UA compliance"), requestSource: z.string().optional().describe("Request source"), }, async ({ inputMethod, files, metadata, pdfa, pdfua, requestSource }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/merge-pdfs`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ inputMethod, files, metadata, pdfa, pdfua, requestSource, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );