suryaashish130703/powerpoint-automation-agent
If you are the rightful owner of powerpoint-automation-agent and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This project demonstrates an AI agent that solves mathematical problems and visualizes the results using Microsoft Paint through an MCP (Model Context Protocol) server.
PowerPoint Automation Agent with MCP Server
This project demonstrates an AI agent that solves mathematical problems and automatically visualizes the results using Microsoft PowerPoint through an MCP (Model Context Protocol) server, with email logging capabilities.
Features
- 🤖 AI-powered mathematical problem solving using Google Gemini
- 📊 Automated PowerPoint presentation creation and manipulation
- 🎨 Automatic rectangle drawing and text insertion
- 📧 Email logging and notifications (success/error reports)
- 🔄 Iterative problem-solving with detailed logging
- 🖥️ Single monitor support (optimized for primary display)
Prerequisites
- Windows 10/11
- Python 3.8+
- Microsoft PowerPoint (Office 365 or standalone)
- Google Gemini API key
- Email account for logging (Gmail recommended)
Installation
-
Clone or download the project files
-
Install Python dependencies:
pip install -r requirements.txt -
Set up your environment configuration:
- Create a
.envfile in the project directory - Copy settings from
email_config_template.txt - Add your API key and email settings:
GEMINI_API_KEY=your_api_key_here SENDER_EMAIL=your-email@gmail.com SENDER_PASSWORD=your_app_password_here RECIPIENT_EMAIL=recipient@example.com SMTP_SERVER=smtp.gmail.com SMTP_PORT=587
- Create a
-
Configure Email Logging (Optional but Recommended):
- For Gmail users:
- Enable 2-Factor Authentication on your Google account
- Go to Google Account Settings > Security > 2-Step Verification > App passwords
- Generate an app password for "Mail"
- Use this app password (not your regular Gmail password) as
SENDER_PASSWORD
- Test your email configuration:
python test_email_logger.py
- For Gmail users:
Files Overview
powerpoint_working_agent.py- Main agent script that solves math problems and controls PowerPointpowerpoint_working_mcp_server.py- MCP server that provides PowerPoint automation toolsemail_logger.py- Email logging module for sending execution logs and notificationstest_email_logger.py- Test script to verify email configurationemail_config_template.txt- Template for email configuration settingsrequirements.txt- Python dependenciesREADME.md- This documentation file
Usage
Quick Start
- Run the PowerPoint agent:
python powerpoint_working_agent.py
What the Agent Does
The agent follows this workflow:
-
Mathematical Problem Solving:
- Solves: "Find ASCII values of characters in 'INDIA' and return sum of exponentials"
- Uses iterative approach with detailed logging
- Shows each step in the terminal
-
PowerPoint Visualization (6 steps):
- Step 1: Opens Microsoft PowerPoint and creates new presentation
- Step 2: Selects rectangle shape (Insert → Shapes → Rectangle)
- Step 3: Draws a rectangle centered on the slide
- Step 4: Selects text box tool (Insert → Text Box)
- Step 5: Clicks inside rectangle area to place text box
- Step 6: Pastes the final result inside the rectangle
Terminal Output
The agent provides detailed logging with clear iteration headers:
============================================================
ITERATION 1: Processing
============================================================
Starting LLM generation...
LLM generation completed
LLM Response: FUNCTION_CALL: strings_to_chars_to_int|INDIA
Calling function: strings_to_chars_to_int
Parameters: ['INDIA']
Function result: [73, 78, 68, 73, 65]
=== AUTOMATIC POWERPOINT WORKFLOW STARTING ===
============================================================
ITERATION 1: Opening PowerPoint and Creating New Presentation
============================================================
ITERATION 1 COMPLETE: PowerPoint opened successfully
Email Logging Features
The agent includes comprehensive email logging capabilities:
📧 Automatic Email Notifications
- Success Emails: Sent when the agent completes successfully
- Error Emails: Sent when the agent encounters errors
- Detailed Logs: All execution steps are included in the email
📋 Email Content Includes:
- Final mathematical result
- Execution time and timestamp
- Complete step-by-step logs
- Status (SUCCESS/ERROR)
- Formatted HTML emails with color-coded logs
🔧 Email Configuration:
- Supports Gmail, Outlook, Yahoo, and custom SMTP servers
- Uses App Passwords for Gmail (more secure than regular passwords)
- Configurable sender and recipient emails
- Test script included to verify configuration
📤 Email Examples:
- Success: "✅ PowerPoint Automation - SUCCESS" with final result and logs
- Error: "❌ PowerPoint Automation - ERROR" with error details and logs
MCP Server Tools
The PowerPoint MCP server provides these tools:
open_powerpoint()- Opens PowerPoint and creates new presentationselect_rectangle_shape()- Selects rectangle shape (Insert → Shapes → Rectangle)draw_rectangle_centered()- Draws rectangle centered on slideselect_text_box()- Selects text box tool (Insert → Text Box)click_inside_rectangle()- Clicks inside rectangle area to place text boxpaste_number(text)- Pastes text inside the rectangle
Customization
Changing Rectangle Position
Edit the coordinates in powerpoint_working_mcp_server.py:
# In draw_rectangle_centered function
slide_center_x = 400 # Center X
slide_center_y = 300 # Center Y
rect_width = 200 # Rectangle width
rect_height = 100 # Rectangle height
Modifying the Math Problem
Change the query in powerpoint_working_agent.py:
query = """Your custom math problem here. After getting the final answer, open PowerPoint, draw a rectangle, and write the result inside it."""
Troubleshooting
Common Issues
-
PowerPoint doesn't open:
- Ensure Microsoft PowerPoint is installed
- Check if PowerPoint is accessible via
powerpnt.exe
-
Tool selection fails:
- PowerPoint interface may vary by version
- The server uses keyboard shortcuts for reliability
-
Rectangle drawing issues:
- Adjust coordinates based on your screen resolution
- The server tries multiple drawing methods automatically
-
API key errors:
- Verify
.envfile exists and contains validGEMINI_API_KEY - Check API key permissions
- Verify
Debug Mode
Run with verbose output:
python -u powerpoint_working_agent.py
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────┐
│powerpoint_agent │───▶│powerpoint_mcp_ │───▶│ Microsoft │
│ (Main Logic) │ │ server │ │ PowerPoint │
└─────────────────┘ └──────────────────┘ └─────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Google Gemini │ │ Windows API │
│ (AI Model) │ │ (pywinauto, etc) │
└─────────────────┘ └──────────────────┘
License
This project is for educational and demonstration purposes.