Skip to main content
Glama

add-slide-title-with-table

Add a slide with a title and structured data table to PowerPoint presentations. Insert organized information with headers and rows for clear data presentation.

Instructions

Add a new slide with a title and table containing the provided data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
presentation_nameYesName of the presentation to add the slide to
titleYesTitle of the slide
dataYesTable data object with headers and rows

Implementation Reference

  • Core handler function that executes the tool logic: adds a new slide with title and a table populated from headers and rows to the specified presentation.
    def add_table_slide(self, presentation_name: str, title: str, headers: str, rows: str) -> Slide:
    
        try:
            prs = self.presentations[presentation_name]
        except KeyError as e:
            raise ValueError(f"Presentation '{presentation_name}' not found")
    
        slide_layout = prs.slide_layouts[self.SLIDE_LAYOUT_TITLE_ONLY]
        slide = prs.slides.add_slide(slide_layout)
    
        # Set the title
        title_shape = slide.shapes.title
        title_shape.text = title
    
        # Calculate table dimensions and position
        num_rows = len(rows) + 1  # +1 for header row
        num_cols = len(headers)
    
        # Position table in the middle of the slide with some margins
        x = Inches(1)  # Left margin
        y = Inches(2)  # Top margin below title
    
        # Make table width proportional to the number of columns
        width_per_col = Inches(8 / num_cols)  # Divide available width (8 inches) by number of columns
        height_per_row = Inches(0.4)  # Standard height per row
    
        # Create table
        shape = slide.shapes.add_table(
            num_rows,
            num_cols,
            x,
            y,
            width_per_col * num_cols,
            height_per_row * num_rows
        )
        table = shape.table
    
        # Add headers
        for col_idx, header in enumerate(headers):
            cell = table.cell(0, col_idx)
            cell.text = str(header)
            # Style header row
            paragraph = cell.text_frame.paragraphs[0]
            paragraph.font.bold = True
            paragraph.font.size = Pt(11)
    
    
    
        # Add data rows
        for row_idx, row_data in enumerate(rows, start=1):
            for col_idx, cell_value in enumerate(row_data):
                cell = table.cell(row_idx, col_idx)
                cell.text = str(cell_value)
                # Style data cells
                paragraph = cell.text_frame.paragraphs[0]
                paragraph.font.size = Pt(10)
    
        return slide
  • Tool schema defining the input parameters: presentation_name (string), title (string), data (object with headers array and rows array of arrays).
    types.Tool(
        name="add-slide-title-with-table",
        description="Add a new slide with a title and table containing the provided data",
        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",
                },
                "data": {
                    "type": "object",
                    "description": "Table data object with headers and rows",
                    "properties": {
                        "headers": {
                            "type": "array",
                            "items": {"type": "string"},
                            "description": "Array of column headers"
                        },
                        "rows": {
                            "type": "array",
                            "items": {
                                "type": "array",
                                "items": {"type": ["string", "number"]},
                            },
                            "description": "Array of row data arrays"
                        }
                    },
                    "required": ["headers", "rows"]
                }
            },
            "required": ["presentation_name", "title", "data"],
        },
    ),
  • Dispatch handler in the main call_tool function that validates inputs, extracts headers and rows from data, and delegates to PresentationManager.add_table_slide.
    elif name == "add-slide-title-with-table":
        presentation_name = arguments.get("presentation_name")
        title = arguments.get("title")
        table_data = arguments.get("data")
    
        if not all([presentation_name, title, table_data]):
            raise ValueError("Missing required arguments")
    
        if presentation_name not in presentation_manager.presentations:
            raise ValueError(f"Presentation not found: {presentation_name}")
    
        # Validate table data structure
        headers = table_data.get("headers", [])
        rows = table_data.get("rows", [])
    
        if not headers:
            raise ValueError("Table headers are required")
    
        if not rows:
            raise ValueError("Table rows are required")
    
        # Validate that all rows match header length
        if not all(len(row) == len(headers) for row in rows):
            raise ValueError("All rows must have the same number of columns as headers")
        try:
            slide = presentation_manager.add_table_slide(presentation_name, title, headers, rows)
        except Exception as e:
            raise ValueError(f"Unable to add slide '{title}' with a table to presentation: {presentation_name}")
    
        return [
            types.TextContent(
                type="text",
                text=f"Added slide '{title}' with a table to presentation: {presentation_name}"
            )
        ]
  • The list_tools handler where the tool is registered by including it in the returned list of available tools.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """List available PowerPoint tools."""
        return [
            types.Tool(
                name="create-presentation",
                description="This tool starts the process of generating a new powerpoint presentation with the name given "
                            "by the user. Use this tool when the user requests to create or generate a new presentation.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string",
                            "description": "Name of the presentation (without .pptx extension)",
                        },
                    },
                    "required": ["name"],
                },
            ),
            types.Tool(
                name="generate-and-save-image",
                description="Generates an image using a FLUX model and save the image to the specified path. The tool "
                            "will return a PNG file path. It should be used when the user asks to generate or create an "
                            "image or a picture.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "prompt": {
                            "type": "string",
                            "description": "Description of the image to generate in the form of a prompt.",
                        },
                        "file_name": {
                            "type": "string",
                            "description": "Filename of the image. Include the extension of .png",
                        },
                    },
                    "required": ["prompt", "file_name"],
                },
            ),
            types.Tool(
                name="add-slide-title-only",
                description="This tool adds a new title slide to the presentation you are working on. The tool doesn't "
                            "return anything. It requires the presentation_name to work on.",
                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",
                        }
                    },
                    "required": ["presentation_name", "title"],
                },
            ),
            types.Tool(
                name="add-slide-section-header",
                description="This tool adds a section header (a.k.a segue) slide to the presentation you are working on. The tool doesn't "
                            "return anything. It requires the presentation_name to work on.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "presentation_name": {
                            "type": "string",
                            "description": "Name of the presentation to add the slide to",
                        },
                        "header": {
                            "type": "string",
                            "description": "Section header title",
                        },
                        "subtitle": {
                            "type": "string",
                            "description": "Section header subtitle",
                        }
    
                    },
                    "required": ["presentation_name", "header"],
                },
            ),
            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"],
                },
            ),
            types.Tool(
                name="add-slide-comparison",
                description="Add a new a comparison slide with title and comparison content. Use when you wish to "
                            "compare two concepts",
                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",
                        },
                        "left_side_title": {
                            "type": "string",
                            "description": "Title of the left concept",
                        },
                        "left_side_content": {
                            "type": "string",
                            "description": "Content/body text of left concept. "
                                           "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"
                        },
                        "right_side_title": {
                            "type": "string",
                            "description": "Title of the right concept",
                        },
                        "right_side_content": {
                            "type": "string",
                            "description": "Content/body text of right concept. "
                                           "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", "left_side_title", "left_side_content",
                                 "right_side_title", "right_side_content"],
                },
            ),
            types.Tool(
                name="add-slide-title-with-table",
                description="Add a new slide with a title and table containing the provided data",
                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",
                        },
                        "data": {
                            "type": "object",
                            "description": "Table data object with headers and rows",
                            "properties": {
                                "headers": {
                                    "type": "array",
                                    "items": {"type": "string"},
                                    "description": "Array of column headers"
                                },
                                "rows": {
                                    "type": "array",
                                    "items": {
                                        "type": "array",
                                        "items": {"type": ["string", "number"]},
                                    },
                                    "description": "Array of row data arrays"
                                }
                            },
                            "required": ["headers", "rows"]
                        }
                    },
                    "required": ["presentation_name", "title", "data"],
                },
            ),
            types.Tool(
                name="add-slide-title-with-chart",
                description="Add a new slide with a title and chart. The chart type will be automatically selected based on the data structure.",
                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",
                        },
                        "data": {
                            "type": "object",
                            "description": "Chart data structure",
                            "properties": {
                                "categories": {
                                    "type": "array",
                                    "items": {"type": ["string", "number"]},
                                    "description": "X-axis categories or labels (optional)"
                                },
                                "series": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": "string",
                                                "description": "Name of the data series"
                                            },
                                            "values": {
                                                "type": "array",
                                                "items": {
                                                    "oneOf": [
                                                        {"type": "number"},
                                                        {
                                                            "type": "array",
                                                            "items": {"type": "number"},
                                                            "minItems": 2,
                                                            "maxItems": 2
                                                        }
                                                    ]
                                                },
                                                "description": "Values for the series. Can be simple numbers or [x,y] pairs for scatter plots"
                                            }
                                        },
                                        "required": ["name", "values"]
                                    }
                                },
                                "x_axis": {
                                    "type": "string",
                                    "description": "X-axis title (optional)"
                                },
                                "y_axis": {
                                    "type": "string",
                                    "description": "Y-axis title (optional)"
                                }
                            },
                            "required": ["series"]
                        }
                    },
                    "required": ["presentation_name", "title", "data"],
                },
            ),
            types.Tool(
                name="add-slide-picture-with-caption",
                description="Add a new slide with a picture and caption 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",
                        },
                        "caption": {
                            "type": "string",
                            "description": "Caption text to appear below the picture"
                        },
                        "image_path": {
                            "type": "string",
                            "description": "Path to the image file to insert"
                        }
                    },
                    "required": ["presentation_name", "title", "caption", "image_path"],
                },
            ),
            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"],
                },
            ),
            types.Tool(
                name="save-presentation",
                description="Save the presentation to a file. Always use this tool at the end of any process that has "
                            "added slides to a presentation.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "presentation_name": {
                            "type": "string",
                            "description": "Name of the presentation to save",
                        },
                        "output_path": {
                            "type": "string",
                            "description": "Path where to save the presentation (optional)",
                        },
                    },
                    "required": ["presentation_name"],
                },
            ),
        ]

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