BruceWayne1 commited on
Commit
019e593
·
verified ·
1 Parent(s): e2e9a4f

Upload 14 files (#1)

Browse files

- Upload 14 files (605241ac69e318b4d9f2c684f5c2fa1b3fc8a4f8)

.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ mcp_all_tools_templates_effects_demo.pptx filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ *.bak
12
+ test/
13
+ .DS_Store
14
+ CLAUDE.md
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
2
+ FROM python:3.10-alpine
3
+
4
+ # Install system dependencies (if any required, e.g., for pillow)
5
+ RUN apk add --no-cache gcc musl-dev libffi-dev
6
+
7
+ # Set work directory
8
+ WORKDIR /app
9
+
10
+ # Copy the application code
11
+ COPY . .
12
+
13
+ # Install Python dependencies
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
+
16
+ # Expose port if needed (not needed for stdio)
17
+
18
+ # Set the entrypoint to run the MCP server
19
+ ENTRYPOINT ["python", "ppt_mcp_server.py"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 GongRzhe
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.
README.md CHANGED
@@ -1,17 +1,986 @@
1
- ---
2
- title: Auxomators
3
- emoji: 💬
4
- colorFrom: yellow
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.42.0
8
- app_file: app.py
9
- pinned: false
10
- hf_oauth: true
11
- hf_oauth_scopes:
12
- - inference-api
13
- license: mit
14
- short_description: ppt builder
15
- ---
16
-
17
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Office-PowerPoint-MCP-Server
2
+ [![smithery badge](https://smithery.ai/badge/@GongRzhe/Office-PowerPoint-MCP-Server)](https://smithery.ai/server/@GongRzhe/Office-PowerPoint-MCP-Server)
3
+ ![](https://badge.mcpx.dev?type=server 'MCP Server')
4
+
5
+ A comprehensive MCP (Model Context Protocol) server for PowerPoint manipulation using python-pptx. **Version 2.0** provides 32 powerful tools organized into 11 specialized modules, offering complete PowerPoint creation, management, and professional design capabilities. The server features a modular architecture with enhanced parameter handling, intelligent operation selection, and comprehensive error handling.
6
+
7
+ ----
8
+
9
+ # **Not so ugly anymore with new slide_layout_templates**
10
+
11
+ <img width="1509" alt="截屏2025-06-20 15 53 45" src="https://github.com/user-attachments/assets/197d82cb-017a-4c00-b969-6e40440ffa36" />
12
+
13
+ ----
14
+
15
+ ### Example
16
+
17
+ #### Pormpt
18
+
19
+ <img width="1280" alt="650f4cc5d0f1ea4f3b1580800cb0deb" src="https://github.com/user-attachments/assets/90633c97-f373-4c85-bc9c-a1d7b891c344" />
20
+
21
+ #### Output
22
+
23
+ <img width="1640" alt="084f1cf4bc7e4fcd4890c8f94f536c1" src="https://github.com/user-attachments/assets/420e63a0-15a4-46d8-b149-1408d23af038" />
24
+
25
+ #### Demo's GIF -> (./public/demo.mp4)
26
+
27
+ ![demo](./public/demo.gif)
28
+
29
+ ## Features
30
+
31
+ ### Core PowerPoint Operations
32
+ - **Round-trip support** for any Open XML presentation (.pptx file) including all elements
33
+ - **Template support** with automatic theme and layout preservation
34
+ - **Multi-presentation management** with global state tracking
35
+ - **Core document properties** management (title, subject, author, keywords, comments)
36
+
37
+ ### Content Creation & Management
38
+ - **Slide management** with flexible layout selection
39
+ - **Text manipulation** with placeholder population and bullet point creation
40
+ - **Advanced text formatting** with font, color, alignment, and style controls
41
+ - **Text validation** with automatic fit checking and optimization suggestions
42
+
43
+ ### Visual Elements
44
+ - **Image handling** with file and base64 input support
45
+ - **Image enhancement** using Pillow with brightness, contrast, saturation, and filter controls
46
+ - **Professional image effects** including shadows, reflections, glows, and soft edges
47
+ - **Shape creation** with 20+ auto shape types (rectangles, ovals, flowchart elements, etc.)
48
+ - **Table creation** with advanced cell formatting and styling
49
+
50
+ ### Charts & Data Visualization
51
+ - **Chart support** for column, bar, line, and pie charts
52
+ - **Data series management** with categories and multiple series support
53
+ - **Chart formatting** with legends, data labels, and titles
54
+
55
+ ### Professional Design Features
56
+ - **4 professional color schemes** (Modern Blue, Corporate Gray, Elegant Green, Warm Red)
57
+ - **Professional typography** with Segoe UI font family and size presets
58
+ - **Theme application** with automatic styling across presentations
59
+ - **Gradient backgrounds** with customizable directions and color schemes
60
+ - **Slide enhancement** tools for existing content
61
+ - **25 built-in slide templates** with dynamic sizing and visual effects
62
+ - **Advanced template features** including auto-wrapping, dynamic font sizing, and professional animations
63
+
64
+ ### Advanced Features
65
+ - **Font analysis and optimization** using FontTools
66
+ - **Picture effects** with 9 different visual effects (shadow, reflection, glow, bevel, etc.)
67
+ - **Comprehensive validation** with automatic error fixing
68
+ - **Template search** with configurable directory paths
69
+ - **Professional layout calculations** with margin and spacing management
70
+
71
+ ## Installation
72
+
73
+ ### Installing via Smithery
74
+
75
+ To install PowerPoint Manipulation Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@GongRzhe/Office-PowerPoint-MCP-Server):
76
+
77
+ ```bash
78
+ npx -y @smithery/cli install @GongRzhe/Office-PowerPoint-MCP-Server --client claude
79
+ ```
80
+
81
+ ### Prerequisites
82
+
83
+ - Python 3.6 or higher (as specified in pyproject.toml)
84
+ - pip package manager
85
+ - Optional: uvx for package execution without local installation
86
+
87
+ ### Installation Options
88
+
89
+ #### Option 1: Using the Setup Script (Recommended)
90
+
91
+ The easiest way to set up the PowerPoint MCP Server is using the provided setup script, which automates the installation process:
92
+
93
+ ```bash
94
+ python setup_mcp.py
95
+ ```
96
+
97
+ This script will:
98
+ - Check prerequisites
99
+ - Offer installation options:
100
+ - Install from PyPI (recommended for most users)
101
+ - Set up local development environment
102
+ - Install required dependencies
103
+ - Generate the appropriate MCP configuration file
104
+ - Provide instructions for integrating with Claude Desktop
105
+
106
+ The script offers different paths based on your environment:
107
+ - If you have `uvx` installed, it will configure using UVX (recommended)
108
+ - If the server is already installed, it provides configuration options
109
+ - If the server is not installed, it offers installation methods
110
+
111
+ #### Option 2: Manual Installation
112
+
113
+ 1. Clone the repository:
114
+ ```bash
115
+ git clone https://github.com/GongRzhe/Office-PowerPoint-MCP-Server.git
116
+ cd Office-PowerPoint-MCP-Server
117
+ ```
118
+
119
+ 2. Install dependencies:
120
+ ```bash
121
+ pip install -r requirements.txt
122
+ ```
123
+
124
+ 3. Make the server executable:
125
+ ```bash
126
+ chmod +x ppt_mcp_server.py
127
+ ```
128
+
129
+ ## Usage
130
+
131
+ Display help text:
132
+ ```bash
133
+ python ppt_mcp_server.py -h
134
+ ```
135
+
136
+ ### Starting the Stdio Server
137
+
138
+ Run the stdio server:
139
+
140
+ ```bash
141
+ python ppt_mcp_server.py
142
+ ```
143
+
144
+ ### Starting the Streamable-Http Server
145
+
146
+ Run the streamable-http server on port 8000:
147
+
148
+ ```bash
149
+ python ppt_mcp_server.py --transport http --port 8000
150
+ ```
151
+
152
+ Run in Docker
153
+ ```bash
154
+ docker build -t ppt_mcp_server .
155
+ docker run -d --rm -p 8000:8000 ppt_mcp_server -t http
156
+ ```
157
+
158
+
159
+ ### MCP Configuration
160
+
161
+ #### Option 1: Local Python Server
162
+
163
+ Add the server to your MCP settings configuration file:
164
+
165
+ ```json
166
+ {
167
+ "mcpServers": {
168
+ "ppt": {
169
+ "command": "python",
170
+ "args": ["/path/to/ppt_mcp_server.py"],
171
+ "env": {}
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ #### Option 2: Using UVX (No Local Installation Required)
178
+
179
+ If you have `uvx` installed, you can run the server directly from PyPI without local installation:
180
+
181
+ ```json
182
+ {
183
+ "mcpServers": {
184
+ "ppt": {
185
+ "command": "uvx",
186
+ "args": [
187
+ "--from", "office-powerpoint-mcp-server", "ppt_mcp_server"
188
+ ],
189
+ "env": {}
190
+ }
191
+ }
192
+ }
193
+ ```
194
+
195
+ ## 🚀 What's New in v2.0
196
+
197
+ ### **Comprehensive Tool Suite (32 Tools)**
198
+ - **Complete PowerPoint manipulation** with 34 specialized tools
199
+ - **11 organized modules** covering all aspects of presentation creation
200
+ - **Enhanced parameter handling** with comprehensive validation
201
+ - **Intelligent defaults** and operation-based interfaces
202
+
203
+ ### **Built-in Slide Templates**
204
+ - **25+ professional slide templates** with dynamic features built-in
205
+ - **Advanced template system** with auto-generation capabilities
206
+ - **Auto-sizing text** that adapts to content length and container size
207
+ - **Professional visual effects** including shadows, glows, and gradients
208
+ - **Complete presentation generation** from template sequences
209
+
210
+ ### **Modular Architecture**
211
+ - **11 specialized modules**: presentation, content, structural, professional, template, hyperlink, chart, connector, master, and transition tools
212
+ - **Better maintainability** with separated concerns
213
+ - **Easier extensibility** for adding new features
214
+ - **Cleaner code structure** with shared utilities
215
+
216
+ ## Available Tools
217
+
218
+ The server provides **34 specialized tools** organized into the following categories:
219
+
220
+ ### **Presentation Management (7 tools)**
221
+ 1. **create_presentation** - Create new presentations
222
+ 2. **create_presentation_from_template** - Create from templates with theme preservation
223
+ 3. **open_presentation** - Open existing presentations
224
+ 4. **save_presentation** - Save presentations to files
225
+ 5. **get_presentation_info** - Get comprehensive presentation information
226
+ 6. **get_template_file_info** - Analyze template files and layouts
227
+ 7. **set_core_properties** - Set document properties
228
+
229
+ ### **Content Management (8 tools)**
230
+ 8. **add_slide** - Add slides with optional background styling
231
+ 9. **get_slide_info** - Get detailed slide information
232
+ 10. **extract_slide_text** - ✨ **NEW** Extract all text content from a specific slide
233
+ 11. **extract_presentation_text** - ✨ **NEW** Extract text content from all slides in presentation
234
+ 12. **populate_placeholder** - Populate placeholders with text
235
+ 13. **add_bullet_points** - Add formatted bullet points
236
+ 14. **manage_text** - ✨ **Unified text tool** (add/format/validate/format_runs)
237
+ 15. **manage_image** - ✨ **Unified image tool** (add/enhance)
238
+
239
+ ### **Template Operations (7 tools)**
240
+ 16. **list_slide_templates** - Browse available slide layout templates
241
+ 17. **apply_slide_template** - Apply structured layout templates to existing slides
242
+ 18. **create_slide_from_template** - Create new slides using layout templates
243
+ 19. **create_presentation_from_templates** - Create complete presentations from template sequences
244
+ 20. **get_template_info** - Get detailed information about specific templates
245
+ 21. **auto_generate_presentation** - Automatically generate presentations based on topic
246
+ 22. **optimize_slide_text** - Optimize text elements for better readability and fit
247
+
248
+ ### **Structural Elements (4 tools)**
249
+ 23. **add_table** - Create tables with enhanced formatting
250
+ 24. **format_table_cell** - Format individual table cells
251
+ 25. **add_shape** - Add shapes with text and formatting options
252
+ 26. **add_chart** - Create charts with comprehensive customization
253
+
254
+ ### **Professional Design (3 tools)**
255
+ 27. **apply_professional_design** - ✨ **Unified design tool** (themes/slides/enhancement)
256
+ 28. **apply_picture_effects** - ✨ **Unified effects tool** (9+ effects combined)
257
+ 29. **manage_fonts** - ✨ **Unified font tool** (analyze/optimize/recommend)
258
+
259
+ ### **Specialized Features (5 tools)**
260
+ 30. **manage_hyperlinks** - Complete hyperlink management (add/remove/list/update)
261
+ 31. **manage_slide_masters** - Access and manage slide master properties and layouts
262
+ 32. **add_connector** - Add connector lines/arrows between points on slides
263
+ 33. **update_chart_data** - Replace existing chart data with new categories and series
264
+ 34. **manage_slide_transitions** - Basic slide transition management
265
+
266
+ ## 🌟 Key Unified Tools
267
+
268
+ ### **`manage_text`** - All-in-One Text Management
269
+ ```python
270
+ # Add text box
271
+ manage_text(slide_index=0, operation="add", text="Hello World", font_size=24)
272
+
273
+ # Format existing text
274
+ manage_text(slide_index=0, operation="format", shape_index=0, bold=True, color=[255,0,0])
275
+
276
+ # Validate text fit with auto-fix
277
+ manage_text(slide_index=0, operation="validate", shape_index=0, validation_only=False)
278
+ ```
279
+
280
+ ### **`manage_image`** - Complete Image Handling
281
+ ```python
282
+ # Add image with enhancement
283
+ manage_image(slide_index=0, operation="add", image_source="logo.png",
284
+ enhancement_style="presentation")
285
+
286
+ # Enhance existing image
287
+ manage_image(slide_index=0, operation="enhance", image_source="photo.jpg",
288
+ brightness=1.2, contrast=1.1, saturation=1.3)
289
+ ```
290
+
291
+ ### **`apply_picture_effects`** - Multiple Effects in One Call
292
+ ```python
293
+ # Apply combined effects
294
+ apply_picture_effects(slide_index=0, shape_index=0, effects={
295
+ "shadow": {"blur_radius": 4.0, "color": [128,128,128]},
296
+ "glow": {"size": 5.0, "color": [0,176,240]},
297
+ "rotation": {"rotation": 15.0}
298
+ })
299
+ ```
300
+
301
+ ### **`apply_professional_design`** - Theme & Design Management
302
+ ```python
303
+ # Add professional slide
304
+ apply_professional_design(operation="slide", slide_type="title_content",
305
+ color_scheme="modern_blue", title="My Presentation")
306
+
307
+ # Apply theme to entire presentation
308
+ apply_professional_design(operation="theme", color_scheme="corporate_gray")
309
+
310
+ # Enhance existing slide
311
+ apply_professional_design(operation="enhance", slide_index=0, color_scheme="elegant_green")
312
+ ```
313
+
314
+ ## Examples
315
+
316
+ ### Creating a New Presentation
317
+
318
+ ```python
319
+ # Create a new presentation
320
+ result = use_mcp_tool(
321
+ server_name="ppt",
322
+ tool_name="create_presentation",
323
+ arguments={}
324
+ )
325
+ presentation_id = result["presentation_id"]
326
+
327
+ # Add a title slide
328
+ result = use_mcp_tool(
329
+ server_name="ppt",
330
+ tool_name="add_slide",
331
+ arguments={
332
+ "layout_index": 0, # Title slide layout
333
+ "title": "My Presentation",
334
+ "presentation_id": presentation_id
335
+ }
336
+ )
337
+ slide_index = result["slide_index"]
338
+
339
+ # Populate subtitle placeholder
340
+ result = use_mcp_tool(
341
+ server_name="ppt",
342
+ tool_name="populate_placeholder",
343
+ arguments={
344
+ "slide_index": slide_index,
345
+ "placeholder_idx": 1, # Subtitle placeholder
346
+ "text": "Created with PowerPoint MCP Server",
347
+ "presentation_id": presentation_id
348
+ }
349
+ )
350
+
351
+ # Save the presentation
352
+ result = use_mcp_tool(
353
+ server_name="ppt",
354
+ tool_name="save_presentation",
355
+ arguments={
356
+ "file_path": "my_presentation.pptx",
357
+ "presentation_id": presentation_id
358
+ }
359
+ )
360
+ ```
361
+
362
+ ### Creating a Professional Presentation with v2.0
363
+
364
+ ```python
365
+ # Create a professional slide with modern styling - CONSOLIDATED TOOL
366
+ result = use_mcp_tool(
367
+ server_name="ppt",
368
+ tool_name="apply_professional_design",
369
+ arguments={
370
+ "operation": "slide",
371
+ "slide_type": "title_content",
372
+ "color_scheme": "modern_blue",
373
+ "title": "Quarterly Business Review",
374
+ "content": [
375
+ "Revenue increased by 15% compared to last quarter",
376
+ "Customer satisfaction scores reached all-time high of 94%",
377
+ "Successfully launched 3 new product features",
378
+ "Expanded team by 12 new talented professionals"
379
+ ]
380
+ }
381
+ )
382
+
383
+ # Apply professional theme to entire presentation - SAME TOOL, DIFFERENT OPERATION
384
+ result = use_mcp_tool(
385
+ server_name="ppt",
386
+ tool_name="apply_professional_design",
387
+ arguments={
388
+ "operation": "theme",
389
+ "color_scheme": "modern_blue",
390
+ "apply_to_existing": True
391
+ }
392
+ )
393
+
394
+ # Add slide with gradient background - ENHANCED ADD_SLIDE
395
+ result = use_mcp_tool(
396
+ server_name="ppt",
397
+ tool_name="add_slide",
398
+ arguments={
399
+ "layout_index": 0,
400
+ "background_type": "professional_gradient",
401
+ "color_scheme": "modern_blue",
402
+ "gradient_direction": "diagonal"
403
+ }
404
+ )
405
+ ```
406
+
407
+ ### Working with Built-in Slide Templates (New in v2.0)
408
+
409
+ ```python
410
+ # List all available slide templates with their features
411
+ result = use_mcp_tool(
412
+ server_name="ppt",
413
+ tool_name="list_slide_templates",
414
+ arguments={}
415
+ )
416
+
417
+ # Apply a professional template to an existing slide
418
+ result = use_mcp_tool(
419
+ server_name="ppt",
420
+ tool_name="apply_slide_template",
421
+ arguments={
422
+ "slide_index": 0,
423
+ "template_id": "title_slide",
424
+ "color_scheme": "modern_blue",
425
+ "content_mapping": {
426
+ "title": "Quarterly Business Review",
427
+ "subtitle": "Q4 2024 Results",
428
+ "author": "Leadership Team"
429
+ }
430
+ }
431
+ )
432
+
433
+ # Create a new slide using a template
434
+ result = use_mcp_tool(
435
+ server_name="ppt",
436
+ tool_name="create_slide_from_template",
437
+ arguments={
438
+ "template_id": "text_with_image",
439
+ "color_scheme": "elegant_green",
440
+ "content_mapping": {
441
+ "title": "Our Revolutionary Solution",
442
+ "content": "• 250% increase in efficiency\n• 98% customer satisfaction\n• Industry-leading performance"
443
+ },
444
+ "image_paths": {
445
+ "supporting": "path/to/product_image.jpg"
446
+ }
447
+ }
448
+ )
449
+
450
+ # Generate a complete presentation from multiple templates
451
+ result = use_mcp_tool(
452
+ server_name="ppt",
453
+ tool_name="create_presentation_from_templates",
454
+ arguments={
455
+ "template_sequence": [
456
+ {
457
+ "template_id": "title_slide",
458
+ "content": {
459
+ "title": "2024 Annual Report",
460
+ "subtitle": "Growth and Innovation",
461
+ "author": "Executive Team"
462
+ }
463
+ },
464
+ {
465
+ "template_id": "key_metrics_dashboard",
466
+ "content": {
467
+ "metric_1_value": "94%",
468
+ "metric_2_value": "$2.4M",
469
+ "metric_3_value": "247"
470
+ }
471
+ },
472
+ {
473
+ "template_id": "before_after_comparison",
474
+ "content": {
475
+ "content_left": "Manual processes taking hours",
476
+ "content_right": "Automated workflows in minutes"
477
+ }
478
+ }
479
+ ],
480
+ "color_scheme": "modern_blue"
481
+ }
482
+ )
483
+ ```
484
+
485
+ ### Enhanced Image Management with v2.0
486
+
487
+ ```python
488
+ # Add image with automatic enhancement - CONSOLIDATED TOOL
489
+ result = use_mcp_tool(
490
+ server_name="ppt",
491
+ tool_name="manage_image",
492
+ arguments={
493
+ "slide_index": 1,
494
+ "operation": "add",
495
+ "image_source": "company_logo.png",
496
+ "left": 1.0,
497
+ "top": 1.0,
498
+ "width": 3.0,
499
+ "height": 2.0,
500
+ "enhancement_style": "presentation"
501
+ }
502
+ )
503
+
504
+ # Apply multiple picture effects at once - CONSOLIDATED TOOL
505
+ result = use_mcp_tool(
506
+ server_name="ppt",
507
+ tool_name="apply_picture_effects",
508
+ arguments={
509
+ "slide_index": 1,
510
+ "shape_index": 0,
511
+ "effects": {
512
+ "shadow": {
513
+ "shadow_type": "outer",
514
+ "blur_radius": 4.0,
515
+ "distance": 3.0,
516
+ "direction": 315.0,
517
+ "color": [128, 128, 128],
518
+ "transparency": 0.6
519
+ },
520
+ "glow": {
521
+ "size": 5.0,
522
+ "color": [0, 176, 240],
523
+ "transparency": 0.4
524
+ }
525
+ }
526
+ }
527
+ )
528
+ ```
529
+
530
+ ### Advanced Text Management with v2.0
531
+
532
+ ```python
533
+ # Add and format text in one operation - CONSOLIDATED TOOL
534
+ result = use_mcp_tool(
535
+ server_name="ppt",
536
+ tool_name="manage_text",
537
+ arguments={
538
+ "slide_index": 0,
539
+ "operation": "add",
540
+ "left": 1.0,
541
+ "top": 2.0,
542
+ "width": 8.0,
543
+ "height": 1.5,
544
+ "text": "Welcome to Our Quarterly Review",
545
+ "font_size": 32,
546
+ "font_name": "Segoe UI",
547
+ "bold": True,
548
+ "color": [0, 120, 215],
549
+ "alignment": "center",
550
+ "auto_fit": True
551
+ }
552
+ )
553
+
554
+ # Validate and fix text fit issues - SAME TOOL, DIFFERENT OPERATION
555
+ result = use_mcp_tool(
556
+ server_name="ppt",
557
+ tool_name="manage_text",
558
+ arguments={
559
+ "slide_index": 0,
560
+ "operation": "validate",
561
+ "shape_index": 0,
562
+ "validation_only": False, # Auto-fix enabled
563
+ "min_font_size": 10,
564
+ "max_font_size": 48
565
+ }
566
+ )
567
+ ```
568
+
569
+ ### Creating a Presentation from Template
570
+
571
+ ```python
572
+ # First, inspect a template to see its layouts and properties
573
+ result = use_mcp_tool(
574
+ server_name="ppt",
575
+ tool_name="get_template_info",
576
+ arguments={
577
+ "template_path": "company_template.pptx"
578
+ }
579
+ )
580
+ template_info = result
581
+
582
+ # Create a new presentation from the template
583
+ result = use_mcp_tool(
584
+ server_name="ppt",
585
+ tool_name="create_presentation_from_template",
586
+ arguments={
587
+ "template_path": "company_template.pptx"
588
+ }
589
+ )
590
+ presentation_id = result["presentation_id"]
591
+
592
+ # Add a slide using one of the template's layouts
593
+ result = use_mcp_tool(
594
+ server_name="ppt",
595
+ tool_name="add_slide",
596
+ arguments={
597
+ "layout_index": 1, # Use layout from template
598
+ "title": "Quarterly Report",
599
+ "presentation_id": presentation_id
600
+ }
601
+ )
602
+
603
+ # Save the presentation
604
+ result = use_mcp_tool(
605
+ server_name="ppt",
606
+ tool_name="save_presentation",
607
+ arguments={
608
+ "file_path": "quarterly_report.pptx",
609
+ "presentation_id": presentation_id
610
+ }
611
+ )
612
+ ```
613
+
614
+ ### Adding Advanced Charts and Data Visualization
615
+
616
+ ```python
617
+ # Add a chart slide
618
+ result = use_mcp_tool(
619
+ server_name="ppt",
620
+ tool_name="add_slide",
621
+ arguments={
622
+ "layout_index": 1, # Content slide layout
623
+ "title": "Sales Data",
624
+ "presentation_id": presentation_id
625
+ }
626
+ )
627
+ slide_index = result["slide_index"]
628
+
629
+ # Add a column chart with comprehensive customization
630
+ result = use_mcp_tool(
631
+ server_name="ppt",
632
+ tool_name="add_chart",
633
+ arguments={
634
+ "slide_index": slide_index,
635
+ "chart_type": "column",
636
+ "left": 1.0,
637
+ "top": 2.0,
638
+ "width": 8.0,
639
+ "height": 4.5,
640
+ "categories": ["Q1", "Q2", "Q3", "Q4"],
641
+ "series_names": ["2023", "2024"],
642
+ "series_values": [
643
+ [100, 120, 140, 160],
644
+ [110, 130, 150, 170]
645
+ ],
646
+ "has_legend": True,
647
+ "legend_position": "bottom",
648
+ "has_data_labels": True,
649
+ "title": "Quarterly Sales Performance",
650
+ "presentation_id": presentation_id
651
+ }
652
+ )
653
+ ```
654
+
655
+ ### Text Validation and Optimization with v2.0
656
+
657
+ ```python
658
+ # Validate text fit and get optimization suggestions - USING CONSOLIDATED TOOL
659
+ result = use_mcp_tool(
660
+ server_name="ppt",
661
+ tool_name="manage_text",
662
+ arguments={
663
+ "slide_index": 0,
664
+ "operation": "validate",
665
+ "shape_index": 0,
666
+ "text": "This is a very long title that might not fit properly in the designated text box area",
667
+ "font_size": 24,
668
+ "validation_only": True
669
+ }
670
+ )
671
+
672
+ # Comprehensive slide validation with automatic fixes - SAME TOOL, AUTO-FIX ENABLED
673
+ result = use_mcp_tool(
674
+ server_name="ppt",
675
+ tool_name="manage_text",
676
+ arguments={
677
+ "slide_index": 0,
678
+ "operation": "validate",
679
+ "shape_index": 0,
680
+ "validation_only": False, # Auto-fix enabled
681
+ "min_font_size": 10,
682
+ "max_font_size": 48
683
+ }
684
+ )
685
+ ```
686
+
687
+ ### Reading Slide Content with New Text Extraction Tools (v2.1)
688
+
689
+ ```python
690
+ # Extract text content from a specific slide - NEW TOOL
691
+ result = use_mcp_tool(
692
+ server_name="ppt",
693
+ tool_name="extract_slide_text",
694
+ arguments={
695
+ "slide_index": 0,
696
+ "presentation_id": presentation_id
697
+ }
698
+ )
699
+
700
+ # The result includes:
701
+ {
702
+ "success": True,
703
+ "slide_index": 0,
704
+ "text_content": {
705
+ "slide_title": "Quarterly Business Review",
706
+ "placeholders": [
707
+ {
708
+ "shape_index": 1,
709
+ "shape_name": "Subtitle Placeholder 2",
710
+ "text": "Q4 2024 Results",
711
+ "placeholder_type": "SUBTITLE",
712
+ "placeholder_idx": 1
713
+ }
714
+ ],
715
+ "text_shapes": [
716
+ {
717
+ "shape_index": 3,
718
+ "shape_name": "TextBox 4",
719
+ "text": "Revenue increased by 15%"
720
+ }
721
+ ],
722
+ "table_text": [],
723
+ "all_text_combined": "Quarterly Business Review\nQ4 2024 Results\nRevenue increased by 15%"
724
+ },
725
+ "total_text_shapes": 2,
726
+ "has_title": True,
727
+ "has_tables": False
728
+ }
729
+
730
+ # Extract text from all slides in the presentation - NEW TOOL
731
+ result = use_mcp_tool(
732
+ server_name="ppt",
733
+ tool_name="extract_presentation_text",
734
+ arguments={
735
+ "presentation_id": presentation_id,
736
+ "include_slide_info": True
737
+ }
738
+ )
739
+
740
+ # The result includes comprehensive text extraction:
741
+ {
742
+ "success": True,
743
+ "presentation_id": "pres_123",
744
+ "total_slides": 5,
745
+ "slides_with_text": 4,
746
+ "total_text_shapes": 12,
747
+ "slides_with_titles": 3,
748
+ "slides_with_tables": 1,
749
+ "slides_text": [...], # Detailed per-slide text content
750
+ "all_presentation_text_combined": "=== SLIDE 1 ===\nTitle Here\nContent here..."
751
+ }
752
+
753
+ # Extract text without additional slide metadata for cleaner output
754
+ result = use_mcp_tool(
755
+ server_name="ppt",
756
+ tool_name="extract_presentation_text",
757
+ arguments={
758
+ "presentation_id": presentation_id,
759
+ "include_slide_info": False
760
+ }
761
+ )
762
+ ```
763
+
764
+ ## Template Support
765
+
766
+ ### Working with Templates
767
+
768
+ The PowerPoint MCP Server provides comprehensive template support for creating presentations from existing template files. This feature enables:
769
+
770
+ - **Corporate branding** with predefined themes, layouts, and styles
771
+ - **Consistent presentations** across teams and projects
772
+ - **Custom slide masters** and specialized layouts
773
+ - **Pre-configured properties** and document settings
774
+ - **Flexible template discovery** with configurable search paths
775
+
776
+ ### Template File Requirements
777
+
778
+ - **Supported formats**: `.pptx` and `.potx` files
779
+ - **Existing content**: Templates can contain existing slides (preserved during creation)
780
+ - **Layout availability**: All custom layouts and slide masters are accessible
781
+ - **Search locations**: Configurable via `PPT_TEMPLATE_PATH` environment variable
782
+ - **Default search paths**: Current directory, `./templates`, `./assets`, `./resources`
783
+
784
+ ### Template Configuration
785
+
786
+ Set the `PPT_TEMPLATE_PATH` environment variable to specify custom template directories:
787
+
788
+ ```bash
789
+ # Unix/Linux/macOS
790
+ export PPT_TEMPLATE_PATH="/path/to/templates:/another/path"
791
+
792
+ # Windows
793
+ set PPT_TEMPLATE_PATH="C:\templates;C:\company_templates"
794
+ ```
795
+
796
+ ### Template Workflow
797
+
798
+ 1. **Inspect Template**: Use `get_template_info` to analyze available layouts and properties
799
+ 2. **Create from Template**: Use `create_presentation_from_template` with automatic theme preservation
800
+ 3. **Use Template Layouts**: Reference layout indices from template analysis when adding slides
801
+ 4. **Maintain Branding**: Template themes, fonts, and colors are automatically applied to new content
802
+
803
+ ### Professional Color Schemes
804
+
805
+ The server includes 4 built-in professional color schemes:
806
+ - **Modern Blue**: Microsoft-inspired blue theme with complementary colors
807
+ - **Corporate Gray**: Professional grayscale theme with blue accents
808
+ - **Elegant Green**: Forest green theme with cream and light green accents
809
+ - **Warm Red**: Deep red theme with orange and yellow accents
810
+
811
+ Each scheme includes primary, secondary, accent, light, and text colors optimized for business presentations.
812
+
813
+ ## 🎨 Built-in Slide Templates (New in v2.0)
814
+
815
+ The PowerPoint MCP Server now includes **25 professional slide templates** with advanced dynamic features. All templates support:
816
+
817
+ ### **Dynamic Features**
818
+ - **Automatic text sizing** based on content length and container dimensions
819
+ - **Intelligent text wrapping** to fit within specified areas
820
+ - **Visual effects** including shadows, glows, and outlines
821
+ - **Gradient backgrounds** with multi-layer compositions
822
+ - **Professional animations** ready for presentation delivery
823
+ - **Interactive hover effects** for enhanced user experience
824
+ - **Smart content overflow handling** with automatic adjustments
825
+
826
+ ### **Available Template Categories**
827
+
828
+ #### **Title & Introduction Slides**
829
+ - `title_slide` - Dynamic title slide with gradient background and text effects
830
+ - `chapter_intro` - Section divider with chapter numbering and styling
831
+ - `thank_you_slide` - Closing slide with contact information and effects
832
+
833
+ #### **Content Layout Slides**
834
+ - `text_with_image` - Text content with stylized image and interactive elements
835
+ - `two_column_text` - Two equal columns of text with dynamic sizing
836
+ - `two_column_text_images` - Two columns with text and corresponding images
837
+ - `three_column_layout` - Three equal columns with text and images
838
+ - `full_image_slide` - Large background image with text overlay
839
+
840
+ #### **Business & Analytics Slides**
841
+ - `key_metrics_dashboard` - Interactive metrics dashboard with animated counters
842
+ - `before_after_comparison` - Dynamic comparison layout with visual dividers
843
+ - `chart_comparison` - Two charts side by side for performance comparison
844
+ - `data_table_slide` - Slide focused on tabular data with professional styling
845
+ - `timeline_slide` - Horizontal timeline with milestones and effects
846
+
847
+ #### **Process & Flow Slides**
848
+ - `process_flow` - Step-by-step process visualization with enhanced effects
849
+ - `agenda_slide` - Table of contents or agenda overview with styling
850
+ - `quote_testimonial` - Featured quote or customer testimonial with effects
851
+
852
+ #### **Team & Organization Slides**
853
+ - `team_introduction` - Team member showcase with photos and roles
854
+
855
+ ### **Template Usage Examples**
856
+
857
+ ```python
858
+ # Browse all available templates
859
+ templates = use_mcp_tool("ppt", "list_slide_templates", {})
860
+
861
+ # Key templates with their features:
862
+ {
863
+ "title_slide": {
864
+ "features": ["Dynamic text sizing", "Gradient backgrounds", "Text effects"],
865
+ "elements": ["title", "subtitle", "author", "decorative_accent"]
866
+ },
867
+ "key_metrics_dashboard": {
868
+ "features": ["Animated counters", "Gradient containers", "Trend visualization"],
869
+ "elements": ["3 metric containers", "trend chart", "insights callout"]
870
+ },
871
+ "before_after_comparison": {
872
+ "features": ["Split gradient background", "VS divider", "Improvement arrow"],
873
+ "elements": ["before/after headers", "comparison content", "improvement metrics"]
874
+ }
875
+ }
876
+ ```
877
+
878
+ ### **Color Scheme Integration**
879
+ All templates work seamlessly with the 4 professional color schemes:
880
+ - **modern_blue**: Microsoft-inspired theme with dynamic gradients
881
+ - **corporate_gray**: Professional grayscale with blue accents
882
+ - **elegant_green**: Forest green with cream and light accents
883
+ - **warm_red**: Deep red with orange and yellow highlights
884
+
885
+ ### **Dynamic Content Adaptation**
886
+ Templates automatically adjust to content:
887
+ - **Font sizes** scale based on text length (8pt - 44pt range)
888
+ - **Line spacing** adjusts for readability (1.0x - 1.4x)
889
+ - **Text wrapping** intelligently breaks lines at optimal points
890
+ - **Container sizing** adapts to content overflow
891
+ - **Visual effects** scale appropriately with element sizes
892
+
893
+ ## 📁 File Structure
894
+
895
+ ```
896
+ Office-PowerPoint-MCP-Server/
897
+ ├── ppt_mcp_server.py # Main consolidated server (v2.0)
898
+ ├── slide_layout_templates.json # 25+ professional slide templates with dynamic features
899
+ ├── tools/ # 11 specialized tool modules (32 tools total)
900
+ │ ├── __init__.py
901
+ │ ├── presentation_tools.py # Presentation management (7 tools)
902
+ │ ├── content_tools.py # Content & slides (6 tools)
903
+ │ ├── template_tools.py # Template operations (7 tools)
904
+ │ ├── structural_tools.py # Tables, shapes, charts (4 tools)
905
+ │ ├── professional_tools.py # Themes, effects, fonts (3 tools)
906
+ │ ├── hyperlink_tools.py # Hyperlink management (1 tool)
907
+ │ ├── chart_tools.py # Advanced chart operations (1 tool)
908
+ │ ├── connector_tools.py # Connector lines/arrows (1 tool)
909
+ │ ├── master_tools.py # Slide master management (1 tool)
910
+ │ └── transition_tools.py # Slide transitions (1 tool)
911
+ ├── utils/ # 7 organized utility modules (68+ functions)
912
+ │ ├── __init__.py
913
+ │ ├── core_utils.py # Error handling & safe operations
914
+ │ ├── presentation_utils.py # Presentation management utilities
915
+ │ ├── content_utils.py # Content & slide operations
916
+ │ ├── design_utils.py # Themes, colors, effects & fonts
917
+ │ ├── template_utils.py # Template management & dynamic features
918
+ │ └── validation_utils.py # Text & layout validation
919
+ ├── setup_mcp.py # Interactive setup script
920
+ ├── pyproject.toml # Updated for v2.0
921
+ └── README.md # This documentation
922
+ ```
923
+
924
+ ## 🏗️ Architecture Benefits
925
+
926
+ ### **Modular Design**
927
+ - **7 focused utility modules** with clear responsibilities
928
+ - **11 organized tool modules** for comprehensive coverage
929
+ - **68+ utility functions** organized by functionality
930
+ - **32 MCP tools** covering all PowerPoint manipulation needs
931
+ - **Clear separation of concerns** for easier development
932
+
933
+ ### **Code Organization**
934
+ - **Logical grouping** of related functionality across modules
935
+ - **Better discoverability** with organized tool categories
936
+ - **Improved testability** with isolated modules
937
+ - **Future extensibility** through modular structure
938
+
939
+ ### **Comprehensive Coverage**
940
+ - **Complete PowerPoint lifecycle** from creation to presentation
941
+ - **Advanced template system** with auto-generation capabilities
942
+ - **Professional design tools** with multiple effects and styling options
943
+ - **Specialized features** including hyperlinks, connectors, and slide masters
944
+
945
+ ### **Developer Experience**
946
+ - **Clear responsibility boundaries** between modules
947
+ - **Easier debugging** with smaller, focused files
948
+ - **Simpler testing** with isolated functionality
949
+ - **Enhanced maintainability** through separation of concerns
950
+
951
+ ## 🔄 What's New in Version 2.0
952
+
953
+ **Enhanced functionality with comprehensive tool coverage!** The updated server provides:
954
+
955
+ ### **New Specialized Tools Added:**
956
+ - **`manage_hyperlinks`** - Complete hyperlink management for text elements
957
+ - **`update_chart_data`** - Advanced chart data replacement and updating
958
+ - **`add_connector`** - Connector lines and arrows between slide elements
959
+ - **`manage_slide_masters`** - Access to slide master properties and layouts
960
+ - **`manage_slide_transitions`** - Basic slide transition management
961
+ - **`auto_generate_presentation`** - AI-powered presentation generation
962
+ - **`optimize_slide_text`** - Text optimization for better readability
963
+
964
+ ### **Enhanced Existing Tools:**
965
+ - **`manage_text`** - Now supports text run formatting with `format_runs` operation
966
+ - **`create_presentation_from_templates`** - Enhanced template sequence processing
967
+ - **`apply_picture_effects`** - Expanded effect combinations and options
968
+
969
+ ## 🔄 What's New in Version 2.1
970
+
971
+ **Text extraction capabilities added!** Now you can read content from existing presentations:
972
+
973
+ ### **New Text Extraction Tools Added:**
974
+ - **`extract_slide_text`** - Extract all text content from a specific slide including titles, placeholders, text shapes, and tables
975
+ - **`extract_presentation_text`** - Extract text content from all slides in a presentation with comprehensive statistics and combined output
976
+
977
+ ### **Key Features of Text Extraction:**
978
+ - **Complete text coverage** - Extracts from titles, placeholders, text boxes, and table cells
979
+ - **Structured output** - Organized by content type (titles, placeholders, shapes, tables)
980
+ - **Presentation-wide analysis** - Statistics on text distribution across slides
981
+ - **Flexible output options** - Individual slide content or combined presentation text
982
+ - **Error handling** - Graceful handling of slides that cannot be processed
983
+
984
+ ## License
985
+
986
+ MIT
__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # PowerPoint MCP Server
mcp-config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mcpServers": {
3
+ "ppt": {
4
+ "command": "c:\\Office-PowerPoint-MCP-Server\\.venv\\Scripts\\python.exe",
5
+ "args": [
6
+ "c:\\Office-PowerPoint-MCP-Server\\ppt_mcp_server.py"
7
+ ],
8
+ "env": {
9
+ "PYTHONPATH": "c:\\Office-PowerPoint-MCP-Server",
10
+ "PPT_TEMPLATE_PATH": "c:\\Office-PowerPoint-MCP-Server\\templates"
11
+ }
12
+ }
13
+ }
14
+ }
mcp_all_tools_templates_effects_demo.pptx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2e1c60e525f71854d83ea313089c7e3850d353c894b6f2cd79703f4e9140ccf
3
+ size 124502
mcp_config_sample.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mcpServers": {
3
+ "word-document-server": {
4
+ "command": "D:\\BackDataService\\Office-Word-MCP-Server\\.venv\\Scripts\\python.exe",
5
+ "args": [
6
+ "D:\\BackDataService\\Office-Word-MCP-Server\\word_server.py"
7
+ ],
8
+ "env": {
9
+ "PYTHONPATH": "D:\\BackDataService\\Office-Word-MCP-Server"
10
+ }
11
+ }
12
+ }
13
+ }
ppt_mcp_server.py ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """
3
+ MCP Server for PowerPoint manipulation using python-pptx.
4
+ Consolidated version with 20 tools organized into multiple modules.
5
+ """
6
+ import os
7
+ import argparse
8
+ from typing import Dict, Any
9
+ from mcp.server.fastmcp import FastMCP
10
+
11
+ # import utils # Currently unused
12
+ from tools import (
13
+ register_presentation_tools,
14
+ register_content_tools,
15
+ register_structural_tools,
16
+ register_professional_tools,
17
+ register_template_tools,
18
+ register_hyperlink_tools,
19
+ register_chart_tools,
20
+ register_connector_tools,
21
+ register_master_tools,
22
+ register_transition_tools
23
+ )
24
+
25
+ # Initialize the FastMCP server
26
+ app = FastMCP(
27
+ name="ppt-mcp-server"
28
+ )
29
+
30
+ # Global state to store presentations in memory
31
+ presentations = {}
32
+ current_presentation_id = None
33
+
34
+ # Template configuration
35
+ def get_template_search_directories():
36
+ """
37
+ Get list of directories to search for templates.
38
+ Uses environment variable PPT_TEMPLATE_PATH if set, otherwise uses default directories.
39
+
40
+ Returns:
41
+ List of directories to search for templates
42
+ """
43
+ template_env_path = os.environ.get('PPT_TEMPLATE_PATH')
44
+
45
+ if template_env_path:
46
+ # If environment variable is set, use it as the primary template directory
47
+ # Support multiple paths separated by colon (Unix) or semicolon (Windows)
48
+ import platform
49
+ separator = ';' if platform.system() == "Windows" else ':'
50
+ env_dirs = [path.strip() for path in template_env_path.split(separator) if path.strip()]
51
+
52
+ # Verify that the directories exist
53
+ valid_env_dirs = []
54
+ for dir_path in env_dirs:
55
+ expanded_path = os.path.expanduser(dir_path)
56
+ if os.path.exists(expanded_path) and os.path.isdir(expanded_path):
57
+ valid_env_dirs.append(expanded_path)
58
+
59
+ if valid_env_dirs:
60
+ # Add default fallback directories
61
+ return valid_env_dirs + ['.', './templates', './assets', './resources']
62
+ else:
63
+ print(f"Warning: PPT_TEMPLATE_PATH directories not found: {template_env_path}")
64
+
65
+ # Default search directories when no environment variable or invalid paths
66
+ return ['.', './templates', './assets', './resources']
67
+
68
+ # ---- Helper Functions ----
69
+
70
+ def get_current_presentation():
71
+ """Get the current presentation object or raise an error if none is loaded."""
72
+ if current_presentation_id is None or current_presentation_id not in presentations:
73
+ raise ValueError("No presentation is currently loaded. Please create or open a presentation first.")
74
+ return presentations[current_presentation_id]
75
+
76
+ def get_current_presentation_id():
77
+ """Get the current presentation ID."""
78
+ return current_presentation_id
79
+
80
+ def set_current_presentation_id(pres_id):
81
+ """Set the current presentation ID."""
82
+ global current_presentation_id
83
+ current_presentation_id = pres_id
84
+
85
+ def validate_parameters(params):
86
+ """
87
+ Validate parameters against constraints.
88
+
89
+ Args:
90
+ params: Dictionary of parameter name: (value, constraints) pairs
91
+
92
+ Returns:
93
+ (True, None) if all valid, or (False, error_message) if invalid
94
+ """
95
+ for param_name, (value, constraints) in params.items():
96
+ for constraint_func, error_msg in constraints:
97
+ if not constraint_func(value):
98
+ return False, f"Parameter '{param_name}': {error_msg}"
99
+ return True, None
100
+
101
+ def is_positive(value):
102
+ """Check if a value is positive."""
103
+ return value > 0
104
+
105
+ def is_non_negative(value):
106
+ """Check if a value is non-negative."""
107
+ return value >= 0
108
+
109
+ def is_in_range(min_val, max_val):
110
+ """Create a function that checks if a value is in a range."""
111
+ return lambda x: min_val <= x <= max_val
112
+
113
+ def is_in_list(valid_list):
114
+ """Create a function that checks if a value is in a list."""
115
+ return lambda x: x in valid_list
116
+
117
+ def is_valid_rgb(color_list):
118
+ """Check if a color list is a valid RGB tuple."""
119
+ if not isinstance(color_list, list) or len(color_list) != 3:
120
+ return False
121
+ return all(isinstance(c, int) and 0 <= c <= 255 for c in color_list)
122
+
123
+ def add_shape_direct(slide, shape_type: str, left: float, top: float, width: float, height: float) -> Any:
124
+ """
125
+ Add an auto shape to a slide using direct integer values instead of enum objects.
126
+
127
+ This implementation provides a reliable alternative that bypasses potential
128
+ enum-related issues in the python-pptx library.
129
+
130
+ Args:
131
+ slide: The slide object
132
+ shape_type: Shape type string (e.g., 'rectangle', 'oval', 'triangle')
133
+ left: Left position in inches
134
+ top: Top position in inches
135
+ width: Width in inches
136
+ height: Height in inches
137
+
138
+ Returns:
139
+ The created shape
140
+ """
141
+ from pptx.util import Inches
142
+
143
+ # Direct mapping of shape types to their integer values
144
+ # These values are directly from the MS Office VBA documentation
145
+ shape_type_map = {
146
+ 'rectangle': 1,
147
+ 'rounded_rectangle': 2,
148
+ 'oval': 9,
149
+ 'diamond': 4,
150
+ 'triangle': 5, # This is ISOSCELES_TRIANGLE
151
+ 'right_triangle': 6,
152
+ 'pentagon': 56,
153
+ 'hexagon': 10,
154
+ 'heptagon': 11,
155
+ 'octagon': 12,
156
+ 'star': 12, # This is STAR_5_POINTS (value 12)
157
+ 'arrow': 13,
158
+ 'cloud': 35,
159
+ 'heart': 21,
160
+ 'lightning_bolt': 22,
161
+ 'sun': 23,
162
+ 'moon': 24,
163
+ 'smiley_face': 17,
164
+ 'no_symbol': 19,
165
+ 'flowchart_process': 112,
166
+ 'flowchart_decision': 114,
167
+ 'flowchart_data': 115,
168
+ 'flowchart_document': 119
169
+ }
170
+
171
+ # Check if shape type is valid before trying to use it
172
+ shape_type_lower = str(shape_type).lower()
173
+ if shape_type_lower not in shape_type_map:
174
+ available_shapes = ', '.join(sorted(shape_type_map.keys()))
175
+ raise ValueError(f"Unsupported shape type: '{shape_type}'. Available shape types: {available_shapes}")
176
+
177
+ # Get the integer value for the shape type
178
+ shape_value = shape_type_map[shape_type_lower]
179
+
180
+ # Create the shape using the direct integer value
181
+ try:
182
+ # The integer value is passed directly to add_shape
183
+ shape = slide.shapes.add_shape(
184
+ shape_value, Inches(left), Inches(top), Inches(width), Inches(height)
185
+ )
186
+ return shape
187
+ except Exception as e:
188
+ raise ValueError(f"Failed to create '{shape_type}' shape using direct value {shape_value}: {str(e)}")
189
+
190
+ # ---- Custom presentation management wrapper ----
191
+
192
+ class PresentationManager:
193
+ """Wrapper to handle presentation state updates."""
194
+
195
+ def __init__(self, presentations_dict):
196
+ self.presentations = presentations_dict
197
+
198
+ def store_presentation(self, pres, pres_id):
199
+ """Store a presentation and set it as current."""
200
+ self.presentations[pres_id] = pres
201
+ set_current_presentation_id(pres_id)
202
+ return pres_id
203
+
204
+ # ---- Register Tools ----
205
+
206
+ # Create presentation manager wrapper
207
+ presentation_manager = PresentationManager(presentations)
208
+
209
+ # Wrapper functions to handle state management
210
+ def create_presentation_wrapper(original_func):
211
+ """Wrapper to handle presentation creation with state management."""
212
+ def wrapper(*args, **kwargs):
213
+ result = original_func(*args, **kwargs)
214
+ if "presentation_id" in result and result["presentation_id"] in presentations:
215
+ set_current_presentation_id(result["presentation_id"])
216
+ return result
217
+ return wrapper
218
+
219
+ def open_presentation_wrapper(original_func):
220
+ """Wrapper to handle presentation opening with state management."""
221
+ def wrapper(*args, **kwargs):
222
+ result = original_func(*args, **kwargs)
223
+ if "presentation_id" in result and result["presentation_id"] in presentations:
224
+ set_current_presentation_id(result["presentation_id"])
225
+ return result
226
+ return wrapper
227
+
228
+ # Register all tool modules
229
+ register_presentation_tools(
230
+ app,
231
+ presentations,
232
+ get_current_presentation_id,
233
+ get_template_search_directories
234
+ )
235
+
236
+ register_content_tools(
237
+ app,
238
+ presentations,
239
+ get_current_presentation_id,
240
+ validate_parameters,
241
+ is_positive,
242
+ is_non_negative,
243
+ is_in_range,
244
+ is_valid_rgb
245
+ )
246
+
247
+ register_structural_tools(
248
+ app,
249
+ presentations,
250
+ get_current_presentation_id,
251
+ validate_parameters,
252
+ is_positive,
253
+ is_non_negative,
254
+ is_in_range,
255
+ is_valid_rgb,
256
+ add_shape_direct
257
+ )
258
+
259
+ register_professional_tools(
260
+ app,
261
+ presentations,
262
+ get_current_presentation_id
263
+ )
264
+
265
+ register_template_tools(
266
+ app,
267
+ presentations,
268
+ get_current_presentation_id
269
+ )
270
+
271
+ register_hyperlink_tools(
272
+ app,
273
+ presentations,
274
+ get_current_presentation_id,
275
+ validate_parameters,
276
+ is_positive,
277
+ is_non_negative,
278
+ is_in_range,
279
+ is_valid_rgb
280
+ )
281
+
282
+ register_chart_tools(
283
+ app,
284
+ presentations,
285
+ get_current_presentation_id,
286
+ validate_parameters,
287
+ is_positive,
288
+ is_non_negative,
289
+ is_in_range,
290
+ is_valid_rgb
291
+ )
292
+
293
+
294
+ register_connector_tools(
295
+ app,
296
+ presentations,
297
+ get_current_presentation_id,
298
+ validate_parameters,
299
+ is_positive,
300
+ is_non_negative,
301
+ is_in_range,
302
+ is_valid_rgb
303
+ )
304
+
305
+ register_master_tools(
306
+ app,
307
+ presentations,
308
+ get_current_presentation_id,
309
+ validate_parameters,
310
+ is_positive,
311
+ is_non_negative,
312
+ is_in_range,
313
+ is_valid_rgb
314
+ )
315
+
316
+ register_transition_tools(
317
+ app,
318
+ presentations,
319
+ get_current_presentation_id,
320
+ validate_parameters,
321
+ is_positive,
322
+ is_non_negative,
323
+ is_in_range,
324
+ is_valid_rgb
325
+ )
326
+
327
+
328
+ # ---- Additional Utility Tools ----
329
+
330
+ @app.tool()
331
+ def list_presentations() -> Dict:
332
+ """List all loaded presentations."""
333
+ return {
334
+ "presentations": [
335
+ {
336
+ "id": pres_id,
337
+ "slide_count": len(pres.slides),
338
+ "is_current": pres_id == current_presentation_id
339
+ }
340
+ for pres_id, pres in presentations.items()
341
+ ],
342
+ "current_presentation_id": current_presentation_id,
343
+ "total_presentations": len(presentations)
344
+ }
345
+
346
+ @app.tool()
347
+ def switch_presentation(presentation_id: str) -> Dict:
348
+ """Switch to a different loaded presentation."""
349
+ if presentation_id not in presentations:
350
+ return {
351
+ "error": f"Presentation '{presentation_id}' not found. Available presentations: {list(presentations.keys())}"
352
+ }
353
+
354
+ global current_presentation_id
355
+ old_id = current_presentation_id
356
+ current_presentation_id = presentation_id
357
+
358
+ return {
359
+ "message": f"Switched from presentation '{old_id}' to '{presentation_id}'",
360
+ "previous_presentation_id": old_id,
361
+ "current_presentation_id": current_presentation_id
362
+ }
363
+
364
+ @app.tool()
365
+ def get_server_info() -> Dict:
366
+ """Get information about the MCP server."""
367
+ return {
368
+ "name": "PowerPoint MCP Server - Enhanced Edition",
369
+ "version": "2.1.0",
370
+ "total_tools": 32, # Organized into 11 specialized modules
371
+ "loaded_presentations": len(presentations),
372
+ "current_presentation": current_presentation_id,
373
+ "features": [
374
+ "Presentation Management (7 tools)",
375
+ "Content Management (6 tools)",
376
+ "Template Operations (7 tools)",
377
+ "Structural Elements (4 tools)",
378
+ "Professional Design (3 tools)",
379
+ "Specialized Features (5 tools)"
380
+ ],
381
+ "improvements": [
382
+ "32 specialized tools organized into 11 focused modules",
383
+ "68+ utility functions across 7 organized utility modules",
384
+ "Enhanced parameter handling and validation",
385
+ "Unified operation interfaces with comprehensive coverage",
386
+ "Advanced template system with auto-generation capabilities",
387
+ "Professional design tools with multiple effects and styling",
388
+ "Specialized features including hyperlinks, connectors, slide masters",
389
+ "Dynamic text sizing and intelligent wrapping",
390
+ "Advanced visual effects and styling",
391
+ "Content-aware optimization and validation",
392
+ "Complete PowerPoint lifecycle management",
393
+ "Modular architecture for better maintainability"
394
+ ],
395
+ "new_enhanced_features": [
396
+ "Hyperlink Management - Add, update, remove, and list hyperlinks in text",
397
+ "Advanced Chart Data Updates - Replace chart data with new categories and series",
398
+ "Advanced Text Run Formatting - Apply formatting to specific text runs",
399
+ "Shape Connectors - Add connector lines and arrows between points",
400
+ "Slide Master Management - Access and manage slide masters and layouts",
401
+ "Slide Transitions - Basic transition management (placeholder for future)"
402
+ ]
403
+ }
404
+
405
+ # ---- Main Function ----
406
+ def main(transport: str = "stdio", port: int = 8001):
407
+ if transport == "http":
408
+ import asyncio
409
+ # Set the port for HTTP transport
410
+ app.settings.port = port
411
+ # Start the FastMCP server with HTTP transport
412
+ try:
413
+ app.run(transport='streamable-http')
414
+ except asyncio.exceptions.CancelledError:
415
+ print("Server stopped by user.")
416
+ except KeyboardInterrupt:
417
+ print("Server stopped by user.")
418
+ except Exception as e:
419
+ print(f"Error starting server: {e}")
420
+
421
+ elif transport == "sse":
422
+ # Run the FastMCP server in SSE (Server Side Events) mode
423
+ app.run(transport='sse')
424
+
425
+ else:
426
+ # Run the FastMCP server
427
+ app.run(transport='stdio')
428
+
429
+ if __name__ == "__main__":
430
+ # Parse command line arguments
431
+ parser = argparse.ArgumentParser(description="MCP Server for PowerPoint manipulation using python-pptx")
432
+
433
+ parser.add_argument(
434
+ "-t",
435
+ "--transport",
436
+ type=str,
437
+ default="stdio",
438
+ choices=["stdio", "http", "sse"],
439
+ help="Transport method for the MCP server (default: stdio)"
440
+ )
441
+
442
+ parser.add_argument(
443
+ "-p",
444
+ "--port",
445
+ type=int,
446
+ default=8001,
447
+ help="Port to run the MCP server on (default: 8001)"
448
+ )
449
+ args = parser.parse_args()
450
+ main(args.transport, args.port)
pyproject.toml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "office-powerpoint-mcp-server"
7
+ version = "2.0.6"
8
+ description = "MCP Server for PowerPoint manipulation using python-pptx - Consolidated Edition"
9
+ readme = "README.md"
10
+ license = {file = "LICENSE"}
11
+ authors = [
12
+ {name = "GongRzhe", email = "gongrzhe@gmail.com"}
13
+ ]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ requires-python = ">=3.6"
20
+ dependencies = [
21
+ "python-pptx>=0.6.21",
22
+ "mcp[cli]>=1.3.0",
23
+ "Pillow>=8.0.0",
24
+ "fonttools>=4.0.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ "Homepage" = "https://github.com/GongRzhe/Office-PowerPoint-MCP-Server.git"
29
+ "Bug Tracker" = "https://github.com/GongRzhe/Office-PowerPoint-MCP-Server.git/issues"
30
+
31
+ [tool.hatch.build.targets.wheel]
32
+ only-include = ["ppt_mcp_server.py", "tools/", "utils/", "enhanced_slide_templates.json", "slide_layout_templates.json"]
33
+ sources = ["."]
34
+
35
+ [tool.hatch.build]
36
+ exclude = [
37
+ "public/demo.mp4",
38
+ "public/demo.gif",
39
+ "*.pptx"
40
+ ]
41
+
42
+ [project.scripts]
43
+ ppt_mcp_server = "ppt_mcp_server:main"
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ mcp[cli]
2
+ python-pptx
3
+ Pillow
4
+ fonttools
setup_mcp.py ADDED
@@ -0,0 +1,561 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary Python standard libraries
2
+ import os # For operating with file system, handling files and directory paths
3
+ import json # For processing JSON format data
4
+ import subprocess # For creating and managing subprocesses
5
+ import sys # For accessing Python interpreter related variables and functions
6
+ import platform # For getting current operating system information
7
+ import shutil # For checking if executables exist in PATH
8
+
9
+ def check_prerequisites():
10
+ """
11
+ Check if necessary prerequisites are installed
12
+
13
+ Returns:
14
+ tuple: (python_ok, uv_installed, uvx_installed, ppt_server_installed)
15
+ """
16
+ # Check Python version
17
+ python_version = sys.version_info
18
+ python_ok = python_version.major >= 3 and python_version.minor >= 6
19
+
20
+ # Check if uv/uvx is installed
21
+ uv_installed = shutil.which("uv") is not None
22
+ uvx_installed = shutil.which("uvx") is not None
23
+
24
+ # Check if office-powerpoint-mcp-server is already installed via pip
25
+ try:
26
+ result = subprocess.run(
27
+ [sys.executable, "-m", "pip", "show", "office-powerpoint-mcp-server"],
28
+ capture_output=True,
29
+ text=True,
30
+ check=False
31
+ )
32
+ ppt_server_installed = result.returncode == 0
33
+ except Exception:
34
+ ppt_server_installed = False
35
+
36
+ return (python_ok, uv_installed, uvx_installed, ppt_server_installed)
37
+
38
+ def setup_venv():
39
+ """
40
+ Function to set up Python virtual environment
41
+
42
+ Features:
43
+ - Checks if Python version meets requirements (3.6+)
44
+ - Creates Python virtual environment (if it doesn't exist)
45
+ - Installs required dependencies in the newly created virtual environment
46
+
47
+ No parameters required
48
+
49
+ Returns: Path to Python interpreter in the virtual environment
50
+ """
51
+ # Check Python version
52
+ python_version = sys.version_info
53
+ if python_version.major < 3 or (python_version.major == 3 and python_version.minor < 6):
54
+ print("Error: Python 3.6 or higher is required.")
55
+ sys.exit(1)
56
+
57
+ # Get absolute path of the directory containing the current script
58
+ base_path = os.path.abspath(os.path.dirname(__file__))
59
+ # Set virtual environment directory path
60
+ venv_path = os.path.join(base_path, '.venv')
61
+
62
+ # Determine pip and python executable paths based on operating system
63
+ is_windows = platform.system() == "Windows"
64
+ if is_windows:
65
+ pip_path = os.path.join(venv_path, 'Scripts', 'pip.exe')
66
+ python_path = os.path.join(venv_path, 'Scripts', 'python.exe')
67
+ else:
68
+ pip_path = os.path.join(venv_path, 'bin', 'pip')
69
+ python_path = os.path.join(venv_path, 'bin', 'python')
70
+
71
+ # Check if virtual environment already exists and is valid
72
+ venv_exists = os.path.exists(venv_path)
73
+ pip_exists = os.path.exists(pip_path)
74
+
75
+ if not venv_exists or not pip_exists:
76
+ print("Creating new virtual environment...")
77
+ # Remove existing venv if it's invalid
78
+ if venv_exists and not pip_exists:
79
+ print("Existing virtual environment is incomplete, recreating it...")
80
+ try:
81
+ shutil.rmtree(venv_path)
82
+ except Exception as e:
83
+ print(f"Warning: Could not remove existing virtual environment: {e}")
84
+ print("Please delete the .venv directory manually and try again.")
85
+ sys.exit(1)
86
+
87
+ # Create virtual environment
88
+ try:
89
+ subprocess.run([sys.executable, '-m', 'venv', venv_path], check=True)
90
+ print("Virtual environment created successfully!")
91
+ except subprocess.CalledProcessError as e:
92
+ print(f"Error creating virtual environment: {e}")
93
+ sys.exit(1)
94
+ else:
95
+ print("Valid virtual environment already exists.")
96
+
97
+ # Double-check that pip exists after creating venv
98
+ if not os.path.exists(pip_path):
99
+ print(f"Error: pip executable not found at {pip_path}")
100
+ print("Try creating the virtual environment manually with: python -m venv .venv")
101
+ sys.exit(1)
102
+
103
+ # Install or update dependencies
104
+ print("\nInstalling requirements...")
105
+ try:
106
+ # Install mcp package
107
+ subprocess.run([pip_path, 'install', 'mcp[cli]'], check=True)
108
+ # Install python-pptx package
109
+ subprocess.run([pip_path, 'install', 'python-pptx'], check=True)
110
+
111
+ # Also install dependencies from requirements.txt if it exists
112
+ requirements_path = os.path.join(base_path, 'requirements.txt')
113
+ if os.path.exists(requirements_path):
114
+ subprocess.run([pip_path, 'install', '-r', requirements_path], check=True)
115
+
116
+
117
+ print("Requirements installed successfully!")
118
+ except subprocess.CalledProcessError as e:
119
+ print(f"Error installing requirements: {e}")
120
+ sys.exit(1)
121
+ except FileNotFoundError:
122
+ print(f"Error: Could not execute {pip_path}")
123
+ print("Try activating the virtual environment manually and installing requirements:")
124
+ if is_windows:
125
+ print(f".venv\\Scripts\\activate")
126
+ else:
127
+ print("source .venv/bin/activate")
128
+ print("pip install mcp[cli] python-pptx")
129
+ sys.exit(1)
130
+
131
+ return python_path
132
+
133
+ def generate_mcp_config_local(python_path):
134
+ """
135
+ Generate MCP configuration for locally installed office-powerpoint-mcp-server
136
+
137
+ Parameters:
138
+ - python_path: Path to Python interpreter in the virtual environment
139
+
140
+ Returns: Path to the generated config file
141
+ """
142
+ # Get absolute path of the directory containing the current script
143
+ base_path = os.path.abspath(os.path.dirname(__file__))
144
+
145
+ # Path to PowerPoint Server script
146
+ server_script_path = os.path.join(base_path, 'ppt_mcp_server.py')
147
+
148
+ # Path to templates directory
149
+ templates_path = os.path.join(base_path, 'templates')
150
+
151
+ # Create MCP configuration dictionary
152
+ config = {
153
+ "mcpServers": {
154
+ "ppt": {
155
+ "command": python_path,
156
+ "args": [server_script_path],
157
+ "env": {
158
+ "PYTHONPATH": base_path,
159
+ "PPT_TEMPLATE_PATH": templates_path
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ # Save configuration to JSON file
166
+ config_path = os.path.join(base_path, 'mcp-config.json')
167
+ with open(config_path, 'w') as f:
168
+ json.dump(config, f, indent=2) # indent=2 gives the JSON file good formatting
169
+
170
+ return config_path
171
+
172
+ def generate_mcp_config_uvx():
173
+ """
174
+ Generate MCP configuration for PyPI-installed office-powerpoint-mcp-server using UVX
175
+
176
+ Returns: Path to the generated config file
177
+ """
178
+ # Get absolute path of the directory containing the current script
179
+ base_path = os.path.abspath(os.path.dirname(__file__))
180
+
181
+ # Path to templates directory (optional for UVX installs)
182
+ templates_path = os.path.join(base_path, 'templates')
183
+
184
+ # Create MCP configuration dictionary
185
+ env_config = {}
186
+ if os.path.exists(templates_path):
187
+ env_config["PPT_TEMPLATE_PATH"] = templates_path
188
+
189
+ config = {
190
+ "mcpServers": {
191
+ "ppt": {
192
+ "command": "uvx",
193
+ "args": ["--from", "office-powerpoint-mcp-server", "ppt_mcp_server"],
194
+ "env": env_config
195
+ }
196
+ }
197
+ }
198
+
199
+ # Save configuration to JSON file
200
+ config_path = os.path.join(base_path, 'mcp-config.json')
201
+ with open(config_path, 'w') as f:
202
+ json.dump(config, f, indent=2) # indent=2 gives the JSON file good formatting
203
+
204
+ return config_path
205
+
206
+ def generate_mcp_config_module():
207
+ """
208
+ Generate MCP configuration for PyPI-installed office-powerpoint-mcp-server using Python module
209
+
210
+ Returns: Path to the generated config file
211
+ """
212
+ # Get absolute path of the directory containing the current script
213
+ base_path = os.path.abspath(os.path.dirname(__file__))
214
+
215
+ # Path to templates directory (optional for module installs)
216
+ templates_path = os.path.join(base_path, 'templates')
217
+
218
+ # Create MCP configuration dictionary
219
+ env_config = {}
220
+ if os.path.exists(templates_path):
221
+ env_config["PPT_TEMPLATE_PATH"] = templates_path
222
+
223
+ config = {
224
+ "mcpServers": {
225
+ "ppt": {
226
+ "command": sys.executable,
227
+ "args": ["-m", "office_powerpoint_mcp_server"],
228
+ "env": env_config
229
+ }
230
+ }
231
+ }
232
+
233
+ # Save configuration to JSON file
234
+ config_path = os.path.join(base_path, 'mcp-config.json')
235
+ with open(config_path, 'w') as f:
236
+ json.dump(config, f, indent=2) # indent=2 gives the JSON file good formatting
237
+
238
+ return config_path
239
+
240
+ def install_from_pypi():
241
+ """
242
+ Install office-powerpoint-mcp-server from PyPI
243
+
244
+ Returns: True if successful, False otherwise
245
+ """
246
+ print("\nInstalling office-powerpoint-mcp-server from PyPI...")
247
+ try:
248
+ subprocess.run([sys.executable, "-m", "pip", "install", "office-powerpoint-mcp-server"], check=True)
249
+ print("office-powerpoint-mcp-server successfully installed from PyPI!")
250
+ return True
251
+ except subprocess.CalledProcessError:
252
+ print("Failed to install office-powerpoint-mcp-server from PyPI.")
253
+ return False
254
+
255
+ def print_config_instructions(config_path):
256
+ """
257
+ Print instructions for using the generated config
258
+
259
+ Parameters:
260
+ - config_path: Path to the generated config file
261
+ """
262
+ print(f"\nMCP configuration has been written to: {config_path}")
263
+
264
+ with open(config_path, 'r') as f:
265
+ config = json.load(f)
266
+
267
+ print("\nMCP configuration for Claude Desktop:")
268
+ print(json.dumps(config, indent=2))
269
+
270
+ # Provide instructions for adding configuration to Claude Desktop configuration file
271
+ if platform.system() == "Windows":
272
+ claude_config_path = os.path.expandvars("%APPDATA%\\Claude\\claude_desktop_config.json")
273
+ else: # macOS
274
+ claude_config_path = os.path.expanduser("~/Library/Application Support/Claude/claude_desktop_config.json")
275
+
276
+ print(f"\nTo use with Claude Desktop, merge this configuration into: {claude_config_path}")
277
+
278
+ def create_package_structure():
279
+ """
280
+ Create necessary package structure and directories
281
+ """
282
+ # Get absolute path of the directory containing the current script
283
+ base_path = os.path.abspath(os.path.dirname(__file__))
284
+
285
+ # Create __init__.py file
286
+ init_path = os.path.join(base_path, '__init__.py')
287
+ if not os.path.exists(init_path):
288
+ with open(init_path, 'w') as f:
289
+ f.write('# PowerPoint MCP Server')
290
+ print(f"Created __init__.py at: {init_path}")
291
+
292
+ # Create requirements.txt file
293
+ requirements_path = os.path.join(base_path, 'requirements.txt')
294
+ if not os.path.exists(requirements_path):
295
+ with open(requirements_path, 'w') as f:
296
+ f.write('mcp[cli]\npython-pptx\n')
297
+ print(f"Created requirements.txt at: {requirements_path}")
298
+
299
+ # Create templates directory for PowerPoint templates
300
+ templates_dir = os.path.join(base_path, 'templates')
301
+ if not os.path.exists(templates_dir):
302
+ os.makedirs(templates_dir)
303
+ print(f"Created templates directory at: {templates_dir}")
304
+
305
+ # Create a README file in templates directory
306
+ readme_path = os.path.join(templates_dir, 'README.md')
307
+ with open(readme_path, 'w') as f:
308
+ f.write("""# PowerPoint Templates
309
+
310
+ This directory is for storing PowerPoint template files (.pptx or .potx) that can be used with the MCP server.
311
+
312
+ ## Usage
313
+
314
+ 1. Place your template files in this directory
315
+ 2. Use the `create_presentation_from_template` tool with the template filename
316
+ 3. The server will automatically search for templates in this directory
317
+
318
+ ## Supported Formats
319
+
320
+ - `.pptx` - PowerPoint presentation files
321
+ - `.potx` - PowerPoint template files
322
+
323
+ ## Example
324
+
325
+ ```python
326
+ # Create presentation from template
327
+ result = create_presentation_from_template("company_template.pptx")
328
+ ```
329
+
330
+ The server will search for templates in:
331
+ - Current directory
332
+ - ./templates/ (this directory)
333
+ - ./assets/
334
+ - ./resources/
335
+ """)
336
+ print(f"Created templates README at: {readme_path}")
337
+
338
+ # Offer to create a sample template
339
+ create_sample = input("\nWould you like to create a sample template for testing? (y/n): ").lower().strip()
340
+ if create_sample in ['y', 'yes']:
341
+ create_sample_template(templates_dir)
342
+
343
+ def create_sample_template(templates_dir):
344
+ """
345
+ Create a sample PowerPoint template for testing
346
+
347
+ Parameters:
348
+ - templates_dir: Directory where templates are stored
349
+ """
350
+ try:
351
+ # Import required modules for creating a sample template
352
+ from pptx import Presentation
353
+ from pptx.util import Inches, Pt
354
+ from pptx.dml.color import RGBColor
355
+ from pptx.enum.text import PP_ALIGN
356
+
357
+ print("Creating sample template...")
358
+
359
+ # Create a new presentation
360
+ prs = Presentation()
361
+
362
+ # Get the title slide layout
363
+ title_slide_layout = prs.slide_layouts[0]
364
+ slide = prs.slides.add_slide(title_slide_layout)
365
+
366
+ # Set title and subtitle
367
+ title = slide.shapes.title
368
+ subtitle = slide.placeholders[1]
369
+
370
+ title.text = "Sample Company Template"
371
+ subtitle.text = "Professional Presentation Template\nCreated by PowerPoint MCP Server"
372
+
373
+ # Format title
374
+ title_paragraph = title.text_frame.paragraphs[0]
375
+ title_paragraph.font.size = Pt(44)
376
+ title_paragraph.font.bold = True
377
+ title_paragraph.font.color.rgb = RGBColor(31, 73, 125) # Dark blue
378
+
379
+ # Format subtitle
380
+ for paragraph in subtitle.text_frame.paragraphs:
381
+ paragraph.font.size = Pt(18)
382
+ paragraph.font.color.rgb = RGBColor(68, 84, 106) # Gray blue
383
+ paragraph.alignment = PP_ALIGN.CENTER
384
+
385
+ # Add a content slide
386
+ content_slide_layout = prs.slide_layouts[1]
387
+ content_slide = prs.slides.add_slide(content_slide_layout)
388
+
389
+ content_title = content_slide.shapes.title
390
+ content_title.text = "Sample Content Slide"
391
+
392
+ # Add bullet points to content
393
+ content_placeholder = content_slide.placeholders[1]
394
+ text_frame = content_placeholder.text_frame
395
+ text_frame.text = "Key Features"
396
+
397
+ # Add bullet points
398
+ bullet_points = [
399
+ "Professional theme and colors",
400
+ "Custom layouts and placeholders",
401
+ "Ready for content creation",
402
+ "Compatible with MCP server tools"
403
+ ]
404
+
405
+ for point in bullet_points:
406
+ p = text_frame.add_paragraph()
407
+ p.text = point
408
+ p.level = 1
409
+
410
+ # Add a section header slide
411
+ section_slide_layout = prs.slide_layouts[2] if len(prs.slide_layouts) > 2 else prs.slide_layouts[0]
412
+ section_slide = prs.slides.add_slide(section_slide_layout)
413
+
414
+ if section_slide.shapes.title:
415
+ section_slide.shapes.title.text = "Template Features"
416
+
417
+ # Save the sample template
418
+ template_path = os.path.join(templates_dir, 'sample_template.pptx')
419
+ prs.save(template_path)
420
+
421
+ print(f"✅ Sample template created: {template_path}")
422
+ print(" You can now test the template feature with:")
423
+ print(" • get_template_info('sample_template.pptx')")
424
+ print(" • create_presentation_from_template('sample_template.pptx')")
425
+
426
+ except ImportError:
427
+ print("⚠️ Cannot create sample template: python-pptx not installed yet")
428
+ print(" Run the setup first, then manually create templates in the templates/ directory")
429
+ except Exception as e:
430
+ print(f"❌ Failed to create sample template: {str(e)}")
431
+ print(" You can manually add template files to the templates/ directory")
432
+
433
+ # Main execution entry point
434
+ if __name__ == '__main__':
435
+ # Check prerequisites
436
+ python_ok, uv_installed, uvx_installed, ppt_server_installed = check_prerequisites()
437
+
438
+ if not python_ok:
439
+ print("Error: Python 3.6 or higher is required.")
440
+ sys.exit(1)
441
+
442
+ print("PowerPoint MCP Server Setup")
443
+ print("===========================\n")
444
+
445
+ # Create necessary files
446
+ create_package_structure()
447
+
448
+ # If office-powerpoint-mcp-server is already installed, offer config options
449
+ if ppt_server_installed:
450
+ print("office-powerpoint-mcp-server is already installed via pip.")
451
+
452
+ if uvx_installed:
453
+ print("\nOptions:")
454
+ print("1. Generate MCP config for UVX (recommended)")
455
+ print("2. Generate MCP config for Python module")
456
+ print("3. Set up local development environment")
457
+
458
+ choice = input("\nEnter your choice (1-3): ")
459
+
460
+ if choice == "1":
461
+ config_path = generate_mcp_config_uvx()
462
+ print_config_instructions(config_path)
463
+ elif choice == "2":
464
+ config_path = generate_mcp_config_module()
465
+ print_config_instructions(config_path)
466
+ elif choice == "3":
467
+ python_path = setup_venv()
468
+ config_path = generate_mcp_config_local(python_path)
469
+ print_config_instructions(config_path)
470
+ else:
471
+ print("Invalid choice. Exiting.")
472
+ sys.exit(1)
473
+ else:
474
+ print("\nOptions:")
475
+ print("1. Generate MCP config for Python module")
476
+ print("2. Set up local development environment")
477
+
478
+ choice = input("\nEnter your choice (1-2): ")
479
+
480
+ if choice == "1":
481
+ config_path = generate_mcp_config_module()
482
+ print_config_instructions(config_path)
483
+ elif choice == "2":
484
+ python_path = setup_venv()
485
+ config_path = generate_mcp_config_local(python_path)
486
+ print_config_instructions(config_path)
487
+ else:
488
+ print("Invalid choice. Exiting.")
489
+ sys.exit(1)
490
+
491
+ # If office-powerpoint-mcp-server is not installed, offer installation options
492
+ else:
493
+ print("office-powerpoint-mcp-server is not installed.")
494
+
495
+ print("\nOptions:")
496
+ print("1. Install from PyPI (recommended)")
497
+ print("2. Set up local development environment")
498
+
499
+ choice = input("\nEnter your choice (1-2): ")
500
+
501
+ if choice == "1":
502
+ if install_from_pypi():
503
+ if uvx_installed:
504
+ print("\nNow generating MCP config for UVX...")
505
+ config_path = generate_mcp_config_uvx()
506
+ else:
507
+ print("\nUVX not found. Generating MCP config for Python module...")
508
+ config_path = generate_mcp_config_module()
509
+ print_config_instructions(config_path)
510
+ elif choice == "2":
511
+ python_path = setup_venv()
512
+ config_path = generate_mcp_config_local(python_path)
513
+ print_config_instructions(config_path)
514
+ else:
515
+ print("Invalid choice. Exiting.")
516
+ sys.exit(1)
517
+
518
+ print("\nSetup complete! You can now use the PowerPoint MCP server with compatible clients like Claude Desktop.")
519
+
520
+ print("\n" + "="*60)
521
+ print("POWERPOINT MCP SERVER - NEW FEATURES")
522
+ print("="*60)
523
+ print("\n📁 Template Support:")
524
+ print(" • Place PowerPoint templates (.pptx/.potx) in the ./templates/ directory")
525
+ print(" • Use 'create_presentation_from_template' tool to create presentations from templates")
526
+ print(" • Use 'get_template_info' tool to inspect template layouts and properties")
527
+ print(" • Templates preserve branding, themes, and custom layouts")
528
+ print(" • Template path configured via PPT_TEMPLATE_PATH environment variable")
529
+
530
+ print("\n🔧 Available MCP Tools:")
531
+ print(" Presentations:")
532
+ print(" • create_presentation - Create new blank presentation")
533
+ print(" • create_presentation_from_template - Create from template file")
534
+ print(" • get_template_info - Inspect template file details")
535
+ print(" • open_presentation - Open existing presentation")
536
+ print(" • save_presentation - Save presentation to file")
537
+
538
+ print("\n Content:")
539
+ print(" • add_slide - Add slides with various layouts")
540
+ print(" • add_textbox - Add formatted text boxes")
541
+ print(" • add_image - Add images from files or base64")
542
+ print(" • add_table - Add formatted tables")
543
+ print(" • add_shape - Add various auto shapes")
544
+ print(" • add_chart - Add column, bar, line, and pie charts")
545
+
546
+ print("\n📚 Documentation:")
547
+ print(" • Full API documentation available in README.md")
548
+ print(" • Template usage examples included")
549
+ print(" • Check ./templates/README.md for template guidelines")
550
+
551
+ print("\n🚀 Quick Start with Templates:")
552
+ print(" 1. Copy your .pptx template to ./templates/")
553
+ print(" 2. Use: create_presentation_from_template('your_template.pptx')")
554
+ print(" 3. Add slides using template layouts")
555
+ print(" 4. Save your presentation")
556
+ print("\n💡 Custom Template Paths:")
557
+ print(" • Set PPT_TEMPLATE_PATH environment variable for custom locations")
558
+ print(" • Supports multiple paths (colon-separated on Unix, semicolon on Windows)")
559
+ print(" • Example: PPT_TEMPLATE_PATH='/path/to/templates:/path/to/more/templates'")
560
+
561
+ print("\n" + "="*60)
slide_layout_templates.json ADDED
The diff for this file is too large to render. See raw diff
 
smithery.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
2
+
3
+ startCommand:
4
+ type: stdio
5
+ configSchema:
6
+ # JSON Schema defining the configuration options for the MCP.
7
+ {}
8
+ commandFunction:
9
+ # A JS function that produces the CLI command based on the given config to start the MCP on stdio.
10
+ |-
11
+ (config) => ({
12
+ command: 'python',
13
+ args: ['ppt_mcp_server.py'],
14
+ env: {}
15
+ })
16
+ exampleConfig: {}