pdfops-mcp 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +12 -12
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ claude mcp add pdfops -- npx -y pdfops-mcp
|
|
|
33
33
|
| Tool | What it does |
|
|
34
34
|
|---|---|
|
|
35
35
|
| `pdf_inspect` | List a PDF's form fields (names, types, options, values) + a paste-ready fill template. Call first on unfamiliar PDFs. |
|
|
36
|
-
| `pdf_fill` | Fill AcroForm fields → write the filled PDF. |
|
|
36
|
+
| `pdf_fill` | Fill AcroForm fields → write the filled PDF. Optional `flatten` bakes values in and drops the form. |
|
|
37
37
|
| `pdf_merge` | Merge ≥2 PDFs in order → write the result. |
|
|
38
38
|
| `pdf_invoice` | Structured data → complete invoice PDF. Deterministic: same input, byte-identical output. |
|
|
39
39
|
| `pdfops_usage` | Quota check for the configured key. |
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
2
|
+
#!/usr/bin/env node
|
|
4
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
5
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
6
|
import { z } from "zod";
|
|
8
7
|
import { PdfOps, PdfOpsError } from "pdfops-sdk";
|
|
9
|
-
|
|
8
|
+
const client = new PdfOps({
|
|
10
9
|
apiKey: process.env.PDFOPS_API_KEY,
|
|
11
10
|
baseUrl: process.env.PDFOPS_BASE_URL,
|
|
12
11
|
clientTag: "mcp"
|
|
13
12
|
});
|
|
14
|
-
|
|
13
|
+
const server = new McpServer({
|
|
15
14
|
name: "pdfops",
|
|
16
|
-
version: "0.1.
|
|
15
|
+
version: "0.1.1"
|
|
17
16
|
});
|
|
18
|
-
|
|
17
|
+
const errText = (e) => e instanceof PdfOpsError ? `PDFops API error ${e.status} (${e.code}): ${e.message}` + (e.code === "rate_limited" ? " \u2014 get a free API key (250/mo) at https://pdfops.dev/pricing and set PDFOPS_API_KEY" : "") : String(e);
|
|
19
18
|
server.tool(
|
|
20
19
|
"pdf_inspect",
|
|
21
|
-
"List a PDF's AcroForm form fields \u2014 names, types, options, current values \u2014 plus a paste-ready fillTemplate object for pdf_fill. A PDF with no form returns count 0. Call this FIRST when filling an unfamiliar PDF: you cannot fill fields whose names you do not know.",
|
|
20
|
+
"List a PDF's AcroForm form fields \u2014 names, types, options, current values, per-field maxLength where declared \u2014 plus a paste-ready fillTemplate object for pdf_fill and a hasXFA flag (hybrid AcroForm/XFA inputs lose their XFA layer when filled). A PDF with no form returns count 0. Call this FIRST when filling an unfamiliar PDF: you cannot fill fields whose names you do not know, and values longer than a field's maxLength are rejected.",
|
|
22
21
|
{ pdf_path: z.string().describe("Absolute path to the PDF to inspect") },
|
|
23
22
|
async ({ pdf_path }) => {
|
|
24
23
|
try {
|
|
@@ -31,15 +30,16 @@ server.tool(
|
|
|
31
30
|
);
|
|
32
31
|
server.tool(
|
|
33
32
|
"pdf_fill",
|
|
34
|
-
`Fill AcroForm form fields in a PDF and save the result. Field names must exist in the PDF (use pdf_inspect first). All values are strings; checkboxes take "true"/"false"; dropdown/radio/optionlist values must be one of the field's options.`,
|
|
33
|
+
`Fill AcroForm form fields in a PDF and save the result. Field names must exist in the PDF (use pdf_inspect first). All values are strings; checkboxes take "true"/"false"; dropdown/radio/optionlist values must be one of the field's options; text values must respect the field's maxLength from pdf_inspect. Encrypted PDFs are rejected with decrypt advice (common for government blanks with an empty user password).`,
|
|
35
34
|
{
|
|
36
35
|
pdf_path: z.string().describe("Absolute path to the template PDF"),
|
|
37
36
|
fields: z.record(z.string()).describe("Field name \u2192 string value (from pdf_inspect's fillTemplate)"),
|
|
38
|
-
output_path: z.string().describe("Absolute path to write the filled PDF")
|
|
37
|
+
output_path: z.string().describe("Absolute path to write the filled PDF"),
|
|
38
|
+
flatten: z.boolean().optional().describe("Bake values into page content and drop the AcroForm so fields are no longer editable")
|
|
39
39
|
},
|
|
40
|
-
async ({ pdf_path, fields, output_path }) => {
|
|
40
|
+
async ({ pdf_path, fields, output_path, flatten }) => {
|
|
41
41
|
try {
|
|
42
|
-
const bytes = await client.fillForm(await readFile(pdf_path), fields);
|
|
42
|
+
const bytes = await client.fillForm(await readFile(pdf_path), fields, { flatten });
|
|
43
43
|
await writeFile(output_path, bytes);
|
|
44
44
|
return {
|
|
45
45
|
content: [
|
|
@@ -129,5 +129,5 @@ server.tool(
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
|
-
|
|
132
|
+
const transport = new StdioServerTransport();
|
|
133
133
|
await server.connect(transport);
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfops-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"mcpName": "dev.pdfops/pdfops-mcp",
|
|
4
5
|
"description": "MCP server for the PDFops API \u2014 give AI agents deterministic PDF tools: inspect AcroForm fields, fill forms, merge PDFs, and generate invoices. Works with Claude Code, Claude Desktop, Cursor, and any MCP client.",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"mcp",
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
"cursor"
|
|
16
17
|
],
|
|
17
18
|
"homepage": "https://pdfops.dev",
|
|
18
|
-
"bugs": "
|
|
19
|
+
"bugs": "https://github.com/pdfops/pdfops-mcp/issues",
|
|
19
20
|
"author": "PDFops <hello@pdfops.dev> (https://pdfops.dev)",
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"type": "module",
|
|
@@ -31,7 +32,11 @@
|
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
34
|
-
"pdfops-sdk": "^0.
|
|
35
|
+
"pdfops-sdk": "^0.4.0",
|
|
35
36
|
"zod": "^3.23.0"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/pdfops/pdfops-mcp.git"
|
|
36
41
|
}
|
|
37
42
|
}
|