lightpdf-aipdf-mcp 0.1.120__py3-none-any.whl → 0.1.122__py3-none-any.whl
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.
- lightpdf_aipdf_mcp/editor.py +5 -6
- lightpdf_aipdf_mcp/server.py +23 -16
- {lightpdf_aipdf_mcp-0.1.120.dist-info → lightpdf_aipdf_mcp-0.1.122.dist-info}/METADATA +1 -1
- {lightpdf_aipdf_mcp-0.1.120.dist-info → lightpdf_aipdf_mcp-0.1.122.dist-info}/RECORD +6 -6
- {lightpdf_aipdf_mcp-0.1.120.dist-info → lightpdf_aipdf_mcp-0.1.122.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.120.dist-info → lightpdf_aipdf_mcp-0.1.122.dist-info}/entry_points.txt +0 -0
lightpdf_aipdf_mcp/editor.py
CHANGED
@@ -73,7 +73,7 @@ class Editor(BaseApiClient):
|
|
73
73
|
file_path: 要拆分的PDF文件路径
|
74
74
|
pages: 拆分页面规则,例如 "1,3,5-7" 表示提取第1,3,5,6,7页,""表示所有页面,默认为""
|
75
75
|
password: 文档密码,如果文档受密码保护,则需要提供(可选)
|
76
|
-
split_type: 拆分类型,可选值: "every"=每页拆分为一个文件, "page"=指定页面规则拆分,"
|
76
|
+
split_type: 拆分类型,可选值: "every"=每页拆分为一个文件, "page"=指定页面规则拆分,"bookmark"=按书签/大纲/目录节点拆分,默认为"page"
|
77
77
|
merge_all: 是否合并拆分后的文件,仅在split_type="page"时有效,0=不合并,1=合并,默认为1
|
78
78
|
original_name: 原始文件名(可选)
|
79
79
|
|
@@ -85,10 +85,10 @@ class Editor(BaseApiClient):
|
|
85
85
|
return EditResult(success=False, file_path=file_path, error_message="非PDF文件", original_name=original_name)
|
86
86
|
|
87
87
|
# 验证拆分类型
|
88
|
-
valid_split_types = {"every", "page", "
|
88
|
+
valid_split_types = {"every", "page", "bookmark"}
|
89
89
|
if split_type not in valid_split_types:
|
90
|
-
await self.logger.error(f"无效的拆分类型: {split_type}。有效值为: every, page,
|
91
|
-
return EditResult(success=False, file_path=file_path, error_message=f"无效的拆分类型: {split_type}。有效值为: every, page,
|
90
|
+
await self.logger.error(f"无效的拆分类型: {split_type}。有效值为: every, page, bookmark")
|
91
|
+
return EditResult(success=False, file_path=file_path, error_message=f"无效的拆分类型: {split_type}。有效值为: every, page, bookmark", original_name=original_name)
|
92
92
|
|
93
93
|
# 构建API参数
|
94
94
|
extra_params = {
|
@@ -99,8 +99,7 @@ class Editor(BaseApiClient):
|
|
99
99
|
if split_type == "page":
|
100
100
|
extra_params["pages"] = pages
|
101
101
|
extra_params["merge_all"] = merge_all
|
102
|
-
|
103
|
-
|
102
|
+
|
104
103
|
# 记录操作描述
|
105
104
|
operation_details = f"类型: {split_type}"
|
106
105
|
if split_type == "page":
|
lightpdf_aipdf_mcp/server.py
CHANGED
@@ -196,7 +196,6 @@ async def process_edit_file(
|
|
196
196
|
original_name=original_name
|
197
197
|
)
|
198
198
|
elif edit_type == "split":
|
199
|
-
# 支持split_type: every(每页)、page(按页范围)、outline(按书签/大纲/目录)
|
200
199
|
return await editor.split_pdf(
|
201
200
|
file_path=file_path,
|
202
201
|
pages=extra_params.get("pages", ""),
|
@@ -356,25 +355,35 @@ async def process_tool_call(
|
|
356
355
|
),
|
357
356
|
"PDF转Markdown"
|
358
357
|
)
|
358
|
+
|
359
359
|
report_msg = generate_result_report(results)
|
360
360
|
elif format == "pdf":
|
361
361
|
# 只调用一次process_batch_files,在lambda里分流
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
362
|
+
async def pdf_convert_dispatcher(file_path, password, original_name):
|
363
|
+
ext = file_handler.get_file_extension(file_path)
|
364
|
+
if ext in [".txt", ".tex"]:
|
365
|
+
if ext == ".txt":
|
366
|
+
extra_params = {"pages": [{"url": "oss://txt2pdf", "oss_file": ""}]}
|
367
|
+
else:
|
368
|
+
extra_params = {"pages": [{"url": "oss://tex2pdf", "oss_file": ""}]}
|
369
|
+
return await editor.edit_pdf(
|
367
370
|
file_path,
|
368
371
|
edit_type=EditType.EDIT,
|
369
|
-
extra_params=
|
372
|
+
extra_params=extra_params,
|
370
373
|
password=password,
|
371
374
|
original_name=original_name
|
372
|
-
)
|
375
|
+
)
|
376
|
+
else:
|
377
|
+
return await process_conversion_file(
|
373
378
|
file_path, format, converter, extra_params, password, original_name
|
374
379
|
)
|
375
|
-
|
380
|
+
results = await process_batch_files(
|
381
|
+
file_objects,
|
382
|
+
logger,
|
383
|
+
pdf_convert_dispatcher,
|
376
384
|
f"转换为 {format} 格式"
|
377
385
|
)
|
386
|
+
|
378
387
|
report_msg = generate_result_report(results)
|
379
388
|
else:
|
380
389
|
# 获取操作描述
|
@@ -398,9 +407,7 @@ async def process_tool_call(
|
|
398
407
|
)
|
399
408
|
|
400
409
|
# 生成报告
|
401
|
-
report_msg = generate_result_report(
|
402
|
-
results
|
403
|
-
)
|
410
|
+
report_msg = generate_result_report(results)
|
404
411
|
|
405
412
|
# 如果全部失败,记录错误
|
406
413
|
if not any(r.success for r in results):
|
@@ -420,7 +427,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
420
427
|
return [
|
421
428
|
types.Tool(
|
422
429
|
name="convert_document",
|
423
|
-
description="Document format conversion tool.\n\nPDF can be converted to: DOCX/XLSX/PPTX/Images (including long images)/HTML/TXT (for text extraction)/CSV;\nOther formats can be converted to PDF: DOCX/XLSX/PPTX/Images/CAD/CAJ/OFD/HTML.\nOnly whole-file conversion is supported
|
430
|
+
description="Document format conversion tool.\n\nPDF can be converted to: DOCX/XLSX/PPTX/Images (including long images)/HTML/TXT (for text extraction)/CSV;\nOther formats can be converted to PDF: DOCX/XLSX/PPTX/Images/CAD/CAJ/OFD/HTML/TEX (LaTeX).\nOnly whole-file conversion is supported. Does not support creating files from content.",
|
424
431
|
inputSchema={
|
425
432
|
"type": "object",
|
426
433
|
"properties": {
|
@@ -793,7 +800,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
793
800
|
),
|
794
801
|
types.Tool(
|
795
802
|
name="split_pdf",
|
796
|
-
description="Split PDF documents by pages. You can split each page into a separate PDF file, split by specified page ranges, or split by
|
803
|
+
description="Split PDF documents by pages. You can split each page into a separate PDF file, split by specified page ranges, or split by bookmarks/outlines/table of contents/headings (bookmark). Split files can be multiple independent PDF files (returned as a zip package) or merged into a single PDF file.",
|
797
804
|
inputSchema={
|
798
805
|
"type": "object",
|
799
806
|
"properties": {
|
@@ -821,8 +828,8 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
821
828
|
},
|
822
829
|
"split_type": {
|
823
830
|
"type": "string",
|
824
|
-
"description": "Split type: 'every' (split each page into a separate file), 'page' (split by page ranges), or '
|
825
|
-
"enum": ["every", "page", "
|
831
|
+
"description": "Split type: 'every' (split each page into a separate file), 'page' (split by page ranges), or 'bookmark' (split by PDF bookmarks/outlines/table of contents/headings, each node as a separate PDF file).",
|
832
|
+
"enum": ["every", "page", "bookmark"]
|
826
833
|
},
|
827
834
|
"pages": {
|
828
835
|
"type": "string",
|
@@ -2,10 +2,10 @@ lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6
|
|
2
2
|
lightpdf_aipdf_mcp/common.py,sha256=PhTf7Zg6mEgn1rTmJDHotXp-4xb2gWFf-Dy_t25qNdY,6660
|
3
3
|
lightpdf_aipdf_mcp/converter.py,sha256=vAFB6XtDFt9NPS9yygKBuL4t43nZU--RqqKPC06Mvkg,16761
|
4
4
|
lightpdf_aipdf_mcp/create_pdf.py,sha256=oALIhOBo60D3Gu_li7d7FF0COhFfSTM-BJpc63r9iAs,2465
|
5
|
-
lightpdf_aipdf_mcp/editor.py,sha256=
|
6
|
-
lightpdf_aipdf_mcp/server.py,sha256=
|
5
|
+
lightpdf_aipdf_mcp/editor.py,sha256=cYJ6NlS9q_HJwL-Aw7mVwCT5CECMLWYlmR_ePhw_Ja4,30081
|
6
|
+
lightpdf_aipdf_mcp/server.py,sha256=Q_5eYgedc9HH2d1EhRRkG4IAOkKLJW7R_A8u_Terp-s,65982
|
7
7
|
lightpdf_aipdf_mcp/translator.py,sha256=NbFDz-mZSD4qCNQVyV0W_0x6xXwbqs_7FiBU13JAxZs,4243
|
8
|
-
lightpdf_aipdf_mcp-0.1.
|
9
|
-
lightpdf_aipdf_mcp-0.1.
|
10
|
-
lightpdf_aipdf_mcp-0.1.
|
11
|
-
lightpdf_aipdf_mcp-0.1.
|
8
|
+
lightpdf_aipdf_mcp-0.1.122.dist-info/METADATA,sha256=X_LIN1xjIVJegnw3aEdvArgZD3m1ZsnNNMmgwASAl-I,8120
|
9
|
+
lightpdf_aipdf_mcp-0.1.122.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
lightpdf_aipdf_mcp-0.1.122.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
11
|
+
lightpdf_aipdf_mcp-0.1.122.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.120.dist-info → lightpdf_aipdf_mcp-0.1.122.dist-info}/entry_points.txt
RENAMED
File without changes
|