Gmail Automation MCP Server
Provides tools for interacting with Gmail via the Gmail API, including listing and searching inbox emails, sending emails with optional PDF attachments, batching operations like marking as read or trashing, and classifying/labeling emails.
Integrates Perplexity AI to classify emails by relevance and generate application emails or cover letters.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gmail Automation MCP ServerShow me my 10 most recent unread emails"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
📧 Gmail Automation Suite & AI Agent 🤖
Ein modulares, performantes Python-System zur vollständigen Gmail-Automatisierung über die offizielle Google Gmail API, kombiniert mit KI-gestützter E-Mail-Klassifizierung (Perplexity AI) und einem standardisierten MCP-Server (Model Context Protocol).
🌟 Highlights & Features
⚡ Gmail API Integration: Vollständiger OAuth 2.0 Auth-Flow, Token-Management und Refresh.
📦 High-Performance Batch-Processing: Bis zu 90% weniger API-Calls durch gebündelte Batch-Operationen (
mark_as_read,trash, Labels, etc.).🧠AI-basierte E-Mail-Klassifizierung: Automatische Erkennung und Sortierung wichtiger E-Mails, Einladungen, Bestätigungen und Absagen (Perplexity AI).
🔌 Model Context Protocol (MCP): Eigener MCP-Server zur direkten Anbindung an KI-Entwicklungsumgebungen und Agents (z.B. Claude Desktop, Cursor, Copilot).
đź’» Interaktives CLI: Komfortable Befehlszeilen-Schnittstelle (
cli.py,main.py) mit interaktivem Menü.🛡️ Sicherheit & Caching: Automatische Token-Speicherung, Memory-Caching und strukturierter Logger.
Related MCP server: gmail-mcp
🏗️ Architektur & Projektstruktur
gmail_automation_project/
├── gmail_bot/ # Kernmodul
│ ├── agent/ # KI-Klassifizierer & Career-Agent (Perplexity)
│ ├── auth/ # Google OAuth 2.0 Authentifizierung
│ ├── config/ # Settings & Konfigurationsmanagement
│ ├── core/ # Gmail API Client & Exception Handling
│ ├── models/ # Datamodels (Email, Batch-Resultate)
│ ├── services/ # EmailService & High-Performance BatchProcessor
│ └── utils/ # Caching, Logging & Hilfsfunktionen
├── mcp_server/ # Standardisierter Model Context Protocol (MCP) Server
├── perplexity_agent/ # Standalone KI-Agenten & Recherchetools
├── tests/ # Pytest Unit- & Integrationstests
├── cli.py # Vollwertige CLI-Schnittstelle
├── main.py # Haupteinstiegspunkt & interaktiver Workflow
├── examples.py # Code-Beispiele zur Modulnutzung
├── pyproject.toml # Paket- & Abhängigkeitsdefinition
└── .env.example # Vorlage für Umgebungsvariablen🚀 Schnellstart & Installation
1. Voraussetzungen
Python >= 3.12
Ein Google Cloud Projekt mit aktivierter Gmail API
OAuth 2.0 Client-ID (
credentials.jsonals Desktop-Anwendung herunterladen)
2. Repository klonen & Abhängigkeiten installieren
git clone https://github.com/hawrekamil/gmail-automation.git
cd gmail-automation
# Virtuelle Umgebung erstellen und aktivieren
python -m venv .venv
source .venv/bin/activate # Unter Windows: .venv\Scripts\activate
# Abhängigkeiten installieren
pip install -e .3. Umgebungsvariablen & Google Credentials einrichten
Kopiere die Vorlage:
cp .env.example .envTrage deinen
PERPLEXITY_API_KEY(optional fĂĽr KI-Features) in die.envein.Platziere deine aus der Google Cloud Console heruntergeladene Datei
credentials.jsonim Verzeichnisconfig/credentials.json(oder direkt im Projektstamm).
đź“– Verwendung
Interaktiver Modus
Starte das interaktive Terminal-MenĂĽ:
python main.pyBeim ersten Start öffnet sich automatisch das Browserfenster zur Google-Autorisierung. Der Token wird sicher lokal für Folgesitzungen zwischengespeichert.
CLI-Nutzung
# Ungelesene E-Mails auflisten
python cli.py list --unread --limit 10
# E-Mail senden
python cli.py send --to "empfaenger@example.com" --subject "Statusupdate" --body "Hallo, hier ist das Update."
# E-Mails automatisch nach Relevanz klassifizieren und sortieren
python main.py --classifyNutzung als Python-Bibliothek
from gmail_bot.services import EmailService
service = EmailService()
# E-Mails mit Suchfilter abfragen
emails = service.get_inbox(query="from:github.com is:unread", max_results=5)
for email in emails:
print(f"Betreff: {email.subject} | Von: {email.sender}")
# High-Performance Batch-Operation
batch_processor = service.get_batch_processor()
msg_ids = [e.id for e in emails]
result = batch_processor.mark_as_read(msg_ids)
print(f"Erfolgreich: {result.success}/{result.total}")🔌 Model Context Protocol (MCP) Server
Der integrierte MCP-Server stellt KI-Modellen Werkzeuge fĂĽr Gmail zur VerfĂĽgung:
python -m mcp_server.serverVerfĂĽgbare MCP-Tools:
list_inbox: Posteingang durchsuchen und anzeigengenerate_application: Perplexity AI-Anschreiben formulierensend_application: E-Mail mit optionalem PDF-Anhang versendenclassify_emails: Automatische Kategorisierung & Labeling
đź§Ş Tests ausfĂĽhren
pytest tests/ -vđź”’ Sicherheitshinweis
Niemals
credentials.json,token.jsonoder.env-Dateien committen.Alle Secrets und persönlichen Dokumente werden über .gitignore strikt gefiltert.
đź“„ Lizenz
Dieses Projekt ist unter der MIT-Lizenz lizenziert.
This server cannot be deployed
Maintenance
Related MCP Connectors
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
1Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to read, search, organize, and draft emails in Gmail inboxes with support for multiple accounts, OAuth authentication, and 26 comprehensive tools for email management.373 npm3MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to manage Gmail emails, including sending, searching, and organizing with labels and attachments via OAuth2.17 npm2MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage Gmail through natural language, including sending, reading, searching, labeling emails, managing attachments, and performing thread operations.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to send, read, list, and reply to emails via the Gmail API.Apache 2.0