lightpdf-aipdf-mcp 0.1.129__py3-none-any.whl → 0.1.131__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.
@@ -279,10 +279,11 @@ async def process_tool_call(
279
279
  """
280
280
  file_handler = FileHandler(logger)
281
281
  editor = Editor(logger, file_handler)
282
+ extra_params = operation_config.get("extra_params", {})
283
+
282
284
  # 新增:翻译操作分支
283
285
  if operation_config.get("is_translate_operation"):
284
286
  translator = Translator(logger, file_handler)
285
- extra_params = operation_config.get("extra_params", {})
286
287
 
287
288
  results = await process_batch_files(
288
289
  file_objects,
@@ -304,8 +305,7 @@ async def process_tool_call(
304
305
  elif operation_config.get("is_edit_operation"):
305
306
  # 编辑操作
306
307
  edit_type = operation_config.get("edit_type", "")
307
- extra_params = operation_config.get("extra_params")
308
-
308
+
309
309
  # 获取操作描述
310
310
  edit_map = {
311
311
  "decrypt": "解密",
@@ -319,7 +319,7 @@ async def process_tool_call(
319
319
  "remove_margin": "去除白边"
320
320
  }
321
321
  operation_desc = f"PDF{edit_map.get(edit_type, edit_type)}"
322
-
322
+
323
323
  # 处理文件
324
324
  results = await process_batch_files(
325
325
  file_objects,
@@ -329,55 +329,60 @@ async def process_tool_call(
329
329
  ),
330
330
  operation_desc
331
331
  )
332
-
332
+
333
333
  # 生成报告
334
- report_msg = generate_result_report(
335
- results
336
- )
334
+ report_msg = generate_result_report(results)
335
+
337
336
  else:
338
337
  # 转换操作
339
338
  converter = Converter(logger, file_handler)
340
339
  format = operation_config.get("format", "")
341
- extra_params = operation_config.get("extra_params")
342
340
 
343
- # 新增:特殊处理PDF转Markdown和TXT转PDF
344
- if format == "md":
345
- # PDF转Markdown,调用Editor.edit_pdf,传递oss://pdf2md
341
+ # 新增:特殊处理PDF转Markdown和TEX(LaTeX)
342
+ if format in ("md", "tex"):
343
+ oss_map = {
344
+ "md": ("oss://pdf2md", "PDF转Markdown"),
345
+ "tex": ("oss://pdf2tex", "PDF转LaTeX")
346
+ }
347
+ oss_url, operation_desc = oss_map[format]
348
+
346
349
  results = await process_batch_files(
347
350
  file_objects,
348
351
  logger,
349
352
  lambda file_path, password, original_name: editor.edit_pdf(
350
353
  file_path,
351
354
  edit_type=EditType.EDIT,
352
- extra_params={"pages": [{"url": "oss://pdf2md", "oss_file": ""}]},
355
+ extra_params={"pages": [{"url": oss_url, "oss_file": ""}]},
353
356
  password=password,
354
357
  original_name=original_name
355
358
  ),
356
- "PDF转Markdown"
359
+ operation_desc
357
360
  )
358
361
 
359
362
  report_msg = generate_result_report(results)
363
+
360
364
  elif format == "pdf":
361
365
  # 只调用一次process_batch_files,在lambda里分流
362
366
  async def pdf_convert_dispatcher(file_path, password, original_name):
363
367
  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": ""}]}
368
+ ext_map = {
369
+ ".txt": ("oss://txt2pdf", "TXT转PDF"),
370
+ ".tex": ("oss://tex2pdf", "LaTeX转PDF")
371
+ }
372
+ if ext in ext_map:
373
+ oss_url, operation_desc = ext_map[ext]
369
374
  return await editor.edit_pdf(
370
375
  file_path,
371
376
  edit_type=EditType.EDIT,
372
- extra_params=extra_params,
377
+ extra_params={"pages": [{"url": oss_url, "oss_file": ""}]},
373
378
  password=password,
374
379
  original_name=original_name
375
380
  )
376
381
  else:
377
- extra_params = operation_config.get("extra_params")
378
382
  return await process_conversion_file(
379
383
  file_path, format, converter, extra_params, password, original_name
380
384
  )
385
+
381
386
  results = await process_batch_files(
382
387
  file_objects,
383
388
  logger,
@@ -386,6 +391,7 @@ async def process_tool_call(
386
391
  )
387
392
 
388
393
  report_msg = generate_result_report(results)
394
+
389
395
  else:
390
396
  # 获取操作描述
391
397
  if format == "doc-repair":
@@ -396,7 +402,7 @@ async def process_tool_call(
396
402
  operation_desc = "展平PDF"
397
403
  else:
398
404
  operation_desc = f"转换为 {format} 格式"
399
-
405
+
400
406
  # 处理文件
401
407
  results = await process_batch_files(
402
408
  file_objects,
@@ -406,14 +412,14 @@ async def process_tool_call(
406
412
  ),
407
413
  operation_desc
408
414
  )
409
-
415
+
410
416
  # 生成报告
411
417
  report_msg = generate_result_report(results)
412
-
418
+
413
419
  # 如果全部失败,记录错误
414
420
  if not any(r.success for r in results):
415
421
  await logger.error(report_msg)
416
-
422
+
417
423
  return types.TextContent(type="text", text=report_msg)
418
424
 
419
425
  # 创建Server实例
@@ -428,7 +434,7 @@ async def handle_list_tools() -> list[types.Tool]:
428
434
  return [
429
435
  types.Tool(
430
436
  name="convert_document",
431
- description="Document format conversion tool.\n\nPDF can be converted to: DOCX, XLSX, PPTX, images (including long images), HTML, TXT (text extraction), CSV, or Markdown (md).\nOther formats (DOCX, XLSX, PPTX, images, CAD, CAJ, OFD, HTML, TEX (LaTeX), TXT) can be converted to PDF. For HTML to PDF, both local HTML files and any web page URL are supported.\n\nPDF to PDF conversion is not supported.\nOnly entire files can be converted.\nContent-based file creation is not supported.",
437
+ description="Document format conversion tool.\n\nPDF can be converted to: DOCX, XLSX, PPTX, images (including long images), HTML, TXT (text extraction), CSV, MD (Markdown), or TEX (LaTeX).\nOther formats (DOCX, XLSX, PPTX, images, CAD, CAJ, OFD, HTML, TEX (LaTeX), TXT) can be converted to PDF. For HTML to PDF, both local HTML files and any web page URL are supported.\n\nPDF to PDF conversion is not supported.\nOnly entire files can be converted.\nContent-based file creation is not supported.",
432
438
  inputSchema={
433
439
  "type": "object",
434
440
  "properties": {
@@ -456,8 +462,8 @@ async def handle_list_tools() -> list[types.Tool]:
456
462
  },
457
463
  "format": {
458
464
  "type": "string",
459
- "description": "Target format. PDF can be converted to: DOCX, XLSX, PPTX, images (including long images), HTML, TXT (text extraction), CSV, or Markdown (md). Other formats (DOCX, XLSX, PPTX, images, CAD, CAJ, OFD, HTML, TEX (LaTeX), TXT) can be converted to PDF. For HTML to PDF, both local HTML files and any web page URL are supported. PDF to PDF conversion is not supported.",
460
- "enum": ["pdf", "docx", "xlsx", "pptx", "jpg", "jpeg", "png", "html", "txt", "csv", "md"]
465
+ "description": "Target format. PDF can be converted to: DOCX, XLSX, PPTX, images (including long images), HTML, TXT (text extraction), CSV, MD (Markdown), or TEX (LaTeX). Other formats (DOCX, XLSX, PPTX, images, CAD, CAJ, OFD, HTML, TEX (LaTeX), TXT) can be converted to PDF. For HTML to PDF, both local HTML files and any web page URL are supported. PDF to PDF conversion is not supported.",
466
+ "enum": ["pdf", "docx", "xlsx", "pptx", "jpg", "jpeg", "png", "html", "txt", "csv", "md", "tex"]
461
467
  },
462
468
  "merge_all": {
463
469
  "type": "integer",
@@ -848,7 +854,7 @@ async def handle_list_tools() -> list[types.Tool]:
848
854
  ),
849
855
  types.Tool(
850
856
  name="merge_pdfs",
851
- description="Merge multiple PDF files into a single PDF file.",
857
+ description="Merge multiple PDF files into a single PDF file. You must provide at least two files in the 'files' array, otherwise the operation will fail.",
852
858
  inputSchema={
853
859
  "type": "object",
854
860
  "properties": {
@@ -872,7 +878,7 @@ async def handle_list_tools() -> list[types.Tool]:
872
878
  },
873
879
  "required": ["path"]
874
880
  },
875
- "description": "List of PDF files to merge, each containing path and optional password"
881
+ "description": "List of PDF files to merge (must be at least two), each containing path and optional password"
876
882
  }
877
883
  },
878
884
  "required": ["files"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lightpdf-aipdf-mcp
3
- Version: 0.1.129
3
+ Version: 0.1.131
4
4
  Summary: MCP Server for LightPDF AI-PDF
5
5
  Author: LightPDF Team
6
6
  License: Proprietary
@@ -3,9 +3,9 @@ lightpdf_aipdf_mcp/common.py,sha256=PhTf7Zg6mEgn1rTmJDHotXp-4xb2gWFf-Dy_t25qNdY,
3
3
  lightpdf_aipdf_mcp/converter.py,sha256=_tXzNZZEaobPRjxXy3v__qHUzbDHIZRTIanmmpCrQB0,17058
4
4
  lightpdf_aipdf_mcp/create_pdf.py,sha256=oALIhOBo60D3Gu_li7d7FF0COhFfSTM-BJpc63r9iAs,2465
5
5
  lightpdf_aipdf_mcp/editor.py,sha256=cYJ6NlS9q_HJwL-Aw7mVwCT5CECMLWYlmR_ePhw_Ja4,30081
6
- lightpdf_aipdf_mcp/server.py,sha256=hiqN2U1CUUQxiCoLHdDY7jlPqPil-7zyzK15CpxXzQc,66352
6
+ lightpdf_aipdf_mcp/server.py,sha256=rg6u8REp_2Xiy74hK6ZaeGB6JZNfiZQ7MHyrIqhh1co,66370
7
7
  lightpdf_aipdf_mcp/translator.py,sha256=NbFDz-mZSD4qCNQVyV0W_0x6xXwbqs_7FiBU13JAxZs,4243
8
- lightpdf_aipdf_mcp-0.1.129.dist-info/METADATA,sha256=tW9zD8T8CAIfC8CoiqShZutS3UBNIL9NvJA0bcKz8Z0,8120
9
- lightpdf_aipdf_mcp-0.1.129.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- lightpdf_aipdf_mcp-0.1.129.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
11
- lightpdf_aipdf_mcp-0.1.129.dist-info/RECORD,,
8
+ lightpdf_aipdf_mcp-0.1.131.dist-info/METADATA,sha256=9l1stJ1dwbOrFer-goU84UdcBV_Tk8uwxQVns_YwbHo,8120
9
+ lightpdf_aipdf_mcp-0.1.131.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ lightpdf_aipdf_mcp-0.1.131.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
11
+ lightpdf_aipdf_mcp-0.1.131.dist-info/RECORD,,