open-presentation
Open existing PowerPoint presentations and create backup copies to preserve original files while editing. This tool helps users work on presentations without risking data loss.
Instructions
Opens an existing presentation and saves a copy to a new file for backup. Use this tool when the user requests to open a presentation that has already been created.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| presentation_name | Yes | Name of the presentation to open | |
| output_path | No | Path where to save the presentation (optional) |
Implementation Reference
- src/powerpoint/server.py:372-408 (handler)Handler logic within the call_tool function that executes the 'open-presentation' tool: validates input, sanitizes file path, loads the PPTX presentation using python-pptx, creates a backup copy, stores the presentation object in PresentationManager, and returns a success message.if name == "open-presentation": presentation_name = arguments.get("presentation_name") if not presentation_name: raise ValueError("Missing presentation name") file_name = f"{presentation_name}.pptx" try: safe_file_path = sanitize_path(folder_path, file_name) except ValueError as e: raise ValueError(f"Invalid file path: {str(e)}") # attempt to load presentation try: prs = Presentation(safe_file_path) except Exception as e: raise ValueError(f"Unable to load {safe_file_path}. Error: {str(e)}") # Create a backup of the original file file_name = BACKUP_FILE_NAME try: safe_file_path = sanitize_path(folder_path, file_name) except ValueError as e: raise ValueError(f"Invalid file path: {str(e)}") # attempt to save a backup of presentation try: prs.save(safe_file_path) except Exception as e: raise ValueError(f"Unable to save {safe_file_path}. Error: {str(e)}") presentation_manager.presentations[presentation_name] = prs return [ types.TextContent( type="text", text=f"Opened presentation: {presentation_name}" ) ]
- src/powerpoint/server.py:324-342 (registration)Registration of the 'open-presentation' tool in the list_tools() handler, including its name, description, and input schema definition.types.Tool( name="open-presentation", description="Opens an existing presentation and saves a copy to a new file for backup. Use this tool when " "the user requests to open a presentation that has already been created.", inputSchema={ "type": "object", "properties": { "presentation_name": { "type": "string", "description": "Name of the presentation to open", }, "output_path": { "type": "string", "description": "Path where to save the presentation (optional)", }, }, "required": ["presentation_name"], }, ),
- src/powerpoint/server.py:328-341 (schema)Input schema definition for the 'open-presentation' tool, specifying required 'presentation_name' and optional 'output_path'.inputSchema={ "type": "object", "properties": { "presentation_name": { "type": "string", "description": "Name of the presentation to open", }, "output_path": { "type": "string", "description": "Path where to save the presentation (optional)", }, }, "required": ["presentation_name"], },