Skip to main content
Glama
daekeun-ml

PowerPoint Translator

by daekeun-ml

get_slide_preview

Extract and preview detailed content of a specific slide from a PowerPoint file, enabling focused analysis or translation workflows within the PowerPoint Translator server.

Instructions

Get a detailed preview of a specific slide's content.

Args: input_file: Path to the PowerPoint file (.pptx) slide_number: Slide number to preview (1-based indexing)

Returns: Detailed preview of the slide content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_fileYes
slide_numberYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'get_slide_preview'. Validates the input file path, creates PowerPointTranslator instance, fetches slide preview, and formats the response with additional context.
    @mcp.tool()
    def get_slide_preview(input_file: str, slide_number: int) -> str:
        """
        Get a detailed preview of a specific slide's content.
        
        Args:
            input_file: Path to the PowerPoint file (.pptx)
            slide_number: Slide number to preview (1-based indexing)
        
        Returns:
            Detailed preview of the slide content
        """
        try:
            # Validate input file using helper function
            input_path, error_msg = validate_input_path(input_file)
            if error_msg:
                return error_msg
            
            # Create translator and get preview
            translator = PowerPointTranslator()
            slide_count = translator.get_slide_count(str(input_path))
            
            if slide_number < 1 or slide_number > slide_count:
                return f"❌ Error: Invalid slide number {slide_number}. Valid range: 1-{slide_count}"
            
            preview = translator.get_slide_preview(str(input_path), slide_number, max_chars=500)
            
            return f"""📄 Slide {slide_number} Preview
    
    📁 File: {input_path}
    📊 Total slides: {slide_count}
    
    📝 Content preview:
    {preview}
    
    💡 To translate this slide:
    translate_specific_slides("{input_file}", "{slide_number}")"""
            
        except Exception as e:
            logger.error(f"Failed to get slide preview: {str(e)}")
            return f"❌ Failed to get slide preview: {str(e)}"
  • Core helper method in PowerPointTranslator class that implements the slide preview logic by loading the PPTX, collecting text from shapes and notes using SlideTextCollector, concatenating them, truncating to max_chars, and returning the preview string.
    def get_slide_preview(self, input_file: str, slide_number: int, max_chars: int = 200) -> str:
        """Get a preview of text content from a specific slide"""
        try:
            Presentation = self.deps.require('pptx')
            prs = Presentation(input_file)
            
            if slide_number < 1 or slide_number > len(prs.slides):
                raise ValueError(f"Invalid slide number: {slide_number}. Valid range: 1-{len(prs.slides)}")
            
            slide = prs.slides[slide_number - 1]  # Convert to 0-based index
            text_items, notes_text = SlideTextCollector().collect_slide_texts(slide)
            
            # Collect all text content
            all_texts = []
            for item in text_items:
                if item['text'].strip():
                    all_texts.append(item['text'].strip())
            
            if notes_text and notes_text.strip():
                all_texts.append(f"[Notes: {notes_text.strip()}]")
            
            # Join and truncate if necessary
            preview = " | ".join(all_texts)
            if len(preview) > max_chars:
                preview = preview[:max_chars] + "..."
            
            return preview if preview else "[No text content found]"
            
        except Exception as e:
            logger.error(f"❌ Failed to get slide preview: {str(e)}")
            raise
  • mcp_server.py:320-320 (registration)
    FastMCP tool registration decorator for the get_slide_preview tool.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns a 'detailed preview' but doesn't specify what that includes (e.g., text, images, formatting), whether it's a read-only operation, potential errors (e.g., invalid file paths or slide numbers), or performance aspects. This leaves significant gaps in understanding the tool's behavior beyond basic input-output.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Args, Returns) and uses minimal, focused sentences. It avoids redundancy and gets straight to the point, though the 'Returns' section is somewhat vague ('Detailed preview') and could be more specific without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no annotations, but has an output schema), the description is adequate but incomplete. It covers basic input semantics and purpose but lacks behavioral details and usage guidelines. The presence of an output schema means the description doesn't need to explain return values in depth, but it should still address broader context like error handling or sibling tool differentiation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for both parameters: 'input_file' is clarified as a 'Path to the PowerPoint file (.pptx)', and 'slide_number' specifies '1-based indexing'. With 0% schema description coverage, this compensates well by explaining parameter purposes and constraints, though it could detail format expectations (e.g., absolute vs. relative paths) for a higher score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('detailed preview of a specific slide's content'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish this tool from its sibling 'get_slide_info', which might have overlapping functionality, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_slide_info' or other PowerPoint-related siblings. It mentions the required parameters but offers no context about prerequisites, typical use cases, or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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