@shuji-bonji/pdf-reader-mcp 0.11.1 → 0.12.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/README.ja.md +90 -5
  3. package/README.md +91 -5
  4. package/dist/constants.d.ts +20 -0
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +20 -0
  7. package/dist/constants.js.map +1 -1
  8. package/dist/index.js +15 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/schemas/tier1.d.ts +53 -1
  11. package/dist/schemas/tier1.d.ts.map +1 -1
  12. package/dist/schemas/tier1.js +80 -2
  13. package/dist/schemas/tier1.js.map +1 -1
  14. package/dist/services/content-stream-service.d.ts +34 -1
  15. package/dist/services/content-stream-service.d.ts.map +1 -1
  16. package/dist/services/content-stream-service.js +92 -9
  17. package/dist/services/content-stream-service.js.map +1 -1
  18. package/dist/services/image-encoder.d.ts +33 -0
  19. package/dist/services/image-encoder.d.ts.map +1 -0
  20. package/dist/services/image-encoder.js +435 -0
  21. package/dist/services/image-encoder.js.map +1 -0
  22. package/dist/services/image-resampler.d.ts +36 -0
  23. package/dist/services/image-resampler.d.ts.map +1 -0
  24. package/dist/services/image-resampler.js +78 -0
  25. package/dist/services/image-resampler.js.map +1 -0
  26. package/dist/services/page-renderer.d.ts +71 -0
  27. package/dist/services/page-renderer.d.ts.map +1 -0
  28. package/dist/services/page-renderer.js +147 -0
  29. package/dist/services/page-renderer.js.map +1 -0
  30. package/dist/services/pdfjs-service.d.ts +24 -3
  31. package/dist/services/pdfjs-service.d.ts.map +1 -1
  32. package/dist/services/pdfjs-service.js +119 -24
  33. package/dist/services/pdfjs-service.js.map +1 -1
  34. package/dist/services/pdflib-service.d.ts +4 -0
  35. package/dist/services/pdflib-service.d.ts.map +1 -1
  36. package/dist/services/pdflib-service.js +6 -1
  37. package/dist/services/pdflib-service.js.map +1 -1
  38. package/dist/services/text-extractability-service.d.ts +44 -0
  39. package/dist/services/text-extractability-service.d.ts.map +1 -0
  40. package/dist/services/text-extractability-service.js +302 -0
  41. package/dist/services/text-extractability-service.js.map +1 -0
  42. package/dist/tools/index.d.ts.map +1 -1
  43. package/dist/tools/index.js +2 -0
  44. package/dist/tools/index.js.map +1 -1
  45. package/dist/tools/tier1/read-images.d.ts +1 -1
  46. package/dist/tools/tier1/read-images.d.ts.map +1 -1
  47. package/dist/tools/tier1/read-images.js +73 -43
  48. package/dist/tools/tier1/read-images.js.map +1 -1
  49. package/dist/tools/tier1/read-text.d.ts.map +1 -1
  50. package/dist/tools/tier1/read-text.js +22 -7
  51. package/dist/tools/tier1/read-text.js.map +1 -1
  52. package/dist/tools/tier1/read-url.d.ts.map +1 -1
  53. package/dist/tools/tier1/read-url.js +24 -6
  54. package/dist/tools/tier1/read-url.js.map +1 -1
  55. package/dist/tools/tier1/render-page.d.ts +6 -0
  56. package/dist/tools/tier1/render-page.d.ts.map +1 -0
  57. package/dist/tools/tier1/render-page.js +93 -0
  58. package/dist/tools/tier1/render-page.js.map +1 -0
  59. package/dist/tools/tier1/search-text.d.ts.map +1 -1
  60. package/dist/tools/tier1/search-text.js +17 -2
  61. package/dist/tools/tier1/search-text.js.map +1 -1
  62. package/dist/tools/tier1/summarize.d.ts.map +1 -1
  63. package/dist/tools/tier1/summarize.js +73 -2
  64. package/dist/tools/tier1/summarize.js.map +1 -1
  65. package/dist/tools/tier2/extract-structured-text.d.ts.map +1 -1
  66. package/dist/tools/tier2/extract-structured-text.js +19 -6
  67. package/dist/tools/tier2/extract-structured-text.js.map +1 -1
  68. package/dist/types.d.ts +96 -1
  69. package/dist/types.d.ts.map +1 -1
  70. package/dist/utils/formatter.d.ts.map +1 -1
  71. package/dist/utils/formatter.js +36 -1
  72. package/dist/utils/formatter.js.map +1 -1
  73. package/package.json +6 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,168 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.12.0] - 2026-08-23
9
+
10
+ ### Added
11
+
12
+ - **Text extractability is reported per page, in three states rather than two (#21).**
13
+ `read_text` answered with text or with nothing, and nothing meant three different things:
14
+ the page is blank, the page is an image with no text layer, or the page shows glyphs whose
15
+ character codes cannot be converted to Unicode. ISO 32000-2 §9.10.1 separates those
16
+ conditions; the return value did not, so a scanned page and an empty page produced the same
17
+ output, and a font without a `/ToUnicode` CMap dropped its text silently — which made a
18
+ partial extraction look like a complete one.
19
+
20
+ Every text-returning path now carries the state: `read_text`, `read_url`, `search_text`,
21
+ `extract_structured_text` and `summarize`. Leaving one path without it would have left the
22
+ hole open, because a caller reaches the same document through any of them.
23
+
24
+ | State | Condition |
25
+ | --- | --- |
26
+ | `extracted` | Every font used by a text-showing operator has a route to Unicode under §9.10.2 |
27
+ | `no_text_layer` | No `Tj` / `TJ` / `'` / `"` on the page, and image content is present |
28
+ | `not_extractable` | A font used has no `/ToUnicode`, no standard encoding and no known CID collection |
29
+ | `not_observed` | Encrypted, or the content stream could not be read — nothing was measured |
30
+
31
+ `not_observed` is the fourth state and is deliberately not folded into any of the other
32
+ three: an encrypted document is not a document without text, and counting it as `extracted`
33
+ would repeat the failure this change exists to fix.
34
+
35
+ `not_extractable` is decided per font, so a page mixing a readable font with an unreadable
36
+ one reports a partial loss and names the fonts responsible, instead of passing as complete.
37
+
38
+ The observation is read from the file with pdf-lib, not from pdfjs's output. pdfjs
39
+ synthesises a `toUnicode` map for every font it loads — a standard-encoding font gets one
40
+ built from its encoding — so asking pdfjs whether a font has a `/ToUnicode` CMap answers yes
41
+ for fonts whose dictionary has none.
42
+
43
+ - **Three fixtures, added before the implementation, because none of the three states could be
44
+ measured without them.** A survey of the existing 17 found no PDF with a `/ToUnicode` CMap,
45
+ none with an image-only page, and no page drawn solely with an unmappable font — so
46
+ `extracted` for composite fonts, `no_text_layer`, and total loss each had zero specimens.
47
+
48
+ - `no-text-layer.pdf` — two image-only pages, no text-showing operator.
49
+ - `tounicode-cid.pdf` — Identity-H with a correct `/ToUnicode` CMap; the `extracted` control.
50
+ - `broken-cid-only.pdf` — a page whose only font is Identity-H without `/ToUnicode`.
51
+
52
+ `cid-font.pdf` is now the fourth: it gained a well-formed Identity-H font with no
53
+ `/ToUnicode` and a line drawn with it, which makes its page the mixed one. Its existing F3
54
+ (a Type0 with no `/DescendantFonts`) could not serve — pdfjs abandons the whole page over it,
55
+ so the Helvetica text disappears too and there is no "partial" left to observe.
56
+
57
+ - **`read_url`'s scope is now stated where it is felt (#25).** The tool returns text and
58
+ discards the fetched bytes; the other 18 tools take a `file_path`; so a URL's PDF cannot
59
+ reach them through this server. That was always the behaviour — what was missing was the
60
+ sentence saying it is a *decision*: every tool here is read-only, a `save_path` (or a
61
+ separate fetch tool) would have the reader writing files, and fetching is the caller's job.
62
+ The tool description, the server `instructions` and both READMEs now say so, with the
63
+ workaround spelled out: download the file first, pass the local path. No code path changed.
64
+
65
+ - **`summarize` ends with a `next` list — tool suggestions derived from its own observations
66
+ (#24).** Tool descriptions say what each tool does; nothing said what to call *given what
67
+ was just observed*, so a caller seeing `hasText: false` had to already know that
68
+ `render_page` is the move. The rules: encrypted → decrypt first (and nothing else, because
69
+ every other suggestion would under-deliver on ciphertext); `no_text_layer` /
70
+ `not_extractable` → `render_page`, with the page numbers; tagged → `extract_structured_text`
71
+ and `extract_tables`; over 50 pages → `search_text` before an unbounded `read_text`. Each
72
+ line names the observation it follows from, so the premise can be checked rather than the
73
+ advice trusted. An ordinary small document gets an empty list — advice that always appears
74
+ is advice that stops being read. Deliberately NOT a workflow: nothing is enforced and no
75
+ ordering is implied; orchestration stays with the Skill layer.
76
+
77
+ - **`read_text` and `read_images` say, in bold, that omitting `pages` means every page** —
78
+ and what to do instead on a large document. The default itself is unchanged; what changed
79
+ is that its cost is stated where the decision is made.
80
+
81
+ - **`render_page` rasterises pages to PNG/JPEG through PDFium-WASM (#23).** `summarize`
82
+ answering `hasText: false` used to be a dead end — nothing in this server could read the
83
+ document any further. Now the page itself can be handed to a vision model: the whole page,
84
+ vector drawings, forms and handwriting included, where `read_images` only extracts embedded
85
+ image XObjects. `pages` is required (rendering all pages of a scan should be a decision, not
86
+ a default), and the #22 response budget applies, with omissions named.
87
+
88
+ The renderer is `@hyzyla/pdfium` in `optionalDependencies` — PDFium compiled to a single
89
+ WebAssembly binary, identical bytes on every platform, so the published package still
90
+ behaves the same everywhere `npx` runs it. When it is not installed, `render_page` reports
91
+ what to install; the other 18 tools are unaffected. Tool count: 18 → 19.
92
+
93
+ pdf.js + `@napi-rs/canvas` was measured first and rejected: versions 1.0.7 and 0.1.80 both
94
+ segfault the process — the whole MCP server — on any page that draws an image, which is
95
+ exactly the class of page this tool exists for; and with `standardFontDataUrl` unset, text
96
+ pages rendered as blank images that looked like success. The e2e suite therefore asserts on
97
+ decoded pixels ("ink"), not on file headers.
98
+
99
+ - **`read_images` returns PNG or JPEG files, in MCP image content blocks (#22).** It used to
100
+ base64 `imgData.data`, which is pdfjs's *decoded pixel array*: 192 bytes for an 8×8 RGB
101
+ image, 256 for 8×8 RGBA, 8 for an 8×8 1 bpp greyscale — measured on `image-kinds.pdf`, with
102
+ no PNG or JPEG signature in any of them. The response looked like an image and was not one,
103
+ so no viewer could open it and no vision model could read it.
104
+
105
+ Both encoders are written out in `src/services/image-encoder.ts`: PNG through
106
+ `zlib.deflateSync`, and baseline JPEG per ISO/IEC 10918-1 with the example tables of its
107
+ Annex K. No dependency is added — the standing reason (#21) is that a native addon ships
108
+ per-platform binaries and breaks the post-release check of the published package.
109
+
110
+ New arguments: `format` (`png` default, `jpeg`), `quality` (JPEG only), `max_width` and
111
+ `max_height` (area-averaged downscale, never enlarges).
112
+
113
+ - **`read_images` has a response budget, and says what it left out.** `read_text` has had a
114
+ character limit since the beginning; `read_images` had none, and a 200 dpi A4 scan is
115
+ 1654×2339×3 = 11.6 MB of pixels on its own. At most 4 MB of encoded image data is returned
116
+ per call. Images past the budget, or over the 40 Mpx encoding limit, are listed in `omitted`
117
+ with the reason and the argument that would fetch them — they are not dropped silently.
118
+
119
+ ### Changed
120
+
121
+ - `ExtractedImage` gained `sourceWidth`, `sourceHeight`, `mimeType`, `encodedBytes` and
122
+ `downscaled`; `ImageExtractionResult` gained `omitted` and `totalEncodedBytes`. `dataBase64`
123
+ now holds a complete image file rather than raw samples.
124
+ - `skippedCount` keeps its meaning — detected but not decodable by pdf.js. "Decoded but not
125
+ returned" is `omitted`, a separate count: folding the two would make a response the caller
126
+ asked to bound look like a file that failed to decode.
127
+ - `PageText` gained an optional `extractability` record, `PdfSummary` gained
128
+ `textExtractability` and `unreadablePages`, `SearchResult` gained `unsearchablePages`, and
129
+ `StructuredTextResult` gained `extractability`. All are additive.
130
+ - `search_text` no longer reports zero hits over an unreadable page as a plain "no matches":
131
+ the note now says the query was not found *in what could be read*.
132
+ - The server `instructions` say that OCR is not performed **and** that the need for it is
133
+ detected and reported. Detecting an unreadable page is inside an observing server's remit;
134
+ staying silent about it is not.
135
+ - No new dependency. The operator walk reuses the existing content-stream scanner; the font
136
+ rules are read with pdf-lib. Tool count stays at 18.
137
+
138
+ ## [0.11.2] - 2026-08-13
139
+
140
+ ### Changed
141
+
142
+ - **`instructions` now open with the running build's name and version.** The text is returned
143
+ from `initialize` and lands in the client's system context, so it is read before any tool is
144
+ considered — which makes it the one place where a stale install can be noticed without
145
+ spending a call. The line names the package and points at `npm view` for comparison.
146
+
147
+ Why this matters more than it sounds: this server is installed through
148
+ `npx -y @shuji-bonji/pdf-reader-mcp@latest`, and npx caches a resolved tree. A client can
149
+ therefore run a build several releases behind while every document about it describes the
150
+ newest one. Until now nothing in the protocol surface said which build was answering — and
151
+ 0.11.1 exists precisely because `instructions` had gone stale about this server's own
152
+ capabilities, which is the same failure seen from the other side.
153
+
154
+ pdf-verify-mcp did this in 0.15.0 and pdf-writer-mcp in 0.19.0; **this release and
155
+ pdf-spec-mcp 0.4.6 complete the family**, which matters because a half-applied diagnostic is
156
+ worse than none: a reader who sees no version line cannot tell "old build" from "build that
157
+ never had the line".
158
+
159
+ No tool, schema or behaviour changed.
160
+
161
+ ### Build
162
+
163
+ - `scripts/sync-plugin-version.mjs` keeps `.claude-plugin/plugin.json` in step with
164
+ `package.json`, wired to the `npm version` hook so the release commit — the tree the tag
165
+ points at — carries the right plugin manifest, and to `prepublishOnly --check` as a
166
+ backstop. Preventive: the drift has happened twice in pdf-verify-mcp and once in
167
+ pdf-writer-mcp, never here, and in each case the fix landed in a commit *after* the tag,
168
+ leaving the tagged tree wrong.
169
+
8
170
  ## [0.11.1] - 2026-07-27
9
171
 
10
172
  ### Fixed
package/README.ja.md CHANGED
@@ -22,7 +22,7 @@ PDF 内部構造解析に特化した MCP (Model Context Protocol) サーバー
22
22
 
23
23
  ## 機能
24
24
 
25
- **18 ツール** を 3 層構成で提供します。
25
+ **19 ツール** を 3 層構成で提供します。
26
26
 
27
27
  ### Tier 1: 基本機能
28
28
 
@@ -30,11 +30,12 @@ PDF 内部構造解析に特化した MCP (Model Context Protocol) サーバー
30
30
  | ---------------- | ----------------------------------------------------- |
31
31
  | `get_page_count` | ページ数の軽量取得 |
32
32
  | `get_metadata` | メタデータ抽出(タイトル、著者、PDF版、タグ有無等) |
33
- | `read_text` | テキスト抽出(Y座標ベースの読み順保持。`split_columns: 2 \| 3` で **タグなし** 多カラム PDF、`compact_whitespace` で 帳票 の U+3000 連続空白を畳み込み)。`/ActualText` 置換(§14.9.4。構造要素・`Span` マーク付きコンテンツの両経路)を解決。**論理順**が要るタグ付き PDF の本文は `extract_structured_text` を推奨 |
33
+ | `read_text` | テキスト抽出(Y座標ベースの読み順保持。`split_columns: 2 \| 3` で **タグなし** 多カラム PDF、`compact_whitespace` で 帳票 の U+3000 連続空白を畳み込み)。`/ActualText` 置換(§14.9.4。構造要素・`Span` マーク付きコンテンツの両経路)を解決。ページごとに**テキスト抽出可能性**(§9.10.1)を併記するので、空の結果が「空のページ」と取り違えられない。**論理順**が要るタグ付き PDF の本文は `extract_structured_text` を推奨 |
34
34
  | `search_text` | 全文検索(前後コンテキスト付き)。`read_text` と同じテキスト(`/ActualText` 解決済み)を検索するため、ヒット=読み手に見えている語(位置合わせできなかったページがあれば `note` で名指し) |
35
- | `read_images` | 画像抽出(base64、メタデータ付き) |
36
- | `read_url` | URLからリモートPDFを取得して処理 |
37
- | `summarize` | 全体概要レポート(メタデータ + テキスト + 画像数) |
35
+ | `read_images` | 埋め込み画像 XObject を **PNG / JPEG ファイル**として抽出し、MCP の image コンテンツブロックで返す(視覚モデルがそのまま読める)。`max_width` / `max_height` で面積平均による縮小。応答にはバイト予算があり、返さなかった画像は理由付きで名指しする |
36
+ | `read_url` | リモート PDF を取得して**テキストだけ**を返す。取得したバイト列は保存しない。URL 上の PDF に他の 18 ツールを使うには、先にローカルへダウンロードしてそのパスを渡す(「read_url と read-only の境界」参照) |
37
+ | `render_page` | ページを **PNG/JPEG** にラスタライズ(PDFium の WASM 版・optionalDependencies の `@hyzyla/pdfium`)。テキスト抽出可能性が `no_text_layer` / `not_extractable` のときの次の一手。ベクタ図形・フォーム込みでページ全体を描く |
38
+ | `summarize` | 全体概要レポート(メタデータ + テキスト + 画像数 + 文書全体のテキスト抽出可能性) |
38
39
 
39
40
  ### Tier 2: 構造解析
40
41
 
@@ -57,6 +58,90 @@ PDF 内部構造解析に特化した MCP (Model Context Protocol) サーバー
57
58
  | `validate_metadata` | **非推奨** — 移管先は上と同じ。次のメジャーまで残置 |
58
59
  | `compare_structure` | 2つのPDFの構造差分比較(プロパティ+フォント) |
59
60
 
61
+ ### read_url と read-only の境界(#25)
62
+
63
+ `read_url` が返すのはテキストだけ。これは設計判断であり、今回それを暗黙から明文にした。
64
+ 取得したバイト列は抽出後に破棄する。保存すれば reader のツールがファイルシステムに
65
+ 書き込むことになり、本サーバの全 19 ツールが read-only(`readOnlyHint: true`)という
66
+ 不変条件が成り立たなくなるため。
67
+
68
+ URL 上の PDF に `search_text` / `inspect_structure` / `extract_tables` / `render_page`
69
+ などを使いたい場合は、呼び出し側の環境が持つ取得手段で**先にローカルへダウンロード**し、
70
+ そのパスを渡す。取得を呼び出し側の責務とするのは意図的で、エージェント環境には必ず
71
+ ファイルを取得する手段が別にあり、ファイルを書く reader は純粋な観測者ではなくなる。
72
+
73
+ 「この URL の文書には何が書いてあるか」という 1 回きりの問いには、引き続き `read_url`
74
+ がそのまま使える。
75
+
76
+ ### テキストが読めない文書はページを描画できる(#23)
77
+
78
+ これまで `summarize` が `hasText: false` を返すと、その先に打つ手が無かった。
79
+ `render_page` はページを PNG / JPEG にラスタライズし、MCP の image コンテンツブロックで
80
+ 返す。スキャン・図面・記入済みフォーム・手書きを、視覚モデルがそのまま読める。
81
+
82
+ ```
83
+ render_page({ file_path: "/path/to/scan.pdf", pages: "1-3", format: "jpeg" })
84
+ ```
85
+
86
+ `pages` は**必須**。描画はこのサーバで最も高価な処理であり、500 ページのスキャンの
87
+ 「全ページ」は既定値ではなく判断であるべきだから。応答予算(4 MB)は `read_images` と
88
+ 同じで、超過分は理由付きで名指しする。
89
+
90
+ 描画エンジンは **PDFium の WebAssembly 版**(`@hyzyla/pdfium`・optionalDependencies)。
91
+ WASM はどのプラットフォームでも同じバイト列なので、`npx` で入る公開版の挙動が環境に
92
+ よらない — ネイティブアドオンを使わない理由がそのまま満たせる。未インストールなら
93
+ `render_page` はインストール方法を返し、他の 18 ツールは通常どおり動く。
94
+ PDFium(BSD-3-Clause)はテキスト読み取りに使っている pdf.js とは別エンジンであり、
95
+ その旨は description に明記してある(エンジン間の描画差をファイルの性質と
96
+ 取り違えないため)。
97
+
98
+ > 採用前の実測: pdf.js + `@napi-rs/canvas`(1.0.7 / 0.1.80)は画像を描くページで
99
+ > プロセスごと Segmentation fault になり(このツールの対象そのもの)、
100
+ > `standardFontDataUrl` 未設定では白紙を「成功」として返した。
101
+
102
+ ### 画像は画像ファイルとして返る(#22)
103
+
104
+ `read_images` は `imgData.data`(pdfjs が**デコードしたピクセル**)をそのまま base64 に
105
+ していた。8×8 RGB なら 192 バイトで、PNG/JPEG のシグネチャはどこにも無い。どのビューアも
106
+ 開けず、画像を取り出す目的そのものである視覚モデルも読めなかった。
107
+
108
+ 現在は PNG(既定・可逆)または JPEG(`format: "jpeg"` と `quality`)にエンコードし、
109
+ MCP の `image` コンテンツブロックで返す。メタデータは従来どおり text ブロックに併記する。
110
+ エンコーダは両方ともこのリポジトリ内に書いてある(ネイティブアドオン無し・
111
+ プラットフォーム別バイナリ無し)。
112
+
113
+ 応答は 4 MB のエンコード済み画像バイトで頭打ちにする。200dpi A4 のスキャンは
114
+ それだけで約 11.6 MB のピクセルになるため、予算を超えた画像は**理由付きで名指し**し、
115
+ 黙って落とさない。
116
+
117
+ ```
118
+ read_images({ file_path: "/path/to/scan.pdf", pages: "1", max_width: 1200, format: "jpeg" })
119
+ ```
120
+
121
+ `read_images` が返すのはページが描く画像 XObject であって、ページの絵ではない。
122
+ ベクタ図形やテキストはこのツールの射程外。
123
+
124
+ ### テキスト抽出可能性 — 2 値ではなく 3 値(#21)
125
+
126
+ `read_text` はこれまで「抽出できたテキスト」か「空」かの 2 値しか返さず、空が 3 つの別々の
127
+ 状態を指していた。ISO 32000-2 §9.10.1 はそれらを区別しているので、本サーバも区別する。
128
+ テキストを返す全ツール(`read_text` / `read_url` / `search_text` /
129
+ `extract_structured_text` / `summarize`)が、ページごとに次を返す。
130
+
131
+ | 状態 | 条件 | 次の一手 |
132
+ | --- | --- | --- |
133
+ | `extracted` | 使われた全フォントが §9.10.2 の方式のいずれかで Unicode に変換できる | そのまま使ってよい |
134
+ | `no_text_layer` | text-showing 演算子(`Tj` `TJ` `'` `"`)が無く、画像が描かれている | ページは画素。OCR かページ画像が要る(本サーバはどちらも行わない) |
135
+ | `not_extractable` | `/ToUnicode` も標準エンコーディングも既知の CID コレクションも持たないフォントが使われている | 一部または全部が欠落している。原因フォント名と根拠条項を併記する |
136
+ | `not_observed` | 暗号化されている、またはコンテンツストリームが読めない | 何も測っていない。「無い」とは別 |
137
+
138
+ `not_extractable` は**フォント単位**で報告するので、読めるフォントと読めないフォントが
139
+ 同じページに混在する場合は「部分的な欠落」としてそう言う。完全な抽出結果には化けない。
140
+
141
+ 判定は pdf.js の出力ではなく**ファイル**から行う。pdf.js は読み込んだ全フォントについて
142
+ `toUnicode` を合成するため、pdf.js に「このフォントは `/ToUnicode` を持つか」と尋ねると、
143
+ 辞書に `/ToUnicode` が無いフォントでも「持つ」と答える。
144
+
60
145
  ## インストール
61
146
 
62
147
  ### npx(推奨)
package/README.md CHANGED
@@ -22,7 +22,7 @@ While typical PDF MCP servers are thin wrappers for text extraction, this projec
22
22
 
23
23
  ## Features
24
24
 
25
- **18 tools** organized into three tiers:
25
+ **19 tools** organized into three tiers:
26
26
 
27
27
  ### Tier 1: Basic Operations
28
28
 
@@ -30,11 +30,12 @@ While typical PDF MCP servers are thin wrappers for text extraction, this projec
30
30
  | ---------------- | -------------------------------------------------------- |
31
31
  | `get_page_count` | Lightweight page count retrieval |
32
32
  | `get_metadata` | Full metadata extraction (title, author, PDF version...) |
33
- | `read_text` | Text extraction with Y-coordinate reading order (opt-in `split_columns: 2 \| 3` for untagged multi-column PDFs, `compact_whitespace` for Japanese forms). Resolves `/ActualText` replacements (§14.9.4, both the structure-element and the `Span` marked-content path). For **logical** order in tagged PDFs, prefer `extract_structured_text` |
33
+ | `read_text` | Text extraction with Y-coordinate reading order (opt-in `split_columns: 2 \| 3` for untagged multi-column PDFs, `compact_whitespace` for Japanese forms). Resolves `/ActualText` replacements (§14.9.4, both the structure-element and the `Span` marked-content path). Reports **text extractability** per page (§9.10.1) so an empty result is never mistaken for an empty page. For **logical** order in tagged PDFs, prefer `extract_structured_text` |
34
34
  | `search_text` | Full-text search with surrounding context. Searches the same text `read_text` returns, `/ActualText` included, so a hit means what a reader sees (a `note` names any page whose marked content could not be aligned) |
35
- | `read_images` | Image extraction as base64 with metadata |
36
- | `read_url` | Fetch and process remote PDFs from URLs |
37
- | `summarize` | Quick overview report (metadata + text + image count) |
35
+ | `read_images` | Embedded image XObjects as **PNG or JPEG files**, returned as MCP image content blocks so a vision model can read them. `max_width` / `max_height` downscale by area average; the response has a byte budget and names anything it leaves out |
36
+ | `read_url` | Fetch a remote PDF and extract its **text** — nothing more. The bytes are not saved; to use the other 18 tools on a URL's PDF, download it first and pass the local path (see "read_url and the read-only boundary") |
37
+ | `render_page` | Rasterise pages to **PNG/JPEG** via PDFium-WASM (optional dependency `@hyzyla/pdfium`). The next step when text extractability says `no_text_layer` / `not_extractable` — draws the whole page, vector art and forms included |
38
+ | `summarize` | Quick overview report (metadata + text + image count + per-document text extractability) |
38
39
 
39
40
  ### Tier 2: Structure Inspection
40
41
 
@@ -57,6 +58,91 @@ While typical PDF MCP servers are thin wrappers for text extraction, this projec
57
58
  | `validate_metadata` | **Deprecated** — same migration path as above. Kept until the next major |
58
59
  | `compare_structure` | Structural diff between two PDFs (properties + fonts)|
59
60
 
61
+ ### read_url and the read-only boundary (#25)
62
+
63
+ `read_url` returns text, and only text. This is a decision, now stated rather than implied:
64
+ the fetched bytes are discarded after extraction, because saving them would make a reader
65
+ tool write to the file system, and every tool of this server is read-only
66
+ (`readOnlyHint: true` — all 19 of them).
67
+
68
+ To run `search_text`, `inspect_structure`, `extract_tables`, `render_page` or anything else
69
+ against a PDF that lives at a URL, download the file first — with whatever fetch capability
70
+ the calling environment has — and pass the local path. Fetching is the caller's
71
+ responsibility, deliberately: an agent environment always has a way to download a file, and a
72
+ reader that also writes files has stopped being a pure observer.
73
+
74
+ `read_url` remains the right tool for the one-shot question: *what does the document at this
75
+ URL say?*
76
+
77
+ ### Pages can be rendered when text cannot be read (#23)
78
+
79
+ `summarize` reporting `hasText: false` used to be a dead end: nothing in this server could
80
+ read the document any further. `render_page` closes that — it rasterises pages to PNG or JPEG
81
+ and returns them as MCP image content blocks, so a vision model can read a scan, a diagram, a
82
+ filled form, or handwriting.
83
+
84
+ ```
85
+ render_page({ file_path: "/path/to/scan.pdf", pages: "1-3", format: "jpeg" })
86
+ ```
87
+
88
+ `pages` is required: rendering is the most expensive operation here, and "all pages" of a
89
+ 500-page scan should be a decision, not a default. The same 4 MB response budget as
90
+ `read_images` applies, with omissions named.
91
+
92
+ Rendering runs on **PDFium compiled to WebAssembly** (`@hyzyla/pdfium`, an optional
93
+ dependency). A WASM binary is the same bytes on every platform, so the published package still
94
+ behaves identically wherever `npx` runs it — the reason native addons are not used here.
95
+ Without the dependency installed, `render_page` reports what to install and every other tool
96
+ works normally. PDFium (BSD-3-Clause) is a different engine from the pdf.js this server reads
97
+ text with; the tool description says so, because a rendering difference between engines must
98
+ not be attributed to the file.
99
+
100
+ > Measured before choosing this: pdf.js + `@napi-rs/canvas` (1.0.7 and 0.1.80) segfaults the
101
+ > whole process on pages that draw images — exactly the pages this tool exists for — and
102
+ > renders blank pages when `standardFontDataUrl` is not configured.
103
+
104
+ ### Images come back as image files (#22)
105
+
106
+ `read_images` used to base64 `imgData.data` — pdfjs's *decoded pixels*. An 8×8 RGB image was
107
+ 192 bytes with no PNG or JPEG signature anywhere in it, so the result could not be opened by
108
+ any viewer and could not be read by a vision model, which is the reason to extract an image in
109
+ the first place.
110
+
111
+ Images are now encoded (PNG by default, lossless; `format: "jpeg"` with `quality` when smaller
112
+ matters) and returned as MCP `image` content blocks, with the metadata alongside in a text
113
+ block. Both encoders are written out here — no native addon, no per-platform binary.
114
+
115
+ The response is bounded at 4 MB of encoded image data. A 200 dpi A4 scan is ~11.6 MB of pixels
116
+ on its own, so images past the budget are **named with the reason** rather than dropped:
117
+
118
+ ```
119
+ read_images({ file_path: "/path/to/scan.pdf", pages: "1", max_width: 1200, format: "jpeg" })
120
+ ```
121
+
122
+ `read_images` returns the image XObjects a page draws. It is not a picture of the page — vector
123
+ drawings and text are not covered by it.
124
+
125
+ ### Text extractability — three states, not two (#21)
126
+
127
+ `read_text` used to answer with text or with nothing, and nothing meant three different things.
128
+ ISO 32000-2 §9.10.1 separates them, so this server does too. Every text-returning tool —
129
+ `read_text`, `read_url`, `search_text`, `extract_structured_text`, `summarize` — reports, per
130
+ page:
131
+
132
+ | State | Condition | What to do next |
133
+ | --- | --- | --- |
134
+ | `extracted` | Every font used has a route to Unicode under §9.10.2 | Use the text |
135
+ | `no_text_layer` | No text-showing operator (`Tj` `TJ` `'` `"`), image content present | The page is pixels. OCR or a rendered image is needed; this server does neither |
136
+ | `not_extractable` | A font used has no `/ToUnicode`, no standard encoding and no known CID collection | Text is missing or wrong. The report names the fonts and the clause |
137
+ | `not_observed` | Encrypted, or the content stream could not be read | Nothing was measured. Not the same as "nothing is there" |
138
+
139
+ `not_extractable` is reported **per font**, so a page that mixes a readable font with an
140
+ unreadable one is a partial loss and says so, rather than passing as complete.
141
+
142
+ The observation is made from the file, not from pdf.js's output: pdf.js synthesises a
143
+ `toUnicode` map for every font it loads, so asking it whether a font has a `/ToUnicode` CMap
144
+ answers yes for fonts whose dictionary has none.
145
+
60
146
  ## Installation
61
147
 
62
148
  ### npx (recommended)
@@ -7,6 +7,26 @@ export declare const CHARACTER_LIMIT = 25000;
7
7
  export declare const MAX_FILE_SIZE: number;
8
8
  /** Default page limit for text extraction */
9
9
  export declare const DEFAULT_PAGE_LIMIT = 50;
10
+ /**
11
+ * Ceiling on the ENCODED image bytes one `read_images` response may carry (#22).
12
+ *
13
+ * A 200 dpi A4 scan decodes to 1654×2339×3 = 11.6 MB of pixels, which is ~15.5 MB
14
+ * once base64'd — a single image can therefore exceed anything a client will
15
+ * accept. `read_text` has had a character limit since the beginning; images had
16
+ * none, which is the asymmetry this closes. Images beyond the budget are named
17
+ * and omitted rather than silently dropped.
18
+ */
19
+ export declare const MAX_IMAGE_RESPONSE_BYTES: number;
20
+ /**
21
+ * Ceiling on the pixels of a single image this server will re-encode.
22
+ *
23
+ * The encoders are plain JavaScript. Above this size the cost is measured in
24
+ * seconds, and a caller who wants such an image should say what size they want
25
+ * it at (`max_width` / `max_height`) rather than wait for the full one.
26
+ */
27
+ export declare const MAX_IMAGE_PIXELS = 40000000;
28
+ /** Default JPEG quality for `read_images` when `format: "jpeg"` is asked for. */
29
+ export declare const DEFAULT_IMAGE_QUALITY = 80;
10
30
  /** Maximum number of search results to return */
11
31
  export declare const MAX_SEARCH_RESULTS = 100;
12
32
  /** Default context characters around search matches */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,0CAA0C;AAC1C,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC,4CAA4C;AAC5C,eAAO,MAAM,aAAa,QAAmB,CAAC;AAE9C,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,iDAAiD;AACjD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,kBAAkB;AAClB,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C,2EAA2E;AAC3E,eAAO,MAAM,cAAc,QAAsB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0CAA0C;AAC1C,eAAO,MAAM,iBAAiB,QAC8D,CAAC;AAE7F,2BAA2B;AAC3B,oBAAY,cAAc;IACxB,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,0CAA0C;AAC1C,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC,4CAA4C;AAC5C,eAAO,MAAM,aAAa,QAAmB,CAAC;AAE9C,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,WAAa,CAAC;AAE3C,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,iDAAiD;AACjD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,kBAAkB;AAClB,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C,2EAA2E;AAC3E,eAAO,MAAM,cAAc,QAAsB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0CAA0C;AAC1C,eAAO,MAAM,iBAAiB,QAC8D,CAAC;AAE7F,2BAA2B;AAC3B,oBAAY,cAAc;IACxB,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd"}
package/dist/constants.js CHANGED
@@ -10,6 +10,26 @@ export const CHARACTER_LIMIT = 25_000;
10
10
  export const MAX_FILE_SIZE = 50 * 1024 * 1024;
11
11
  /** Default page limit for text extraction */
12
12
  export const DEFAULT_PAGE_LIMIT = 50;
13
+ /**
14
+ * Ceiling on the ENCODED image bytes one `read_images` response may carry (#22).
15
+ *
16
+ * A 200 dpi A4 scan decodes to 1654×2339×3 = 11.6 MB of pixels, which is ~15.5 MB
17
+ * once base64'd — a single image can therefore exceed anything a client will
18
+ * accept. `read_text` has had a character limit since the beginning; images had
19
+ * none, which is the asymmetry this closes. Images beyond the budget are named
20
+ * and omitted rather than silently dropped.
21
+ */
22
+ export const MAX_IMAGE_RESPONSE_BYTES = 4 * 1024 * 1024;
23
+ /**
24
+ * Ceiling on the pixels of a single image this server will re-encode.
25
+ *
26
+ * The encoders are plain JavaScript. Above this size the cost is measured in
27
+ * seconds, and a caller who wants such an image should say what size they want
28
+ * it at (`max_width` / `max_height`) rather than wait for the full one.
29
+ */
30
+ export const MAX_IMAGE_PIXELS = 40_000_000;
31
+ /** Default JPEG quality for `read_images` when `format: "jpeg"` is asked for. */
32
+ export const DEFAULT_IMAGE_QUALITY = 80;
13
33
  /** Maximum number of search results to return */
14
34
  export const MAX_SEARCH_RESULTS = 100;
15
35
  /** Default context characters around search matches */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAEtE,0CAA0C;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,6CAA6C;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,iDAAiD;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,uDAAuD;AACvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,kBAAkB;AAClB,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAE5C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAC5B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,yBAAyB,CAAC;AAE7F,2BAA2B;AAC3B,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
1
+ {"version":3,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AAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
package/dist/index.js CHANGED
@@ -24,7 +24,9 @@ import { registerAllTools } from './tools/index.js';
24
24
  * 呼ばないうちに読まれる — 射程を伝える位置としてはここが最も早い。
25
25
  * 先例は pdf-spec-mcp v0.4.5(Issue #13)。
26
26
  */
27
- const INSTRUCTIONS = `This server OBSERVES what is inside a PDF. It does not judge whether it is correct.
27
+ const INSTRUCTIONS = `${SERVER_NAME} v${SERVER_VERSION} — the running build identifies itself here so a stale install is visible without a tool call; compare against \`npm view @shuji-bonji/pdf-reader-mcp version\` when freshness matters.
28
+
29
+ This server OBSERVES what is inside a PDF. It does not judge whether it is correct.
28
30
 
29
31
  Everything it returns is an observation: extracted text, tables, the structure tree, fonts,
30
32
  annotations, images, and the *structure* of signature fields. Treat the output as evidence,
@@ -36,7 +38,13 @@ What it does NOT do:
36
38
  (verify_signatures / verify_integrity).
37
39
  - No conformance judgement. validate_tagged / validate_metadata are deprecated in favour of
38
40
  pdf-verify-mcp's validate_conformance, which delegates to veraPDF.
39
- - No incremental-update history (that is pdf-verify-mcp verify_integrity), and no OCR.
41
+ - No incremental-update history (that is pdf-verify-mcp verify_integrity), and no OCR. It
42
+ does DETECT that OCR is needed and say so: every text-returning tool reports, per page,
43
+ whether the characters could be converted to Unicode at all (ISO 32000-2 §9.10.1) —
44
+ extracted / no_text_layer / not_extractable / not_observed. An empty extraction result is
45
+ therefore never on its own evidence that a page has no text. When a page cannot be read as
46
+ text, render_page rasterises it (PDFium-WASM, optional dependency) so a vision model can
47
+ read the pixels instead.
40
48
 
41
49
  It DOES map content to coordinates: locate_objects turns an object number into a page and a
42
50
  rectangle, and extract_structured_text with include_bbox does the same for a structure element.
@@ -47,6 +55,11 @@ measurement and a rectangle the file merely declares are not the same claim.
47
55
  Where an observation here and a verdict from pdf-verify-mcp disagree, the verdict wins —
48
56
  this server reads the file, the validator applies the rules.
49
57
 
58
+ This server never writes to the file system — every tool is read-only. That is also why
59
+ read_url returns text and nothing more: it does not save the fetched bytes, so pointing the
60
+ other tools at a URL's PDF means downloading the file first (the caller's job, not this
61
+ server's) and passing its local path.
62
+
50
63
  For what the specification *requires*, ask pdf-spec-mcp. This server never quotes ISO clauses.`;
51
64
  const server = new McpServer({
52
65
  name: SERVER_NAME,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,8CAA8C;AAC9C,sEAAsE;AACtE,sEAAsE;AACtE,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;AACxC,MAAM,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1C,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AACtE,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;+FAuB0E,CAAC;AAEhG,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;IACE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;CACxB,EACD,EAAE,YAAY,EAAE,YAAY,EAAE,CAC/B,CAAC;AA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AK,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+FAoCyC,CAAC;AAEhG,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;IACE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;CACxB,EACD,EAAE,YAAY,EAAE,YAAY,EAAE,CAC/B,CAAC;AAEF,qBAAqB;AACrB,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAEzB,wCAAwC;AACxC,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,GAAG,WAAW,KAAK,cAAc,oBAAoB,CAAC,CAAC;AACvE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -87,16 +87,36 @@ export declare const SearchTextSchema: z.ZodObject<{
87
87
  context_chars?: number | undefined;
88
88
  max_results?: number | undefined;
89
89
  }>;
90
- /** read_images */
90
+ /**
91
+ * `read_images` — Issue #22: the response is now real image files, and its size
92
+ * is bounded.
93
+ *
94
+ * `format` defaults to PNG because PNG is lossless: an image extracted for
95
+ * inspection should not have JPEG artefacts added on the way out. `quality`
96
+ * exists for the case where the caller would rather have a smaller response,
97
+ * and is ignored for PNG rather than silently doing nothing surprising.
98
+ */
91
99
  export declare const ReadImagesSchema: z.ZodObject<{
92
100
  file_path: z.ZodString;
93
101
  pages: z.ZodOptional<z.ZodString>;
102
+ format: z.ZodOptional<z.ZodEnum<["png", "jpeg"]>>;
103
+ quality: z.ZodOptional<z.ZodNumber>;
104
+ max_width: z.ZodOptional<z.ZodNumber>;
105
+ max_height: z.ZodOptional<z.ZodNumber>;
94
106
  }, "strict", z.ZodTypeAny, {
95
107
  file_path: string;
96
108
  pages?: string | undefined;
109
+ format?: "png" | "jpeg" | undefined;
110
+ quality?: number | undefined;
111
+ max_width?: number | undefined;
112
+ max_height?: number | undefined;
97
113
  }, {
98
114
  file_path: string;
99
115
  pages?: string | undefined;
116
+ format?: "png" | "jpeg" | undefined;
117
+ quality?: number | undefined;
118
+ max_width?: number | undefined;
119
+ max_height?: number | undefined;
100
120
  }>;
101
121
  /** read_url */
102
122
  export declare const ReadUrlSchema: z.ZodObject<{
@@ -129,6 +149,37 @@ export declare const SummarizeSchema: z.ZodObject<{
129
149
  file_path: string;
130
150
  response_format?: import("../constants.js").ResponseFormat | undefined;
131
151
  }>;
152
+ /**
153
+ * `render_page` — Issue #23: rasterise pages for documents whose text cannot
154
+ * be read as text.
155
+ *
156
+ * `pages` is REQUIRED, unlike every other tool here. Rendering is the most
157
+ * expensive thing this server does, and "all pages" of a 500-page scan is
158
+ * never what a caller means; making the range explicit keeps the cost a
159
+ * decision instead of a default.
160
+ */
161
+ export declare const RenderPageSchema: z.ZodObject<{
162
+ file_path: z.ZodString;
163
+ pages: z.ZodString;
164
+ dpi: z.ZodOptional<z.ZodNumber>;
165
+ max_width: z.ZodOptional<z.ZodNumber>;
166
+ format: z.ZodOptional<z.ZodEnum<["png", "jpeg"]>>;
167
+ quality: z.ZodOptional<z.ZodNumber>;
168
+ }, "strict", z.ZodTypeAny, {
169
+ file_path: string;
170
+ pages: string;
171
+ format?: "png" | "jpeg" | undefined;
172
+ quality?: number | undefined;
173
+ max_width?: number | undefined;
174
+ dpi?: number | undefined;
175
+ }, {
176
+ file_path: string;
177
+ pages: string;
178
+ format?: "png" | "jpeg" | undefined;
179
+ quality?: number | undefined;
180
+ max_width?: number | undefined;
181
+ dpi?: number | undefined;
182
+ }>;
132
183
  export type GetPageCountInput = z.infer<typeof GetPageCountSchema>;
133
184
  export type GetMetadataInput = z.infer<typeof GetMetadataSchema>;
134
185
  export type ReadTextInput = z.infer<typeof ReadTextSchema>;
@@ -136,4 +187,5 @@ export type SearchTextInput = z.infer<typeof SearchTextSchema>;
136
187
  export type ReadImagesInput = z.infer<typeof ReadImagesSchema>;
137
188
  export type ReadUrlInput = z.infer<typeof ReadUrlSchema>;
138
189
  export type SummarizeInput = z.infer<typeof SummarizeSchema>;
190
+ export type RenderPageInput = z.infer<typeof RenderPageSchema>;
139
191
  //# sourceMappingURL=tier1.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tier1.d.ts","sourceRoot":"","sources":["../../src/schemas/tier1.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,qBAAqB;AACrB,eAAO,MAAM,kBAAkB;;;;;;EAIpB,CAAC;AAEZ,mBAAmB;AACnB,eAAO,MAAM,iBAAiB;;;;;;;;;EAKnB,CAAC;AAEZ;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,4BAW5B,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,6BAOjC,CAAC;AAEJ,gBAAgB;AAChB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;EAQhB,CAAC;AAEZ,kBAAkB;AAClB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAyBlB,CAAC;AAEZ,kBAAkB;AAClB,eAAO,MAAM,gBAAgB;;;;;;;;;EAKlB,CAAC;AAEZ,eAAe;AACf,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAQf,CAAC;AAEZ,gBAAgB;AAChB,eAAO,MAAM,eAAe;;;;;;;;;EAKjB,CAAC;AAGZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACnE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACjE,MAAM,MAAM,aAAa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