This project is a demo of a chat application that interacts with an AI model to analyze emails. The application leverages a custom MCP server and provides tools that allow the AI to access and analyze emails from the Apple Mail client on a MacBook.
- Clone the Repository:
git clone https://github.com/nikyta384/mails-analysis-chat.git cd mails-analysis-chat - Set up a Virtual Environment:
python3 -m venv venv source venv/bin/activate - Install Requirements:
pip install -r requirements.txt
- Choose model: If you choose llama3.2, you must provide a URL for the llama model. You can specify the URL using the --llama-url flag, or the default URL http://localhost:11434/v1 will be used (see command for running in step 4).
If you choose openai:gpt-4.1-mini, ensure your OPENAI_APIKEY environment variable is set with your OpenAI API key.
export OPENAI_API_KEY="your-openai-api-key"- Running the Application:
python3 run.py --model <model-type> # llama3.2 or openai:gpt-4.1-mini
The AI agent has access to the following tools to interact with the user's emails:
check_email_for_hours(hours, exclude_subjects=None) Fetches emails from the last specified number of hours, excluding specified subjects.
check_latest_emails(n, exclude_subjects=None) Retrieves the latest n emails, excluding specified subjects.
##NOTE Ensure that your MacBook has Apple Mail configured and accessible by the AppleScript, as the tools rely on it to fetch and analyze emails.