Skip to main content
Glama
Ichigo3766

PowerPoint MCP Server

by Ichigo3766

open-presentation

Open an existing PowerPoint presentation and create a backup copy. Specify the presentation name and optional save path to ensure data preservation during editing.

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
NameRequiredDescriptionDefault
output_pathNoPath where to save the presentation (optional)
presentation_nameYesName of the presentation to open

Implementation Reference

  • Registers the 'open-presentation' tool with MCP server, including description and input schema.
    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"],
        },
    ),
  • Handler function that loads the specified presentation file, sanitizes the path, creates a backup as 'backup.pptx', loads it into python-pptx Presentation object, and stores it in PresentationManager for further editing.
    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}"
            )
        ]
  • Helper function used by open-presentation to sanitize file paths and prevent directory traversal.
    def sanitize_path(base_path: str, file_name: str) -> str:
        """
        Ensure that the resulting path doesn't escape outside the base directory
        Returns a safe, normalized path
        """
    
        joined_path = os.path.join(base_path, file_name)
        normalized_path = os.path.normpath(joined_path)
    
        if not normalized_path.startswith(base_path):
            raise ValueError(f"Invalid path. Attempted to access location outside allowed directory.")
    
        return normalized_path

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ichigo3766/powerpoint-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server