lightpdf-aipdf-mcp 0.1.140__py3-none-any.whl → 0.1.142__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.
@@ -173,8 +173,8 @@ class Converter(BaseApiClient):
173
173
  await self.logger.error("未找到API_KEY。请在客户端配置API_KEY环境变量。")
174
174
  return ConversionResult(success=False, file_path=file_path, error_message="未找到API_KEY", original_name=original_name)
175
175
 
176
- # 特殊格式:doc-repair用于去除水印,number-pdf用于添加页码,输出均为PDF
177
- is_special_operation = format in ["doc-repair", "number-pdf", "flatten-pdf", "resize-pdf"]
176
+ # 特殊格式:doc-repair用于去除水印,number-pdf用于添加页码,pdf-replace-text用于替换文本,输出均为PDF
177
+ is_special_operation = format in ["doc-repair", "number-pdf", "flatten-pdf", "resize-pdf", "pdf-replace-text"]
178
178
  actual_output_format = "pdf" if is_special_operation else format
179
179
 
180
180
  # 检查是否为URL或OSS路径,如果是则跳过文件格式检查
@@ -214,6 +214,12 @@ class Converter(BaseApiClient):
214
214
  await self.logger.error(error_msg)
215
215
  return ConversionResult(success=False, file_path=file_path, error_message=error_msg, original_name=original_name)
216
216
 
217
+ # 如果是替换文本操作,检查是否PDF文件
218
+ if format == "pdf-replace-text" and input_format != InputFormat.PDF:
219
+ error_msg = "替换文本功能仅支持PDF文件"
220
+ await self.logger.error(error_msg)
221
+ return ConversionResult(success=False, file_path=file_path, error_message=error_msg, original_name=original_name)
222
+
217
223
  # 验证输出格式(除去特殊操作外)
218
224
  if not is_special_operation:
219
225
  try:
@@ -252,6 +258,8 @@ class Converter(BaseApiClient):
252
258
  operation_desc = "展平PDF"
253
259
  elif format == "resize-pdf":
254
260
  operation_desc = "调整PDF大小"
261
+ elif format == "pdf-replace-text":
262
+ operation_desc = "替换文本"
255
263
  else:
256
264
  if is_remote_path:
257
265
  operation_desc = f"转换为 {output_format.value.upper()} 格式"
@@ -445,6 +445,8 @@ async def process_tool_call(
445
445
  operation_desc = "添加页码"
446
446
  elif format == "flatten-pdf":
447
447
  operation_desc = "展平PDF"
448
+ elif format == "pdf-replace-text":
449
+ operation_desc = "替换文本"
448
450
  else:
449
451
  operation_desc = f"转换为 {format} 格式"
450
452
 
@@ -581,7 +583,7 @@ async def handle_list_tools() -> list[types.Tool]:
581
583
  ),
582
584
  types.Tool(
583
585
  name="remove_watermark",
584
- description="Remove watermarks from PDF files.",
586
+ description="Remove watermarks from PDF files. Watermarks are usually overlaid text or images added for copyright protection or branding purposes. This tool specifically targets watermark removal and is not intended for deleting regular document text content. For deleting normal document text, use the replace_text tool instead.",
585
587
  inputSchema={
586
588
  "type": "object",
587
589
  "properties": {
@@ -1160,6 +1162,46 @@ async def handle_list_tools() -> list[types.Tool]:
1160
1162
  "required": ["files"]
1161
1163
  }
1162
1164
  ),
1165
+ types.Tool(
1166
+ name="replace_text",
1167
+ description="Replace, edit, or delete regular text content in PDF files. Use this tool to modify or remove normal document text. When new_text is empty, the old_text will be completely deleted from the PDF. Note: This tool is for regular document text only, not for removing watermarks. For watermark removal, use the remove_watermark tool instead.",
1168
+ inputSchema={
1169
+ "type": "object",
1170
+ "properties": {
1171
+ "files": {
1172
+ "type": "array",
1173
+ "items": {
1174
+ "type": "object",
1175
+ "properties": {
1176
+ "path": {
1177
+ "type": "string",
1178
+ "description": "PDF file URL to replace text in, must include protocol, supports http/https/oss"
1179
+ },
1180
+ "password": {
1181
+ "type": "string",
1182
+ "description": "PDF document password, required if the document is password-protected"
1183
+ },
1184
+ "name": {
1185
+ "type": "string",
1186
+ "description": "Original filename of the document"
1187
+ }
1188
+ },
1189
+ "required": ["path"]
1190
+ },
1191
+ "description": "List of PDF files to replace text in, each containing path and optional password"
1192
+ },
1193
+ "old_text": {
1194
+ "type": "string",
1195
+ "description": "The text to be replaced or deleted"
1196
+ },
1197
+ "new_text": {
1198
+ "type": "string",
1199
+ "description": "The replacement text. If empty, the old_text will be deleted"
1200
+ }
1201
+ },
1202
+ "required": ["files", "old_text", "new_text"]
1203
+ }
1204
+ ),
1163
1205
  types.Tool(
1164
1206
  name="create_pdf",
1165
1207
  description="Create a PDF file from LaTeX source code string only. File upload is NOT supported. If you want to convert a TEX file to PDF, please use the convert_document tool instead. This tool only accepts pure LaTeX code as input.",
@@ -1345,6 +1387,11 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
1345
1387
  "is_edit_operation": False,
1346
1388
  "param_keys": ["page_size", "resolution"]
1347
1389
  },
1390
+ "replace_text": {
1391
+ "format": "pdf-replace-text",
1392
+ "is_edit_operation": False,
1393
+ "param_keys": ["old_text", "new_text"]
1394
+ },
1348
1395
  "unlock_pdf": {
1349
1396
  "edit_type": "decrypt", # 编辑类型
1350
1397
  "is_edit_operation": True, # 标记为编辑操作
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lightpdf-aipdf-mcp
3
- Version: 0.1.140
3
+ Version: 0.1.142
4
4
  Summary: MCP Server for LightPDF AI-PDF
5
5
  Author: LightPDF Team
6
6
  License: Proprietary
@@ -1,13 +1,13 @@
1
1
  lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
2
2
  lightpdf_aipdf_mcp/common.py,sha256=T4WKhtoWvDEosoU36ryZ-7IS62iNm_TL8H_jo6nFf7c,9214
3
- lightpdf_aipdf_mcp/converter.py,sha256=6e-p5zh6d5ijXtTgXuBtePp4xEQVMYt6F4j29cj4Kr4,14796
3
+ lightpdf_aipdf_mcp/converter.py,sha256=r8iO5R5vLNNKWdb6WSnwzTwwmp2TvgLXSIvvA4y___o,15336
4
4
  lightpdf_aipdf_mcp/create_pdf.py,sha256=oALIhOBo60D3Gu_li7d7FF0COhFfSTM-BJpc63r9iAs,2465
5
5
  lightpdf_aipdf_mcp/editor.py,sha256=BR-sWW9L7tybEPOhdc8W-uwdBoom19EPTmGDvy_2gMc,27941
6
6
  lightpdf_aipdf_mcp/ocr.py,sha256=IyzxisA6qtXcGTHZofpUYXYDdcIjUaaHcVUKpM7DH9A,2832
7
- lightpdf_aipdf_mcp/server.py,sha256=gCo4ZcoHG6YfFbq1xLezjf_xEkX_Bj3JgBmCPZvHQlQ,75412
7
+ lightpdf_aipdf_mcp/server.py,sha256=a8UTsGZtU2nfpexw21ZcH2PyXobPtypgyZWz0t6vRkQ,78137
8
8
  lightpdf_aipdf_mcp/summarizer.py,sha256=2QMMgo_xxlEDSd_STPh7-1lBc4VRsL4SPSTijJPyb3I,5456
9
9
  lightpdf_aipdf_mcp/translator.py,sha256=nuZa4FpsA0xeRWAEGqSPIM55aJuazJX1m32uajowo7I,2778
10
- lightpdf_aipdf_mcp-0.1.140.dist-info/METADATA,sha256=T4a6FUHQrUQpDcmApOUGnlkrlKy-7nly2sQd3jrgy0g,8120
11
- lightpdf_aipdf_mcp-0.1.140.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
- lightpdf_aipdf_mcp-0.1.140.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
13
- lightpdf_aipdf_mcp-0.1.140.dist-info/RECORD,,
10
+ lightpdf_aipdf_mcp-0.1.142.dist-info/METADATA,sha256=U1It2JPOVoFuuiQA9FPpE2oirZP9XeqN8p7UVPQx5Es,8120
11
+ lightpdf_aipdf_mcp-0.1.142.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ lightpdf_aipdf_mcp-0.1.142.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
13
+ lightpdf_aipdf_mcp-0.1.142.dist-info/RECORD,,