@shuji-bonji/pdf-spec-mcp 0.2.1 → 0.2.2

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.ja.md +288 -39
  2. package/README.md +285 -39
  3. package/package.json +1 -1
package/README.ja.md CHANGED
@@ -7,6 +7,14 @@
7
7
 
8
8
  ISO 32000(PDF)仕様書への構造化アクセスを提供する MCP(Model Context Protocol)サーバーです。LLM が PDF 仕様書をナビゲート・検索・分析するためのツールを提供します。
9
9
 
10
+ > [!IMPORTANT]
11
+ > **PDF 仕様書ファイルは同梱されていません。**
12
+ > このサーバーを利用するには、PDF 仕様書を別途入手し、ローカルディレクトリに配置する必要があります。
13
+ >
14
+ > **入手先:** [PDF Association — Sponsored Standards](https://pdfa.org/sponsored-standards/)
15
+ >
16
+ > 詳しくは「[セットアップ](#セットアップ)」を参照してください。
17
+
10
18
  ## 特徴
11
19
 
12
20
  - **マルチ仕様対応** — 最大17の PDF 関連文書を自動検出(ISO 32000-2、PDF/UA、Tagged PDF ガイド等)
@@ -18,37 +26,135 @@ ISO 32000(PDF)仕様書への構造化アクセスを提供する MCP(Mode
18
26
  - **バージョン比較** — PDF 1.7 と PDF 2.0 のセクション構造差分
19
27
  - **並行処理** — 大規模ドキュメントのチャンク並行ページ処理
20
28
 
21
- ## 提供ツール
29
+ ## アーキテクチャ
22
30
 
23
- | ツール | 説明 |
24
- | ------------------ | ----------------------------------------------- |
25
- | `list_specs` | 検出済みの全 PDF 仕様一覧をメタデータ付きで取得 |
26
- | `get_structure` | セクション階層(目次)を深さ指定で取得 |
27
- | `get_section` | 指定セクションの構造化コンテンツを取得 |
28
- | `search_spec` | 仕様書内の全文キーワード検索 |
29
- | `get_requirements` | 規範的要件(shall/must/may)を抽出 |
30
- | `get_definitions` | 用語定義を検索 |
31
- | `get_tables` | セクション内のテーブル構造を抽出 |
32
- | `compare_versions` | PDF 1.7 と PDF 2.0 のセクション構造を比較 |
31
+ ```mermaid
32
+ graph LR
33
+ subgraph Client["MCP クライアント"]
34
+ LLM["LLM<br/>(Claude, etc.)"]
35
+ end
36
+
37
+ subgraph Server["PDF Spec MCP Server"]
38
+ direction TB
39
+ MCP["MCP Server<br/>index.ts"]
40
+
41
+ subgraph Tools["Tools Layer"]
42
+ direction LR
43
+ T1["list_specs"]
44
+ T2["get_structure"]
45
+ T3["get_section"]
46
+ T4["search_spec"]
47
+ T5["get_requirements"]
48
+ T6["get_definitions"]
49
+ T7["get_tables"]
50
+ T8["compare_versions"]
51
+ end
52
+
53
+ subgraph Services["Services Layer"]
54
+ direction LR
55
+ REG["Registry<br/>PDF 自動検出"]
56
+ LOADER["Loader<br/>LRU キャッシュ"]
57
+ SVC["PDFService<br/>オーケストレーション"]
58
+ CMP["CompareService<br/>バージョン比較"]
59
+ end
60
+
61
+ subgraph Extractors["Extractors"]
62
+ direction LR
63
+ OUTLINE["OutlineResolver<br/>目次・セクション索引"]
64
+ CONTENT["ContentExtractor<br/>構造化抽出"]
65
+ SEARCH["SearchIndex<br/>全文検索"]
66
+ REQ["RequirementExtractor"]
67
+ DEF["DefinitionExtractor"]
68
+ end
69
+
70
+ subgraph Utils["Utils"]
71
+ direction LR
72
+ CACHE["LRU Cache"]
73
+ CONC["Concurrency"]
74
+ VALID["Validation"]
75
+ end
76
+ end
77
+
78
+ subgraph PDFs["PDF 仕様書ファイル (別途入手)"]
79
+ direction LR
80
+ PDF1["ISO 32000-2<br/>(PDF 2.0)"]
81
+ PDF2["ISO 32000-1<br/>(PDF 1.7)"]
82
+ PDF3["TS 32001–32005<br/>PDF/UA 等"]
83
+ end
84
+
85
+ LLM <-->|"stdio / JSON-RPC"| MCP
86
+ MCP --> Tools
87
+ Tools --> Services
88
+ Services --> Extractors
89
+ Services --> Utils
90
+ LOADER --> PDFs
91
+ REG -->|"ファイル名パターン<br/>自動検出"| PDFs
92
+
93
+ style Client fill:#e8f4f8,stroke:#2196F3
94
+ style PDFs fill:#fff3e0,stroke:#FF9800
95
+ style Tools fill:#e8f5e9,stroke:#4CAF50
96
+ style Services fill:#f3e5f5,stroke:#9C27B0
97
+ style Extractors fill:#fce4ec,stroke:#E91E63
98
+ style Utils fill:#f5f5f5,stroke:#9E9E9E
99
+ ```
33
100
 
34
- ## 対応仕様
101
+ ### レイヤー構成
35
102
 
36
- `PDF_SPEC_DIR` 内の PDF ファイルをファイル名パターンで自動検出します:
103
+ | レイヤー | 役割 |
104
+ | -------------- | ------------------------------------------------------------------ |
105
+ | **Tools** | MCP ツールスキーマ定義 & ハンドラー(入力バリデーション) |
106
+ | **Services** | ビジネスロジック(PDF レジストリ、ローダー、オーケストレーション) |
107
+ | **Extractors** | PDF からの情報抽出(目次、コンテンツ、検索、要件、定義) |
108
+ | **Utils** | 共通ユーティリティ(キャッシュ、並行処理、バリデーション) |
37
109
 
38
- | カテゴリ | Spec ID | 文書 |
39
- | -------------------------- | ---------------------------------------------------- | ------------------------------------------------- |
40
- | **標準** | `iso32000-2`, `iso32000-2-2020`, `pdf17`, `pdf17old` | ISO 32000-2 (PDF 2.0), ISO 32000-1 (PDF 1.7) |
41
- | **技術仕様** | `ts32001` – `ts32005` | ハッシュ、電子署名、AES-GCM、整合性保護、名前空間 |
42
- | **PDF/UA** | `pdfua1`, `pdfua2` | アクセシビリティ (ISO 14289-1, 14289-2) |
43
- | **ガイド** | `tagged-bpg`, `wtpdf`, `declarations` | Tagged PDF、Well-Tagged PDF、Declarations |
44
- | **アプリケーションノート** | `an001` – `an003` | BPC、Associated Files、Object Metadata |
110
+ ## セットアップ
45
111
 
46
- ## 前提条件
112
+ ### 1. PDF 仕様書の入手
47
113
 
48
- - Node.js >= 20.0.0
49
- - PDF 仕様書ファイル(同梱されません [PDF Association](https://pdfa.org/sponsored-standards/) から入手してください)
114
+ > [!WARNING]
115
+ > PDF 仕様書は **著作権で保護されたドキュメント** であり、このパッケージには含まれていません。
116
+ > 以下から入手し、任意のローカルディレクトリに配置してください。
50
117
 
51
- ## インストール
118
+ | 文書 | 入手先 |
119
+ | ------------------------- | ----------------------------------------------------------------------------------------------- |
120
+ | ISO 32000-2 (PDF 2.0) | [PDF Association](https://pdfa.org/resource/iso-32000-pdf/) |
121
+ | ISO 32000-1 (PDF 1.7) | [Adobe (無償)](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf) |
122
+ | TS 32001–32005, PDF/UA 等 | [PDF Association — Sponsored Standards](https://pdfa.org/sponsored-standards/) |
123
+
124
+ 以下の全17ファイルに対応しています。すべてを揃える必要はなく、必要な仕様書だけ配置すれば動作します(最低限 ISO 32000-2 を推奨)。
125
+
126
+ ```
127
+ pdf-specs/
128
+
129
+ │ ── 標準 ──────────────────────────────────
130
+ ├── ISO_32000-2_sponsored-ec2.pdf # iso32000-2 : PDF 2.0 EC2(推奨・主対象)
131
+ ├── ISO_32000-2-2020_sponsored.pdf # iso32000-2-2020 : PDF 2.0 原版
132
+ ├── PDF32000_2008.pdf # pdf17 : PDF 1.7(バージョン比較用)
133
+ ├── pdfreference1.7old.pdf # pdf17old : Adobe PDF Reference 1.7
134
+
135
+ │ ── 技術仕様(TS)──────────────────────────
136
+ ├── ISO_TS_32001-2022_sponsored.pdf # ts32001 : ハッシュ拡張 (SHA-3)
137
+ ├── ISO_TS_32002-2022_sponsored.pdf # ts32002 : 電子署名拡張 (ECC/PAdES)
138
+ ├── ISO_TS_32003-2023_sponsored.pdf # ts32003 : AES-GCM 暗号化
139
+ ├── ISO-TS-32004-2024_sponsored.pdf # ts32004 : 整合性保護
140
+ ├── ISO-TS-32005-2023-sponsored.pdf # ts32005 : 名前空間マッピング
141
+
142
+ │ ── PDF/UA(アクセシビリティ)──────────────
143
+ ├── ISO-14289-1-2014-sponsored.pdf # pdfua1 : PDF/UA-1
144
+ ├── ISO-14289-2-2024-sponsored.pdf # pdfua2 : PDF/UA-2
145
+
146
+ │ ── ガイド ─────────────────────────────────
147
+ ├── Tagged-PDF-Best-Practice-Guide.pdf # tagged-bpg : Tagged PDF ベストプラクティス
148
+ ├── Well-Tagged-PDF-WTPDF-1.0.pdf # wtpdf : Well-Tagged PDF
149
+ ├── PDF-Declarations.pdf # declarations: PDF Declarations
150
+
151
+ │ ── アプリケーションノート ─────────────────
152
+ ├── PDF20_AN001-BPC.pdf # an001 : Black Point Compensation
153
+ ├── PDF20_AN002-AF.pdf # an002 : Associated Files
154
+ └── PDF20_AN003-ObjectMetadataLocations.pdf # an003 : Object Metadata
155
+ ```
156
+
157
+ ### 2. インストール
52
158
 
53
159
  ```bash
54
160
  npm install @shuji-bonji/pdf-spec-mcp
@@ -60,15 +166,15 @@ npx での直接実行も可能です:
60
166
  PDF_SPEC_DIR=/path/to/pdf-specs npx @shuji-bonji/pdf-spec-mcp
61
167
  ```
62
168
 
63
- ## 設定
169
+ ### 3. MCP クライアント設定
64
170
 
65
- ### 環境変数
171
+ #### 環境変数
66
172
 
67
173
  | 変数 | 説明 | デフォルト |
68
174
  | -------------- | ------------------------------------------ | ---------- |
69
175
  | `PDF_SPEC_DIR` | PDF 仕様書ファイルが格納されたディレクトリ | (必須) |
70
176
 
71
- ### Claude Desktop
177
+ #### Claude Desktop
72
178
 
73
179
  `claude_desktop_config.json` に追加:
74
180
 
@@ -86,7 +192,7 @@ PDF_SPEC_DIR=/path/to/pdf-specs npx @shuji-bonji/pdf-spec-mcp
86
192
  }
87
193
  ```
88
194
 
89
- ### Cursor / VS Code
195
+ #### Cursor / VS Code
90
196
 
91
197
  `.cursor/mcp.json` または VS Code の MCP 設定に追加:
92
198
 
@@ -104,22 +210,165 @@ PDF_SPEC_DIR=/path/to/pdf-specs npx @shuji-bonji/pdf-spec-mcp
104
210
  }
105
211
  ```
106
212
 
107
- ## 使用例
213
+ ## 提供ツール
214
+
215
+ 全ツールで `spec` パラメータにより対象仕様を切り替えられます(デフォルト: `iso32000-2`)。
108
216
 
109
- 接続後、LLM は以下のようにツールを利用できます:
217
+ > **Note:** 以前検討されていた `get_ts_section` は、`get_section` に `spec` パラメータを追加することで統合されました。
218
+ > TS 仕様や PDF/UA も同じツールセットで参照できます。
110
219
 
220
+ | ツール | 説明 |
221
+ | ------------------ | ----------------------------------------------- |
222
+ | `list_specs` | 検出済みの全 PDF 仕様一覧をメタデータ付きで取得 |
223
+ | `get_structure` | セクション階層(目次)を深さ指定で取得 |
224
+ | `get_section` | 指定セクションの構造化コンテンツを取得 |
225
+ | `search_spec` | 仕様書内の全文キーワード検索 |
226
+ | `get_requirements` | 規範的要件(shall/must/may)を抽出 |
227
+ | `get_definitions` | 用語定義を検索 |
228
+ | `get_tables` | セクション内のテーブル構造を抽出 |
229
+ | `compare_versions` | PDF 1.7 と PDF 2.0 のセクション構造を比較 |
230
+
231
+ ### `list_specs` — 仕様一覧
232
+
233
+ 利用可能な全仕様書の一覧を取得します。他のツールで使う `spec` ID を確認できます。
234
+
235
+ ```jsonc
236
+ // 全仕様を一覧
237
+ { }
238
+
239
+ // カテゴリでフィルタ
240
+ { "category": "ts" } // 技術仕様のみ
241
+ { "category": "pdfua" } // PDF/UA のみ
242
+ { "category": "guide" } // ガイド文書のみ
111
243
  ```
112
- > list_specs
113
- > get_structure { "max_depth": 2 }
114
- > get_section { "section": "7.3.4" }
115
- > search_spec { "query": "digital signature" }
116
- > get_requirements { "section": "12.8", "level": "shall" }
117
- > get_definitions { "term": "font" }
118
- > get_tables { "section": "7.3.4" }
119
- > compare_versions { "section": "12.8" }
244
+
245
+ ### `get_structure` 目次取得
246
+
247
+ 仕様書のセクション階層(目次ツリー)を取得します。
248
+
249
+ ```jsonc
250
+ // PDF 2.0 のトップレベルセクションのみ
251
+ { "max_depth": 1 }
252
+
253
+ // 2階層まで展開
254
+ { "max_depth": 2 }
255
+
256
+ // TS 32002(電子署名)の全構造
257
+ { "spec": "ts32002" }
258
+
259
+ // PDF/UA-2 の構造
260
+ { "spec": "pdfua2", "max_depth": 2 }
120
261
  ```
121
262
 
122
- ## アーキテクチャ
263
+ ### `get_section` — セクション内容取得
264
+
265
+ 指定セクションの構造化コンテンツ(見出し・段落・リスト・テーブル・注記)を取得します。
266
+
267
+ ```jsonc
268
+ // PDF 2.0 のセクション 7.3.4(String Objects)
269
+ { "section": "7.3.4" }
270
+
271
+ // PDF 2.0 の Annex A
272
+ { "section": "Annex A" }
273
+
274
+ // TS 32002 のセクション 5
275
+ { "spec": "ts32002", "section": "5" }
276
+
277
+ // PDF/UA-2 のセクション 8(Tagged PDF)
278
+ { "spec": "pdfua2", "section": "8" }
279
+ ```
280
+
281
+ ### `search_spec` — 全文検索
282
+
283
+ 仕様書内をキーワード検索し、セクションコンテキスト付きの結果を返します。
284
+
285
+ ```jsonc
286
+ // PDF 2.0 で "digital signature" を検索
287
+ { "query": "digital signature" }
288
+
289
+ // 結果数を制限
290
+ { "query": "font", "max_results": 5 }
291
+
292
+ // TS 32002 内で検索
293
+ { "spec": "ts32002", "query": "CMS" }
294
+ ```
295
+
296
+ ### `get_requirements` — 要件抽出
297
+
298
+ ISO 規約に基づく規範的要件(shall / must / may)を抽出します。
299
+
300
+ ```jsonc
301
+ // セクション 12.8 の全要件
302
+ { "section": "12.8" }
303
+
304
+ // "shall" 要件のみ
305
+ { "section": "12.8", "level": "shall" }
306
+
307
+ // "shall not" 要件のみ
308
+ { "section": "7.3", "level": "shall not" }
309
+
310
+ // PDF/UA-2 の要件
311
+ { "spec": "pdfua2", "section": "8", "level": "shall" }
312
+ ```
313
+
314
+ ### `get_definitions` — 用語定義検索
315
+
316
+ Section 3(用語定義)からの用語検索を行います。
317
+
318
+ ```jsonc
319
+ // "font" に関する定義を検索
320
+ { "term": "font" }
321
+
322
+ // 全定義を一覧
323
+ { }
324
+
325
+ // PDF/UA の用語定義
326
+ { "spec": "pdfua2", "term": "artifact" }
327
+ ```
328
+
329
+ ### `get_tables` — テーブル抽出
330
+
331
+ セクション内のテーブル構造(ヘッダー・行・キャプション)を抽出します。複数ページにまたがるテーブルも自動マージされます。
332
+
333
+ ```jsonc
334
+ // セクション 7.3.4 の全テーブル
335
+ { "section": "7.3.4" }
336
+
337
+ // 特定のテーブルのみ(0始まりのインデックス)
338
+ { "section": "7.3.4", "table_index": 0 }
339
+
340
+ // TS 仕様のテーブル
341
+ { "spec": "ts32002", "section": "5" }
342
+ ```
343
+
344
+ ### `compare_versions` — バージョン比較
345
+
346
+ PDF 1.7(ISO 32000-1)と PDF 2.0(ISO 32000-2)のセクション構造を比較します。タイトルベースの自動マッチングにより、一致・追加・削除されたセクションを検出します。
347
+
348
+ > [!NOTE]
349
+ > このツールには PDF 1.7 (`PDF32000_2008.pdf`) と PDF 2.0 の両方が `PDF_SPEC_DIR` に必要です。
350
+
351
+ ```jsonc
352
+ // セクション 12.8(Digital Signatures)の差分
353
+ { "section": "12.8" }
354
+
355
+ // トップレベルの全セクション比較
356
+ { }
357
+ ```
358
+
359
+ ## 対応仕様
360
+
361
+ `PDF_SPEC_DIR` 内の PDF ファイルをファイル名パターンで自動検出します:
362
+
363
+ | カテゴリ | Spec ID | 文書 |
364
+ | -------------------------- | ---------------------------------------------------- | ------------------------------------------------- |
365
+ | **標準** | `iso32000-2`, `iso32000-2-2020`, `pdf17`, `pdf17old` | ISO 32000-2 (PDF 2.0), ISO 32000-1 (PDF 1.7) |
366
+ | **技術仕様** | `ts32001` – `ts32005` | ハッシュ、電子署名、AES-GCM、整合性保護、名前空間 |
367
+ | **PDF/UA** | `pdfua1`, `pdfua2` | アクセシビリティ (ISO 14289-1, 14289-2) |
368
+ | **ガイド** | `tagged-bpg`, `wtpdf`, `declarations` | Tagged PDF、Well-Tagged PDF、Declarations |
369
+ | **アプリケーションノート** | `an001` – `an003` | BPC、Associated Files、Object Metadata |
370
+
371
+ ## ディレクトリ構造
123
372
 
124
373
  ```
125
374
  src/
package/README.md CHANGED
@@ -7,6 +7,14 @@
7
7
 
8
8
  An MCP (Model Context Protocol) server that provides structured access to ISO 32000 (PDF) specification documents. Enables LLMs to navigate, search, and analyze PDF specifications through well-defined tools.
9
9
 
10
+ > [!IMPORTANT]
11
+ > **PDF specification files are NOT included in this package.**
12
+ > You must obtain the PDF specification documents separately and place them in a local directory.
13
+ >
14
+ > **Download from:** [PDF Association — Sponsored Standards](https://pdfa.org/sponsored-standards/)
15
+ >
16
+ > See "[Setup](#setup)" for details.
17
+
10
18
  ## Features
11
19
 
12
20
  - **Multi-spec support** — Auto-discovers and manages up to 17 PDF-related documents (ISO 32000-2, PDF/UA, Tagged PDF guides, etc.)
@@ -18,37 +26,135 @@ An MCP (Model Context Protocol) server that provides structured access to ISO 32
18
26
  - **Version comparison** — Diff PDF 1.7 vs PDF 2.0 section structures
19
27
  - **Bounded-concurrency processing** — Parallel page processing for large documents
20
28
 
21
- ## Available Tools
29
+ ## Architecture
22
30
 
23
- | Tool | Description |
24
- | ------------------ | ----------------------------------------------------------------- |
25
- | `list_specs` | List all discovered PDF specifications with metadata |
26
- | `get_structure` | Get section hierarchy (table of contents) with configurable depth |
27
- | `get_section` | Get structured content of a specific section |
28
- | `search_spec` | Full-text keyword search across a specification |
29
- | `get_requirements` | Extract normative requirements (shall/must/may) |
30
- | `get_definitions` | Lookup term definitions |
31
- | `get_tables` | Extract table structures from a section |
32
- | `compare_versions` | Compare PDF 1.7 and PDF 2.0 section structures |
31
+ ```mermaid
32
+ graph LR
33
+ subgraph Client["MCP Client"]
34
+ LLM["LLM<br/>(Claude, etc.)"]
35
+ end
36
+
37
+ subgraph Server["PDF Spec MCP Server"]
38
+ direction TB
39
+ MCP["MCP Server<br/>index.ts"]
40
+
41
+ subgraph Tools["Tools Layer"]
42
+ direction LR
43
+ T1["list_specs"]
44
+ T2["get_structure"]
45
+ T3["get_section"]
46
+ T4["search_spec"]
47
+ T5["get_requirements"]
48
+ T6["get_definitions"]
49
+ T7["get_tables"]
50
+ T8["compare_versions"]
51
+ end
52
+
53
+ subgraph Services["Services Layer"]
54
+ direction LR
55
+ REG["Registry<br/>Auto-discovery"]
56
+ LOADER["Loader<br/>LRU Cache"]
57
+ SVC["PDFService<br/>Orchestration"]
58
+ CMP["CompareService<br/>Version Diff"]
59
+ end
60
+
61
+ subgraph Extractors["Extractors"]
62
+ direction LR
63
+ OUTLINE["OutlineResolver<br/>TOC & Section Index"]
64
+ CONTENT["ContentExtractor<br/>Structured Extraction"]
65
+ SEARCH["SearchIndex<br/>Full-text Search"]
66
+ REQ["RequirementExtractor"]
67
+ DEF["DefinitionExtractor"]
68
+ end
69
+
70
+ subgraph Utils["Utils"]
71
+ direction LR
72
+ CACHE["LRU Cache"]
73
+ CONC["Concurrency"]
74
+ VALID["Validation"]
75
+ end
76
+ end
77
+
78
+ subgraph PDFs["PDF Spec Files (obtained separately)"]
79
+ direction LR
80
+ PDF1["ISO 32000-2<br/>(PDF 2.0)"]
81
+ PDF2["ISO 32000-1<br/>(PDF 1.7)"]
82
+ PDF3["TS 32001–32005<br/>PDF/UA, etc."]
83
+ end
84
+
85
+ LLM <-->|"stdio / JSON-RPC"| MCP
86
+ MCP --> Tools
87
+ Tools --> Services
88
+ Services --> Extractors
89
+ Services --> Utils
90
+ LOADER --> PDFs
91
+ REG -->|"Filename pattern<br/>auto-discovery"| PDFs
92
+
93
+ style Client fill:#e8f4f8,stroke:#2196F3
94
+ style PDFs fill:#fff3e0,stroke:#FF9800
95
+ style Tools fill:#e8f5e9,stroke:#4CAF50
96
+ style Services fill:#f3e5f5,stroke:#9C27B0
97
+ style Extractors fill:#fce4ec,stroke:#E91E63
98
+ style Utils fill:#f5f5f5,stroke:#9E9E9E
99
+ ```
33
100
 
34
- ## Supported Specifications
101
+ ### Layer Overview
35
102
 
36
- The server auto-discovers PDF files in `PDF_SPEC_DIR` by filename pattern matching:
103
+ | Layer | Responsibility |
104
+ | -------------- | ---------------------------------------------------------------------------------- |
105
+ | **Tools** | MCP tool schema definitions & handlers (input validation) |
106
+ | **Services** | Business logic (PDF registry, loader, orchestration) |
107
+ | **Extractors** | Information extraction from PDFs (TOC, content, search, requirements, definitions) |
108
+ | **Utils** | Shared utilities (cache, concurrency, validation) |
37
109
 
38
- | Category | Spec IDs | Documents |
39
- | ------------------ | ---------------------------------------------------- | ------------------------------------------------------- |
40
- | **Standard** | `iso32000-2`, `iso32000-2-2020`, `pdf17`, `pdf17old` | ISO 32000-2 (PDF 2.0), ISO 32000-1 (PDF 1.7) |
41
- | **Technical Spec** | `ts32001` – `ts32005` | Hash, Digital Signatures, AES-GCM, Integrity, Namespace |
42
- | **PDF/UA** | `pdfua1`, `pdfua2` | Accessibility (ISO 14289-1, 14289-2) |
43
- | **Guide** | `tagged-bpg`, `wtpdf`, `declarations` | Tagged PDF, Well-Tagged PDF, Declarations |
44
- | **App Note** | `an001` `an003` | BPC, Associated Files, Object Metadata |
110
+ ## Setup
111
+
112
+ ### 1. Obtain PDF Specification Files
113
+
114
+ > [!WARNING]
115
+ > PDF specifications are **copyrighted documents** and are not included in this package.
116
+ > Download them from the sources below and place them in a local directory.
45
117
 
46
- ## Prerequisites
118
+ | Document | Source |
119
+ | ---------------------------- | ----------------------------------------------------------------------------------------------- |
120
+ | ISO 32000-2 (PDF 2.0) | [PDF Association](https://pdfa.org/resource/iso-32000-pdf/) |
121
+ | ISO 32000-1 (PDF 1.7) | [Adobe (free)](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf) |
122
+ | TS 32001–32005, PDF/UA, etc. | [PDF Association — Sponsored Standards](https://pdfa.org/sponsored-standards/) |
47
123
 
48
- - Node.js >= 20.0.0
49
- - PDF specification files (not included — obtain from [PDF Association](https://pdfa.org/sponsored-standards/))
124
+ All 17 files below are supported. You do not need all of them — place only the specs you need (at minimum, ISO 32000-2 is recommended).
50
125
 
51
- ## Installation
126
+ ```
127
+ pdf-specs/
128
+
129
+ │ ── Standards ─────────────────────────────
130
+ ├── ISO_32000-2_sponsored-ec2.pdf # iso32000-2 : PDF 2.0 EC2 (recommended)
131
+ ├── ISO_32000-2-2020_sponsored.pdf # iso32000-2-2020 : PDF 2.0 original
132
+ ├── PDF32000_2008.pdf # pdf17 : PDF 1.7 (for version comparison)
133
+ ├── pdfreference1.7old.pdf # pdf17old : Adobe PDF Reference 1.7
134
+
135
+ │ ── Technical Specifications (TS) ─────────
136
+ ├── ISO_TS_32001-2022_sponsored.pdf # ts32001 : Hash extensions (SHA-3)
137
+ ├── ISO_TS_32002-2022_sponsored.pdf # ts32002 : Digital signature extensions (ECC/PAdES)
138
+ ├── ISO_TS_32003-2023_sponsored.pdf # ts32003 : AES-GCM encryption
139
+ ├── ISO-TS-32004-2024_sponsored.pdf # ts32004 : Integrity protection
140
+ ├── ISO-TS-32005-2023-sponsored.pdf # ts32005 : Namespace mapping
141
+
142
+ │ ── PDF/UA (Accessibility) ────────────────
143
+ ├── ISO-14289-1-2014-sponsored.pdf # pdfua1 : PDF/UA-1
144
+ ├── ISO-14289-2-2024-sponsored.pdf # pdfua2 : PDF/UA-2
145
+
146
+ │ ── Guides ────────────────────────────────
147
+ ├── Tagged-PDF-Best-Practice-Guide.pdf # tagged-bpg : Tagged PDF Best Practice
148
+ ├── Well-Tagged-PDF-WTPDF-1.0.pdf # wtpdf : Well-Tagged PDF
149
+ ├── PDF-Declarations.pdf # declarations: PDF Declarations
150
+
151
+ │ ── Application Notes ─────────────────────
152
+ ├── PDF20_AN001-BPC.pdf # an001 : Black Point Compensation
153
+ ├── PDF20_AN002-AF.pdf # an002 : Associated Files
154
+ └── PDF20_AN003-ObjectMetadataLocations.pdf # an003 : Object Metadata
155
+ ```
156
+
157
+ ### 2. Install
52
158
 
53
159
  ```bash
54
160
  npm install @shuji-bonji/pdf-spec-mcp
@@ -60,15 +166,15 @@ Or run directly with npx:
60
166
  PDF_SPEC_DIR=/path/to/pdf-specs npx @shuji-bonji/pdf-spec-mcp
61
167
  ```
62
168
 
63
- ## Configuration
169
+ ### 3. Configure MCP Client
64
170
 
65
- ### Environment Variable
171
+ #### Environment Variable
66
172
 
67
173
  | Variable | Description | Default |
68
174
  | -------------- | -------------------------------------------- | ---------- |
69
175
  | `PDF_SPEC_DIR` | Directory containing PDF specification files | (required) |
70
176
 
71
- ### Claude Desktop
177
+ #### Claude Desktop
72
178
 
73
179
  Add to `claude_desktop_config.json`:
74
180
 
@@ -86,7 +192,7 @@ Add to `claude_desktop_config.json`:
86
192
  }
87
193
  ```
88
194
 
89
- ### Cursor / VS Code
195
+ #### Cursor / VS Code
90
196
 
91
197
  Add to `.cursor/mcp.json` or VS Code MCP settings:
92
198
 
@@ -104,22 +210,162 @@ Add to `.cursor/mcp.json` or VS Code MCP settings:
104
210
  }
105
211
  ```
106
212
 
107
- ## Usage Examples
213
+ ## Available Tools
108
214
 
109
- Once connected, your LLM can use tools like:
215
+ All tools accept an optional `spec` parameter to target a specific specification (default: `iso32000-2`).
110
216
 
217
+ | Tool | Description |
218
+ | ------------------ | ----------------------------------------------------------------- |
219
+ | `list_specs` | List all discovered PDF specifications with metadata |
220
+ | `get_structure` | Get section hierarchy (table of contents) with configurable depth |
221
+ | `get_section` | Get structured content of a specific section |
222
+ | `search_spec` | Full-text keyword search across a specification |
223
+ | `get_requirements` | Extract normative requirements (shall/must/may) |
224
+ | `get_definitions` | Lookup term definitions |
225
+ | `get_tables` | Extract table structures from a section |
226
+ | `compare_versions` | Compare PDF 1.7 and PDF 2.0 section structures |
227
+
228
+ ### `list_specs` — Discover Specifications
229
+
230
+ List all available specification documents. Use the returned IDs as the `spec` parameter in other tools.
231
+
232
+ ```jsonc
233
+ // List all specs
234
+ { }
235
+
236
+ // Filter by category
237
+ { "category": "ts" } // Technical specs only
238
+ { "category": "pdfua" } // PDF/UA only
239
+ { "category": "guide" } // Guide documents only
111
240
  ```
112
- > list_specs
113
- > get_structure { "max_depth": 2 }
114
- > get_section { "section": "7.3.4" }
115
- > search_spec { "query": "digital signature" }
116
- > get_requirements { "section": "12.8", "level": "shall" }
117
- > get_definitions { "term": "font" }
118
- > get_tables { "section": "7.3.4" }
119
- > compare_versions { "section": "12.8" }
241
+
242
+ ### `get_structure` Table of Contents
243
+
244
+ Get the section hierarchy (TOC tree) of a specification.
245
+
246
+ ```jsonc
247
+ // PDF 2.0 top-level sections only
248
+ { "max_depth": 1 }
249
+
250
+ // Expand to 2 levels
251
+ { "max_depth": 2 }
252
+
253
+ // TS 32002 (Digital Signatures) full structure
254
+ { "spec": "ts32002" }
255
+
256
+ // PDF/UA-2 structure
257
+ { "spec": "pdfua2", "max_depth": 2 }
120
258
  ```
121
259
 
122
- ## Architecture
260
+ ### `get_section` — Section Content
261
+
262
+ Get structured content (headings, paragraphs, lists, tables, notes) of a specific section.
263
+
264
+ ```jsonc
265
+ // PDF 2.0 Section 7.3.4 (String Objects)
266
+ { "section": "7.3.4" }
267
+
268
+ // PDF 2.0 Annex A
269
+ { "section": "Annex A" }
270
+
271
+ // TS 32002 Section 5
272
+ { "spec": "ts32002", "section": "5" }
273
+
274
+ // PDF/UA-2 Section 8 (Tagged PDF)
275
+ { "spec": "pdfua2", "section": "8" }
276
+ ```
277
+
278
+ ### `search_spec` — Full-text Search
279
+
280
+ Search across a specification with section-aware context snippets.
281
+
282
+ ```jsonc
283
+ // Search PDF 2.0 for "digital signature"
284
+ { "query": "digital signature" }
285
+
286
+ // Limit results
287
+ { "query": "font", "max_results": 5 }
288
+
289
+ // Search within TS 32002
290
+ { "spec": "ts32002", "query": "CMS" }
291
+ ```
292
+
293
+ ### `get_requirements` — Normative Requirements
294
+
295
+ Extract normative requirements (shall / must / may) per ISO conventions.
296
+
297
+ ```jsonc
298
+ // All requirements in section 12.8
299
+ { "section": "12.8" }
300
+
301
+ // Only "shall" requirements
302
+ { "section": "12.8", "level": "shall" }
303
+
304
+ // Only "shall not" requirements
305
+ { "section": "7.3", "level": "shall not" }
306
+
307
+ // PDF/UA-2 requirements
308
+ { "spec": "pdfua2", "section": "8", "level": "shall" }
309
+ ```
310
+
311
+ ### `get_definitions` — Term Definitions
312
+
313
+ Look up term definitions from Section 3 (Definitions).
314
+
315
+ ```jsonc
316
+ // Search for "font" definitions
317
+ { "term": "font" }
318
+
319
+ // List all definitions
320
+ { }
321
+
322
+ // PDF/UA definitions
323
+ { "spec": "pdfua2", "term": "artifact" }
324
+ ```
325
+
326
+ ### `get_tables` — Table Extraction
327
+
328
+ Extract table structures (headers, rows, captions) from a section. Multi-page tables are automatically merged.
329
+
330
+ ```jsonc
331
+ // All tables in section 7.3.4
332
+ { "section": "7.3.4" }
333
+
334
+ // Specific table only (0-based index)
335
+ { "section": "7.3.4", "table_index": 0 }
336
+
337
+ // TS spec tables
338
+ { "spec": "ts32002", "section": "5" }
339
+ ```
340
+
341
+ ### `compare_versions` — Version Comparison
342
+
343
+ Compare section structures between PDF 1.7 (ISO 32000-1) and PDF 2.0 (ISO 32000-2). Uses title-based automatic matching to detect matched, added, and removed sections.
344
+
345
+ > [!NOTE]
346
+ > This tool requires both PDF 1.7 (`PDF32000_2008.pdf`) and PDF 2.0 files in `PDF_SPEC_DIR`.
347
+
348
+ ```jsonc
349
+ // Diff section 12.8 (Digital Signatures)
350
+ { "section": "12.8" }
351
+
352
+ // Compare all top-level sections
353
+ { }
354
+ ```
355
+
356
+ ## Supported Specifications
357
+
358
+ The server auto-discovers PDF files in `PDF_SPEC_DIR` by filename pattern matching:
359
+
360
+ | Category | Spec IDs | Documents |
361
+ | ------------------ | ---------------------------------------------------- | ------------------------------------------------------- |
362
+ | **Standard** | `iso32000-2`, `iso32000-2-2020`, `pdf17`, `pdf17old` | ISO 32000-2 (PDF 2.0), ISO 32000-1 (PDF 1.7) |
363
+ | **Technical Spec** | `ts32001` – `ts32005` | Hash, Digital Signatures, AES-GCM, Integrity, Namespace |
364
+ | **PDF/UA** | `pdfua1`, `pdfua2` | Accessibility (ISO 14289-1, 14289-2) |
365
+ | **Guide** | `tagged-bpg`, `wtpdf`, `declarations` | Tagged PDF, Well-Tagged PDF, Declarations |
366
+ | **App Note** | `an001` – `an003` | BPC, Associated Files, Object Metadata |
367
+
368
+ ## Directory Structure
123
369
 
124
370
  ```
125
371
  src/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuji-bonji/pdf-spec-mcp",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "MCP server for structured understanding of ISO 32000 (PDF) specifications",
5
5
  "keywords": [
6
6
  "mcp",