@shuji-bonji/pdf-reader-mcp 0.9.2 → 0.11.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.
- package/CHANGELOG.md +88 -0
- package/README.ja.md +41 -2
- package/README.md +43 -2
- package/dist/schemas/tier2.d.ts +18 -0
- package/dist/schemas/tier2.d.ts.map +1 -1
- package/dist/schemas/tier2.js +23 -0
- package/dist/schemas/tier2.js.map +1 -1
- package/dist/services/object-locator.d.ts +33 -0
- package/dist/services/object-locator.d.ts.map +1 -0
- package/dist/services/object-locator.js +340 -0
- package/dist/services/object-locator.js.map +1 -0
- package/dist/services/pdfjs-service.d.ts +61 -0
- package/dist/services/pdfjs-service.d.ts.map +1 -1
- package/dist/services/pdfjs-service.js +160 -0
- package/dist/services/pdfjs-service.js.map +1 -1
- package/dist/services/struct-tree-service.d.ts +13 -1
- package/dist/services/struct-tree-service.d.ts.map +1 -1
- package/dist/services/struct-tree-service.js +208 -5
- package/dist/services/struct-tree-service.js.map +1 -1
- package/dist/services/struct-tree-walker.d.ts +13 -0
- package/dist/services/struct-tree-walker.d.ts.map +1 -1
- package/dist/services/struct-tree-walker.js +77 -3
- package/dist/services/struct-tree-walker.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/tier2/extract-structured-text.d.ts.map +1 -1
- package/dist/tools/tier2/extract-structured-text.js +30 -2
- package/dist/tools/tier2/extract-structured-text.js.map +1 -1
- package/dist/tools/tier2/locate-objects.d.ts +6 -0
- package/dist/tools/tier2/locate-objects.d.ts.map +1 -0
- package/dist/tools/tier2/locate-objects.js +61 -0
- package/dist/tools/tier2/locate-objects.js.map +1 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/formatter.d.ts +10 -1
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +71 -0
- package/dist/utils/formatter.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,94 @@ 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.11.0] - 2026-07-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`extract_structured_text` `include_bbox` — structure element → drawing rectangle**
|
|
13
|
+
([#20](https://github.com/shuji-bonji/pdf-reader-mcp/issues/20), stage 2). Stage 1
|
|
14
|
+
(`locate_objects`) answered "where is object 27?", which is what a revision diff hands over.
|
|
15
|
+
This answers the question the issue was actually filed for: **"where is this paragraph?"** —
|
|
16
|
+
UC-7's step 4, annotating the element a report points at. Measured end to end: a rectangle from
|
|
17
|
+
here goes into `add_annotation` unchanged and comes back out of `inspect_annotations` identical.
|
|
18
|
+
|
|
19
|
+
Added to the existing tool rather than as a nineteenth: it already resolves MCID → text, so the
|
|
20
|
+
extra cost is small, and "which element, what it says, where it is" arrives in one call.
|
|
21
|
+
Off by default; it costs a second pass over every page.
|
|
22
|
+
|
|
23
|
+
Each element gains `boxes` — **one rectangle per page**, because an element that spans pages has
|
|
24
|
+
no single rectangle and merging them would place content on a page it is not on. Rectangles are
|
|
25
|
+
in PDF default user space (origin bottom-left, pt, normalised), unaffected by `/Rotate` or by a
|
|
26
|
+
`/CropBox` whose origin is not (0, 0).
|
|
27
|
+
|
|
28
|
+
**Each names its `basis`, and the two are different kinds of claim:**
|
|
29
|
+
|
|
30
|
+
| basis | what it is |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `layout-attribute-bbox` | the `/BBox` the file **declares** (ISO 32000-2 Table 379), read through `/A` and through `/C` + `/ClassMap` (§14.7.6.2). A producer's statement about its own geometry — and the only source for content that has no text |
|
|
33
|
+
| `text-extent` | **measured** from the element's text: the run's baseline origin (§9.4.4's Trm without the device transform) plus the font's ascent/descent. The line box, not the glyph outlines. Images and vector art contribute nothing |
|
|
34
|
+
|
|
35
|
+
**A declaration is reported as-is, and cross-checked.** Files state nonsense: the cover `Figure`
|
|
36
|
+
of *both* Well-Tagged PDF 1.0 and the Tagged PDF Best Practice Guide declares
|
|
37
|
+
`/BBox [-32768 -32768 32767 32767]` — int16 sentinels where a rectangle should be — and
|
|
38
|
+
PDF32000_2008 has 131 of its 545 declarations reaching past the page edge. Since the whole point
|
|
39
|
+
of this output is that it goes straight into `add_annotation`, a declaration is checked against
|
|
40
|
+
the page box (§7.7.3.3) and against the element's own text; either contradiction is reported in
|
|
41
|
+
`boxNote`, with the rectangle still returned unaltered. An element with no rectangle says why
|
|
42
|
+
instead of returning a zero-sized one — a `Figure` holding one image is the usual case
|
|
43
|
+
(§14.8.4.8.5: such an element "should have a BBox attribute").
|
|
44
|
+
|
|
45
|
+
Two things are deliberately not done, because getting them wrong yields a *plausible* rectangle
|
|
46
|
+
rather than an error: text is measured along the **run's own axes**, not the page's (an
|
|
47
|
+
axis-aligned `x + width` puts 20 pt text rotated 45° at x2 = 317.8 instead of 300.9); and an
|
|
48
|
+
element containing **vertical writing** gets no rectangle at all, since pdfjs reports the advance
|
|
49
|
+
in `height` for those and a box covering only the horizontal part would be wrong, not absent.
|
|
50
|
+
|
|
51
|
+
Validated against independent ground truth rather than against fixtures: on *Well-Tagged PDF
|
|
52
|
+
(WTPDF) 1.0*, the 166 `Link` structure elements were compared with the 173 `Link` **annotation**
|
|
53
|
+
`/Rect` values the producer placed for the same links — median IoU **0.972**, none disjoint.
|
|
54
|
+
The invariant "an element that has text has a rectangle" holds over 78,198 elements across
|
|
55
|
+
WTPDF 1.0, the Tagged PDF Best Practice Guide, PDF32000_2008 and ISO 32000-2.
|
|
56
|
+
|
|
57
|
+
## [0.10.0] - 2026-07-27
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- **`locate_objects` — object number → page and rectangle**
|
|
62
|
+
([#20](https://github.com/shuji-bonji/pdf-reader-mcp/issues/20)). The family could say *which*
|
|
63
|
+
object changed (`verify_integrity`) and could *draw* on a rectangle (`add_annotation`), but had
|
|
64
|
+
no way to get from one to the other: `add_annotation` requires a rect, and nothing in the family
|
|
65
|
+
could produce it. That gap is why UC-10 — "point at the object that was tampered with" — was
|
|
66
|
+
filed as undesigned rather than as work.
|
|
67
|
+
|
|
68
|
+
The rectangle comes back in PDF user space, origin bottom-left, in points, normalised to
|
|
69
|
+
`x1 < x2` and `y1 < y2` (ISO 32000-1 §7.9.5). That is not a formatting choice: it is the exact
|
|
70
|
+
shape `add_annotation` accepts, so the result can be handed over without being reinterpreted —
|
|
71
|
+
and reinterpretation is where coordinate systems go wrong.
|
|
72
|
+
|
|
73
|
+
**Every location names the basis it rests on**, because they are not equally strong claims:
|
|
74
|
+
|
|
75
|
+
| basis | what it means | how exact |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `annotation-rect` | the object's own `/Rect` | exact |
|
|
78
|
+
| `page-box` | the object is a page; its crop/media box | exact |
|
|
79
|
+
| `page-content-stream` | the object draws the page | **the whole page**, not the part that changed |
|
|
80
|
+
| `page-resource` | a font, image or colour space the page uses | no rectangle exists |
|
|
81
|
+
|
|
82
|
+
Collapsing those into one "rect" field would let a page-sized rectangle be read as "the region
|
|
83
|
+
that changed". Narrowing a content stream to the paragraph that moved needs a content-stream
|
|
84
|
+
walk carrying the graphics state — the structure-element→bbox half of #20, which stays open.
|
|
85
|
+
|
|
86
|
+
Two distinctions kept deliberately: an object number with no object is `found: false`, not
|
|
87
|
+
"found but unlocatable" (a diff hands over objects a later revision freed, and the two readings
|
|
88
|
+
are opposite); and in an encrypted document coordinates and types are still reported — numbers
|
|
89
|
+
and names are not encrypted, ISO 32000-1 §7.6.2 — while `/T` field names come back as `null`
|
|
90
|
+
rather than as the ciphertext pdf-lib would hand over.
|
|
91
|
+
|
|
92
|
+
Verified against 60 PDFs on hand: 0 errors. On a real sign-then-annotate specimen the tool turns
|
|
93
|
+
verify's "object 27 was added after the signature" into page 1, rect (72, 700, 300, 720), which
|
|
94
|
+
`add_annotation` takes as-is — UC-10 end to end.
|
|
95
|
+
|
|
8
96
|
## [0.9.2] - 2026-07-25
|
|
9
97
|
|
|
10
98
|
### Documentation
|
package/README.ja.md
CHANGED
|
@@ -22,7 +22,7 @@ PDF 内部構造解析に特化した MCP (Model Context Protocol) サーバー
|
|
|
22
22
|
|
|
23
23
|
## 機能
|
|
24
24
|
|
|
25
|
-
**
|
|
25
|
+
**18 ツール** を 3 層構成で提供します。
|
|
26
26
|
|
|
27
27
|
### Tier 1: 基本機能
|
|
28
28
|
|
|
@@ -45,8 +45,9 @@ PDF 内部構造解析に特化した MCP (Model Context Protocol) サーバー
|
|
|
45
45
|
| `inspect_fonts` | フォント一覧(埋め込み/サブセット/Type判定) |
|
|
46
46
|
| `inspect_annotations` | 注釈一覧(タイプ別分類) |
|
|
47
47
|
| `inspect_signatures` | 電子署名フィールドの構造解析 |
|
|
48
|
-
| `extract_structured_text` | Tagged PDF のテキストを**論理コンテンツ順**(ISO 32000-2 §14.8.2.5)で、構造タイプ(`H1` / `P` / `Table` …)のラベル付きで抽出。`/ActualText` を解決し、`/Alt`・箇条書き記号は本文と分離、ページ跨ぎ要素は 1
|
|
48
|
+
| `extract_structured_text` | Tagged PDF のテキストを**論理コンテンツ順**(ISO 32000-2 §14.8.2.5)で、構造タイプ(`H1` / `P` / `Table` …)のラベル付きで抽出。`/ActualText` を解決し、`/Alt`・箇条書き記号は本文と分離、ページ跨ぎ要素は 1 要素のまま。`include_bbox: true` で**各要素の描画位置**(ページごとに 1 矩形・`add_annotation` がそのまま取る形)を追加 |
|
|
49
49
|
| `extract_tables` | Tagged PDF の `<Table>` を Markdown テーブルとして抽出。ページを跨ぐ表は 1 つの表(`pages` 配列)として返す |
|
|
50
|
+
| `locate_objects` | オブジェクト番号 → ページ + 矩形。座標は [pdf-writer-mcp](https://github.com/shuji-bonji/pdf-writer-mcp) の `add_annotation` がそのまま受け取る形(PDF 座標系・左下原点・pt・正規化済み)。[pdf-verify-mcp](https://github.com/shuji-bonji/pdf-verify-mcp) の `verify_integrity` が返す「どのオブジェクトが変わったか」を「どこにあるか」に繋ぐ。各位置は根拠(`basis`)を明示する — 注釈自身の `/Rect` は正確、コンテンツストリームは「ページ全体」までしか言えない |
|
|
50
51
|
|
|
51
52
|
### Tier 3: 検証・分析
|
|
52
53
|
|
|
@@ -188,6 +189,44 @@ extract_structured_text({ file_path: "/path/to/report.pdf", pages: "1-2" })
|
|
|
188
189
|
`roles: ["H1", "H2"]` でアウトラインだけの取得も可能。タグ無し文書は座標から
|
|
189
190
|
推測せず `isTagged: false` と理由を返します。
|
|
190
191
|
|
|
192
|
+
#### `include_bbox`: 要素がどこに描かれているか
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
extract_structured_text({ file_path: "/doc.pdf", roles: ["P"], include_bbox: true })
|
|
196
|
+
→ - **P** (page 1) — Measured paragraph
|
|
197
|
+
- *bbox* p1 `(50.0, 297.5, 161.4, 308.6)` — text-extent
|
|
198
|
+
- **Figure** (page 1)
|
|
199
|
+
- *bbox* p1 `(50.0, 150.0, 110.0, 190.0)` — layout-attribute-bbox
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
矩形は PDF default user space(左下原点・pt・正規化済み)=
|
|
203
|
+
[pdf-writer-mcp](https://github.com/shuji-bonji/pdf-writer-mcp) `add_annotation`
|
|
204
|
+
がそのまま取る形なので、「この段落に注釈を付ける」の途中で座標系を解釈し直す
|
|
205
|
+
必要がありません。`/Rotate` や原点がずれた `/CropBox` の影響も受けません。
|
|
206
|
+
|
|
207
|
+
`basis` は主張の強さを表し、2 つは**種類が違う**:
|
|
208
|
+
|
|
209
|
+
| `basis` | 中身 |
|
|
210
|
+
| --- | --- |
|
|
211
|
+
| `layout-attribute-bbox` | ファイルが**宣言**している `/BBox`(ISO 32000-2 Table 379)。`/A` と `/C` + `/ClassMap` の両経路を読む。生成者の申告をそのまま返す=**テキストを持たない内容について言える唯一の根拠** |
|
|
212
|
+
| `text-extent` | 要素が持つテキストからの**実測**。ベースライン原点+フォントの ascent/descent = 行ボックスであってグリフ輪郭ではない。画像・ベクター描画は一切寄与しない |
|
|
213
|
+
|
|
214
|
+
ページを跨ぐ要素は**ページごとに 1 矩形**(1 つに潰すと、その要素が無いページに
|
|
215
|
+
矩形を置くことになる)。矩形が出せない要素は 0 幅の矩形ではなく `boxNote` で
|
|
216
|
+
理由を述べます。
|
|
217
|
+
|
|
218
|
+
**宣言はそのまま返した上で、突き合わせます。** ファイルは平気で嘘を書きます —
|
|
219
|
+
*Well-Tagged PDF 1.0* と *Tagged PDF Best Practice Guide* の**両方**の表紙 `Figure` が
|
|
220
|
+
`/BBox [-32768 -32768 32767 32767]`(矩形であるべき場所に int16 のセンチネル)を
|
|
221
|
+
宣言しており、PDF32000_2008 は 545 件中 131 件がページの外まで届きます。
|
|
222
|
+
この出力は `add_annotation` にそのまま渡される前提なので、宣言は**ページボックス
|
|
223
|
+
(§7.7.3.3)**と**要素自身の本文**の両方に突き合わせ、どちらかと矛盾すれば
|
|
224
|
+
`boxNote` で報告します(矩形自体は改変せずそのまま返します)。
|
|
225
|
+
|
|
226
|
+
**独立した正解との突き合わせ**: *Well-Tagged PDF (WTPDF) 1.0* で、`Link` 構造要素
|
|
227
|
+
166 件の実測矩形を、生成者が同じリンクに対して置いた `Link` **注釈**の `/Rect`
|
|
228
|
+
173 件と比較した結果、IoU 中央値 **0.972**・完全に外れたものは 0 件。
|
|
229
|
+
|
|
191
230
|
### Tagged PDF からテーブル抽出
|
|
192
231
|
|
|
193
232
|
```
|
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
|
-
**
|
|
25
|
+
**18 tools** organized into three tiers:
|
|
26
26
|
|
|
27
27
|
### Tier 1: Basic Operations
|
|
28
28
|
|
|
@@ -45,8 +45,9 @@ While typical PDF MCP servers are thin wrappers for text extraction, this projec
|
|
|
45
45
|
| `inspect_fonts` | Font inventory (embedded/subset/type detection) |
|
|
46
46
|
| `inspect_annotations` | Annotation listing (categorized by subtype) |
|
|
47
47
|
| `inspect_signatures` | Digital signature field structure analysis |
|
|
48
|
-
| `extract_structured_text` | Tagged PDF text in **logical content order** (ISO 32000-2 §14.8.2.5), each piece labelled with its structure type (`H1` / `P` / `Table` …). Resolves `/ActualText`, separates `/Alt` and list labels, keeps page-spanning elements whole |
|
|
48
|
+
| `extract_structured_text` | Tagged PDF text in **logical content order** (ISO 32000-2 §14.8.2.5), each piece labelled with its structure type (`H1` / `P` / `Table` …). Resolves `/ActualText`, separates `/Alt` and list labels, keeps page-spanning elements whole. `include_bbox: true` adds **where each element is drawn** — one rectangle per page, in the form `add_annotation` takes |
|
|
49
49
|
| `extract_tables` | Tagged PDF `<Table>` subtree → Markdown table (preserves columns). A table continuing across a page break is ONE table (`pages` array) |
|
|
50
|
+
| `locate_objects` | Object number → page and rectangle, in the coordinate form [pdf-writer-mcp](https://github.com/shuji-bonji/pdf-writer-mcp) `add_annotation` takes. Bridges [pdf-verify-mcp](https://github.com/shuji-bonji/pdf-verify-mcp) `verify_integrity`'s "which objects changed" to "where they are". Each location names its `basis`: an annotation's own `/Rect` is exact, a content stream can only say "the whole page" |
|
|
50
51
|
|
|
51
52
|
### Tier 3: Validation & Analysis
|
|
52
53
|
|
|
@@ -190,6 +191,46 @@ separately, and an element spanning a page break stays ONE element. Use
|
|
|
190
191
|
`roles: ["H1", "H2"]` to pull an outline. Untagged PDFs return
|
|
191
192
|
`isTagged: false` with a reason — nothing is guessed from coordinates.
|
|
192
193
|
|
|
194
|
+
#### `include_bbox`: where the element is drawn
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
extract_structured_text({ file_path: "/doc.pdf", roles: ["P"], include_bbox: true })
|
|
198
|
+
→ - **P** (page 1) — Measured paragraph
|
|
199
|
+
- *bbox* p1 `(50.0, 297.5, 161.4, 308.6)` — text-extent
|
|
200
|
+
- **Figure** (page 1)
|
|
201
|
+
- *bbox* p1 `(50.0, 150.0, 110.0, 190.0)` — layout-attribute-bbox
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Rectangles are in PDF default user space (origin bottom-left, pt, normalised) —
|
|
205
|
+
exactly what [pdf-writer-mcp](https://github.com/shuji-bonji/pdf-writer-mcp)
|
|
206
|
+
`add_annotation` takes, so "annotate this paragraph" needs no coordinate
|
|
207
|
+
conversion in between. `/Rotate` and a shifted `/CropBox` do not move them.
|
|
208
|
+
|
|
209
|
+
`basis` says how strong the claim is, and the two are different in kind:
|
|
210
|
+
|
|
211
|
+
| `basis` | What it is |
|
|
212
|
+
| --- | --- |
|
|
213
|
+
| `layout-attribute-bbox` | The `/BBox` the file **declares** (ISO 32000-2 Table 379), read through `/A` or `/C` + `/ClassMap`. A statement by the producer, reported as-is — and the only source for content that has no text |
|
|
214
|
+
| `text-extent` | **Measured** from the element's text: baseline origin plus the font's ascent/descent. The line box, not the glyph outlines. Images and vector art contribute nothing |
|
|
215
|
+
|
|
216
|
+
An element spanning pages gets ONE RECTANGLE PER PAGE — merging them would put
|
|
217
|
+
content on a page it is not on. An element with no rectangle says why in
|
|
218
|
+
`boxNote` rather than returning a zero-sized one.
|
|
219
|
+
|
|
220
|
+
**A declaration is reported as-is, and cross-checked.** Files state nonsense:
|
|
221
|
+
the cover `Figure` of *both* Well-Tagged PDF 1.0 and the Tagged PDF Best Practice
|
|
222
|
+
Guide declares `/BBox [-32768 -32768 32767 32767]` — int16 sentinels where a
|
|
223
|
+
rectangle should be — and PDF32000_2008 has 131 of its 545 declarations reaching
|
|
224
|
+
past the page edge. Since this output is meant to go straight into
|
|
225
|
+
`add_annotation`, a declaration is checked against the page box (§7.7.3.3) and
|
|
226
|
+
against the element's own text; either contradiction is reported in `boxNote`,
|
|
227
|
+
with the rectangle still returned unaltered.
|
|
228
|
+
|
|
229
|
+
Measured against independent ground truth: on *Well-Tagged PDF (WTPDF) 1.0*, the
|
|
230
|
+
166 `Link` structure elements were compared with the 173 `Link` **annotation**
|
|
231
|
+
`/Rect` values the producer placed for the same links — median IoU **0.972**,
|
|
232
|
+
none disjoint.
|
|
233
|
+
|
|
193
234
|
### Extract Tables (Tagged PDF)
|
|
194
235
|
|
|
195
236
|
```
|
package/dist/schemas/tier2.d.ts
CHANGED
|
@@ -49,15 +49,31 @@ export declare const InspectAnnotationsSchema: z.ZodObject<{
|
|
|
49
49
|
response_format?: import("../constants.js").ResponseFormat | undefined;
|
|
50
50
|
pages?: string | undefined;
|
|
51
51
|
}>;
|
|
52
|
+
/** locate_objects */
|
|
53
|
+
export declare const LocateObjectsSchema: z.ZodObject<{
|
|
54
|
+
file_path: z.ZodString;
|
|
55
|
+
object_numbers: z.ZodArray<z.ZodNumber, "many">;
|
|
56
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../constants.js").ResponseFormat>>;
|
|
57
|
+
}, "strict", z.ZodTypeAny, {
|
|
58
|
+
file_path: string;
|
|
59
|
+
response_format: import("../constants.js").ResponseFormat;
|
|
60
|
+
object_numbers: number[];
|
|
61
|
+
}, {
|
|
62
|
+
file_path: string;
|
|
63
|
+
object_numbers: number[];
|
|
64
|
+
response_format?: import("../constants.js").ResponseFormat | undefined;
|
|
65
|
+
}>;
|
|
52
66
|
/** extract_structured_text */
|
|
53
67
|
export declare const ExtractStructuredTextSchema: z.ZodObject<{
|
|
54
68
|
file_path: z.ZodString;
|
|
55
69
|
pages: z.ZodOptional<z.ZodString>;
|
|
56
70
|
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
71
|
+
include_bbox: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
57
72
|
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../constants.js").ResponseFormat>>;
|
|
58
73
|
}, "strict", z.ZodTypeAny, {
|
|
59
74
|
file_path: string;
|
|
60
75
|
response_format: import("../constants.js").ResponseFormat;
|
|
76
|
+
include_bbox: boolean;
|
|
61
77
|
pages?: string | undefined;
|
|
62
78
|
roles?: string[] | undefined;
|
|
63
79
|
}, {
|
|
@@ -65,6 +81,7 @@ export declare const ExtractStructuredTextSchema: z.ZodObject<{
|
|
|
65
81
|
response_format?: import("../constants.js").ResponseFormat | undefined;
|
|
66
82
|
pages?: string | undefined;
|
|
67
83
|
roles?: string[] | undefined;
|
|
84
|
+
include_bbox?: boolean | undefined;
|
|
68
85
|
}>;
|
|
69
86
|
/** inspect_signatures */
|
|
70
87
|
export declare const InspectSignaturesSchema: z.ZodObject<{
|
|
@@ -98,4 +115,5 @@ export type InspectAnnotationsInput = z.infer<typeof InspectAnnotationsSchema>;
|
|
|
98
115
|
export type InspectSignaturesInput = z.infer<typeof InspectSignaturesSchema>;
|
|
99
116
|
export type ExtractTablesInput = z.infer<typeof ExtractTablesSchema>;
|
|
100
117
|
export type ExtractStructuredTextInput = z.infer<typeof ExtractStructuredTextSchema>;
|
|
118
|
+
export type LocateObjectsInput = z.infer<typeof LocateObjectsSchema>;
|
|
101
119
|
//# sourceMappingURL=tier2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tier2.d.ts","sourceRoot":"","sources":["../../src/schemas/tier2.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wBAAwB;AACxB,eAAO,MAAM,sBAAsB;;;;;;;;;EAKxB,CAAC;AAEZ,mBAAmB;AACnB,eAAO,MAAM,iBAAiB;;;;;;;;;EAKnB,CAAC;AAEZ,oBAAoB;AACpB,eAAO,MAAM,kBAAkB;;;;;;;;;EAKpB,CAAC;AAEZ,0BAA0B;AAC1B,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAM1B,CAAC;AAEZ,8BAA8B;AAC9B,eAAO,MAAM,2BAA2B
|
|
1
|
+
{"version":3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AO,2BAA2B,CAAC,CAAC;AACrF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/schemas/tier2.js
CHANGED
|
@@ -32,6 +32,19 @@ export const InspectAnnotationsSchema = z
|
|
|
32
32
|
response_format: ResponseFormatSchema,
|
|
33
33
|
})
|
|
34
34
|
.strict();
|
|
35
|
+
/** locate_objects */
|
|
36
|
+
export const LocateObjectsSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
file_path: FilePathSchema,
|
|
39
|
+
object_numbers: z
|
|
40
|
+
.array(z.number().int().min(1))
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(200)
|
|
43
|
+
.describe('Object numbers to locate, e.g. [25, 27]. Typically the objects ' +
|
|
44
|
+
"pdf-verify-mcp's verify_integrity reported as changed."),
|
|
45
|
+
response_format: ResponseFormatSchema,
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
35
48
|
/** extract_structured_text */
|
|
36
49
|
export const ExtractStructuredTextSchema = z
|
|
37
50
|
.object({
|
|
@@ -42,6 +55,16 @@ export const ExtractStructuredTextSchema = z
|
|
|
42
55
|
.array(z.string())
|
|
43
56
|
.optional()
|
|
44
57
|
.describe('Structure types to include, e.g. ["H1","H2"] to extract an outline. Omit for all roles.'),
|
|
58
|
+
include_bbox: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.optional()
|
|
61
|
+
.default(false)
|
|
62
|
+
.describe('Also report where each element is drawn, as boxes: one rectangle per page in PDF ' +
|
|
63
|
+
'default user space (origin bottom-left, pt, normalised) — the form pdf-writer-mcp ' +
|
|
64
|
+
'add_annotation takes. Each carries a basis: "layout-attribute-bbox" (the /BBox the ' +
|
|
65
|
+
'file declares) or "text-extent" (measured from the element\'s text; images and ' +
|
|
66
|
+
'vector art contribute nothing). Elements with no rectangle carry boxNote saying why. ' +
|
|
67
|
+
'Off by default: it costs a second pass over every page.'),
|
|
45
68
|
response_format: ResponseFormatSchema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mB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,SAAS,EAAE,cAAc;IACzB,KAAK,EAAE,WAAW;IAClB,eAAe,EAAE,oBAAoB;CACtC,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object number → drawing coordinates (Issue #20 / family gap G-A).
|
|
3
|
+
*
|
|
4
|
+
* `pdf-verify-mcp` can say *which objects* an incremental update rewrote, and
|
|
5
|
+
* `pdf-writer-mcp`'s `add_annotation` wants a page number and a rectangle. This
|
|
6
|
+
* service is the bridge between the two: given object numbers, it reports where
|
|
7
|
+
* on the page each object is, in the coordinate system the writer expects
|
|
8
|
+
* (PDF user space, origin bottom-left, pt).
|
|
9
|
+
*
|
|
10
|
+
* It OBSERVES. Nothing here judges whether an object should have changed —
|
|
11
|
+
* that is a question the family answers elsewhere, and mostly not at all.
|
|
12
|
+
*
|
|
13
|
+
* What it cannot do, and says so instead of guessing:
|
|
14
|
+
*
|
|
15
|
+
* - **A content stream draws the whole page.** Narrowing "obj 6 changed" to
|
|
16
|
+
* the paragraph that moved needs a content-stream walk with the graphics
|
|
17
|
+
* state carried along; that is the second half of Issue #20 (structure
|
|
18
|
+
* element → bbox) and is not implemented here. The page box is returned
|
|
19
|
+
* with the basis saying exactly that.
|
|
20
|
+
* - **Resources (fonts, images, colour spaces) have no coordinates.** The
|
|
21
|
+
* page that uses them is reported; the rectangle stays null.
|
|
22
|
+
* - **An object that no longer exists** — freed by a later revision, which is
|
|
23
|
+
* precisely what a diff may hand over — is reported as `found: false`, not
|
|
24
|
+
* as "no coordinates".
|
|
25
|
+
*/
|
|
26
|
+
import type { ObjectLocationResult } from '../types.js';
|
|
27
|
+
/**
|
|
28
|
+
* Locate the given object numbers. Objects are matched by number: the
|
|
29
|
+
* generation actually present in the document is reported back, so a caller
|
|
30
|
+
* holding a stale generation still gets an answer rather than a miss.
|
|
31
|
+
*/
|
|
32
|
+
export declare function locateObjects(filePath: string, objectNumbers: number[]): Promise<ObjectLocationResult>;
|
|
33
|
+
//# sourceMappingURL=object-locator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-locator.d.ts","sourceRoot":"","sources":["../../src/services/object-locator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAYH,OAAO,KAAK,EAAiC,oBAAoB,EAAc,MAAM,aAAa,CAAC;AA2MnG;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,oBAAoB,CAAC,CAgJ/B"}
|