lightpdf-aipdf-mcp 0.1.140__py3-none-any.whl → 0.1.141__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/converter.py +10 -2
- lightpdf_aipdf_mcp/server.py +47 -0
- {lightpdf_aipdf_mcp-0.1.140.dist-info → lightpdf_aipdf_mcp-0.1.141.dist-info}/METADATA +1 -1
- {lightpdf_aipdf_mcp-0.1.140.dist-info → lightpdf_aipdf_mcp-0.1.141.dist-info}/RECORD +6 -6
- {lightpdf_aipdf_mcp-0.1.140.dist-info → lightpdf_aipdf_mcp-0.1.141.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.140.dist-info → lightpdf_aipdf_mcp-0.1.141.dist-info}/entry_points.txt +0 -0
lightpdf_aipdf_mcp/converter.py
CHANGED
@@ -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
|
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()} 格式"
|
lightpdf_aipdf_mcp/server.py
CHANGED
@@ -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
|
|
@@ -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 or delete text in PDF files. When new_text is empty, the old_text will be deleted from the PDF.",
|
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,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=
|
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=
|
7
|
+
lightpdf_aipdf_mcp/server.py,sha256=gLzV_td5TVkt2bzTvJAFyDiEgJSiAWh4RtJJ-2G4m5c,77622
|
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.
|
11
|
-
lightpdf_aipdf_mcp-0.1.
|
12
|
-
lightpdf_aipdf_mcp-0.1.
|
13
|
-
lightpdf_aipdf_mcp-0.1.
|
10
|
+
lightpdf_aipdf_mcp-0.1.141.dist-info/METADATA,sha256=kYlwLqSPgIdI5O4-IE3y14MOdUlbGcHSUAJBXjpgxFE,8120
|
11
|
+
lightpdf_aipdf_mcp-0.1.141.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
12
|
+
lightpdf_aipdf_mcp-0.1.141.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
13
|
+
lightpdf_aipdf_mcp-0.1.141.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.140.dist-info → lightpdf_aipdf_mcp-0.1.141.dist-info}/entry_points.txt
RENAMED
File without changes
|