write-pdf-metadata
Add or modify metadata in PDF files, including Title, Author, Subject, and Keywords, using URLs or base64-encoded inputs for streamlined document processing.
Instructions
Write metadata to PDF files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | Array of URLs or base64-encoded PDFs | |
| inputMethod | Yes | Input method | |
| metadata | Yes | Metadata to write |
Implementation Reference
- src/index.ts:838-852 (handler)The handler function that implements the tool logic by proxying requests to the external Dumpling AI API endpoint for writing PDF metadata.async ({ inputMethod, files, metadata }) => { 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/write-pdf-metadata`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ inputMethod, files, metadata }), }); 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:824-837 (schema)Zod schema defining the input parameters for the write-pdf-metadata tool: inputMethod (url or base64), files (array of PDFs), and metadata object.{ 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(), Creator: z.string().optional(), Producer: z.string().optional(), }) .describe("Metadata to write"), },
- src/index.ts:821-854 (registration)The complete MCP server.tool registration call for the 'write-pdf-metadata' tool, specifying name, description, input schema, and handler function.server.tool( "write-pdf-metadata", "Write metadata to PDF files.", { 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(), Creator: z.string().optional(), Producer: z.string().optional(), }) .describe("Metadata to write"), }, async ({ inputMethod, files, metadata }) => { 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/write-pdf-metadata`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ inputMethod, files, metadata }), }); 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) }] }; } );