lightpdf-aipdf-mcp 0.1.57__py3-none-any.whl → 0.1.59__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 +1 -1
- lightpdf_aipdf_mcp/server.py +39 -12
- {lightpdf_aipdf_mcp-0.1.57.dist-info → lightpdf_aipdf_mcp-0.1.59.dist-info}/METADATA +1 -1
- lightpdf_aipdf_mcp-0.1.59.dist-info/RECORD +9 -0
- lightpdf_aipdf_mcp-0.1.57.dist-info/RECORD +0 -9
- {lightpdf_aipdf_mcp-0.1.57.dist-info → lightpdf_aipdf_mcp-0.1.59.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.57.dist-info → lightpdf_aipdf_mcp-0.1.59.dist-info}/entry_points.txt +0 -0
lightpdf_aipdf_mcp/editor.py
CHANGED
lightpdf_aipdf_mcp/server.py
CHANGED
@@ -58,16 +58,20 @@ def generate_result_report(
|
|
58
58
|
if result.success:
|
59
59
|
# 添加成功的文件信息
|
60
60
|
report_obj["success_files"].append({
|
61
|
-
"
|
62
|
-
"
|
63
|
-
|
61
|
+
"download_url": result.download_url,
|
62
|
+
"original_info": {
|
63
|
+
"path": result.file_path,
|
64
|
+
"name": result.original_name,
|
65
|
+
}
|
64
66
|
})
|
65
67
|
else:
|
66
68
|
# 添加失败的文件信息
|
67
69
|
report_obj["failed_files"].append({
|
68
|
-
"
|
69
|
-
"
|
70
|
-
|
70
|
+
"error_message": result.error_message,
|
71
|
+
"original_info": {
|
72
|
+
"path": result.file_path,
|
73
|
+
"name": result.original_name,
|
74
|
+
}
|
71
75
|
})
|
72
76
|
|
73
77
|
# 返回JSON字符串
|
@@ -93,8 +97,8 @@ async def process_batch_files(
|
|
93
97
|
if len(file_objects) > 1 and operation_desc:
|
94
98
|
await logger.log("info", f"开始批量{operation_desc},共 {len(file_objects)} 个文件")
|
95
99
|
|
96
|
-
# 并发处理文件,限制并发数为
|
97
|
-
semaphore = asyncio.Semaphore(
|
100
|
+
# 并发处理文件,限制并发数为2
|
101
|
+
semaphore = asyncio.Semaphore(2)
|
98
102
|
|
99
103
|
async def process_with_semaphore(file_obj: Dict[str, str]) -> T:
|
100
104
|
async with semaphore:
|
@@ -135,6 +139,17 @@ async def process_conversion_file(
|
|
135
139
|
original_name
|
136
140
|
)
|
137
141
|
else:
|
142
|
+
# 处理extra_params
|
143
|
+
if extra_params is None:
|
144
|
+
extra_params = {}
|
145
|
+
|
146
|
+
# 处理is_long_image参数,如果需要转换为长图,则添加merge_all=1参数
|
147
|
+
if extra_params.get("is_long_image") and format in ["jpg", "jpeg", "png"]:
|
148
|
+
extra_params["merge_all"] = 1
|
149
|
+
# 从extra_params中移除is_long_image,因为API不需要这个参数
|
150
|
+
if "is_long_image" in extra_params:
|
151
|
+
del extra_params["is_long_image"]
|
152
|
+
|
138
153
|
# 对于其他操作,使用convert_file方法
|
139
154
|
return await converter.convert_file(file_path, format, extra_params, password, original_name)
|
140
155
|
|
@@ -268,7 +283,8 @@ async def process_tool_call(
|
|
268
283
|
"compress": "压缩",
|
269
284
|
"split": "拆分",
|
270
285
|
"merge": "合并",
|
271
|
-
"rotate": "旋转"
|
286
|
+
"rotate": "旋转",
|
287
|
+
"remove_margin": "去除白边"
|
272
288
|
}
|
273
289
|
operation_desc = f"PDF{edit_map.get(edit_type, edit_type)}"
|
274
290
|
|
@@ -340,7 +356,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
340
356
|
return [
|
341
357
|
types.Tool(
|
342
358
|
name="convert_document",
|
343
|
-
description="文档格式转换工具。\n\nPDF可转换为:DOCX/XLSX/PPTX
|
359
|
+
description="文档格式转换工具。\n\nPDF可转换为:DOCX/XLSX/PPTX/图片(长图)/HTML/TXT;\n其他格式可转换为PDF:DOCX/XLSX/PPTX/图片/CAD/CAJ/OFD",
|
344
360
|
inputSchema={
|
345
361
|
"type": "object",
|
346
362
|
"properties": {
|
@@ -370,6 +386,11 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
370
386
|
"type": "string",
|
371
387
|
"description": "目标格式",
|
372
388
|
"enum": ["pdf", "docx", "xlsx", "pptx", "jpg", "jpeg", "png", "html", "txt"]
|
389
|
+
},
|
390
|
+
"is_long_image": {
|
391
|
+
"type": "boolean",
|
392
|
+
"description": "是否需要转换为长图。仅当format为jpg/jpeg/png时有效",
|
393
|
+
"default": False
|
373
394
|
}
|
374
395
|
},
|
375
396
|
"required": ["files", "format"]
|
@@ -771,7 +792,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
771
792
|
),
|
772
793
|
types.Tool(
|
773
794
|
name="remove_margin",
|
774
|
-
description="去除PDF
|
795
|
+
description="去除PDF文件的白边(裁剪去掉页面边距)。",
|
775
796
|
inputSchema={
|
776
797
|
"type": "object",
|
777
798
|
"properties": {
|
@@ -927,6 +948,12 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
|
|
927
948
|
if name == "protect_pdf" and "password" in arguments:
|
928
949
|
operation_config["extra_params"]["password"] = arguments.get("password")
|
929
950
|
|
951
|
+
# 处理convert_document工具的is_long_image参数
|
952
|
+
if name == "convert_document" and "is_long_image" in arguments:
|
953
|
+
if operation_config.get("extra_params") is None:
|
954
|
+
operation_config["extra_params"] = {}
|
955
|
+
operation_config["extra_params"]["is_long_image"] = arguments.get("is_long_image", False)
|
956
|
+
|
930
957
|
# 特殊处理merge_pdfs工具
|
931
958
|
if name == "merge_pdfs":
|
932
959
|
# 创建编辑器
|
@@ -1053,4 +1080,4 @@ def cli_main():
|
|
1053
1080
|
sys.exit(1)
|
1054
1081
|
|
1055
1082
|
if __name__ == "__main__":
|
1056
|
-
cli_main()
|
1083
|
+
cli_main()
|
@@ -0,0 +1,9 @@
|
|
1
|
+
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
|
+
lightpdf_aipdf_mcp/common.py,sha256=-7LU6gm-As_F8Ly68ssy15Vc9Zt_eNSnvDLEtVZDwlI,6633
|
3
|
+
lightpdf_aipdf_mcp/converter.py,sha256=d90pNUT8pQn93u1fJSlu4f2KyLDzhOdTrqyBkSTRFBE,14450
|
4
|
+
lightpdf_aipdf_mcp/editor.py,sha256=fGzIiAp48uTXBBKWWlHcGT0nwgZQBpjvrsxSf6Ockk4,24730
|
5
|
+
lightpdf_aipdf_mcp/server.py,sha256=0FcdFUQLdINscScE8_tDeA41hC1TqvJWoNcfLhxqTfo,44612
|
6
|
+
lightpdf_aipdf_mcp-0.1.59.dist-info/METADATA,sha256=syXcd6G9JRqGJAqWvKfVad6VnVI1dWfkxzJxZDQBB4U,7826
|
7
|
+
lightpdf_aipdf_mcp-0.1.59.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
+
lightpdf_aipdf_mcp-0.1.59.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
+
lightpdf_aipdf_mcp-0.1.59.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
|
-
lightpdf_aipdf_mcp/common.py,sha256=-7LU6gm-As_F8Ly68ssy15Vc9Zt_eNSnvDLEtVZDwlI,6633
|
3
|
-
lightpdf_aipdf_mcp/converter.py,sha256=d90pNUT8pQn93u1fJSlu4f2KyLDzhOdTrqyBkSTRFBE,14450
|
4
|
-
lightpdf_aipdf_mcp/editor.py,sha256=krnbUnILN3v5fbepsx88thoQkpmkYHXkhHTiIwC8-a0,24727
|
5
|
-
lightpdf_aipdf_mcp/server.py,sha256=57oQ2wBOF6ajJs67q41w3MNjrIiYaOf3Z_LJ17OC7Ag,43306
|
6
|
-
lightpdf_aipdf_mcp-0.1.57.dist-info/METADATA,sha256=cebBp7rWZ834MRE8Dz7SI9cHwyYLOEkCBAMdoPKgtR4,7826
|
7
|
-
lightpdf_aipdf_mcp-0.1.57.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
lightpdf_aipdf_mcp-0.1.57.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
-
lightpdf_aipdf_mcp-0.1.57.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.57.dist-info → lightpdf_aipdf_mcp-0.1.59.dist-info}/entry_points.txt
RENAMED
File without changes
|