lightpdf-aipdf-mcp 0.1.88__py3-none-any.whl → 0.1.90__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.
@@ -171,7 +171,7 @@ class Converter(BaseApiClient):
171
171
  return ConversionResult(success=False, file_path=file_path, error_message="未找到API_KEY", original_name=original_name)
172
172
 
173
173
  # 特殊格式:doc-repair用于去除水印,number-pdf用于添加页码,输出均为PDF
174
- is_special_operation = format in ["doc-repair", "number-pdf"]
174
+ is_special_operation = format in ["doc-repair", "number-pdf", "flatten-pdf", "resize-pdf"]
175
175
  actual_output_format = "pdf" if is_special_operation else format
176
176
 
177
177
  # 检查是否为URL或OSS路径,如果是则跳过文件格式检查
@@ -198,6 +198,18 @@ class Converter(BaseApiClient):
198
198
  error_msg = "添加页码功能仅支持PDF文件"
199
199
  await self.logger.error(error_msg)
200
200
  return ConversionResult(success=False, file_path=file_path, error_message=error_msg, original_name=original_name)
201
+
202
+ # 如果是展平PDF操作,检查是否PDF文件
203
+ if format == "flatten-pdf" and input_format != InputFormat.PDF:
204
+ error_msg = "展平PDF功能仅支持PDF文件"
205
+ await self.logger.error(error_msg)
206
+ return ConversionResult(success=False, file_path=file_path, error_message=error_msg, original_name=original_name)
207
+
208
+ # 如果是调整PDF大小操作,检查是否PDF文件
209
+ if format == "resize-pdf" and input_format != InputFormat.PDF:
210
+ error_msg = "调整PDF大小功能仅支持PDF文件"
211
+ await self.logger.error(error_msg)
212
+ return ConversionResult(success=False, file_path=file_path, error_message=error_msg, original_name=original_name)
201
213
 
202
214
  # 验证输出格式(除去特殊操作外)
203
215
  if not is_special_operation:
@@ -233,6 +245,10 @@ class Converter(BaseApiClient):
233
245
  operation_desc = "去除水印"
234
246
  elif format == "number-pdf":
235
247
  operation_desc = "添加页码"
248
+ elif format == "flatten-pdf":
249
+ operation_desc = "展平PDF"
250
+ elif format == "resize-pdf":
251
+ operation_desc = "调整PDF大小"
236
252
  else:
237
253
  if is_remote_path:
238
254
  operation_desc = f"转换为 {output_format.value.upper()} 格式"
@@ -1096,6 +1096,46 @@ async def handle_list_tools() -> list[types.Tool]:
1096
1096
  "required": ["files", "target"]
1097
1097
  }
1098
1098
  ),
1099
+ types.Tool(
1100
+ name="resize-pdf",
1101
+ description="Resize PDF pages. You can specify the target page size (a0/a1/a2/a3/a4/a5/a6/letter) and/or the image resolution (dpi, e.g., 72). If not set, the corresponding property will not be changed.",
1102
+ inputSchema={
1103
+ "type": "object",
1104
+ "properties": {
1105
+ "files": {
1106
+ "type": "array",
1107
+ "items": {
1108
+ "type": "object",
1109
+ "properties": {
1110
+ "path": {
1111
+ "type": "string",
1112
+ "description": "PDF file URL to resize, must include protocol, supports http/https/oss"
1113
+ },
1114
+ "password": {
1115
+ "type": "string",
1116
+ "description": "PDF document password, required if the document is password-protected"
1117
+ },
1118
+ "name": {
1119
+ "type": "string",
1120
+ "description": "Original filename of the document"
1121
+ }
1122
+ },
1123
+ "required": ["path"]
1124
+ },
1125
+ "description": "List of PDF files to resize, each containing path and optional password"
1126
+ },
1127
+ "page_size": {
1128
+ "type": "string",
1129
+ "description": "Target page size. Any valid page size name is supported (e.g., a4, letter, legal, etc.), or use width,height in points (pt, e.g., 595,842). If not set, page size will not be changed."
1130
+ },
1131
+ "resolution": {
1132
+ "type": "integer",
1133
+ "description": "Image resolution (dpi), e.g., 72. If not set, resolution will not be changed."
1134
+ }
1135
+ },
1136
+ "required": ["files"]
1137
+ }
1138
+ ),
1099
1139
  ]
1100
1140
 
1101
1141
  @app.call_tool()
@@ -1122,6 +1162,11 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
1122
1162
  "format": "flatten-pdf", # 固定format
1123
1163
  "is_edit_operation": False
1124
1164
  },
1165
+ "resize-pdf": {
1166
+ "format": "resize-pdf",
1167
+ "is_edit_operation": False,
1168
+ "param_keys": ["page_size", "resolution"]
1169
+ },
1125
1170
  "unlock_pdf": {
1126
1171
  "edit_type": "decrypt", # 编辑类型
1127
1172
  "is_edit_operation": True, # 标记为编辑操作
@@ -1194,7 +1239,9 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
1194
1239
  "merge_all": 1,
1195
1240
  "angle": 90,
1196
1241
  "pages": "all", # 更新默认值为"all"
1197
- "format": "png" # 提取图片的默认格式
1242
+ "format": "png", # 提取图片的默认格式
1243
+ "page_size": "",
1244
+ "resolution": 0,
1198
1245
  }
1199
1246
 
1200
1247
  if name in TOOL_CONFIG:
@@ -75,6 +75,13 @@ class Translator(BaseApiClient):
75
75
  headers=headers
76
76
  )
77
77
  elif self.file_handler.is_url(file_path):
78
+ # arxiv.org/pdf/特殊处理
79
+ if isinstance(file_path, str) and "arxiv.org/pdf/" in file_path:
80
+ from urllib.parse import urlparse, urlunparse
81
+ url_obj = urlparse(file_path)
82
+ if not url_obj.path.endswith(".pdf"):
83
+ new_path = url_obj.path + ".pdf"
84
+ file_path = urlunparse(url_obj._replace(path=new_path))
78
85
  data["url"] = file_path
79
86
  headers["Content-Type"] = "application/json"
80
87
  response = await client.post(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lightpdf-aipdf-mcp
3
- Version: 0.1.88
3
+ Version: 0.1.90
4
4
  Summary: MCP Server for LightPDF AI-PDF
5
5
  Author: LightPDF Team
6
6
  License: Proprietary
@@ -0,0 +1,10 @@
1
+ lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
2
+ lightpdf_aipdf_mcp/common.py,sha256=_UO1f6S9Qr_3k6u5iBpdVDpvTK5U-tHEpu9KsDGqV8Y,6635
3
+ lightpdf_aipdf_mcp/converter.py,sha256=Q_4vXcysqcJ7w6bUKY9JhoBDlCRcAJSpW7p0jh5qekU,16120
4
+ lightpdf_aipdf_mcp/editor.py,sha256=9teOqi2y2JbjcCI-kUhYpSXL-F75i7Mfr9E20KKyZP0,29909
5
+ lightpdf_aipdf_mcp/server.py,sha256=uLb_gOB1uP6eN53BDMp2qLXQk_9GjKJjYJDSjb75iyo,62324
6
+ lightpdf_aipdf_mcp/translator.py,sha256=NbFDz-mZSD4qCNQVyV0W_0x6xXwbqs_7FiBU13JAxZs,4243
7
+ lightpdf_aipdf_mcp-0.1.90.dist-info/METADATA,sha256=jHqG5XdMATbeDUTBlhhRygdzAU45er5yBrZNBbw0yVc,8119
8
+ lightpdf_aipdf_mcp-0.1.90.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ lightpdf_aipdf_mcp-0.1.90.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
10
+ lightpdf_aipdf_mcp-0.1.90.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
2
- lightpdf_aipdf_mcp/common.py,sha256=_UO1f6S9Qr_3k6u5iBpdVDpvTK5U-tHEpu9KsDGqV8Y,6635
3
- lightpdf_aipdf_mcp/converter.py,sha256=f0gS8tAQlJ8uwJUVUmd9nAA4O9m558e9lAT2B_MxmIo,15135
4
- lightpdf_aipdf_mcp/editor.py,sha256=9teOqi2y2JbjcCI-kUhYpSXL-F75i7Mfr9E20KKyZP0,29909
5
- lightpdf_aipdf_mcp/server.py,sha256=khv6gJNWx8nhH6gpOu4jdeeL8p7xMPONEv7mAf8oWXQ,59952
6
- lightpdf_aipdf_mcp/translator.py,sha256=FACnFcnz1zNDdndR3tAgTfDDkfk1rJRRgWorFbiiEUk,3834
7
- lightpdf_aipdf_mcp-0.1.88.dist-info/METADATA,sha256=AOlJAa2HvSrrcN2I264tvQ5FR3-Gl4Nz7jqo1Ai4Wjs,8119
8
- lightpdf_aipdf_mcp-0.1.88.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- lightpdf_aipdf_mcp-0.1.88.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
10
- lightpdf_aipdf_mcp-0.1.88.dist-info/RECORD,,