-
Notifications
You must be signed in to change notification settings - Fork 613
[FEATURE][MCP-SERVER]: Python sample - PowerPoint editor (python-pptx)Β #989
Copy link
Copy link
Closed
Copy link
Labels
enhancementNew feature or requestNew feature or requestmcp-serversMCP Server SamplesMCP Server SamplespythonPython / backend development (FastAPI)Python / backend development (FastAPI)
Milestone
Description
π§ 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 pathtemplate?: 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.* toolsUser 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 successUser 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 slideUser 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 insertionUser 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, boldUser 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
π 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
- Scaffold repo
mcp-servers/python/pptx_serverwith structure above. - Implement core presentation tools: create, save, get_info.
- Add slide manipulation: add_slide, remove_slide, duplicate_slide.
- Implement content insertion: add_text, add_image, add_table.
- Add formatting capabilities: format_text, styling options.
- Create comprehensive test suite with sample presentations.
- Add input validation and error handling throughout.
- Document all tools with usage examples.
- Verify MCP Gateway integration and provide setup guide.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestmcp-serversMCP Server SamplesMCP Server SamplespythonPython / backend development (FastAPI)Python / backend development (FastAPI)