@exactpdf/mcp 0.2.10 → 0.2.11
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 +2 -0
- package/dist/run.js +95 -2
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -66,10 +66,12 @@ Document outputs are saved to `EXACTPDF_API_OUTPUT_DIR` or your OS temp director
|
|
|
66
66
|
| `exactpdf_account` | GET /api/v1/account | 0 |
|
|
67
67
|
| `exactpdf_pdf_info` | POST /api/v1/pdf-info | 0 |
|
|
68
68
|
| `exactpdf_merge_pdfs` | POST /api/v1/merge | 1 |
|
|
69
|
+
| `exactpdf_merge_and_compress_pdfs` | POST /api/v1/merge-compress | 1 |
|
|
69
70
|
| `exactpdf_split_pdf` | POST /api/v1/split | 1 |
|
|
70
71
|
| `exactpdf_rotate_pdf` | POST /api/v1/rotate | 1 |
|
|
71
72
|
| `exactpdf_compress_pdf` | POST /api/v1/compress | 1 |
|
|
72
73
|
| `exactpdf_images_to_pdf` | POST /api/v1/images-to-pdf | 1 |
|
|
74
|
+
| `exactpdf_images_to_pdf_and_compress` | POST /api/v1/images-to-pdf-compress | 1 |
|
|
73
75
|
| `exactpdf_extract_text` | POST /api/v1/extract-text | 1 |
|
|
74
76
|
| `exactpdf_pdf_structured_markdown` | POST /api/v1/pdf-structured-markdown | 1 |
|
|
75
77
|
| `exactpdf_estimate_speech_cost` | local estimate | 0 |
|
package/dist/run.js
CHANGED
|
@@ -24,8 +24,8 @@ function requireKey() {
|
|
|
24
24
|
}
|
|
25
25
|
return k;
|
|
26
26
|
}
|
|
27
|
-
const server = new McpServer({ name: 'exactpdf', version: '0.2.
|
|
28
|
-
instructions: 'ExactPDF turns local PDFs into production outputs for agents: inspect metadata, merge/split/rotate/compress, extract text/structured Markdown, create voice previews, and queue async PDF speech/audiobook/translation/presentation narration jobs. Start with exactpdf_first_run_checklist, then exactpdf_account and exactpdf_pdf_info before paid work. Free tools: first-run checklist, account, pdf-info, voice-preview, speech cost estimate. Standard document tools cost 1 credit on success. Async speech jobs are metered by generated minutes. Use absolute local file paths; binary outputs are saved to EXACTPDF_API_OUTPUT_DIR or the OS temp directory. For async jobs, submit first, then poll exactpdf_get_speech_job, then download with exactpdf_download_audio when succeeded.',
|
|
27
|
+
const server = new McpServer({ name: 'exactpdf', version: '0.2.11' }, {
|
|
28
|
+
instructions: 'ExactPDF turns local PDFs into production outputs for agents: inspect metadata, merge/split/rotate/compress, create portal-ready merge/images workflows, extract text/structured Markdown, create voice previews, and queue async PDF speech/audiobook/translation/presentation narration jobs. Start with exactpdf_first_run_checklist, then exactpdf_account and exactpdf_pdf_info before paid work. Free tools: first-run checklist, account, pdf-info, voice-preview, speech cost estimate. Standard document tools cost 1 credit on success, including launch portal-ready workflows. Async speech jobs are metered by generated minutes. Use absolute local file paths; binary outputs are saved to EXACTPDF_API_OUTPUT_DIR or the OS temp directory. For async jobs, submit first, then poll exactpdf_get_speech_job, then download with exactpdf_download_audio when succeeded.',
|
|
29
29
|
});
|
|
30
30
|
async function saveBinaryFromResponse(res, prefix, fallbackExt) {
|
|
31
31
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
@@ -47,6 +47,16 @@ function extensionFromContentType(contentType, fallback) {
|
|
|
47
47
|
return 'pdf';
|
|
48
48
|
return fallback;
|
|
49
49
|
}
|
|
50
|
+
function targetStatus(res) {
|
|
51
|
+
const target = res.headers.get('x-target-bytes');
|
|
52
|
+
if (!target)
|
|
53
|
+
return 'No target_bytes requested.';
|
|
54
|
+
const reached = res.headers.get('x-target-reached') ?? 'unknown';
|
|
55
|
+
const original = res.headers.get('x-original-bytes') ?? '?';
|
|
56
|
+
const output = res.headers.get('x-output-bytes') ?? '?';
|
|
57
|
+
const mode = res.headers.get('x-compression-mode') ?? 'best_effort';
|
|
58
|
+
return `Target bytes: ${target}\nTarget reached: ${reached}\nOriginal bytes: ${original}\nOutput bytes: ${output}\nCompression mode: ${mode}`;
|
|
59
|
+
}
|
|
50
60
|
server.registerTool('exactpdf_first_run_checklist', {
|
|
51
61
|
description: 'Return the safest first-run sequence for ExactPDF MCP clients, including API key setup, free probe tools, credit rules, output directory behavior, and docs links. Free; no API key required.',
|
|
52
62
|
inputSchema: z.object({}),
|
|
@@ -72,6 +82,7 @@ server.registerTool('exactpdf_first_run_checklist', {
|
|
|
72
82
|
credit_model: {
|
|
73
83
|
free: ['exactpdf_first_run_checklist', 'exactpdf_account', 'exactpdf_pdf_info', 'exactpdf_voice_preview', 'exactpdf_estimate_speech_cost', 'job polling'],
|
|
74
84
|
standard_document_tools: '1 credit only after successful output',
|
|
85
|
+
launch_portal_ready_workflows: '1 credit on successful output: exactpdf_merge_and_compress_pdfs, exactpdf_images_to_pdf_and_compress',
|
|
75
86
|
speech_audiobook_presentation: '1 credit per generated minute',
|
|
76
87
|
translate_and_speak: '3 credits per generated minute',
|
|
77
88
|
},
|
|
@@ -101,6 +112,44 @@ server.registerTool('exactpdf_account', {
|
|
|
101
112
|
content: [{ type: 'text', text: `HTTP ${res.status}\n${text}` }],
|
|
102
113
|
};
|
|
103
114
|
});
|
|
115
|
+
server.registerTool('exactpdf_merge_and_compress_pdfs', {
|
|
116
|
+
description: 'Portal-ready workflow: merge 2-20 local PDFs in order, then best-effort repack/compress the final PDF for an upload limit. Costs 1 launch credit on success. Returns measured output size and whether target_bytes was reached; exact target compression for image-heavy PDFs may require Max/browser workflows.',
|
|
117
|
+
inputSchema: z.object({
|
|
118
|
+
paths: z.array(z.string()).min(2).describe('Absolute paths to PDF files on this machine, in merge order.'),
|
|
119
|
+
target_bytes: z.number().int().positive().optional().describe('Optional upload limit, e.g. 1048576 for 1MB or 2097152 for 2MB.'),
|
|
120
|
+
}),
|
|
121
|
+
}, async ({ paths, target_bytes }) => {
|
|
122
|
+
const key = requireKey();
|
|
123
|
+
const form = new FormData();
|
|
124
|
+
for (const p of paths) {
|
|
125
|
+
const buf = await readFile(p);
|
|
126
|
+
form.append('file', new Blob([buf], { type: 'application/pdf' }), basename(p));
|
|
127
|
+
}
|
|
128
|
+
if (typeof target_bytes === 'number')
|
|
129
|
+
form.append('target_bytes', String(target_bytes));
|
|
130
|
+
const res = await fetch(`${BASE}/api/v1/merge-compress`, {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
133
|
+
body: form,
|
|
134
|
+
});
|
|
135
|
+
const credits = res.headers.get('x-credits-remaining') ?? '?';
|
|
136
|
+
if (!res.ok) {
|
|
137
|
+
const errBody = await res.text();
|
|
138
|
+
return {
|
|
139
|
+
content: [{ type: 'text', text: `merge-compress failed HTTP ${res.status}. Credits: ${credits}\n${errBody.slice(0, 8000)}` }],
|
|
140
|
+
isError: true,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const outPath = await saveBinaryFromResponse(res, 'exactpdf-merged-compressed', 'pdf');
|
|
144
|
+
return {
|
|
145
|
+
content: [
|
|
146
|
+
{
|
|
147
|
+
type: 'text',
|
|
148
|
+
text: `Merged and best-effort compressed ${paths.length} PDFs → ${outPath}\nCredits remaining: ${credits}\n${targetStatus(res)}`,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
});
|
|
104
153
|
server.registerTool('exactpdf_merge_pdfs', {
|
|
105
154
|
description: 'Merge 2-20 local PDF files into one PDF in the exact order provided. Costs 1 credit only on successful output. Saves the merged PDF locally and returns its path.',
|
|
106
155
|
inputSchema: z.object({
|
|
@@ -289,6 +338,50 @@ server.registerTool('exactpdf_compress_pdf', {
|
|
|
289
338
|
],
|
|
290
339
|
};
|
|
291
340
|
});
|
|
341
|
+
server.registerTool('exactpdf_images_to_pdf_and_compress', {
|
|
342
|
+
description: 'Portal-ready workflow: convert local PNG/JPEG images into one ordered PDF, then best-effort repack/compress for an upload limit. Costs 1 launch credit on success. Returns measured output size and whether target_bytes was reached.',
|
|
343
|
+
inputSchema: z.object({
|
|
344
|
+
paths: z.array(z.string()).min(1).describe('Absolute paths to PNG or JPEG files, in PDF order.'),
|
|
345
|
+
target_bytes: z.number().int().positive().optional().describe('Optional upload limit, e.g. 524288 for 500KB or 1048576 for 1MB.'),
|
|
346
|
+
}),
|
|
347
|
+
}, async ({ paths, target_bytes }) => {
|
|
348
|
+
const key = requireKey();
|
|
349
|
+
const form = new FormData();
|
|
350
|
+
for (const p of paths) {
|
|
351
|
+
const buf = await readFile(p);
|
|
352
|
+
const lower = p.toLowerCase();
|
|
353
|
+
const type = lower.endsWith('.png')
|
|
354
|
+
? 'image/png'
|
|
355
|
+
: lower.endsWith('.jpg') || lower.endsWith('.jpeg')
|
|
356
|
+
? 'image/jpeg'
|
|
357
|
+
: 'application/octet-stream';
|
|
358
|
+
form.append('file', new Blob([buf], { type }), basename(p));
|
|
359
|
+
}
|
|
360
|
+
if (typeof target_bytes === 'number')
|
|
361
|
+
form.append('target_bytes', String(target_bytes));
|
|
362
|
+
const res = await fetch(`${BASE}/api/v1/images-to-pdf-compress`, {
|
|
363
|
+
method: 'POST',
|
|
364
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
365
|
+
body: form,
|
|
366
|
+
});
|
|
367
|
+
const credits = res.headers.get('x-credits-remaining') ?? '?';
|
|
368
|
+
if (!res.ok) {
|
|
369
|
+
const errBody = await res.text();
|
|
370
|
+
return {
|
|
371
|
+
content: [{ type: 'text', text: `images-to-pdf-compress failed HTTP ${res.status}. Credits: ${credits}\n${errBody.slice(0, 8000)}` }],
|
|
372
|
+
isError: true,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
const outPath = await saveBinaryFromResponse(res, 'exactpdf-images-compressed', 'pdf');
|
|
376
|
+
return {
|
|
377
|
+
content: [
|
|
378
|
+
{
|
|
379
|
+
type: 'text',
|
|
380
|
+
text: `Built and best-effort compressed PDF from ${paths.length} images → ${outPath}\nCredits remaining: ${credits}\n${targetStatus(res)}`,
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
};
|
|
384
|
+
});
|
|
292
385
|
server.registerTool('exactpdf_images_to_pdf', {
|
|
293
386
|
description: 'Convert local PNG/JPEG images into one ordered PDF. Costs 1 credit on success. Saves the resulting PDF locally and returns its path.',
|
|
294
387
|
inputSchema: z.object({
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"name": "com.exactpdf/mcp",
|
|
4
4
|
"title": "ExactPDF",
|
|
5
5
|
"description": "Agent-facing PDF API: merge, split, rotate, compress, images, metadata, text, Markdown, voice previews, async speech/audiobook, multilingual speech, and presentation narration jobs.",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.11",
|
|
7
7
|
"websiteUrl": "https://exactpdf.com/docs/api",
|
|
8
8
|
"packages": [
|
|
9
9
|
{
|
|
10
10
|
"registryType": "npm",
|
|
11
11
|
"identifier": "@exactpdf/mcp",
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.11",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
|
15
15
|
}
|