Skip to main content
Glama

add-slide-title-with-chart

Add a slide with a title and automatically generated chart to PowerPoint presentations. The tool analyzes data structure to select appropriate chart types for clear data visualization.

Instructions

Add a new slide with a title and chart. The chart type will be automatically selected based on the data structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
presentation_nameYesName of the presentation to add the slide to
titleYesTitle of the slide
dataYesChart data structure

Implementation Reference

  • Main handler logic for the 'add-slide-title-with-chart' tool. Creates a title slide, determines chart type, adds the chart, and returns success message.
    elif name == "add-slide-title-with-chart":
        presentation_name = arguments.get("presentation_name")
        title = arguments.get("title")
        chart_data = arguments.get("data")
    
        if not all([presentation_name, title, chart_data]):
            raise ValueError("Missing required arguments")
    
        if presentation_name not in presentation_manager.presentations:
            raise ValueError(f"Presentation not found: {presentation_name}")
    
        # Get the presentation and create a new slide
        prs = presentation_manager.presentations[presentation_name]
        slide_layout = prs.slide_layouts[5]  # Title and blank content
        slide = prs.slides.add_slide(slide_layout)
    
        # Set the title
        title_shape = slide.shapes.title
        title_shape.text = title
    
        # Determine the best chart type for the data
        try:
            chart_type, chart_format = chart_manager.determine_chart_type(chart_data)
        except Exception as e:
            raise ValueError(f"Unable to determine chart type.")
    
        # Add the chart to the slide
        try:
            chart = chart_manager.add_chart_to_slide(slide, chart_type, chart_data, chart_format)
            chart_type_name = chart_type.name.lower().replace('xl_chart_type.', '')
    
            return [
                types.TextContent(
                    type="text",
                    text=f"Added slide '{title}' with a {chart_type_name} chart to presentation: {presentation_name}"
                )
            ]
        except Exception as e:
            raise ValueError(f"Failed to create slide with chart: {str(e)}")
  • Tool registration in list_tools() including name, description, and input schema definition.
    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"],
        },
    ),
  • Helper method to automatically determine the best chart type (e.g., scatter, pie, line, bar, column) based on the input data structure.
    def determine_chart_type(self, data: Dict[str, Any]) -> tuple[XL_CHART_TYPE, str]:
        """
        Analyze the data structure and determine the most appropriate chart type.
        Returns tuple of (PowerPoint chart type enum, chart_format)
        """
        # evaluate the data
        series_count = len(data["series"])
        categories = data.get("categories", [])
    
        # Check for XY data more safely by checking the first value of each series
        is_xy_data = False
        for series in data["series"]:
            values = series.get("values", [])
            if values:
                first_value = values[0]
                is_xy_data = isinstance(first_value, (list, tuple)) and len(first_value) == 2
                break
    
        if is_xy_data:
            return XL_CHART_TYPE.XY_SCATTER, "xy"
    
        # If we have percentage data that adds up to ~100, suggest pie chart
        if series_count == 1 and categories:
            values = data["series"][0].get("values", [])
            if len(values) <= 8:
                try:
                    total = sum(float(v) for v in values)
                    if 95 <= total <= 105:
                        return XL_CHART_TYPE.PIE, "category"
                except (TypeError, ValueError):
                    pass
    
        # For time series or trending data, suggest line chart
        if categories and any(
                isinstance(cat, (str, int)) and
                any(term in str(cat).lower() for term in
                    ["date", "time", "year", "month", "quarter", "q1", "q2", "q3", "q4"])
                for cat in categories
        ):
            return XL_CHART_TYPE.LINE, "category"
    
        # For multiple series comparing values, suggest bar chart
        if series_count > 1 and categories:
            return XL_CHART_TYPE.BAR_CLUSTERED, "category"
    
        # Default to column chart for single series
        return XL_CHART_TYPE.COLUMN_CLUSTERED, "category"
  • Helper method that constructs and adds the chart to the slide, handling category and XY data formats, positioning, legend, and axis titles.
    def add_chart_to_slide(self, slide, chart_type: XL_CHART_TYPE, data: Dict[str, Any],
                           chart_format: str = "category") -> chart:
        """Add a chart to the slide with the specified data."""
        # Position chart in the middle of the slide with margins
        left = Inches(1)
        top = Inches(2)
        width = Inches(8)
        height = Inches(5)
    
        if chart_format == "category":
            chart_data = CategoryChartData()
            chart_data.categories = data.get("categories", [])
    
            # Add each series
            for series in data["series"]:
                chart_data.add_series(series["name"], series["values"])
    
        elif chart_format == "xy":
            chart_data = XyChartData()
    
            # Add each series
            for series in data["series"]:
                series_data = chart_data.add_series(series["name"])
                for x, y in series["values"]:
                    series_data.add_data_point(x, y)
    
        # Add and configure the chart
        graphic_frame = slide.shapes.add_chart(
            chart_type, left, top, width, height, chart_data
        )
        chart = graphic_frame.chart
    
        # Basic formatting
        chart.has_legend = True
        if len(data["series"]) > 1:
            chart.legend.position = XL_LEGEND_POSITION.BOTTOM
    
        # Add axis titles if provided
        if "x_axis" in data:
            chart.category_axis.axis_title.text_frame.text = data["x_axis"]
        if "y_axis" in data:
            chart.value_axis.axis_title.text_frame.text = data["y_axis"]
    
        return chart
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that 'chart type will be automatically selected based on the data structure,' which adds some context about automation. However, it lacks critical details: whether this is a mutation (likely, but not stated), what permissions are needed, if there are rate limits, or what happens on failure. For a tool that creates content with no annotation coverage, this is insufficient.

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

Conciseness5/5

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

The description is a single, efficient sentence that states the core functionality upfront. There's no wasted text or redundancy, making it easy for an agent to parse quickly. It's appropriately sized for the tool's complexity.

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

Completeness2/5

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

Given the tool's complexity (3 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't cover behavioral aspects like mutation effects, error handling, or output format. For a tool that creates slides with charts, more context is needed to guide the agent effectively, especially without annotations or output schema.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents the three parameters. The description adds minimal value beyond the schema: it implies the 'data' parameter influences chart type selection, but doesn't explain how. With high schema coverage, the baseline is 3, as the description doesn't significantly enhance parameter understanding.

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: 'Add a new slide with a title and chart.' It specifies both the action (add) and the resources (slide with title and chart). However, it doesn't explicitly differentiate from sibling tools like 'add-slide-title-with-table' or 'add-slide-title-only,' which would require a 5.

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. It doesn't mention sibling tools like 'add-slide-title-with-table' for tabular data or 'add-slide-title-only' for slides without charts, nor does it specify prerequisites or exclusions. This leaves the agent without clear usage context.

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

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