@shuji-bonji/pdf-writer-mcp 0.2.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +208 -0
  3. package/dist/config.d.ts +34 -0
  4. package/dist/config.js +38 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/constants.d.ts +46 -0
  7. package/dist/constants.js +46 -0
  8. package/dist/constants.js.map +1 -0
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.js +52 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/services/builder.d.ts +10 -0
  13. package/dist/services/builder.js +40 -0
  14. package/dist/services/builder.js.map +1 -0
  15. package/dist/services/editor.d.ts +24 -0
  16. package/dist/services/editor.js +194 -0
  17. package/dist/services/editor.js.map +1 -0
  18. package/dist/services/font-manager.d.ts +18 -0
  19. package/dist/services/font-manager.js +59 -0
  20. package/dist/services/font-manager.js.map +1 -0
  21. package/dist/services/layout.d.ts +62 -0
  22. package/dist/services/layout.js +198 -0
  23. package/dist/services/layout.js.map +1 -0
  24. package/dist/services/output.d.ts +13 -0
  25. package/dist/services/output.js +60 -0
  26. package/dist/services/output.js.map +1 -0
  27. package/dist/services/renderers/markdown.d.ts +8 -0
  28. package/dist/services/renderers/markdown.js +132 -0
  29. package/dist/services/renderers/markdown.js.map +1 -0
  30. package/dist/services/renderers/table.d.ts +7 -0
  31. package/dist/services/renderers/table.js +89 -0
  32. package/dist/services/renderers/table.js.map +1 -0
  33. package/dist/services/renderers/text.d.ts +9 -0
  34. package/dist/services/renderers/text.js +29 -0
  35. package/dist/services/renderers/text.js.map +1 -0
  36. package/dist/tools/definitions.d.ts +388 -0
  37. package/dist/tools/definitions.js +241 -0
  38. package/dist/tools/definitions.js.map +1 -0
  39. package/dist/tools/handlers.d.ts +23 -0
  40. package/dist/tools/handlers.js +82 -0
  41. package/dist/tools/handlers.js.map +1 -0
  42. package/dist/types/index.d.ts +135 -0
  43. package/dist/types/index.js +5 -0
  44. package/dist/types/index.js.map +1 -0
  45. package/dist/utils/logger.d.ts +14 -0
  46. package/dist/utils/logger.js +28 -0
  47. package/dist/utils/logger.js.map +1 -0
  48. package/dist/utils/page-spec.d.ts +12 -0
  49. package/dist/utils/page-spec.js +55 -0
  50. package/dist/utils/page-spec.js.map +1 -0
  51. package/dist/utils/validation.d.ts +24 -0
  52. package/dist/utils/validation.js +187 -0
  53. package/dist/utils/validation.js.map +1 -0
  54. package/package.json +48 -0
@@ -0,0 +1,388 @@
1
+ /**
2
+ * MCP Tool 定義(入力スキーマ)
3
+ * 実装は handlers.ts、型は types/index.ts と対応させる。
4
+ */
5
+ export declare const tools: readonly [{
6
+ readonly name: 'create_text_pdf';
7
+ readonly description: 'プレーンテキストから PDF を生成する。改行(\\n)を尊重し、空行を段落区切りとして扱う。長い行は自動で折り返す。';
8
+ readonly inputSchema: {
9
+ readonly type: 'object';
10
+ readonly properties: {
11
+ readonly outputPath: {
12
+ readonly type: 'string';
13
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
14
+ };
15
+ readonly returnBase64: {
16
+ readonly type: 'boolean';
17
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
18
+ };
19
+ readonly fontPath: {
20
+ readonly type: 'string';
21
+ readonly description: string;
22
+ };
23
+ readonly fontSize: {
24
+ readonly type: 'number';
25
+ readonly description: '本文フォントサイズ(pt)。既定 11。範囲 4〜96。';
26
+ };
27
+ readonly pageSize: {
28
+ readonly type: 'string';
29
+ readonly enum: readonly ['A4', 'A3', 'A5', 'LETTER', 'LEGAL'];
30
+ readonly description: 'ページサイズ。既定 A4。';
31
+ };
32
+ readonly margin: {
33
+ readonly type: 'number';
34
+ readonly description: '上下左右マージン(pt)。既定 56(≒20mm)。範囲 0〜300。';
35
+ };
36
+ readonly title: {
37
+ readonly type: 'string';
38
+ readonly description: 'PDF タイトル。メタデータに設定し、本文冒頭にも見出しとして描画する。';
39
+ };
40
+ readonly author: {
41
+ readonly type: 'string';
42
+ readonly description: 'PDF 作成者(メタデータ)。';
43
+ };
44
+ readonly text: {
45
+ readonly type: 'string';
46
+ readonly description: '本文テキスト。\\n で改行、空行で段落区切り。';
47
+ };
48
+ };
49
+ readonly required: readonly ['text'];
50
+ };
51
+ }, {
52
+ readonly name: 'create_markdown_pdf';
53
+ readonly description: string;
54
+ readonly inputSchema: {
55
+ readonly type: 'object';
56
+ readonly properties: {
57
+ readonly outputPath: {
58
+ readonly type: 'string';
59
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
60
+ };
61
+ readonly returnBase64: {
62
+ readonly type: 'boolean';
63
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
64
+ };
65
+ readonly fontPath: {
66
+ readonly type: 'string';
67
+ readonly description: string;
68
+ };
69
+ readonly fontSize: {
70
+ readonly type: 'number';
71
+ readonly description: '本文フォントサイズ(pt)。既定 11。範囲 4〜96。';
72
+ };
73
+ readonly pageSize: {
74
+ readonly type: 'string';
75
+ readonly enum: readonly ['A4', 'A3', 'A5', 'LETTER', 'LEGAL'];
76
+ readonly description: 'ページサイズ。既定 A4。';
77
+ };
78
+ readonly margin: {
79
+ readonly type: 'number';
80
+ readonly description: '上下左右マージン(pt)。既定 56(≒20mm)。範囲 0〜300。';
81
+ };
82
+ readonly title: {
83
+ readonly type: 'string';
84
+ readonly description: 'PDF タイトル。メタデータに設定し、本文冒頭にも見出しとして描画する。';
85
+ };
86
+ readonly author: {
87
+ readonly type: 'string';
88
+ readonly description: 'PDF 作成者(メタデータ)。';
89
+ };
90
+ readonly markdown: {
91
+ readonly type: 'string';
92
+ readonly description: 'Markdown 文字列。';
93
+ };
94
+ };
95
+ readonly required: readonly ['markdown'];
96
+ };
97
+ }, {
98
+ readonly name: 'create_table_pdf';
99
+ readonly description: 'ヘッダと行データから罫線付きの表 PDF を生成する。列幅は内容から自動算出し、セル内は折り返す。改ページ時はヘッダを再描画する。';
100
+ readonly inputSchema: {
101
+ readonly type: 'object';
102
+ readonly properties: {
103
+ readonly outputPath: {
104
+ readonly type: 'string';
105
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
106
+ };
107
+ readonly returnBase64: {
108
+ readonly type: 'boolean';
109
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
110
+ };
111
+ readonly fontPath: {
112
+ readonly type: 'string';
113
+ readonly description: string;
114
+ };
115
+ readonly fontSize: {
116
+ readonly type: 'number';
117
+ readonly description: '本文フォントサイズ(pt)。既定 11。範囲 4〜96。';
118
+ };
119
+ readonly pageSize: {
120
+ readonly type: 'string';
121
+ readonly enum: readonly ['A4', 'A3', 'A5', 'LETTER', 'LEGAL'];
122
+ readonly description: 'ページサイズ。既定 A4。';
123
+ };
124
+ readonly margin: {
125
+ readonly type: 'number';
126
+ readonly description: '上下左右マージン(pt)。既定 56(≒20mm)。範囲 0〜300。';
127
+ };
128
+ readonly title: {
129
+ readonly type: 'string';
130
+ readonly description: 'PDF タイトル。メタデータに設定し、本文冒頭にも見出しとして描画する。';
131
+ };
132
+ readonly author: {
133
+ readonly type: 'string';
134
+ readonly description: 'PDF 作成者(メタデータ)。';
135
+ };
136
+ readonly headers: {
137
+ readonly type: 'array';
138
+ readonly items: {
139
+ readonly type: 'string';
140
+ };
141
+ readonly description: 'ヘッダ行(列見出し)の配列。';
142
+ };
143
+ readonly rows: {
144
+ readonly type: 'array';
145
+ readonly items: {
146
+ readonly type: 'array';
147
+ readonly items: {
148
+ readonly type: 'string';
149
+ };
150
+ };
151
+ readonly description: 'データ行の配列。各行は文字列の配列で、headers と同じ列数を推奨。';
152
+ };
153
+ };
154
+ readonly required: readonly ['headers', 'rows'];
155
+ };
156
+ }, {
157
+ readonly name: 'set_metadata';
158
+ readonly description: string;
159
+ readonly inputSchema: {
160
+ readonly type: 'object';
161
+ readonly properties: {
162
+ readonly outputPath: {
163
+ readonly type: 'string';
164
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
165
+ };
166
+ readonly returnBase64: {
167
+ readonly type: 'boolean';
168
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
169
+ };
170
+ readonly allowBreakingSignatures: {
171
+ readonly type: 'boolean';
172
+ readonly description: string;
173
+ };
174
+ readonly inputPath: {
175
+ readonly type: 'string';
176
+ readonly description: '編集対象 PDF の絶対パス。';
177
+ };
178
+ readonly title: {
179
+ readonly type: 'string';
180
+ readonly description: 'タイトル。';
181
+ };
182
+ readonly author: {
183
+ readonly type: 'string';
184
+ readonly description: '作成者。';
185
+ };
186
+ readonly subject: {
187
+ readonly type: 'string';
188
+ readonly description: 'サブタイトル・件名。';
189
+ };
190
+ readonly keywords: {
191
+ readonly type: 'array';
192
+ readonly items: {
193
+ readonly type: 'string';
194
+ };
195
+ readonly description: 'キーワードの配列。';
196
+ };
197
+ readonly creator: {
198
+ readonly type: 'string';
199
+ readonly description: '作成アプリケーション名。';
200
+ };
201
+ };
202
+ readonly required: readonly ['inputPath'];
203
+ };
204
+ }, {
205
+ readonly name: 'merge_pdfs';
206
+ readonly description: '複数の PDF を指定順に 1 つへ結合する。文書メタデータは先頭ファイルから引き継ぐ。';
207
+ readonly inputSchema: {
208
+ readonly type: 'object';
209
+ readonly properties: {
210
+ readonly outputPath: {
211
+ readonly type: 'string';
212
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
213
+ };
214
+ readonly returnBase64: {
215
+ readonly type: 'boolean';
216
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
217
+ };
218
+ readonly allowBreakingSignatures: {
219
+ readonly type: 'boolean';
220
+ readonly description: string;
221
+ };
222
+ readonly inputPaths: {
223
+ readonly type: 'array';
224
+ readonly items: {
225
+ readonly type: 'string';
226
+ };
227
+ readonly description: '結合する PDF の絶対パスの配列(結合順・2 件以上)。';
228
+ };
229
+ };
230
+ readonly required: readonly ['inputPaths'];
231
+ };
232
+ }, {
233
+ readonly name: 'split_pdf';
234
+ readonly description: string;
235
+ readonly inputSchema: {
236
+ readonly type: 'object';
237
+ readonly properties: {
238
+ readonly inputPath: {
239
+ readonly type: 'string';
240
+ readonly description: '分割対象 PDF の絶対パス。';
241
+ };
242
+ readonly ranges: {
243
+ readonly type: 'array';
244
+ readonly items: {
245
+ readonly type: 'string';
246
+ };
247
+ readonly description: 'ページ範囲指定の配列。各要素は "1-3" / "5" / "7-" / "-2" 形式(1 始まり)。例: ["1-3", "4-"]。';
248
+ };
249
+ readonly outputDir: {
250
+ readonly type: 'string';
251
+ readonly description: '出力先ディレクトリ。';
252
+ };
253
+ readonly prefix: {
254
+ readonly type: 'string';
255
+ readonly description: '出力ファイル名の接頭辞。既定は "<入力ファイル名>-part"。';
256
+ };
257
+ readonly allowBreakingSignatures: {
258
+ readonly type: 'boolean';
259
+ readonly description: string;
260
+ };
261
+ };
262
+ readonly required: readonly ['inputPath', 'ranges', 'outputDir'];
263
+ };
264
+ }, {
265
+ readonly name: 'extract_pages';
266
+ readonly description: '指定ページだけを含む新しい PDF を作る。指定順を保持するため、ページの並べ替えを兼ねた抽出も可能。';
267
+ readonly inputSchema: {
268
+ readonly type: 'object';
269
+ readonly properties: {
270
+ readonly outputPath: {
271
+ readonly type: 'string';
272
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
273
+ };
274
+ readonly returnBase64: {
275
+ readonly type: 'boolean';
276
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
277
+ };
278
+ readonly allowBreakingSignatures: {
279
+ readonly type: 'boolean';
280
+ readonly description: string;
281
+ };
282
+ readonly inputPath: {
283
+ readonly type: 'string';
284
+ readonly description: '対象 PDF の絶対パス。';
285
+ };
286
+ readonly pages: {
287
+ readonly type: 'string';
288
+ readonly description: 'ページ指定。"1,3-5,8-" 形式(1 始まり)。指定順が出力順になる。';
289
+ };
290
+ };
291
+ readonly required: readonly ['inputPath', 'pages'];
292
+ };
293
+ }, {
294
+ readonly name: 'delete_pages';
295
+ readonly description: '指定ページを削除した新しい PDF を作る。全ページの削除はエラー。';
296
+ readonly inputSchema: {
297
+ readonly type: 'object';
298
+ readonly properties: {
299
+ readonly outputPath: {
300
+ readonly type: 'string';
301
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
302
+ };
303
+ readonly returnBase64: {
304
+ readonly type: 'boolean';
305
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
306
+ };
307
+ readonly allowBreakingSignatures: {
308
+ readonly type: 'boolean';
309
+ readonly description: string;
310
+ };
311
+ readonly inputPath: {
312
+ readonly type: 'string';
313
+ readonly description: '対象 PDF の絶対パス。';
314
+ };
315
+ readonly pages: {
316
+ readonly type: 'string';
317
+ readonly description: '削除するページ指定。"1,3-5,8-" 形式(1 始まり)。';
318
+ };
319
+ };
320
+ readonly required: readonly ['inputPath', 'pages'];
321
+ };
322
+ }, {
323
+ readonly name: 'reorder_pages';
324
+ readonly description: 'ページを並べ替える。order には全ページを新しい順序で 1 回ずつ列挙する。';
325
+ readonly inputSchema: {
326
+ readonly type: 'object';
327
+ readonly properties: {
328
+ readonly outputPath: {
329
+ readonly type: 'string';
330
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
331
+ };
332
+ readonly returnBase64: {
333
+ readonly type: 'boolean';
334
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
335
+ };
336
+ readonly allowBreakingSignatures: {
337
+ readonly type: 'boolean';
338
+ readonly description: string;
339
+ };
340
+ readonly inputPath: {
341
+ readonly type: 'string';
342
+ readonly description: '対象 PDF の絶対パス。';
343
+ };
344
+ readonly order: {
345
+ readonly type: 'array';
346
+ readonly items: {
347
+ readonly type: 'number';
348
+ };
349
+ readonly description: '新しいページ順(1 始まり)。例: 5 ページの逆順は [5,4,3,2,1]。';
350
+ };
351
+ };
352
+ readonly required: readonly ['inputPath', 'order'];
353
+ };
354
+ }, {
355
+ readonly name: 'rotate_pages';
356
+ readonly description: 'ページを時計回りに回転する(90/180/270 度)。pages 省略時は全ページ。';
357
+ readonly inputSchema: {
358
+ readonly type: 'object';
359
+ readonly properties: {
360
+ readonly outputPath: {
361
+ readonly type: 'string';
362
+ readonly description: '保存先ファイルパス。省略した場合は base64 文字列を返す。';
363
+ };
364
+ readonly returnBase64: {
365
+ readonly type: 'boolean';
366
+ readonly description: 'true の場合、保存に加えて base64 文字列も結果に含める。';
367
+ };
368
+ readonly allowBreakingSignatures: {
369
+ readonly type: 'boolean';
370
+ readonly description: string;
371
+ };
372
+ readonly inputPath: {
373
+ readonly type: 'string';
374
+ readonly description: '対象 PDF の絶対パス。';
375
+ };
376
+ readonly rotation: {
377
+ readonly type: 'number';
378
+ readonly enum: readonly [90, 180, 270];
379
+ readonly description: '時計回りの回転角(度)。';
380
+ };
381
+ readonly pages: {
382
+ readonly type: 'string';
383
+ readonly description: '対象ページ指定。"1,3-5" 形式(1 始まり)。省略時は全ページ。';
384
+ };
385
+ };
386
+ readonly required: readonly ['inputPath', 'rotation'];
387
+ };
388
+ }];
@@ -0,0 +1,241 @@
1
+ /**
2
+ * MCP Tool 定義(入力スキーマ)
3
+ * 実装は handlers.ts、型は types/index.ts と対応させる。
4
+ */
5
+ const commonProperties = {
6
+ outputPath: {
7
+ type: 'string',
8
+ description: '保存先ファイルパス。省略した場合は base64 文字列を返す。',
9
+ },
10
+ returnBase64: {
11
+ type: 'boolean',
12
+ description: 'true の場合、保存に加えて base64 文字列も結果に含める。',
13
+ },
14
+ fontPath: {
15
+ type: 'string',
16
+ description: '埋め込むフォントファイル(.ttf / .otf)の絶対パス。日本語など非ラテン文字を含む場合は必須。' +
17
+ '.ttc(TrueTypeCollection)は非対応。環境変数 PDF_WRITER_FONT でも指定可。',
18
+ },
19
+ fontSize: {
20
+ type: 'number',
21
+ description: '本文フォントサイズ(pt)。既定 11。範囲 4〜96。',
22
+ },
23
+ pageSize: {
24
+ type: 'string',
25
+ enum: ['A4', 'A3', 'A5', 'LETTER', 'LEGAL'],
26
+ description: 'ページサイズ。既定 A4。',
27
+ },
28
+ margin: {
29
+ type: 'number',
30
+ description: '上下左右マージン(pt)。既定 56(≒20mm)。範囲 0〜300。',
31
+ },
32
+ title: {
33
+ type: 'string',
34
+ description: 'PDF タイトル。メタデータに設定し、本文冒頭にも見出しとして描画する。',
35
+ },
36
+ author: {
37
+ type: 'string',
38
+ description: 'PDF 作成者(メタデータ)。',
39
+ },
40
+ };
41
+ const editCommonProperties = {
42
+ outputPath: {
43
+ type: 'string',
44
+ description: '保存先ファイルパス。省略した場合は base64 文字列を返す。',
45
+ },
46
+ returnBase64: {
47
+ type: 'boolean',
48
+ description: 'true の場合、保存に加えて base64 文字列も結果に含める。',
49
+ },
50
+ allowBreakingSignatures: {
51
+ type: 'boolean',
52
+ description: '編集対象が電子署名済み(/ByteRange 検知)の場合、既定ではエラーにする。' +
53
+ 'true を指定すると署名が無効化されることを承知の上で編集を続行する。',
54
+ },
55
+ };
56
+ export const tools = [
57
+ {
58
+ name: 'create_text_pdf',
59
+ description: 'プレーンテキストから PDF を生成する。改行(\\n)を尊重し、空行を段落区切りとして扱う。長い行は自動で折り返す。',
60
+ inputSchema: {
61
+ type: 'object',
62
+ properties: {
63
+ text: {
64
+ type: 'string',
65
+ description: '本文テキスト。\\n で改行、空行で段落区切り。',
66
+ },
67
+ ...commonProperties,
68
+ },
69
+ required: ['text'],
70
+ },
71
+ },
72
+ {
73
+ name: 'create_markdown_pdf',
74
+ description: 'Markdown から PDF を生成する。見出し・段落・箇条書き/番号リスト・コードブロック・引用・水平線・表に対応。' +
75
+ 'インライン装飾の記号は除去し字面のみ反映する(単一フォントのため)。',
76
+ inputSchema: {
77
+ type: 'object',
78
+ properties: {
79
+ markdown: {
80
+ type: 'string',
81
+ description: 'Markdown 文字列。',
82
+ },
83
+ ...commonProperties,
84
+ },
85
+ required: ['markdown'],
86
+ },
87
+ },
88
+ {
89
+ name: 'create_table_pdf',
90
+ description: 'ヘッダと行データから罫線付きの表 PDF を生成する。列幅は内容から自動算出し、セル内は折り返す。改ページ時はヘッダを再描画する。',
91
+ inputSchema: {
92
+ type: 'object',
93
+ properties: {
94
+ headers: {
95
+ type: 'array',
96
+ items: { type: 'string' },
97
+ description: 'ヘッダ行(列見出し)の配列。',
98
+ },
99
+ rows: {
100
+ type: 'array',
101
+ items: { type: 'array', items: { type: 'string' } },
102
+ description: 'データ行の配列。各行は文字列の配列で、headers と同じ列数を推奨。',
103
+ },
104
+ ...commonProperties,
105
+ },
106
+ required: ['headers', 'rows'],
107
+ },
108
+ },
109
+ {
110
+ name: 'set_metadata',
111
+ description: '既存 PDF のメタデータ(Info 辞書)を更新する。指定したフィールドのみ変更し、他は保持する。' +
112
+ 'title / author / subject / keywords / creator のうち最低 1 つが必要。',
113
+ inputSchema: {
114
+ type: 'object',
115
+ properties: {
116
+ inputPath: { type: 'string', description: '編集対象 PDF の絶対パス。' },
117
+ title: { type: 'string', description: 'タイトル。' },
118
+ author: { type: 'string', description: '作成者。' },
119
+ subject: { type: 'string', description: 'サブタイトル・件名。' },
120
+ keywords: {
121
+ type: 'array',
122
+ items: { type: 'string' },
123
+ description: 'キーワードの配列。',
124
+ },
125
+ creator: { type: 'string', description: '作成アプリケーション名。' },
126
+ ...editCommonProperties,
127
+ },
128
+ required: ['inputPath'],
129
+ },
130
+ },
131
+ {
132
+ name: 'merge_pdfs',
133
+ description: '複数の PDF を指定順に 1 つへ結合する。文書メタデータは先頭ファイルから引き継ぐ。',
134
+ inputSchema: {
135
+ type: 'object',
136
+ properties: {
137
+ inputPaths: {
138
+ type: 'array',
139
+ items: { type: 'string' },
140
+ description: '結合する PDF の絶対パスの配列(結合順・2 件以上)。',
141
+ },
142
+ ...editCommonProperties,
143
+ },
144
+ required: ['inputPaths'],
145
+ },
146
+ },
147
+ {
148
+ name: 'split_pdf',
149
+ description: 'PDF をページ範囲ごとに複数ファイルへ分割する。ranges の各要素が 1 ファイルになる。' +
150
+ '出力は "<prefix>1.pdf", "<prefix>2.pdf", ... の連番。',
151
+ inputSchema: {
152
+ type: 'object',
153
+ properties: {
154
+ inputPath: { type: 'string', description: '分割対象 PDF の絶対パス。' },
155
+ ranges: {
156
+ type: 'array',
157
+ items: { type: 'string' },
158
+ description: 'ページ範囲指定の配列。各要素は "1-3" / "5" / "7-" / "-2" 形式(1 始まり)。例: ["1-3", "4-"]。',
159
+ },
160
+ outputDir: { type: 'string', description: '出力先ディレクトリ。' },
161
+ prefix: {
162
+ type: 'string',
163
+ description: '出力ファイル名の接頭辞。既定は "<入力ファイル名>-part"。',
164
+ },
165
+ allowBreakingSignatures: editCommonProperties.allowBreakingSignatures,
166
+ },
167
+ required: ['inputPath', 'ranges', 'outputDir'],
168
+ },
169
+ },
170
+ {
171
+ name: 'extract_pages',
172
+ description: '指定ページだけを含む新しい PDF を作る。指定順を保持するため、ページの並べ替えを兼ねた抽出も可能。',
173
+ inputSchema: {
174
+ type: 'object',
175
+ properties: {
176
+ inputPath: { type: 'string', description: '対象 PDF の絶対パス。' },
177
+ pages: {
178
+ type: 'string',
179
+ description: 'ページ指定。"1,3-5,8-" 形式(1 始まり)。指定順が出力順になる。',
180
+ },
181
+ ...editCommonProperties,
182
+ },
183
+ required: ['inputPath', 'pages'],
184
+ },
185
+ },
186
+ {
187
+ name: 'delete_pages',
188
+ description: '指定ページを削除した新しい PDF を作る。全ページの削除はエラー。',
189
+ inputSchema: {
190
+ type: 'object',
191
+ properties: {
192
+ inputPath: { type: 'string', description: '対象 PDF の絶対パス。' },
193
+ pages: {
194
+ type: 'string',
195
+ description: '削除するページ指定。"1,3-5,8-" 形式(1 始まり)。',
196
+ },
197
+ ...editCommonProperties,
198
+ },
199
+ required: ['inputPath', 'pages'],
200
+ },
201
+ },
202
+ {
203
+ name: 'reorder_pages',
204
+ description: 'ページを並べ替える。order には全ページを新しい順序で 1 回ずつ列挙する。',
205
+ inputSchema: {
206
+ type: 'object',
207
+ properties: {
208
+ inputPath: { type: 'string', description: '対象 PDF の絶対パス。' },
209
+ order: {
210
+ type: 'array',
211
+ items: { type: 'number' },
212
+ description: '新しいページ順(1 始まり)。例: 5 ページの逆順は [5,4,3,2,1]。',
213
+ },
214
+ ...editCommonProperties,
215
+ },
216
+ required: ['inputPath', 'order'],
217
+ },
218
+ },
219
+ {
220
+ name: 'rotate_pages',
221
+ description: 'ページを時計回りに回転する(90/180/270 度)。pages 省略時は全ページ。',
222
+ inputSchema: {
223
+ type: 'object',
224
+ properties: {
225
+ inputPath: { type: 'string', description: '対象 PDF の絶対パス。' },
226
+ rotation: {
227
+ type: 'number',
228
+ enum: [90, 180, 270],
229
+ description: '時計回りの回転角(度)。',
230
+ },
231
+ pages: {
232
+ type: 'string',
233
+ description: '対象ページ指定。"1,3-5" 形式(1 始まり)。省略時は全ページ。',
234
+ },
235
+ ...editCommonProperties,
236
+ },
237
+ required: ['inputPath', 'rotation'],
238
+ },
239
+ },
240
+ ];
241
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,gBAAgB,GAAG;IACvB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,kCAAkC;KAChD;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,oCAAoC;KAClD;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,qDAAqD;YACrD,0DAA0D;KAC7D;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,8BAA8B;KAC5C;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC;QAC3C,WAAW,EAAE,eAAe;KAC7B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,qCAAqC;KACnD;IACD,KAAK,EAAE;QACL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AE,QAAQ;oBACd,WAAW,EAAE,iCAAiC;iBAC/C;gBACD,GAAG,oBAAoB;aACxB;YACD,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;SACjC;KACF;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,0CAA0C;QACvD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE;gBAC3D,KAAK,EAAE;oBACL,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,0CAA0C;iBACxD;gBACD,GAAG,oBAAoB;aACxB;YACD,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;SACjC;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,6CAA6C;QAC1D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE;gBAC3D,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC;oBACpB,WAAW,EAAE,cAAc;iBAC5B;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qCAAqC;iBACnD;gBACD,GAAG,oBAAoB;aACxB;YACD,QAAQ,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;SACpC;KACF;CACO,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Tool ハンドラ群 + ディスパッチ用 Map
3
+ *
4
+ * 新しいツールを追加するときは:
5
+ * 1. handleXxx 関数を実装
6
+ * 2. 下の toolHandlers に 1 行追加
7
+ * だけでよい。引数検査は validation.ts に集約。
8
+ */
9
+ import type { CreateResult, EditResult, SplitResult } from '../types/index.js';
10
+ export declare function handleCreateTextPdf(args: unknown): Promise<CreateResult>;
11
+ export declare function handleCreateMarkdownPdf(args: unknown): Promise<CreateResult>;
12
+ export declare function handleCreateTablePdf(args: unknown): Promise<CreateResult>;
13
+ export declare function handleSetMetadata(args: unknown): Promise<EditResult>;
14
+ export declare function handleMergePdfs(args: unknown): Promise<EditResult>;
15
+ export declare function handleSplitPdf(args: unknown): Promise<SplitResult>;
16
+ export declare function handleExtractPages(args: unknown): Promise<EditResult>;
17
+ export declare function handleDeletePages(args: unknown): Promise<EditResult>;
18
+ export declare function handleReorderPages(args: unknown): Promise<EditResult>;
19
+ export declare function handleRotatePages(args: unknown): Promise<EditResult>;
20
+ /**
21
+ * Tool ハンドラの Map(引数型は各ハンドラ側で検査するため any を許容)
22
+ */
23
+ export declare const toolHandlers: Record<string, (args: any) => Promise<unknown>>;