Skip to content

[FEATURE][MCP-SERVER]: Python sample - PowerPoint editor (python-pptx)Β #989

@crivetimihai

Description

@crivetimihai

🧭 Epic

Title: MCP Server – Python PowerPoint Editor Implementation ("pptx-server")


Goal

Develop pptx-server, a Python MCP server that provides comprehensive PowerPoint presentation editing capabilities using the python-pptx library. The server enables programmatic creation, modification, and management of PPTX files through MCP tool invocations.

The project demonstrates:

  • Full PowerPoint presentation lifecycle management (create, read, update, delete)
  • Slide manipulation (add, remove, reorder, duplicate)
  • Content management (text, images, shapes, tables)
  • Template-based presentation generation
  • Slide layout and master management
  • Text formatting and styling capabilities

Repository root: mcp-servers/python/pptx_server


🧭 Type of Feature

  • Developer tooling / sample code
  • Document processing
  • Office automation

πŸ›  Tool Catalogue

Tool Purpose Required Inputs Result & Notes
pptx.create_presentation Create a new PowerPoint presentation filename: string – output file path
template?: string – optional template path
Creates empty presentation or from template
pptx.add_slide Add a new slide to presentation filename: string, layout_index?: number, position?: number Adds slide with specified layout at position
pptx.add_text Add text content to a slide filename: string, slide_index: number, text: string, left?: number, top?: number, width?: number, height?: number Adds text box with content and positioning
pptx.add_image Insert image into slide filename: string, slide_index: number, image_path: string, left?: number, top?: number, width?: number, height?: number Inserts image with positioning and sizing
pptx.add_table Create table in slide filename: string, slide_index: number, rows: number, cols: number, left?: number, top?: number Creates table with specified dimensions
pptx.format_text Apply text formatting filename: string, slide_index: number, shape_index: number, font_name?: string, font_size?: number, bold?: bool, italic?: bool Applies text formatting to specified text shape
pptx.remove_slide Remove slide from presentation filename: string, slide_index: number Removes slide at specified index
pptx.duplicate_slide Duplicate an existing slide filename: string, slide_index: number, position?: number Duplicates slide and places at specified position
pptx.get_slide_count Get number of slides in presentation filename: string Returns total slide count
pptx.get_slide_layouts List available slide layouts filename: string Returns array of layout names and indices
pptx.save_as Save presentation with new filename filename: string, new_filename: string Saves copy of presentation
pptx.get_presentation_info Get presentation metadata filename: string Returns title, author, slide count, creation date, etc.

πŸ™‹β€β™‚οΈ User Stories & Acceptance Criteria

User Story 1 β€” Quick Server Start

Scenario: Start pptx-server locally
Given Python β‰₯3.8 and python-pptx are installed
When I execute "python -m pptx_server --transport=stdio"
Then the process starts and responds to MCP protocol
And tools/list returns all pptx.* tools

User Story 2 β€” Create New Presentation

Scenario: Create blank presentation
When I invoke pptx.create_presentation with filename="new_deck.pptx"
Then file "new_deck.pptx" is created
And tool result indicates success

User Story 3 β€” Add Slide with Content

Scenario: Add slide with title and content
Given presentation "deck.pptx" exists
When I invoke pptx.add_slide with layout_index=1
And I invoke pptx.add_text with text="Welcome" at position (100, 100)
Then the slide contains the text "Welcome"
And the presentation has one additional slide

User Story 4 β€” Insert Image

Scenario: Add image to slide
Given presentation "deck.pptx" exists with at least one slide
And image file "chart.png" exists
When I invoke pptx.add_image with slide_index=0, image_path="chart.png"
Then the slide contains the inserted image
And tool result confirms successful insertion

User Story 5 β€” Format Text Content

Scenario: Apply text formatting
Given slide has text content at shape_index=0
When I invoke pptx.format_text with font_name="Arial", font_size=24, bold=true
Then the text formatting is applied
And the text appears in Arial, 24pt, bold

User Story 6 β€” Presentation Management

Scenario: Manage slide order
Given presentation with 3 slides
When I invoke pptx.duplicate_slide with slide_index=1, position=0
And I invoke pptx.remove_slide with slide_index=3
Then presentation has 3 slides with duplicated slide at beginning
And original slide 3 is removed

πŸ“ Design Sketch (Mermaid)

sequenceDiagram
    participant Client
    participant Gateway as MCP Gateway
    participant PptxSrv as pptx-server
    Client->>Gateway: JSON-RPC pptx.add_slide
    Gateway->>PptxSrv: pptx.add_slide request
    PptxSrv->>PptxSrv: Load presentation
    PptxSrv->>PptxSrv: Add slide with layout
    PptxSrv->>PptxSrv: Save presentation
    PptxSrv-->>Gateway: success response
    Gateway-->>Client: slide added confirmation
Loading

πŸ“‚ Filesystem Layout

pptx_server/
β”œβ”€β”€ __init__.py
β”œβ”€β”€ main.py                   # MCP server entry point
β”œβ”€β”€ server.py                 # MCP server implementation
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ presentation.py       # Create, save, metadata tools
β”‚   β”œβ”€β”€ slides.py            # Slide manipulation tools
β”‚   β”œβ”€β”€ content.py           # Text, image, table tools
β”‚   └── formatting.py        # Text formatting tools
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ validation.py        # Input validation helpers
β”‚   └── pptx_helpers.py      # python-pptx utility functions
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ pyproject.toml
└── README.md

πŸ“‚ Component Matrix

Path / Component Purpose
main.py CLI entry point and MCP server startup
server.py MCP server implementation with tool registration
tools/presentation.py Presentation lifecycle: create, save, info
tools/slides.py Slide operations: add, remove, duplicate, reorder
tools/content.py Content insertion: text, images, tables, shapes
tools/formatting.py Text and shape formatting capabilities
utils/validation.py Input validation and sanitization
utils/pptx_helpers.py Common python-pptx operations and utilities
requirements.txt Python dependencies including python-pptx
pyproject.toml Project configuration and metadata
README.md Usage examples and MCP Gateway integration guide

πŸ“‹ Global Acceptance Checklist

  • Server starts via stdio transport (Story 1) passes.
  • Create new presentation (Story 2) succeeds.
  • Add slides with content (Story 3) works correctly.
  • Image insertion (Story 4) functions properly.
  • Text formatting (Story 5) applies correctly.
  • Slide management (Story 6) maintains presentation integrity.
  • All tools handle edge cases and invalid inputs gracefully.
  • Comprehensive test coverage β‰₯ 85%.
  • Documentation includes usage examples for each tool.
  • MCP Gateway registration example provided.

πŸ”„ Roll-Out Plan

  1. Scaffold repo mcp-servers/python/pptx_server with structure above.
  2. Implement core presentation tools: create, save, get_info.
  3. Add slide manipulation: add_slide, remove_slide, duplicate_slide.
  4. Implement content insertion: add_text, add_image, add_table.
  5. Add formatting capabilities: format_text, styling options.
  6. Create comprehensive test suite with sample presentations.
  7. Add input validation and error handling throughout.
  8. Document all tools with usage examples.
  9. Verify MCP Gateway integration and provide setup guide.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestmcp-serversMCP Server SamplespythonPython / backend development (FastAPI)

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions