Skip to main content
Glama

add-slide-title-content

Add a slide with a title and content to an existing PowerPoint presentation using structured text formatting for main and sub-points.

Instructions

Add a new slide with a title and content to an existing presentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
presentation_nameYesName of the presentation to add the slide to
titleYesTitle of the slide
contentYesContent/body text of the slide. Separate main points with a single carriage return character.Make sub-points with tab character.Do not use bullet points, asterisks or dashes for points.Max main points is 4

Implementation Reference

  • Core handler function that creates a new slide using TITLE_AND_CONTENT layout, sets the title, and formats the content into bullets using the helper function.
    def add_title_with_content_slide(self, presentation_name: str, title: str, content: str) -> Slide:
        try:
            prs = self.presentations[presentation_name]
        except KeyError as e:
            raise ValueError(f"Presentation '{presentation_name}' not found")
        slide_master = prs.slide_master
        # Add a slide with title and content
        slide_layout = prs.slide_layouts[self.SLIDE_LAYOUT_TITLE_AND_CONTENT]  # Use layout with title and content
        slide = prs.slides.add_slide(slide_layout)
    
        # Set the title
        title_shape = slide.shapes.title
        title_shape.text = title
    
        # Set the content
        content_shape = slide.placeholders[1]
        #content_shape.text = content
        # Get the content placeholder and add our formatted text
    
        text_frame = content_shape.text_frame
        self._add_formatted_bullets(text_frame, content)
        return slide
  • Registers the tool in the list_tools() callback with name, description, and input schema.
    types.Tool(
        name="add-slide-title-content",
        description="Add a new slide with a title and content to an existing presentation",
        inputSchema={
            "type": "object",
            "properties": {
                "presentation_name": {
                    "type": "string",
                    "description": "Name of the presentation to add the slide to",
                },
                "title": {
                    "type": "string",
                    "description": "Title of the slide",
                },
                "content": {
                    "type": "string",
                    "description": "Content/body text of the slide. "
                                   "Separate main points with a single carriage return character."
                                   "Make sub-points with tab character."
                                   "Do not use bullet points, asterisks or dashes for points."
                                   "Max main points is 4"
                },
            },
            "required": ["presentation_name", "title", "content"],
        },
    ),
  • Dispatch logic in the call_tool handler that validates arguments and invokes the presentation manager method.
    elif name == "add-slide-title-content":
        presentation_name = arguments.get("presentation_name")
        title = arguments.get("title")
        content = arguments.get("content")
    
        if not all([presentation_name, title, content]):
            raise ValueError("Missing required arguments")
    
        if presentation_name not in presentation_manager.presentations:
            raise ValueError(f"Presentation not found: {presentation_name}")
    
        try:
            slide = presentation_manager.add_title_with_content_slide(presentation_name, title, content)
        except Exception as e:
            raise ValueError(f"Unable to add slide '{title}' to presentation: {presentation_name}")
    
        return [
            types.TextContent(
                type="text",
                text=f"Added slide '{title}' to presentation: {presentation_name}"
            )
        ]
  • Input schema defining parameters: presentation_name (string, required), title (string, required), content (string with formatting instructions, required).
    inputSchema={
        "type": "object",
        "properties": {
            "presentation_name": {
                "type": "string",
                "description": "Name of the presentation to add the slide to",
            },
            "title": {
                "type": "string",
                "description": "Title of the slide",
            },
            "content": {
                "type": "string",
                "description": "Content/body text of the slide. "
                               "Separate main points with a single carriage return character."
                               "Make sub-points with tab character."
                               "Do not use bullet points, asterisks or dashes for points."
                               "Max main points is 4"
            },
        },
        "required": ["presentation_name", "title", "content"],
    },
  • Helper utility that parses content string using line feeds for main bullets and tabs for sub-bullets, applying proper paragraph levels in PowerPoint.
    def _add_formatted_bullets(self, text_frame, text_block):
        """
        Process a text block and add paragraphs with proper bullet indentation
        using ASCII code detection:
        - ASCII 10 (LF) or ASCII 13 (CR) or combination for new lines (main bullets)
        - ASCII 9 (HT) for tab indentation (sub-bullets)
    
        Args:
            text_frame: The PowerPoint text frame to add text to
            text_block: String of text to process
        """
        # First, normalize all line endings to a single format
        # Replace CR+LF (Windows) with a single marker
        normalized_text = text_block.replace('\r\n', '\n')
        # Replace any remaining CR (old Mac) with LF
        normalized_text = normalized_text.replace('\r', '\n')
    
        # Split the text block into lines using ASCII 10 (LF)
        lines = normalized_text.split('\n')
    
        # Clear any existing text
        if text_frame.paragraphs:
            p = text_frame.paragraphs[0]
            p.text = ""
        else:
            p = text_frame.add_paragraph()
    
        # Process the first line separately (if it exists)
        if lines and lines[0].strip():
            first_line = lines[0]
            # Count leading tabs (ASCII 9) to determine indentation level
            level = 0
            while first_line and ord(first_line[0]) == 9:  # ASCII 9 is HT (tab)
                level += 1
                first_line = first_line[1:]
    
            p.text = first_line.strip()
            p.level = level
    
        # Process remaining lines
        for line in lines[1:]:
            if not line.strip():
                continue  # Skip empty lines
    
            # Count leading tabs (ASCII 9) to determine indentation level
            level = 0
            while line and ord(line[0]) == 9:  # ASCII 9 is HT (tab)
                level += 1
                line = line[1:]
    
            # Add the paragraph with proper indentation
            p = text_frame.add_paragraph()
            p.text = line.strip()
            p.level = level

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/supercurses/powerpoint'

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