Office PowerPoint MCP Server
The `office-powerpoint-mcp-server` library provides a Flask-based HTTP API server for programmatic manipulation of PowerPoint presentations using `python-pptx`. It exposes endpoints to open, save, add slides, add text boxes, and perform various other operations on PPTX files. The current version is 2.0.7, with updates occurring infrequently as it wraps `python-pptx`.
Common errors
-
ModuleNotFoundError: No module named 'office_powerpoint_mcp_server'
cause The `office-powerpoint-mcp-server` package is not installed in the active Python environment, or the environment is not correctly activated.fixEnsure the package is installed by running `pip install office-powerpoint-mcp-server`. If using a virtual environment, activate it before running the command. -
OSError: [Errno 98] Address already in use
cause Another process is already using the specified host and port (default: 127.0.0.1:5000) that the server is attempting to bind to.fixChange the port by running `python -m office_powerpoint_mcp_server --port <ANOTHER_PORT>` (e.g., 5001), or identify and terminate the process currently occupying the port. -
HTTP 400 Bad Request (and server logs showing KeyError: 'filename' or similar)
cause The JSON payload sent to an API endpoint is missing a required key (e.g., 'filename', 'text') or has an incorrect structure, as defined by the server's expected input for that endpoint.fixConsult the `app.py` source code on GitHub (specifically the route definitions) to understand the exact expected JSON structure and required keys for the endpoint you are calling. Ensure your client sends all necessary parameters with correct keys.
Warnings
- gotcha The server does not include any built-in authentication or authorization mechanisms. Exposing it on a public network without additional security measures (e.g., reverse proxy with auth) can lead to unauthorized PowerPoint file manipulation.
- breaking While no explicit changelog exists, upgrading from `1.x` to `2.x` might introduce changes to API endpoint paths or expected JSON payload structures. Always test upgrades thoroughly.
- gotcha The default port (5000) might conflict with other applications (e.g., Flask development servers, common services). If the server fails to start, check for port conflicts.
Install
-
pip install office-powerpoint-mcp-server
Imports
- app
from office_powerpoint_mcp_server import app
Quickstart
import subprocess
import time
import requests
print("Starting Office PowerPoint MCP Server...")
# Use a non-default port to reduce conflict chances for example
server_process = subprocess.Popen(['python', '-m', 'office_powerpoint_mcp_server', '--host', '127.0.0.1', '--port', '5001'])
server_url = "http://127.0.0.1:5001"
try:
print(f"Server started. Waiting 5 seconds to ensure it's up on {server_url}...")
time.sleep(5) # Give the server time to start
# Test if the server is reachable
try:
response = requests.get(server_url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
print(f"Server is reachable! Response: {response.text}")
except requests.exceptions.ConnectionError:
print("Error: Could not connect to the server. It might not have started correctly.")
except requests.exceptions.RequestException as e:
print(f"An unexpected error occurred: {e}")
print(f"You can now send HTTP requests to its API endpoints, e.g., POST to {server_url}/open or {server_url}/save")
print("To stop the server, interrupt this script (Ctrl+C).")
# In a real scenario, you'd make various HTTP requests here to manipulate PowerPoint files.
input("Press Enter to stop the server...") # Keep process alive until user input
finally:
print("Stopping server...")
server_process.terminate()
server_process.wait()
print("Server stopped.")