Skip to main content
Glama
daekeun-ml

PowerPoint Translator

by daekeun-ml

get_slide_info

Extract detailed slide information from PowerPoint presentations, including slide count and previews, for efficient content analysis and management.

Instructions

Get information about slides in a PowerPoint presentation.

Args: input_file: Path to the PowerPoint file (.pptx)

Returns: Information about the presentation including slide count and preview of each slide

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_fileYes

Implementation Reference

  • The main handler function for the 'get_slide_info' MCP tool. It validates the input PPTX file path, retrieves the slide count and previews (up to 10 slides) using PowerPointTranslator, formats a detailed information report, and includes usage examples. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def get_slide_info(input_file: str) -> str:
        """
        Get information about slides in a PowerPoint presentation.
        
        Args:
            input_file: Path to the PowerPoint file (.pptx)
        
        Returns:
            Information about the presentation including slide count and preview of each slide
        """
        try:
            # Validate input file using helper function
            input_path, error_msg = validate_input_path(input_file)
            if error_msg:
                return error_msg
            
            # Create translator to access slide info methods
            translator = PowerPointTranslator()
            slide_count = translator.get_slide_count(str(input_path))
            
            info_text = f"""๐Ÿ“Š PowerPoint Presentation Information
    
    ๐Ÿ“ File: {input_path}
    ๐Ÿ“„ Total slides: {slide_count}
    
    ๐Ÿ“‹ Slide previews:
    """
            
            # Get preview for each slide (limit to first 10 slides for readability)
            max_preview_slides = min(slide_count, 10)
            for i in range(1, max_preview_slides + 1):
                try:
                    preview = translator.get_slide_preview(str(input_path), i, max_chars=150)
                    info_text += f"\n๐Ÿ”ธ Slide {i}: {preview}"
                except Exception as e:
                    info_text += f"\n๐Ÿ”ธ Slide {i}: [Error getting preview: {str(e)}]"
            
            if slide_count > 10:
                info_text += f"\n\n... and {slide_count - 10} more slides"
            
            info_text += f"""
    
    ๐Ÿ’ก Usage examples:
    โ€ข Translate all slides: translate_powerpoint("{input_file}")
    โ€ข Translate specific slides: translate_specific_slides("{input_file}", "1,3,5")
    โ€ข Translate slide range: translate_specific_slides("{input_file}", "2-4")"""
            
            return info_text
            
        except Exception as e:
            logger.error(f"Failed to get slide info: {str(e)}")
            return f"โŒ Failed to get slide info: {str(e)}"
  • Shared helper function used by get_slide_info (and other tools) to validate and resolve the input PowerPoint file path, checking existence and .pptx extension, providing detailed error messages.
    def validate_input_path(input_file: str) -> tuple[Path, str]:
        """
        Validate input file path, handling both absolute and relative paths.
        
        Args:
            input_file: Input file path (absolute or relative)
        
        Returns:
            Tuple of (validated_path, error_message). If error_message is not empty, path validation failed.
        """
        input_path = Path(input_file)
        
        # If it's a relative path, try to resolve it from current working directory
        if not input_path.is_absolute():
            # Try current working directory first
            cwd_path = Path.cwd() / input_file
            if cwd_path.exists():
                input_path = cwd_path
            else:
                # Try the script's directory as fallback
                script_dir = Path(__file__).parent
                script_path = script_dir / input_file
                if script_path.exists():
                    input_path = script_path
        
        if not input_path.exists():
            # Provide more helpful error message with current working directory info
            cwd = Path.cwd()
            script_dir = Path(__file__).parent
            error_msg = f"""โŒ Error: File not found: {input_file}
    ๐Ÿ“ Current working directory: {cwd}
    ๐Ÿ“ Script directory: {script_dir}
    ๐Ÿ’ก Tried paths:
       โ€ข {input_file} (as provided)
       โ€ข {cwd / input_file} (from current directory)
       โ€ข {script_dir / input_file} (from script directory)
    ๐Ÿ’ก Try using absolute path or ensure file is in one of these directories"""
            return input_path, error_msg
        
        if not input_path.suffix.lower() == '.pptx':
            return input_path, f"โŒ Error: File must be a PowerPoint (.pptx) file: {input_file}"
        
        return input_path, ""
Install Server

Other Tools

Related Tools

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/daekeun-ml/ppt-translator'

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