@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.
Files changed (3) hide show
  1. package/README.md +14 -13
  2. package/dist/index.js +27 -32
  3. package/package.json +102 -104
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  <div align="center">
2
2
 
3
- # PDF Reader MCP 📄
3
+ # 📄 @sylphx/pdf-reader-mcp
4
4
 
5
- **Production-ready PDF processing server for AI agents**
5
+ > Production-ready PDF processing server for AI agents
6
6
 
7
+ [![npm version](https://img.shields.io/npm/v/@sylphx/pdf-reader-mcp?style=flat-square)](https://www.npmjs.com/package/@sylphx/pdf-reader-mcp)
8
+ [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](https://opensource.org/licenses/MIT)
7
9
  [![CI/CD](https://img.shields.io/github/actions/workflow/status/SylphxAI/pdf-reader-mcp/ci.yml?style=flat-square&label=CI/CD)](https://github.com/SylphxAI/pdf-reader-mcp/actions/workflows/ci.yml)
8
10
  [![codecov](https://img.shields.io/codecov/c/github/SylphxAI/pdf-reader-mcp?style=flat-square)](https://codecov.io/gh/SylphxAI/pdf-reader-mcp)
9
- [![npm version](https://img.shields.io/npm/v/@sylphx/pdf-reader-mcp?style=flat-square)](https://www.npmjs.com/package/@sylphx/pdf-reader-mcp)
10
11
  [![coverage](https://img.shields.io/badge/coverage-94.17%25-brightgreen?style=flat-square)](https://pdf-reader-msu3esos4-sylphx.vercel.app)
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg?style=flat-square)](https://www.typescriptlang.org/)
11
13
  [![Downloads](https://img.shields.io/npm/dm/@sylphx/pdf-reader-mcp?style=flat-square)](https://www.npmjs.com/package/@sylphx/pdf-reader-mcp)
12
- [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](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
- <p align="center">
784
- <strong>5-10x faster. Production-ready. Battle-tested.</strong>
785
- <br>
786
- <sub>The PDF processing server that actually scales</sub>
787
- <br><br>
788
- <a href="https://sylphx.com">sylphx.com</a> •
789
- <a href="https://x.com/SylphxAI">@SylphxAI</a>
790
- <a href="mailto:hi@sylphx.com">hi@sylphx.com</a>
791
- </p>
784
+ ## Star History
785
+
786
+ [![Star History Chart](https://api.star-history.com/svg?repos=SylphxAI/pdf-reader-mcp&type=Date)](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
- const resolvedPath = path.isAbsolute(normalizedUserPath) ? normalizedUserPath : path.resolve(PROJECT_ROOT, normalizedUserPath);
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 { z } from "zod";
469
- var pageSpecifierSchema = z.union([
470
- z.array(z.number().int().min(1)).min(1).describe("Array of page numbers (1-based)"),
471
- z.string().min(1).refine((val) => /^[0-9,-]+$/.test(val.replace(/\s/g, "")), {
472
- message: "Page string must contain only numbers, commas, and hyphens."
473
- }).describe('Page range string (e.g., "1-5,10,15-20")')
474
- ]);
475
- var pdfSourceSchema = z.object({
476
- path: z.string().min(1).optional().describe("Path to the local PDF file (absolute or relative to cwd)."),
477
- url: z.string().url().optional().describe("URL of the PDF file."),
478
- pages: pageSpecifierSchema.optional().describe("Extract text only from specific pages (1-based) or ranges for this source. If provided, 'include_full_text' is ignored for this source.")
479
- }).strict().refine((data) => !!(data.path && !data.url) || !!(!data.path && data.url), {
480
- message: "Each source must have either 'path' or 'url', but not both."
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.DEBUG_MCP) {
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
- "name": "@sylphx/pdf-reader-mcp",
3
- "version": "2.0.3",
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
- "types": "./dist/index.d.ts"
18
- }
19
- },
20
- "publishConfig": {
21
- "access": "public"
22
- },
23
- "engines": {
24
- "node": ">=22.0.0"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/SylphxAI/pdf-reader-mcp.git"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/SylphxAI/pdf-reader-mcp/issues"
32
- },
33
- "homepage": "https://github.com/SylphxAI/pdf-reader-mcp#readme",
34
- "author": "Sylphx <contact@sylphx.com> (https://sylphx.com)",
35
- "license": "MIT",
36
- "keywords": [
37
- "mcp",
38
- "model-context-protocol",
39
- "pdf",
40
- "reader",
41
- "parser",
42
- "typescript",
43
- "node",
44
- "ai",
45
- "agent",
46
- "tool"
47
- ],
48
- "scripts": {
49
- "build": "bunup",
50
- "watch": "tsc --watch",
51
- "inspector": "npx @modelcontextprotocol/inspector dist/index.js",
52
- "test": "bun test",
53
- "test:watch": "bun test --watch",
54
- "test:cov": "bun test --coverage",
55
- "lint": "biome lint .",
56
- "lint:fix": "biome lint --write .",
57
- "format": "biome format --write .",
58
- "check-format": "biome format .",
59
- "check": "biome check .",
60
- "check:fix": "biome check --write .",
61
- "validate": "bun run check && bun run test",
62
- "docs:dev": "leaf dev docs",
63
- "docs:build": "leaf build docs",
64
- "docs:preview": "leaf preview docs",
65
- "start": "node dist/index.js",
66
- "typecheck": "tsc --noEmit",
67
- "benchmark": "bun bench",
68
- "clean": "rm -rf dist coverage",
69
- "docs:api": "typedoc --entryPoints src/index.ts --tsconfig tsconfig.json --plugin typedoc-plugin-markdown --out docs/api --readme none",
70
- "prepublishOnly": "bunx @sylphx/doctor prepublish && bun run clean && bun run build",
71
- "release": "standard-version",
72
- "prepare": "node_modules/.bin/lefthook install || true"
73
- },
74
- "dependencies": {
75
- "@sylphx/mcp-server-sdk": "1.2.0",
76
- "glob": "^13.0.0",
77
- "pdfjs-dist": "^5.4.394",
78
- "pngjs": "^7.0.0",
79
- "zod": "4.2.0-canary.20251124T022609",
80
- "zod-to-json-schema": "^3.25.0"
81
- },
82
- "devDependencies": {
83
- "@biomejs/biome": "^2.3.8",
84
- "@solidjs/router": "^0.15.4",
85
- "@sylphx/biome-config": "^0.4.0",
86
- "@sylphx/bump": "^0.12.1",
87
- "@sylphx/doctor": "^1.23.3",
88
- "@sylphx/leaf": "^1.0.0",
89
- "@sylphx/leaf-theme-default": "^1.0.0",
90
- "@sylphx/tsconfig": "^0.3.0",
91
- "@types/glob": "^8.1.0",
92
- "@types/node": "^24.10.1",
93
- "@types/pngjs": "^6.0.5",
94
- "bunup": "^0.16.10",
95
- "lefthook": "^2.0.4",
96
- "solid-js": "^1.9.10",
97
- "typedoc": "^0.28.14",
98
- "typedoc-plugin-markdown": "^4.9.0",
99
- "typescript": "^5.9.3",
100
- "vite": "^7.2.4"
101
- },
102
- "packageManager": "bun@1.3.1",
103
- "overrides": {
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
  }