mcpcn-office-powerpoint-mcp-server 2.0.7__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.
- mcpcn_office_powerpoint_mcp_server-2.0.7.dist-info/METADATA +1023 -0
- mcpcn_office_powerpoint_mcp_server-2.0.7.dist-info/RECORD +25 -0
- mcpcn_office_powerpoint_mcp_server-2.0.7.dist-info/WHEEL +4 -0
- mcpcn_office_powerpoint_mcp_server-2.0.7.dist-info/entry_points.txt +2 -0
- mcpcn_office_powerpoint_mcp_server-2.0.7.dist-info/licenses/LICENSE +21 -0
- ppt_mcp_server.py +450 -0
- slide_layout_templates.json +3690 -0
- tools/__init__.py +28 -0
- tools/chart_tools.py +82 -0
- tools/connector_tools.py +91 -0
- tools/content_tools.py +593 -0
- tools/hyperlink_tools.py +138 -0
- tools/master_tools.py +114 -0
- tools/presentation_tools.py +212 -0
- tools/professional_tools.py +290 -0
- tools/structural_tools.py +373 -0
- tools/template_tools.py +521 -0
- tools/transition_tools.py +75 -0
- utils/__init__.py +69 -0
- utils/content_utils.py +579 -0
- utils/core_utils.py +55 -0
- utils/design_utils.py +689 -0
- utils/presentation_utils.py +217 -0
- utils/template_utils.py +1143 -0
- utils/validation_utils.py +323 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Presentation management utilities for PowerPoint MCP Server.
|
|
3
|
+
Functions for creating, opening, saving, and managing presentations.
|
|
4
|
+
"""
|
|
5
|
+
from pptx import Presentation
|
|
6
|
+
from typing import Dict, List, Optional
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def create_presentation() -> Presentation:
|
|
11
|
+
"""
|
|
12
|
+
Create a new PowerPoint presentation.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
A new Presentation object
|
|
16
|
+
"""
|
|
17
|
+
return Presentation()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def open_presentation(file_path: str) -> Presentation:
|
|
21
|
+
"""
|
|
22
|
+
Open an existing PowerPoint presentation.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
file_path: Path to the PowerPoint file
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
A Presentation object
|
|
29
|
+
"""
|
|
30
|
+
return Presentation(file_path)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def create_presentation_from_template(template_path: str) -> Presentation:
|
|
34
|
+
"""
|
|
35
|
+
Create a new PowerPoint presentation from a template file.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
template_path: Path to the template .pptx file
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
A new Presentation object based on the template
|
|
42
|
+
|
|
43
|
+
Raises:
|
|
44
|
+
FileNotFoundError: If the template file doesn't exist
|
|
45
|
+
Exception: If the template file is corrupted or invalid
|
|
46
|
+
"""
|
|
47
|
+
if not os.path.exists(template_path):
|
|
48
|
+
raise FileNotFoundError(f"Template file not found: {template_path}")
|
|
49
|
+
|
|
50
|
+
if not template_path.lower().endswith(('.pptx', '.potx')):
|
|
51
|
+
raise ValueError("Template file must be a .pptx or .potx file")
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
# Load the template file as a presentation
|
|
55
|
+
presentation = Presentation(template_path)
|
|
56
|
+
return presentation
|
|
57
|
+
except Exception as e:
|
|
58
|
+
raise Exception(f"Failed to load template file '{template_path}': {str(e)}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def save_presentation(presentation: Presentation, file_path: str) -> str:
|
|
62
|
+
"""
|
|
63
|
+
Save a PowerPoint presentation to a file.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
presentation: The Presentation object
|
|
67
|
+
file_path: Path where the file should be saved
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
The file path where the presentation was saved
|
|
71
|
+
"""
|
|
72
|
+
presentation.save(file_path)
|
|
73
|
+
return file_path
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def get_template_info(template_path: str) -> Dict:
|
|
77
|
+
"""
|
|
78
|
+
Get information about a template file.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
template_path: Path to the template .pptx file
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Dictionary containing template information
|
|
85
|
+
"""
|
|
86
|
+
if not os.path.exists(template_path):
|
|
87
|
+
raise FileNotFoundError(f"Template file not found: {template_path}")
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
presentation = Presentation(template_path)
|
|
91
|
+
|
|
92
|
+
# Get slide layouts
|
|
93
|
+
layouts = get_slide_layouts(presentation)
|
|
94
|
+
|
|
95
|
+
# Get core properties
|
|
96
|
+
core_props = get_core_properties(presentation)
|
|
97
|
+
|
|
98
|
+
# Get slide count
|
|
99
|
+
slide_count = len(presentation.slides)
|
|
100
|
+
|
|
101
|
+
# Get file size
|
|
102
|
+
file_size = os.path.getsize(template_path)
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
"template_path": template_path,
|
|
106
|
+
"file_size_bytes": file_size,
|
|
107
|
+
"slide_count": slide_count,
|
|
108
|
+
"layout_count": len(layouts),
|
|
109
|
+
"slide_layouts": layouts,
|
|
110
|
+
"core_properties": core_props
|
|
111
|
+
}
|
|
112
|
+
except Exception as e:
|
|
113
|
+
raise Exception(f"Failed to read template info from '{template_path}': {str(e)}")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def get_presentation_info(presentation: Presentation) -> Dict:
|
|
117
|
+
"""
|
|
118
|
+
Get information about a presentation.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
presentation: The Presentation object
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
Dictionary containing presentation information
|
|
125
|
+
"""
|
|
126
|
+
try:
|
|
127
|
+
# Get slide layouts
|
|
128
|
+
layouts = get_slide_layouts(presentation)
|
|
129
|
+
|
|
130
|
+
# Get core properties
|
|
131
|
+
core_props = get_core_properties(presentation)
|
|
132
|
+
|
|
133
|
+
# Get slide count
|
|
134
|
+
slide_count = len(presentation.slides)
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
"slide_count": slide_count,
|
|
138
|
+
"layout_count": len(layouts),
|
|
139
|
+
"slide_layouts": layouts,
|
|
140
|
+
"core_properties": core_props,
|
|
141
|
+
"slide_width": presentation.slide_width,
|
|
142
|
+
"slide_height": presentation.slide_height
|
|
143
|
+
}
|
|
144
|
+
except Exception as e:
|
|
145
|
+
raise Exception(f"Failed to get presentation info: {str(e)}")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_slide_layouts(presentation: Presentation) -> List[Dict]:
|
|
149
|
+
"""
|
|
150
|
+
Get all available slide layouts in the presentation.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
presentation: The Presentation object
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
A list of dictionaries with layout information
|
|
157
|
+
"""
|
|
158
|
+
layouts = []
|
|
159
|
+
for i, layout in enumerate(presentation.slide_layouts):
|
|
160
|
+
layout_info = {
|
|
161
|
+
"index": i,
|
|
162
|
+
"name": layout.name,
|
|
163
|
+
"placeholder_count": len(layout.placeholders)
|
|
164
|
+
}
|
|
165
|
+
layouts.append(layout_info)
|
|
166
|
+
return layouts
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def set_core_properties(presentation: Presentation, title: str = None, subject: str = None,
|
|
170
|
+
author: str = None, keywords: str = None, comments: str = None) -> None:
|
|
171
|
+
"""
|
|
172
|
+
Set core document properties.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
presentation: The Presentation object
|
|
176
|
+
title: Document title
|
|
177
|
+
subject: Document subject
|
|
178
|
+
author: Document author
|
|
179
|
+
keywords: Document keywords
|
|
180
|
+
comments: Document comments
|
|
181
|
+
"""
|
|
182
|
+
core_props = presentation.core_properties
|
|
183
|
+
|
|
184
|
+
if title is not None:
|
|
185
|
+
core_props.title = title
|
|
186
|
+
if subject is not None:
|
|
187
|
+
core_props.subject = subject
|
|
188
|
+
if author is not None:
|
|
189
|
+
core_props.author = author
|
|
190
|
+
if keywords is not None:
|
|
191
|
+
core_props.keywords = keywords
|
|
192
|
+
if comments is not None:
|
|
193
|
+
core_props.comments = comments
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def get_core_properties(presentation: Presentation) -> Dict:
|
|
197
|
+
"""
|
|
198
|
+
Get core document properties.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
presentation: The Presentation object
|
|
202
|
+
|
|
203
|
+
Returns:
|
|
204
|
+
Dictionary containing core properties
|
|
205
|
+
"""
|
|
206
|
+
core_props = presentation.core_properties
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
"title": core_props.title,
|
|
210
|
+
"subject": core_props.subject,
|
|
211
|
+
"author": core_props.author,
|
|
212
|
+
"keywords": core_props.keywords,
|
|
213
|
+
"comments": core_props.comments,
|
|
214
|
+
"created": core_props.created.isoformat() if core_props.created else None,
|
|
215
|
+
"last_modified_by": core_props.last_modified_by,
|
|
216
|
+
"modified": core_props.modified.isoformat() if core_props.modified else None
|
|
217
|
+
}
|