@exactpdf/mcp 0.2.9 → 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 CHANGED
@@ -51,23 +51,27 @@ For a local checkout of this monorepo:
51
51
  Safe first run:
52
52
 
53
53
  ```text
54
- 1. exactpdf_account
55
- 2. exactpdf_pdf_info(path="/absolute/path/document.pdf")
56
- 3. exactpdf_voice_preview(text="Short sample...", voice_style="professional")
57
- 4. exactpdf_estimate_speech_cost(path="/absolute/path/document.pdf", mode="audiobook")
54
+ 1. exactpdf_first_run_checklist
55
+ 2. exactpdf_account
56
+ 3. exactpdf_pdf_info(path="/absolute/path/document.pdf")
57
+ 4. exactpdf_voice_preview(text="Short sample...", voice_style="professional")
58
+ 5. exactpdf_estimate_speech_cost(path="/absolute/path/document.pdf", mode="audiobook")
58
59
  ```
59
60
 
60
61
  Document outputs are saved to `EXACTPDF_API_OUTPUT_DIR` or your OS temp directory. Paid document tools consume credits only on successful output. Async speech jobs are metered by generated minutes.
61
62
 
62
63
  | Tool | Endpoint | Credits |
63
64
  |------|----------|--------:|
65
+ | `exactpdf_first_run_checklist` | local guidance | 0 |
64
66
  | `exactpdf_account` | GET /api/v1/account | 0 |
65
67
  | `exactpdf_pdf_info` | POST /api/v1/pdf-info | 0 |
66
68
  | `exactpdf_merge_pdfs` | POST /api/v1/merge | 1 |
69
+ | `exactpdf_merge_and_compress_pdfs` | POST /api/v1/merge-compress | 1 |
67
70
  | `exactpdf_split_pdf` | POST /api/v1/split | 1 |
68
71
  | `exactpdf_rotate_pdf` | POST /api/v1/rotate | 1 |
69
72
  | `exactpdf_compress_pdf` | POST /api/v1/compress | 1 |
70
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 |
71
75
  | `exactpdf_extract_text` | POST /api/v1/extract-text | 1 |
72
76
  | `exactpdf_pdf_structured_markdown` | POST /api/v1/pdf-structured-markdown | 1 |
73
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.8' }, {
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. Free tools: 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,55 @@ 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
+ }
60
+ server.registerTool('exactpdf_first_run_checklist', {
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.',
62
+ inputSchema: z.object({}),
63
+ }, async () => ({
64
+ content: [
65
+ {
66
+ type: 'text',
67
+ text: JSON.stringify({
68
+ ok: true,
69
+ setup: {
70
+ required_env: 'EXACTPDF_API_KEY=sk_live_...',
71
+ create_key_url: `${BASE}/max/account`,
72
+ optional_output_dir: 'EXACTPDF_API_OUTPUT_DIR=/absolute/output/folder',
73
+ docs: `${BASE}/docs/api`,
74
+ openapi: `${BASE}/openapi.json`,
75
+ },
76
+ safe_first_run: [
77
+ 'Call exactpdf_account to verify the key and credit balance.',
78
+ 'Call exactpdf_pdf_info with a small absolute PDF path before extraction or conversion.',
79
+ 'Call exactpdf_voice_preview with a short text sample before long narration.',
80
+ 'Call exactpdf_estimate_speech_cost before audiobook, speech, translation, or presentation narration.',
81
+ ],
82
+ credit_model: {
83
+ free: ['exactpdf_first_run_checklist', 'exactpdf_account', 'exactpdf_pdf_info', 'exactpdf_voice_preview', 'exactpdf_estimate_speech_cost', 'job polling'],
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',
86
+ speech_audiobook_presentation: '1 credit per generated minute',
87
+ translate_and_speak: '3 credits per generated minute',
88
+ },
89
+ reliability_rules: [
90
+ 'Use absolute local file paths; relative paths are client-dependent.',
91
+ 'Never paste API keys into prompts, screenshots, commits, or logs.',
92
+ 'Async jobs return a job_id first; poll until succeeded, then download.',
93
+ 'If a tool returns isError, show the HTTP status and response body to the user.',
94
+ ],
95
+ }, null, 2),
96
+ },
97
+ ],
98
+ }));
50
99
  server.registerTool('exactpdf_account', {
51
100
  description: 'Check whether the ExactPDF API key works and return credit balance/key metadata. Free; does not consume credits. Use this before any paid tool.',
52
101
  inputSchema: z.object({}),
@@ -63,6 +112,44 @@ server.registerTool('exactpdf_account', {
63
112
  content: [{ type: 'text', text: `HTTP ${res.status}\n${text}` }],
64
113
  };
65
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
+ });
66
153
  server.registerTool('exactpdf_merge_pdfs', {
67
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.',
68
155
  inputSchema: z.object({
@@ -251,6 +338,50 @@ server.registerTool('exactpdf_compress_pdf', {
251
338
  ],
252
339
  };
253
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
+ });
254
385
  server.registerTool('exactpdf_images_to_pdf', {
255
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.',
256
387
  inputSchema: z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exactpdf/mcp",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "MCP server for ExactPDF — PDF tools, voice previews, async PDF speech/audiobook jobs, polling, and API credits.",
5
5
  "mcpName": "com.exactpdf/mcp",
6
6
  "type": "module",
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.9",
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.9",
12
+ "version": "0.2.11",
13
13
  "transport": {
14
14
  "type": "stdio"
15
15
  }