- MCP AI Agent
MCP AI Agent
MCP AI Agent
This project demonstrates an intelligent agent that can perform complex mathematical operations, create visual presentations, and communicate results via email using Google's services. It showcases the integration of multiple MCP (Model Context Protocol) servers working together to solve a compound task.
Project Goal
The main goal is to solve the following task:
Calculate the sum of exponential of first five fibonacci numbers, write the answer in a slide, download it as a PNG file, and send it via email.
This involves:
- Mathematical computation (Fibonacci + exponential)
- Visual presentation (Google Slides)
- Communication (Gmail)
System Architecture
The system consists of three main MCP servers:
-
Math Server (
mcp_servers/math_server.py)- Calculates Fibonacci sequences
- Performs exponential operations
- Handles mathematical computations
-
Slides Server (
mcp_servers/slides_server.py)- Creates Google Slides presentations
- Adds text to slides
- Downloads slides as PNG images
-
Gmail Server (
mcp_servers/gmail_server.py)- Sends emails with attachments
- Manages email operations (read, trash, mark as read)
- Handles Gmail API authentication
Setup Instructions
Prerequisites
- Python 3.8+
- Linux/Unix environment (tested on Linux 5.15.0-136-generic)
- X11 display server (for slides functionality)
- Google account with Gmail and Google Slides access
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Google API Setup
-
Gmail Setup:
- Create project in Google Cloud Console
- Enable Gmail API
- Create OAuth 2.0 credentials
- Save credentials as
mcp_servers/credentials.json
-
Environment Variables (optional):
GMAIL_CREDS_FILE: Path to credentials.jsonGMAIL_TOKEN_FILE: Path to token.json
Usage
- Start the agent:
python agent.py
- The system will:
- Calculate the Fibonacci sequence and exponentials
- Create a slide with the result
- Save the slide as PNG in
content/slide.png - Send the PNG via email
Project Structure
.
├── agent.py # Main agent implementation
├── ai.py # Gemini Interactions
├── prompt.py # Prompt used for the project
├── mcp_servers/
│ ├── slides_server.py # Google Slides operations
│ ├── gmail_server.py # Gmail operations
│ └── math_server.py # Mathematical computations
├── content/ # Generated content (slides, images)
└── requirements.txt # Project dependencies
Troubleshooting
- Display Issues: Ensure X11 display server is running
- Gmail Authorization:
- First run will prompt for Google account access
- If auth fails, delete
token.jsonand retry
- File Paths:
- Images are saved to
content/slide.png - Use absolute paths when specifying file locations
- Images are saved to
Example Output
After running the agent, you should:
- See mathematical calculations in the console
- Find a PNG file in the content directory
- Receive an email with the PNG attachment
