lightpdf-aipdf-mcp 0.1.52__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 +45 -15
- {lightpdf_aipdf_mcp-0.1.52.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.52.dist-info/RECORD +0 -9
- {lightpdf_aipdf_mcp-0.1.52.dist-info → lightpdf_aipdf_mcp-0.1.53.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.52.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
|
)
|
@@ -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=25UY58YF3vIypWjUx3GdEP0PHxA2hvZMiblT_A4ispg,40063
|
6
|
-
lightpdf_aipdf_mcp-0.1.52.dist-info/METADATA,sha256=tdV-B3SqBY78N7czBjSTRi0sJQkNiXwF6a0unYDUrnI,7906
|
7
|
-
lightpdf_aipdf_mcp-0.1.52.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
lightpdf_aipdf_mcp-0.1.52.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
-
lightpdf_aipdf_mcp-0.1.52.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.52.dist-info → lightpdf_aipdf_mcp-0.1.53.dist-info}/entry_points.txt
RENAMED
File without changes
|