@sylphx/pdf-reader-mcp 2.0.3 → 2.0.8
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 +14 -13
- package/dist/index.js +27 -32
- package/package.json +102 -104
package/README.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# 📄 @sylphx/pdf-reader-mcp
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> Production-ready PDF processing server for AI agents
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/@sylphx/pdf-reader-mcp)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
9
|
[](https://github.com/SylphxAI/pdf-reader-mcp/actions/workflows/ci.yml)
|
|
8
10
|
[](https://codecov.io/gh/SylphxAI/pdf-reader-mcp)
|
|
9
|
-
[](https://www.npmjs.com/package/@sylphx/pdf-reader-mcp)
|
|
10
11
|
[](https://pdf-reader-msu3esos4-sylphx.vercel.app)
|
|
12
|
+
[](https://www.typescriptlang.org/)
|
|
11
13
|
[](https://www.npmjs.com/package/@sylphx/pdf-reader-mcp)
|
|
12
|
-
[](https://opensource.org/licenses/MIT)
|
|
13
14
|
|
|
14
15
|
**5-10x faster parallel processing** • **Y-coordinate content ordering** • **94%+ test coverage** • **103 tests passing**
|
|
15
16
|
|
|
@@ -780,12 +781,12 @@ This project uses the following [@sylphx](https://github.com/SylphxAI) packages:
|
|
|
780
781
|
|
|
781
782
|
---
|
|
782
783
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
</
|
|
784
|
+
## Star History
|
|
785
|
+
|
|
786
|
+
[](https://star-history.com/#SylphxAI/pdf-reader-mcp&Date)
|
|
787
|
+
|
|
788
|
+
---
|
|
789
|
+
|
|
790
|
+
<div align="center">
|
|
791
|
+
<sub>Built with ❤️ by <a href="https://github.com/SylphxAI">Sylphx</a></sub>
|
|
792
|
+
</div>
|
package/dist/index.js
CHANGED
|
@@ -329,24 +329,14 @@ class PdfError extends Error {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
// src/utils/pathUtils.ts
|
|
332
|
-
import os from "node:os";
|
|
333
332
|
import path from "node:path";
|
|
334
333
|
var PROJECT_ROOT = process.cwd();
|
|
335
|
-
var ALLOWED_ROOTS = [PROJECT_ROOT, os.homedir()];
|
|
336
334
|
var resolvePath = (userPath) => {
|
|
337
335
|
if (typeof userPath !== "string") {
|
|
338
336
|
throw new PdfError(-32602 /* InvalidParams */, "Path must be a string.");
|
|
339
337
|
}
|
|
340
338
|
const normalizedUserPath = path.normalize(userPath);
|
|
341
|
-
|
|
342
|
-
const isWithinAllowedRoot = ALLOWED_ROOTS.some((allowedRoot) => {
|
|
343
|
-
const relativePath = path.relative(allowedRoot, resolvedPath);
|
|
344
|
-
return relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
|
|
345
|
-
});
|
|
346
|
-
if (!isWithinAllowedRoot) {
|
|
347
|
-
throw new PdfError(-32602 /* InvalidParams */, "Access denied: Path resolves outside allowed directories.");
|
|
348
|
-
}
|
|
349
|
-
return resolvedPath;
|
|
339
|
+
return path.isAbsolute(normalizedUserPath) ? normalizedUserPath : path.resolve(PROJECT_ROOT, normalizedUserPath);
|
|
350
340
|
};
|
|
351
341
|
|
|
352
342
|
// src/pdf/loader.ts
|
|
@@ -465,27 +455,32 @@ var determinePagesToProcess = (targetPages, totalPages, includeFullText) => {
|
|
|
465
455
|
};
|
|
466
456
|
|
|
467
457
|
// src/schemas/readPdf.ts
|
|
468
|
-
import {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
458
|
+
import {
|
|
459
|
+
array,
|
|
460
|
+
bool,
|
|
461
|
+
description,
|
|
462
|
+
gte,
|
|
463
|
+
int,
|
|
464
|
+
min,
|
|
465
|
+
num,
|
|
466
|
+
object,
|
|
467
|
+
optional,
|
|
468
|
+
str,
|
|
469
|
+
union
|
|
470
|
+
} from "@sylphx/vex";
|
|
471
|
+
var pageSpecifierSchema = union(array(num(int, gte(1))), str(min(1)));
|
|
472
|
+
var pdfSourceSchema = object({
|
|
473
|
+
path: optional(str(min(1), description("Path to the local PDF file (absolute or relative to cwd)."))),
|
|
474
|
+
url: optional(str(min(1), description("URL of the PDF file."))),
|
|
475
|
+
pages: optional(pageSpecifierSchema)
|
|
476
|
+
});
|
|
477
|
+
var readPdfArgsSchema = object({
|
|
478
|
+
sources: array(pdfSourceSchema),
|
|
479
|
+
include_full_text: optional(bool(description("Include the full text content of each PDF (only if 'pages' is not specified for that source)."))),
|
|
480
|
+
include_metadata: optional(bool(description("Include metadata and info objects for each PDF."))),
|
|
481
|
+
include_page_count: optional(bool(description("Include the total number of pages for each PDF."))),
|
|
482
|
+
include_images: optional(bool(description("Extract and include embedded images from the PDF pages as base64-encoded data.")))
|
|
481
483
|
});
|
|
482
|
-
var readPdfArgsSchema = z.object({
|
|
483
|
-
sources: z.array(pdfSourceSchema).min(1).describe("An array of PDF sources to process, each can optionally specify pages."),
|
|
484
|
-
include_full_text: z.boolean().optional().default(false).describe("Include the full text content of each PDF (only if 'pages' is not specified for that source)."),
|
|
485
|
-
include_metadata: z.boolean().optional().default(true).describe("Include metadata and info objects for each PDF."),
|
|
486
|
-
include_page_count: z.boolean().optional().default(true).describe("Include the total number of pages for each PDF."),
|
|
487
|
-
include_images: z.boolean().optional().default(false).describe("Extract and include embedded images from the PDF pages as base64-encoded data.")
|
|
488
|
-
}).strict();
|
|
489
484
|
|
|
490
485
|
// src/handlers/readPdf.ts
|
|
491
486
|
var logger5 = createLogger("ReadPdf");
|
|
@@ -617,7 +612,7 @@ var server = createServer({
|
|
|
617
612
|
});
|
|
618
613
|
async function main() {
|
|
619
614
|
await server.start();
|
|
620
|
-
if (process.env
|
|
615
|
+
if (process.env["DEBUG_MCP"]) {
|
|
621
616
|
console.error("[PDF Reader MCP] Server running on stdio");
|
|
622
617
|
console.error("[PDF Reader MCP] Project root:", process.cwd());
|
|
623
618
|
}
|
package/package.json
CHANGED
|
@@ -1,106 +1,104 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"js-yaml": "^4.1.0"
|
|
105
|
-
}
|
|
2
|
+
"name": "@sylphx/pdf-reader-mcp",
|
|
3
|
+
"version": "2.0.8",
|
|
4
|
+
"description": "An MCP server providing tools to read PDF files.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pdf-reader-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.0.0"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/SylphxAI/pdf-reader-mcp.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/SylphxAI/pdf-reader-mcp/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/SylphxAI/pdf-reader-mcp#readme",
|
|
33
|
+
"author": "Sylphx <contact@sylphx.com> (https://sylphx.com)",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"mcp",
|
|
37
|
+
"model-context-protocol",
|
|
38
|
+
"pdf",
|
|
39
|
+
"reader",
|
|
40
|
+
"parser",
|
|
41
|
+
"typescript",
|
|
42
|
+
"node",
|
|
43
|
+
"ai",
|
|
44
|
+
"agent",
|
|
45
|
+
"tool"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "bunup",
|
|
49
|
+
"watch": "tsc --watch",
|
|
50
|
+
"inspector": "npx @modelcontextprotocol/inspector dist/index.js",
|
|
51
|
+
"test": "bun test",
|
|
52
|
+
"test:watch": "bun test --watch",
|
|
53
|
+
"test:cov": "bun test --coverage",
|
|
54
|
+
"lint": "biome lint .",
|
|
55
|
+
"lint:fix": "biome lint --write .",
|
|
56
|
+
"format": "biome format --write .",
|
|
57
|
+
"check-format": "biome format .",
|
|
58
|
+
"check": "biome check .",
|
|
59
|
+
"check:fix": "biome check --write .",
|
|
60
|
+
"validate": "bun run check && bun run test",
|
|
61
|
+
"docs:dev": "bunx @sylphx/leaf dev docs",
|
|
62
|
+
"docs:build": "bunx @sylphx/leaf build docs",
|
|
63
|
+
"docs:preview": "bunx @sylphx/leaf preview docs",
|
|
64
|
+
"start": "node dist/index.js",
|
|
65
|
+
"typecheck": "tsc --noEmit",
|
|
66
|
+
"benchmark": "bun bench",
|
|
67
|
+
"clean": "rm -rf dist coverage",
|
|
68
|
+
"docs:api": "typedoc --entryPoints src/index.ts --tsconfig tsconfig.json --plugin typedoc-plugin-markdown --out docs/api --readme none",
|
|
69
|
+
"prepublishOnly": "bunx @sylphx/doctor prepublish && bun run clean && bun run build",
|
|
70
|
+
"release": "standard-version",
|
|
71
|
+
"prepare": "node_modules/.bin/lefthook install || true"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@sylphx/mcp-server-sdk": "^2.1.0",
|
|
75
|
+
"@sylphx/vex": "^0.1.11",
|
|
76
|
+
"glob": "^13.0.0",
|
|
77
|
+
"pdfjs-dist": "^5.4.449",
|
|
78
|
+
"pngjs": "^7.0.0"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@biomejs/biome": "^2.3.8",
|
|
82
|
+
"@solidjs/router": "^0.15.4",
|
|
83
|
+
"@sylphx/biome-config": "^0.4.1",
|
|
84
|
+
"@sylphx/bump": "^1.6.1",
|
|
85
|
+
"@sylphx/doctor": "^1.32.1",
|
|
86
|
+
"@sylphx/leaf": "^1.0.0",
|
|
87
|
+
"@sylphx/leaf-theme-default": "^1.0.0",
|
|
88
|
+
"@sylphx/tsconfig": "^0.3.1",
|
|
89
|
+
"@types/glob": "^8.1.0",
|
|
90
|
+
"@types/node": "^24.10.1",
|
|
91
|
+
"@types/pngjs": "^6.0.5",
|
|
92
|
+
"bunup": "^0.16.10",
|
|
93
|
+
"lefthook": "^2.0.7",
|
|
94
|
+
"solid-js": "^1.9.10",
|
|
95
|
+
"typedoc": "^0.28.15",
|
|
96
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
97
|
+
"typescript": "^5.9.3",
|
|
98
|
+
"vite": "^7.2.6"
|
|
99
|
+
},
|
|
100
|
+
"packageManager": "bun@1.3.1",
|
|
101
|
+
"overrides": {
|
|
102
|
+
"js-yaml": "^4.1.0"
|
|
103
|
+
}
|
|
106
104
|
}
|