iflow-mcp_mcp-server-okppt 0.2.0__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.
@@ -0,0 +1,372 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-mcp_mcp-server-okppt
3
+ Version: 0.2.0
4
+ Summary: A Python package to insert SVG images into PowerPoint presentations, with MCP server capabilities.
5
+ Author-email: NeekChaw <your.email@example.com>
6
+ Project-URL: Homepage, https://github.com/NeekChaw/mcp-server-okppt
7
+ Project-URL: Bug Tracker, https://github.com/NeekChaw/mcp-server-okppt/issues
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: mcp[cli]>=1.8.0
12
+ Requires-Dist: lxml>=4.9.2
13
+ Requires-Dist: python-pptx>=0.6.21
14
+ Requires-Dist: reportlab>=4.0.0
15
+ Requires-Dist: svglib>=1.5.1
16
+ Requires-Dist: rlPyCairo>=0.1.0
17
+ Dynamic: license-file
18
+
19
+ # MCP OKPPT Server
20
+
21
+ [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-blue)](https://github.com/anthropics/anthropic-tools)
22
+
23
+ 一个基于Model Context Protocol (MCP)的服务器工具,专门用于将SVG图像插入到PowerPoint演示文稿中。它能够保留SVG的矢量特性,确保在PowerPoint中显示的图像保持高品质和可缩放性。
24
+
25
+ ## 设计理念
26
+
27
+ 此项目是让大型语言模型(如Claude、GPT等)能够自主设计PowerPoint演示文稿的"曲线救国"解决方案。通过让AI生成SVG图像,再借助本工具将其全屏插入PPT幻灯片,我们成功实现了AI完全控制PPT设计的能力,而无需直接操作复杂的PPT对象模型。
28
+
29
+ 这种方法带来三大核心优势:
30
+ 1. **AI完全控制**:充分发挥现代AI的图形设计能力,同时避开PPT编程的复杂性
31
+ 2. **用户可编辑**:Office PowerPoint提供了强大的SVG编辑功能,插入后的SVG元素可以像原生PPT元素一样直接编辑、调整和重新着色,让用户能轻松地在AI生成基础上进行二次修改
32
+ 3. **矢量级质量**:保持高品质可缩放的矢量特性,确保演示内容在任何尺寸下都清晰锐利
33
+
34
+ 这一创新思路通过SVG作为AI与PPT之间的桥梁,既保证了设计的高度自由,又兼顾了最终成果的实用性和可维护性。
35
+
36
+ ## 功能特点
37
+
38
+ - **矢量图保留**: 将SVG作为真实矢量图插入PPTX,保证高品质和可缩放性
39
+ - **批量批处理**: 支持一次操作多个SVG文件和幻灯片
40
+ - **全新演示文稿**: 直接从SVG文件创建完整的演示文稿
41
+ - **幻灯片复制与替换**: 智能复制SVG幻灯片并替换现有内容
42
+ - **SVG代码处理**: 支持直接从SVG代码创建文件
43
+ - **格式转换支持**: 内置SVG到PNG的转换功能
44
+
45
+ ## 安装方法
46
+
47
+ ### 方法一:从PyPI安装
48
+
49
+ ```bash
50
+ # 使用pip安装
51
+ pip install mcp-server-okppt
52
+
53
+ # 或使用uv安装
54
+ uv pip install mcp-server-okppt
55
+ ```
56
+
57
+ ### 方法二:配置Claude Desktop
58
+
59
+ 在Claude Desktop配置文件中添加服务器配置:
60
+
61
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
62
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
63
+
64
+ 添加以下配置:
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "okppt": {
70
+ "command": "uvx",
71
+ "args": [
72
+ "mcp-server-okppt"
73
+ ]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### 方法三:从源码安装并配置Cursor本地开发环境
80
+
81
+ 在Cursor IDE中,可以通过本地配置文件来设置MCP服务器:
82
+
83
+ **Windows**: `C:\Users\用户名\.cursor\mcp.json`
84
+ **macOS**: `~/.cursor/mcp.json`
85
+
86
+ 添加以下配置:
87
+
88
+ ```json
89
+ {
90
+ "mcpServers": {
91
+ "okppt": {
92
+ "command": "uv",
93
+ "args": [
94
+ "--directory",
95
+ "D:\\本地项目路径\\mcp-server-okppt\\src\\mcp_server_okppt",
96
+ "run",
97
+ "cli.py"
98
+ ]
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ 这种配置方式适合本地开发和测试使用,可以直接指向本地代码目录。
105
+
106
+ ## 使用方法
107
+
108
+ ### 使用Claude Desktop
109
+
110
+ 1. 安装并配置Claude Desktop
111
+ 2. 在配置文件中添加上述MCP服务器配置
112
+ 3. 重启Claude Desktop
113
+ 4. 在对话中使用PPTX相关工具
114
+
115
+ ### 使用MCP CLI进行开发
116
+
117
+ ```bash
118
+ # 运行测试
119
+ mcp test server.py
120
+ ```
121
+
122
+ ## 可用工具
123
+
124
+ ### 1. 插入SVG图像 (insert_svg)
125
+
126
+ ```python
127
+ def insert_svg(
128
+ pptx_path: str,
129
+ svg_path: List[str],
130
+ slide_number: int = 1,
131
+ x_inches: float = 0,
132
+ y_inches: float = 0,
133
+ width_inches: float = 16,
134
+ height_inches: float = 9,
135
+ output_path: str = "",
136
+ create_if_not_exists: bool = True
137
+ ) -> str
138
+ ```
139
+
140
+ 将SVG图像插入到PPTX文件的指定位置。
141
+
142
+ **参数**:
143
+ - `pptx_path`: PPTX文件路径
144
+ - `svg_path`: SVG文件路径或路径列表
145
+ - `slide_number`: 要插入的幻灯片编号(从1开始)
146
+ - `x_inches`: X坐标(英寸)
147
+ - `y_inches`: Y坐标(英寸)
148
+ - `width_inches`: 宽度(英寸)
149
+ - `height_inches`: 高度(英寸)
150
+ - `output_path`: 输出文件路径
151
+ - `create_if_not_exists`: 如果PPTX不存在是否创建
152
+
153
+ **返回**: 操作结果消息
154
+
155
+ ### 2. 列出目录文件 (list_files)
156
+
157
+ ```python
158
+ def list_files(
159
+ directory: str = ".",
160
+ file_type: Optional[str] = None
161
+ ) -> str
162
+ ```
163
+
164
+ 列出目录中的文件。
165
+
166
+ **参数**:
167
+ - `directory`: 目录路径
168
+ - `file_type`: 文件类型过滤,可以是"svg"或"pptx"
169
+
170
+ **返回**: 文件列表
171
+
172
+ ### 3. 获取文件信息 (get_file_info)
173
+
174
+ ```python
175
+ def get_file_info(
176
+ file_path: str
177
+ ) -> str
178
+ ```
179
+
180
+ 获取文件信息。
181
+
182
+ **参数**:
183
+ - `file_path`: 文件路径
184
+
185
+ **返回**: 文件信息
186
+
187
+ ### 4. 转换SVG为PNG (convert_svg_to_png)
188
+
189
+ ```python
190
+ def convert_svg_to_png(
191
+ svg_path: str,
192
+ output_path: Optional[str] = None
193
+ ) -> str
194
+ ```
195
+
196
+ 将SVG文件转换为PNG图像。
197
+
198
+ **参数**:
199
+ - `svg_path`: SVG文件路径
200
+ - `output_path`: 输出PNG文件路径
201
+
202
+ **返回**: 操作结果消息
203
+
204
+ ### 5. 获取PPTX信息 (get_pptx_info)
205
+
206
+ ```python
207
+ def get_pptx_info(
208
+ pptx_path: str
209
+ ) -> str
210
+ ```
211
+
212
+ 获取PPTX文件的基本信息。
213
+
214
+ **参数**:
215
+ - `pptx_path`: PPTX文件路径
216
+
217
+ **返回**: 包含文件信息和幻灯片数量的字符串
218
+
219
+ ### 6. 保存SVG代码 (save_svg_code)
220
+
221
+ ```python
222
+ def save_svg_code(
223
+ svg_code: str
224
+ ) -> str
225
+ ```
226
+
227
+ 将SVG代码保存为SVG文件并返回保存的绝对路径。
228
+
229
+ **参数**:
230
+ - `svg_code`: SVG代码内容
231
+
232
+ **返回**: 操作结果消息和保存的文件路径
233
+
234
+ ### 7. 删除幻灯片 (delete_slide)
235
+
236
+ ```python
237
+ def delete_slide(
238
+ pptx_path: str,
239
+ slide_number: int,
240
+ output_path: Optional[str] = None
241
+ ) -> str
242
+ ```
243
+
244
+ 从PPTX文件中删除指定编号的幻灯片。
245
+
246
+ **参数**:
247
+ - `pptx_path`: PPTX文件路径
248
+ - `slide_number`: 要删除的幻灯片编号
249
+ - `output_path`: 输出文件路径
250
+
251
+ **返回**: 操作结果消息
252
+
253
+ ### 8. 插入空白幻灯片 (insert_blank_slide)
254
+
255
+ ```python
256
+ def insert_blank_slide(
257
+ pptx_path: str,
258
+ slide_number: int,
259
+ layout_index: int = 6,
260
+ output_path: Optional[str] = None,
261
+ create_if_not_exists: bool = True
262
+ ) -> str
263
+ ```
264
+
265
+ 在PPTX文件的指定位置插入一个空白幻灯片。
266
+
267
+ **参数**:
268
+ - `pptx_path`: PPTX文件路径
269
+ - `slide_number`: 插入位置
270
+ - `layout_index`: 幻灯片布局索引,默认为6(空白布局)
271
+ - `output_path`: 输出文件路径
272
+ - `create_if_not_exists`: 如果PPTX不存在是否创建
273
+
274
+ **返回**: 操作结果消息
275
+
276
+ ### 9. 复制SVG幻灯片 (copy_svg_slide)
277
+
278
+ ```python
279
+ def copy_svg_slide(
280
+ source_pptx_path: str,
281
+ target_pptx_path: str = "",
282
+ source_slide_number: int = 1,
283
+ target_slide_number: Optional[int] = None,
284
+ output_path: Optional[str] = None,
285
+ create_if_not_exists: bool = True
286
+ ) -> str
287
+ ```
288
+
289
+ 复制包含SVG图像的幻灯片。
290
+
291
+ **参数**:
292
+ - `source_pptx_path`: 源PPTX文件路径
293
+ - `target_pptx_path`: 目标PPTX文件路径
294
+ - `source_slide_number`: 要复制的源幻灯片编号
295
+ - `target_slide_number`: 要插入到目标文件的位置
296
+ - `output_path`: 输出文件路径
297
+ - `create_if_not_exists`: 如果目标PPTX不存在是否创建
298
+
299
+ **返回**: 操作结果消息
300
+
301
+ ## 最佳实践
302
+
303
+ ### 替换幻灯片内容的推荐方法
304
+
305
+ #### 方法一:完全替换法(最可靠)
306
+
307
+ ```python
308
+ # 步骤1:删除要替换的幻灯片
309
+ delete_slide(
310
+ pptx_path="演示文稿.pptx",
311
+ slide_number=3,
312
+ output_path="临时文件.pptx"
313
+ )
314
+
315
+ # 步骤2:在同一位置插入空白幻灯片
316
+ insert_blank_slide(
317
+ pptx_path="临时文件.pptx",
318
+ slide_number=3,
319
+ output_path="临时文件2.pptx"
320
+ )
321
+
322
+ # 步骤3:将新SVG插入到空白幻灯片
323
+ insert_svg(
324
+ pptx_path="临时文件2.pptx",
325
+ svg_path=["新内容.svg"],
326
+ slide_number=3,
327
+ output_path="最终文件.pptx"
328
+ )
329
+ ```
330
+
331
+ ## 注意事项
332
+
333
+ 1. **避免内容叠加**:直接对现有幻灯片插入SVG会导致新内容叠加在原内容上,而非替换
334
+ 2. **批量处理**:批量插入SVG时,`svg_path`参数必须是数组形式,即使只有一个文件
335
+ 3. **SVG代码转义**:在使用`save_svg_code`时,特殊字符(如"&")需要正确转义为"&amp;"
336
+ 4. **文件路径**:尽量使用英文路径,避免路径中出现特殊字符
337
+ 5. **检查结果**:每次操作后应检查输出文件以确认修改是否成功
338
+
339
+ ## 常见问题解答
340
+
341
+ ### Q: SVG插入后变成了位图而非矢量图?
342
+ A: 请确保使用`copy_svg_slide`或`create_pptx_from_svg`函数,这些函数专门设计用于保留SVG的矢量特性。
343
+
344
+ ### Q: 如何批量处理多个SVG文件?
345
+ A: 可以使用`insert_svg`函数并将多个SVG路径作为列表传入,或者使用`create_pptx_from_svg`一次性创建包含多个SVG的演示文稿。
346
+
347
+ ### Q: 文件名变得很长且复杂?
348
+ A: 这是因为每次操作都会添加时间戳。建议使用"新文件法"一次性创建最终文件,或在最后一步操作中指定简洁的输出文件名。
349
+
350
+ ## 版本信息
351
+
352
+ 当前最新版本: v0.2.0
353
+
354
+ 查看所有版本和更新信息: [GitHub Releases](https://github.com/NeekChaw/mcp-server-okppt/releases)
355
+
356
+ ## 致谢
357
+
358
+ 本项目在开发过程中受益于[Model Context Protocol(MCP) 编程极速入门](https://github.com/liaokongVFX/MCP-Chinese-Getting-Started-Guide)这一优质资源。该项目提供了全面而清晰的MCP开发指南,涵盖了从基础概念到实际部署的各个方面,极大地降低了开发者学习MCP协议的门槛。特别感谢其在服务配置、工具开发和部署流程等方面的详细示例和说明,为MCP生态的发展和普及做出了宝贵贡献。推荐所有对MCP开发感兴趣的开发者参考这份指南,它将帮助你快速掌握MCP服务器的开发与配置技能。
359
+
360
+ ## 贡献指南
361
+
362
+ 欢迎提交问题和拉取请求到[项目仓库](https://github.com/NeekChaw/mcp-server-okppt)!以下是一些潜在的改进方向:
363
+
364
+ - 添加更多幻灯片布局支持
365
+ - 增强SVG处理和兼容性
366
+ - 添加批量SVG处理的进度报告
367
+ - 改进错误处理和诊断功能
368
+ - 添加图表和表格的特殊处理功能
369
+
370
+ ## 许可证
371
+
372
+ 本项目采用MIT许可证。
@@ -0,0 +1,12 @@
1
+ iflow_mcp_mcp_server_okppt-0.2.0.dist-info/licenses/LICENSE,sha256=r1Po_3uEiU5Q0n-AQZPcAqo5pmKm0UOBIibxQQoDvzo,1065
2
+ mcp_server_okppt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ mcp_server_okppt/__main__.py,sha256=exrxWnOwf2Zggmpx8xaZePYgtfHl4qlNL6oOHMzYp-c,127
4
+ mcp_server_okppt/cli.py,sha256=79zY6CC0QPGCEBXVHQt7i48_qFD4YhINNONvDJEB2mo,645
5
+ mcp_server_okppt/ppt_operations.py,sha256=tjD5Oj0gdFHsplisUlKoBLBgnaD_Z_tWOkGlAA05GzE,24930
6
+ mcp_server_okppt/server.py,sha256=6PjnzViriKmvDN1mVWGyLT-awfIO6sBSnn8d8aZ38gE,82701
7
+ mcp_server_okppt/svg_module.py,sha256=YHEFGDXl-o7pDyDc4MBPCCpadmAsT_Ado6T1ox9Q0o0,39934
8
+ iflow_mcp_mcp_server_okppt-0.2.0.dist-info/METADATA,sha256=vL0Ix3lWPcz2yvPUeAciNeCC9MVv-16DePh4rnLlow0,10546
9
+ iflow_mcp_mcp_server_okppt-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ iflow_mcp_mcp_server_okppt-0.2.0.dist-info/entry_points.txt,sha256=c1GjYAm7U2CWlWPfoSE95XsruGAsQcU0kefaNAlk8uo,63
11
+ iflow_mcp_mcp_server_okppt-0.2.0.dist-info/top_level.txt,sha256=GikBUfBEoRjxyZB6oH2EW34kQTsx8r5J9t5cPI5wX7c,17
12
+ iflow_mcp_mcp_server_okppt-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcp-server-okppt = mcp_server_okppt.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 NeekChaw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ mcp_server_okppt
File without changes
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ 主模块入口点
4
+ """
5
+ from mcp_server_okppt.cli import main
6
+
7
+ if __name__ == "__main__":
8
+ main()
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ 命令行入口点,用于运行 MCP OKPPT 服务器
4
+ """
5
+ import sys
6
+ import logging
7
+ from mcp.server.fastmcp import FastMCP
8
+ from mcp_server_okppt.server import mcp
9
+
10
+ # 设置日志格式
11
+ logging.basicConfig(
12
+ level=logging.INFO,
13
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
14
+ )
15
+
16
+ def main():
17
+ """主函数,运行MCP服务器"""
18
+ try:
19
+ print("启动 MCP OKPPT 服务器...", file=sys.stderr)
20
+ # 运行服务器
21
+ mcp.run(transport='stdio')
22
+ except Exception as e:
23
+ print(f"Error: {e}", file=sys.stderr)
24
+ sys.exit(1)
25
+
26
+ if __name__ == "__main__":
27
+ main()