lightpdf-aipdf-mcp 0.1.82__py3-none-any.whl → 0.1.83__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.
@@ -139,15 +139,8 @@ async def process_conversion_file(
139
139
  # 处理extra_params
140
140
  if extra_params is None:
141
141
  extra_params = {}
142
-
143
- # 处理is_long_image参数,如果需要转换为长图,则添加merge_all=1参数
144
- if extra_params.get("is_long_image") and format in ["jpg", "jpeg", "png"]:
145
- extra_params["merge_all"] = 1
146
- # 从extra_params中移除is_long_image,因为API不需要这个参数
147
- if "is_long_image" in extra_params:
148
- del extra_params["is_long_image"]
149
-
150
- # 对于其他操作,使用convert_file方法
142
+ # 直接传递 merge_all 参数(如有)
143
+ # 其它逻辑交由 converter.convert_file 处理
151
144
  return await converter.convert_file(file_path, format, extra_params, password, original_name)
152
145
 
153
146
  async def process_edit_file(
@@ -312,16 +305,17 @@ async def process_tool_call(
312
305
  converter = Converter(logger, file_handler)
313
306
  format = operation_config.get("format", "")
314
307
  extra_params = operation_config.get("extra_params")
315
- is_watermark_removal = operation_config.get("is_watermark_removal", False)
316
- is_page_numbering = operation_config.get("is_page_numbering", False)
317
308
 
318
309
  # 获取操作描述
319
- if is_watermark_removal:
310
+ if format == "doc-repair":
320
311
  operation_desc = "去除水印"
321
312
  task_type = "水印去除"
322
- elif is_page_numbering:
313
+ elif format == "number-pdf":
323
314
  operation_desc = "添加页码"
324
315
  task_type = "添加页码"
316
+ elif format == "flatten-pdf":
317
+ operation_desc = "展平PDF"
318
+ task_type = "展平PDF"
325
319
  else:
326
320
  operation_desc = f"转换为 {format} 格式"
327
321
  task_type = "转换"
@@ -390,10 +384,11 @@ async def handle_list_tools() -> list[types.Tool]:
390
384
  "description": "Target format",
391
385
  "enum": ["pdf", "docx", "xlsx", "pptx", "jpg", "jpeg", "png", "html", "txt", "csv"]
392
386
  },
393
- "is_long_image": {
394
- "type": "boolean",
395
- "description": "Whether to convert to a long image. Only valid when format is jpg/jpeg/png",
396
- "default": False
387
+ "merge_all": {
388
+ "type": "integer",
389
+ "enum": [0, 1],
390
+ "default": 0,
391
+ "description": "Whether to merge results: 1 = merge all, 0 = separate. Only valid for: PDF to Excel (1: all pages to one sheet, 0: each page to a sheet), PDF to Image (1: merge to long image, 0: each page to an image), Image to PDF (1: all images to one PDF, 0: each image to a PDF)"
397
392
  }
398
393
  },
399
394
  "required": ["files", "format"]
@@ -862,6 +857,38 @@ async def handle_list_tools() -> list[types.Tool]:
862
857
  },
863
858
  "required": ["files"]
864
859
  }
860
+ ),
861
+ types.Tool(
862
+ name="flatten_pdf",
863
+ description="Flatten PDF files (convert editable elements such as text, form fields, annotations, and layers into non-editable static content or fixed content)",
864
+ inputSchema={
865
+ "type": "object",
866
+ "properties": {
867
+ "files": {
868
+ "type": "array",
869
+ "items": {
870
+ "type": "object",
871
+ "properties": {
872
+ "path": {
873
+ "type": "string",
874
+ "description": "PDF file URL to flatten, must include protocol, supports http/https/oss"
875
+ },
876
+ "password": {
877
+ "type": "string",
878
+ "description": "PDF document password, required if the document is password-protected"
879
+ },
880
+ "name": {
881
+ "type": "string",
882
+ "description": "Original filename of the document"
883
+ }
884
+ },
885
+ "required": ["path"]
886
+ },
887
+ "description": "List of PDF files to flatten, each containing path and optional password"
888
+ }
889
+ },
890
+ "required": ["files"]
891
+ }
865
892
  )
866
893
  ]
867
894
 
@@ -874,23 +901,21 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
874
901
  TOOL_CONFIG = {
875
902
  "convert_document": {
876
903
  "format_key": "format", # 从arguments获取format
877
- "is_watermark_removal": False,
878
- "is_page_numbering": False,
879
904
  "is_edit_operation": False,
880
905
  },
881
906
  "remove_watermark": {
882
907
  "format": "doc-repair", # 固定format
883
- "is_watermark_removal": True,
884
- "is_page_numbering": False,
885
908
  "is_edit_operation": False,
886
909
  },
887
910
  "add_page_numbers": {
888
911
  "format": "number-pdf", # 固定format
889
- "is_watermark_removal": False,
890
- "is_page_numbering": True,
891
912
  "is_edit_operation": False,
892
913
  "param_keys": ["start_num", "position", "margin"] # 需要从arguments获取的参数
893
914
  },
915
+ "flatten_pdf": {
916
+ "format": "flatten-pdf", # 固定format
917
+ "is_edit_operation": False
918
+ },
894
919
  "unlock_pdf": {
895
920
  "edit_type": "decrypt", # 编辑类型
896
921
  "is_edit_operation": True, # 标记为编辑操作
@@ -995,12 +1020,6 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
995
1020
  if name == "protect_pdf" and "password" in arguments:
996
1021
  operation_config["extra_params"]["password"] = arguments.get("password")
997
1022
 
998
- # 处理convert_document工具的is_long_image参数
999
- if name == "convert_document" and "is_long_image" in arguments:
1000
- if operation_config.get("extra_params") is None:
1001
- operation_config["extra_params"] = {}
1002
- operation_config["extra_params"]["is_long_image"] = arguments.get("is_long_image", False)
1003
-
1004
1023
  # 特殊处理merge_pdfs工具
1005
1024
  if name == "merge_pdfs":
1006
1025
  # 创建编辑器
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lightpdf-aipdf-mcp
3
- Version: 0.1.82
3
+ Version: 0.1.83
4
4
  Summary: MCP Server for LightPDF AI-PDF
5
5
  Author: LightPDF Team
6
6
  License: Proprietary
@@ -2,8 +2,8 @@ lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6
2
2
  lightpdf_aipdf_mcp/common.py,sha256=_UO1f6S9Qr_3k6u5iBpdVDpvTK5U-tHEpu9KsDGqV8Y,6635
3
3
  lightpdf_aipdf_mcp/converter.py,sha256=f9YuDtOmXBGlMmS3O4Xn3rdWljY9XcNxu0CjftH4s0o,14726
4
4
  lightpdf_aipdf_mcp/editor.py,sha256=O7wF_HWs5l-IiXLbZYLNYjj1ygo2v4yGJEYMJtn7jpo,26916
5
- lightpdf_aipdf_mcp/server.py,sha256=_G85-okjOSfvzBkj_7vehs6caJNeMB1-ACGn5ji6aOI,47557
6
- lightpdf_aipdf_mcp-0.1.82.dist-info/METADATA,sha256=vkLJNOf6YwBJtswwg4t7eLqE5r1fOogBWK-gyG07Lis,8119
7
- lightpdf_aipdf_mcp-0.1.82.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- lightpdf_aipdf_mcp-0.1.82.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
9
- lightpdf_aipdf_mcp-0.1.82.dist-info/RECORD,,
5
+ lightpdf_aipdf_mcp/server.py,sha256=cWekqqhTfJNCyNA6UPgM-XSVhQl2QNireEhUH5uBBgQ,48454
6
+ lightpdf_aipdf_mcp-0.1.83.dist-info/METADATA,sha256=UsoTcuqr1U4RfR1A-d5yJ62b1EQlSlqXRKDi8jkVQAo,8119
7
+ lightpdf_aipdf_mcp-0.1.83.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ lightpdf_aipdf_mcp-0.1.83.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
9
+ lightpdf_aipdf_mcp-0.1.83.dist-info/RECORD,,