lightpdf-aipdf-mcp 0.1.51__py3-none-any.whl → 0.1.53__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/editor.py +10 -10
- lightpdf_aipdf_mcp/server.py +49 -19
- {lightpdf_aipdf_mcp-0.1.51.dist-info → lightpdf_aipdf_mcp-0.1.53.dist-info}/METADATA +1 -1
- lightpdf_aipdf_mcp-0.1.53.dist-info/RECORD +9 -0
- lightpdf_aipdf_mcp-0.1.51.dist-info/RECORD +0 -9
- {lightpdf_aipdf_mcp-0.1.51.dist-info → lightpdf_aipdf_mcp-0.1.53.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.51.dist-info → lightpdf_aipdf_mcp-0.1.53.dist-info}/entry_points.txt +0 -0
lightpdf_aipdf_mcp/editor.py
CHANGED
@@ -163,13 +163,12 @@ class Editor(BaseApiClient):
|
|
163
163
|
original_name=original_name
|
164
164
|
)
|
165
165
|
|
166
|
-
async def rotate_pdf(self, file_path: str,
|
166
|
+
async def rotate_pdf(self, file_path: str, angle_params: Dict[str, str], password: Optional[str] = None, original_name: Optional[str] = None) -> EditResult:
|
167
167
|
"""旋转PDF文件的页面
|
168
168
|
|
169
169
|
Args:
|
170
170
|
file_path: 要旋转的PDF文件路径
|
171
|
-
|
172
|
-
pages: 指定要旋转的页面范围,例如 "1,3,5-7" 或 "" 表示所有页面
|
171
|
+
angle_params: 旋转角度和页面范围的映射,如 {"90": "1-3", "180": "4-6"}
|
173
172
|
password: 文档密码,如果文档受密码保护,则需要提供(可选)
|
174
173
|
original_name: 原始文件名(可选)
|
175
174
|
|
@@ -181,19 +180,20 @@ class Editor(BaseApiClient):
|
|
181
180
|
return EditResult(success=False, file_path=file_path, error_message="非PDF文件", original_name=original_name)
|
182
181
|
|
183
182
|
# 验证旋转角度
|
184
|
-
valid_angles = {90, 180, 270}
|
185
|
-
|
186
|
-
|
187
|
-
|
183
|
+
valid_angles = {"90", "180", "270"}
|
184
|
+
for angle in angle_params.keys():
|
185
|
+
if angle not in valid_angles:
|
186
|
+
await self.logger.error("无效的旋转角度。角度必须是: 90, 180, 270")
|
187
|
+
return EditResult(success=False, file_path=file_path, error_message="无效的旋转角度。角度必须是: 90, 180, 270", original_name=original_name)
|
188
188
|
|
189
189
|
# 构建API参数
|
190
190
|
extra_params = {
|
191
|
-
"angle": json.dumps(
|
191
|
+
"angle": json.dumps(angle_params)
|
192
192
|
}
|
193
193
|
|
194
194
|
# 记录操作描述
|
195
|
-
|
196
|
-
await self._log_operation("旋转PDF文件", f"参数: {
|
195
|
+
angle_details = ", ".join([f"{angle}°: {pages}" for angle, pages in angle_params.items()])
|
196
|
+
await self._log_operation("旋转PDF文件", f"参数: {angle_details}")
|
197
197
|
|
198
198
|
# 调用edit_pdf方法处理API请求
|
199
199
|
return await self.edit_pdf(file_path, EditType.ROTATE, extra_params, password, original_name)
|
lightpdf_aipdf_mcp/server.py
CHANGED
@@ -195,10 +195,29 @@ async def process_edit_file(
|
|
195
195
|
original_name=original_name
|
196
196
|
)
|
197
197
|
elif edit_type == "rotate":
|
198
|
+
# 从extra_params获取旋转参数列表
|
199
|
+
rotation_arguments = extra_params.get("arguments", [])
|
200
|
+
|
201
|
+
# 验证旋转参数列表
|
202
|
+
if not rotation_arguments:
|
203
|
+
return EditResult(
|
204
|
+
success=False,
|
205
|
+
file_path=file_path,
|
206
|
+
error_message="旋转操作需要至少提供一个旋转参数",
|
207
|
+
original_name=original_name
|
208
|
+
)
|
209
|
+
|
210
|
+
# 构建angle_params字典: {"90": "2-4,6-8", "180": "all"}
|
211
|
+
angle_params = {}
|
212
|
+
for arg in rotation_arguments:
|
213
|
+
angle = str(arg.get("angle", 90))
|
214
|
+
pages = arg.get("pages", "all") or "all" # 确保空字符串转为"all"
|
215
|
+
angle_params[angle] = pages
|
216
|
+
|
217
|
+
# 直接调用rotate_pdf方法,传入角度参数字典
|
198
218
|
return await editor.rotate_pdf(
|
199
|
-
file_path=file_path,
|
200
|
-
|
201
|
-
pages=extra_params.get("pages", ""),
|
219
|
+
file_path=file_path,
|
220
|
+
angle_params=angle_params,
|
202
221
|
password=password,
|
203
222
|
original_name=original_name
|
204
223
|
)
|
@@ -401,7 +420,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
401
420
|
),
|
402
421
|
types.Tool(
|
403
422
|
name="remove_watermark",
|
404
|
-
description="去除PDF
|
423
|
+
description="去除PDF文件中的水印。",
|
405
424
|
inputSchema={
|
406
425
|
"type": "object",
|
407
426
|
"properties": {
|
@@ -505,7 +524,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
505
524
|
),
|
506
525
|
types.Tool(
|
507
526
|
name="unlock_pdf",
|
508
|
-
description="移除PDF
|
527
|
+
description="移除PDF文件的密码保护。",
|
509
528
|
inputSchema={
|
510
529
|
"type": "object",
|
511
530
|
"properties": {
|
@@ -612,7 +631,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
612
631
|
),
|
613
632
|
types.Tool(
|
614
633
|
name="split_pdf",
|
615
|
-
description="拆分PDF
|
634
|
+
description="拆分PDF文件的每一页(或每个连续的页面范围)到一个文件(如果有多个文件,则返回zip包),或者提取指定的页面范围到一个PDF文件。",
|
616
635
|
inputSchema={
|
617
636
|
"type": "object",
|
618
637
|
"properties": {
|
@@ -660,7 +679,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
660
679
|
),
|
661
680
|
types.Tool(
|
662
681
|
name="merge_pdfs",
|
663
|
-
description="合并多个PDF文件。",
|
682
|
+
description="合并多个PDF文件到一个PDF文件。",
|
664
683
|
inputSchema={
|
665
684
|
"type": "object",
|
666
685
|
"properties": {
|
@@ -718,18 +737,29 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
718
737
|
},
|
719
738
|
"description": "需要旋转的PDF文件列表,每个文件包含路径和可选的密码"
|
720
739
|
},
|
721
|
-
"
|
722
|
-
"type": "
|
723
|
-
"
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
740
|
+
"arguments": {
|
741
|
+
"type": "array",
|
742
|
+
"items": {
|
743
|
+
"type": "object",
|
744
|
+
"properties": {
|
745
|
+
"angle": {
|
746
|
+
"type": "integer",
|
747
|
+
"description": "旋转角度,可选值为90、180、270",
|
748
|
+
"enum": [90, 180, 270],
|
749
|
+
"default": 90
|
750
|
+
},
|
751
|
+
"pages": {
|
752
|
+
"type": "string",
|
753
|
+
"description": "指定要旋转的页面范围,例如 '1,3,5-7' 或 'all' 表示所有页面",
|
754
|
+
"default": "all"
|
755
|
+
}
|
756
|
+
},
|
757
|
+
"required": ["angle", "pages"]
|
758
|
+
},
|
759
|
+
"description": "参数列表,每个参数包含旋转角度和页面范围"
|
730
760
|
}
|
731
761
|
},
|
732
|
-
"required": ["files", "
|
762
|
+
"required": ["files", "arguments"]
|
733
763
|
}
|
734
764
|
)
|
735
765
|
]
|
@@ -792,7 +822,7 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
|
|
792
822
|
"rotate_pdf": {
|
793
823
|
"edit_type": "rotate", # 编辑类型
|
794
824
|
"is_edit_operation": True, # 标记为编辑操作
|
795
|
-
"param_keys": ["
|
825
|
+
"param_keys": ["arguments"] # 只需要arguments参数,移除对旧格式的支持
|
796
826
|
}
|
797
827
|
}
|
798
828
|
|
@@ -808,7 +838,7 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
|
|
808
838
|
"split_type": "page",
|
809
839
|
"merge_all": 1,
|
810
840
|
"angle": 90,
|
811
|
-
"pages": ""
|
841
|
+
"pages": "all" # 更新默认值为"all"
|
812
842
|
}
|
813
843
|
|
814
844
|
if name in TOOL_CONFIG:
|
@@ -0,0 +1,9 @@
|
|
1
|
+
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
|
+
lightpdf_aipdf_mcp/common.py,sha256=-7LU6gm-As_F8Ly68ssy15Vc9Zt_eNSnvDLEtVZDwlI,6633
|
3
|
+
lightpdf_aipdf_mcp/converter.py,sha256=QBwKcCg83FrGGDCy3IFyXjldIZg2hzej_zCH8nyOPak,14768
|
4
|
+
lightpdf_aipdf_mcp/editor.py,sha256=RuHxTMlyvUp2keh0Plue2g4vwGe4Vzv5mauJuncyM8o,23551
|
5
|
+
lightpdf_aipdf_mcp/server.py,sha256=9EQ6sodIjKC8fZMpVQbKN1FRttebIQ9o9LCH0_IPtyo,41465
|
6
|
+
lightpdf_aipdf_mcp-0.1.53.dist-info/METADATA,sha256=tgBnVSIcOx5eLRV27B5gIlnqb3ysWuKaHJwepEGCy6o,7906
|
7
|
+
lightpdf_aipdf_mcp-0.1.53.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
+
lightpdf_aipdf_mcp-0.1.53.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
+
lightpdf_aipdf_mcp-0.1.53.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
|
-
lightpdf_aipdf_mcp/common.py,sha256=-7LU6gm-As_F8Ly68ssy15Vc9Zt_eNSnvDLEtVZDwlI,6633
|
3
|
-
lightpdf_aipdf_mcp/converter.py,sha256=QBwKcCg83FrGGDCy3IFyXjldIZg2hzej_zCH8nyOPak,14768
|
4
|
-
lightpdf_aipdf_mcp/editor.py,sha256=PVsgpgqc89MTf7-D2iRoescXJW90Kv51mP1oXGeneaY,23534
|
5
|
-
lightpdf_aipdf_mcp/server.py,sha256=F_He-Vnazoku1u45A3n652YTW2al3JehtPJO0aPfXIA,39982
|
6
|
-
lightpdf_aipdf_mcp-0.1.51.dist-info/METADATA,sha256=BcGSTsudsmnH9Og5JatE3D7LsbfhRHZRuKm8MD_EFHA,7906
|
7
|
-
lightpdf_aipdf_mcp-0.1.51.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
lightpdf_aipdf_mcp-0.1.51.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
-
lightpdf_aipdf_mcp-0.1.51.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.51.dist-info → lightpdf_aipdf_mcp-0.1.53.dist-info}/entry_points.txt
RENAMED
File without changes
|