Personal AI Assistant using MCP
A comprehensive personal AI assistant built with Model Context Protocol (MCP) that can handle email, PDF reading, meeting scheduling, web search, pizza ordering, and interactive questioning while protecting your private information.
Features
Core Capabilities (7 points total)
- 📧 Email Management (1pt)
- Write and send emails on your behalf - Support for both plain text and HTML emails - Privacy protection for email content
- 📄 PDF Reading & Q&A (1pt)
- Read multiple PDF files and extract text - Answer questions about PDF content - Automatic privacy detection and local processing
- 📅 Meeting Scheduling (1pt)
- Schedule meetings in your calendar - Create iCalendar (.ics) files - Conflict detection and management - Meeting reminders
- 🔍 Web Search (1pt)
- Real-time internet search - Multiple search providers (Google, DuckDuckGo) - News search capabilities - Fallback web scraping
- 🍕 Pizza Ordering (2pt)
- Order from multiple pizza providers (Domino's, Pizza Hut, Local) - Menu browsing and price calculation - Order tracking and confirmation - Address and phone validation
- ❓ Interactive Questioning (2pt)
- Ask questions for clarification - Handle private information requests - Context-aware questioning - Privacy-aware responses
Key Requirements (2pt)
- 🔒 Privacy Protection
- Local LLM processing for private data - Automatic private information detection - Data masking and sanitization - No private data leakage to public APIs
Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ MCP Client │◄──►│ MCP Server │◄──►│ External APIs │
│ │ │ │ │ │
│ - User Interface│ │ - Tool Registry │ │ - OpenAI/Claude │
│ - Input Handling│ │ - Privacy Mgmt │ │ - Email SMTP │
│ - Response Display│ │ - Local LLM │ │ - Web Search │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Local Storage │
│ │
│ - PDFs │
│ - Meetings │
│ - Orders │
└─────────────────┘Installation
Prerequisites
- Python 3.8 or higher
- pip package manager
- Chrome browser (for web scraping)
- Local LLM setup (optional, for private data processing)
Setup
- Clone or download the project
cd /Users/simranjotkaur/Desktop/Programming LLMs/HW3- Install dependencies
pip install -r requirements.txt- Set up environment variables
Create a .env file in the project root:
# API Keys
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# Email Configuration
EMAIL_ADDRESS=your_email@gmail.com
EMAIL_PASSWORD=your_app_password_here
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
# Local LLM Configuration (for private data processing)
LOCAL_LLM_URL=http://localhost:11434/v1
LOCAL_LLM_MODEL=llama2
# Calendar Configuration
CALENDAR_EMAIL=your_calendar_email@gmail.com
# Pizza Ordering APIs (example - replace with actual APIs)
DOMINOS_API_KEY=your_dominos_api_key
PIZZA_HUT_API_KEY=your_pizza_hut_api_key
# Web Search
GOOGLE_SEARCH_API_KEY=your_google_search_api_key
GOOGLE_SEARCH_ENGINE_ID=your_search_engine_id- Set up local LLM (optional but recommended)
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Pull a model
ollama pull llama2
# Start Ollama server
ollama serveUsage
Running the MCP Server
python run_server.pyRunning the MCP Client
python run_client.pyInteractive Commands
The client provides an interactive menu with the following options:
- Send Email
- Enter recipient, subject, and body - Choose HTML or plain text format - Automatic privacy checking
- Read PDF
- Provide PDF file path - Ask questions about the content - Automatic private data detection
- Schedule Meeting
- Enter meeting details - Set start/end times - Add attendees and description - Automatic conflict checking
- Web Search
- Enter search query - Specify number of results - Real-time information retrieval
- Order Pizza
- Choose provider (Domino's, Pizza Hut, Local) - Select pizza type and size - Add toppings and delivery details - Price calculation and confirmation
- Ask Question
- Ask for clarification or private information - Context-aware questioning - Privacy-aware responses
Privacy Protection
Automatic Detection
The system automatically detects private information using:
- Pattern Matching: SSN, credit cards, phone numbers, emails
- Keyword Detection: Personal, private, confidential, etc.
- Context Analysis: Addresses, bank accounts, etc.
Local Processing
When private data is detected:
- Local LLM Processing: Uses Ollama or similar local LLM
- Data Masking: Automatically masks sensitive information
- No External APIs: Private data never leaves your machine
- Secure Storage: Local file storage with proper permissions
Privacy Keywords
The system monitors for these privacy-related terms:
- password, ssn, social security
- credit card, bank account
- personal, private, confidential
- address, phone number
File Structure
HW3/
├── README.md # This file
├── requirements.txt # Python dependencies
├── config.py # Configuration management
├── mcp_server.py # Main MCP server
├── mcp_client.py # MCP client interface
├── privacy_manager.py # Privacy protection
├── local_llm_client.py # Local LLM integration
├── web_scraper.py # Web search and scraping
├── pizza_ordering.py # Pizza ordering system
├── calendar_manager.py # Meeting scheduling
├── run_server.py # Server startup script
└── run_client.py # Client startup scriptAPI Integration
Email (SMTP)
- Gmail SMTP support
- App password authentication
- HTML and plain text support
Web Search
- Google Custom Search API
- DuckDuckGo fallback
- Selenium-based scraping
Pizza Ordering
- Multiple provider support
- Menu and pricing integration
- Order tracking simulation
Calendar
- iCalendar (.ics) file generation
- Meeting conflict detection
- Reminder system
Security Features
- Environment Variables: Sensitive data stored in .env
- Input Validation: All inputs validated and sanitized
- Error Handling: Comprehensive error handling
- Logging: Detailed logging for debugging
- Rate Limiting: Built-in rate limiting for APIs
Troubleshooting
Common Issues
- Email not sending
- Check SMTP credentials - Enable app passwords for Gmail - Verify firewall settings
- PDF reading fails
- Ensure PDF is not password protected - Check file permissions - Try different PDF libraries
- Web search not working
- Check API keys - Verify internet connection - Try fallback scraping
- Local LLM not responding
- Ensure Ollama is running - Check model availability - Verify URL configuration
Debug Mode
Enable debug logging by setting:
logging.basicConfig(level=logging.DEBUG)Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is for educational purposes. Please ensure you comply with all API terms of service and local regulations.
Support
For issues and questions:
- Check the troubleshooting section
- Review the logs for error messages
- Ensure all dependencies are installed
- Verify environment variables are set correctly
Note: This is a demonstration project. In production, additional security measures, error handling, and testing would be required.
