An open-source, plug-and-play toolkit for running personalized Gmail outreach and automated follow-ups β controllable over the Model Context Protocol (MCP) so you can drive it from any MCP-compatible client or run it as a 24/7 background service.
Everything that's specific to a campaign β sender identity, subject lines, email
copy, and your contact list β lives in config files and the templates/
directory. The code itself ships with no business, industry, or personal data
baked in. Clone it, drop in your credentials, edit a few text files, and go.
β οΈ Send responsibly. Only email people who have agreed to hear from you, honor unsubscribe/opt-out requests, respect Gmail's sending limits, and comply with anti-spam laws (e.g. CAN-SPAM, GDPR, CASL) in your jurisdiction.
- Features
- How it works
- Project structure
- Quick start
- MCP server
- Configuration reference
- Deployment
- Security & privacy
- More docs
- Contributing
- License
- CSV-driven outreach β send templated, personalized emails to a contact list.
- Automated follow-up sequences β configurable timing (default: day 3 and day 7).
- Response tracking β incremental, idempotent Gmail sync detects replies.
- Keyword-based lead scoring β categorize replies as interested / not interested.
- Auto-replies β optionally respond to interested leads automatically.
- MCP server β start/stop/monitor the agent from any MCP client.
- Runs anywhere β locally, via Docker, or as a systemd service.
ββββββββββββββββββββ
MCP client ββββΊ β mcp_server β βββΊ start / stop / status / report
(Claude, CLI) ββββββββββ¬ββββββββββ
β drives
βΌ
contacts.csv βββΊ ββββββββββββββββββββ βββΊ personalized emails βββ
templates/ βββΊ β lead_nurturer β βΌ
config βββΊ ββββββββββ¬ββββββββββ ββββββββββββββ
β reads replies, scores leads β Gmail API β
βββββββββββββββββββββββββββββββββ€ (OAuth2) β
ββββββββββββββ
- Outreach β
send_from_csv.pysends yourbody.txttemplate to each row incontacts.csv, rate-limited and logged. - Listen β each cycle,
lead_nurturer.pychecks Gmail for replies (incrementally, never reprocessing a message) and scores them against your keywords. - Follow up β leads who haven't replied get follow-ups on your schedule; interested leads optionally get an auto-reply.
- Control β run it once, on a scheduler, or as an MCP server you drive from any MCP client.
βββ send_from_csv.py # One-shot CSV email sender (initial outreach)
βββ lead_nurturer.py # Follow-up sequences, response tracking, scoring
βββ mcp_server.py # MCP server exposing control tools
βββ mcp_client.py # Simple CLI client for the MCP server
βββ lead_dashboard.py # Prints a status dashboard
βββ run_nurturing.py # Standalone scheduler (no MCP needed)
βββ templates/ # Your email copy (Jinja2) β edit these
β βββ initial.txt
β βββ followup_1.txt
β βββ followup_2.txt
β βββ interested.txt
βββ contacts.csv # Sample contact list β replace with your own
βββ body.txt # Body template for send_from_csv.py
βββ nurturing_config.json # Sender identity, schedule, scoring, automation
βββ credentials.example.json # Template for your Gmail OAuth client
βββ env.example # Template for environment variables
βββ Dockerfile / docker-compose.yml / deploy.sh
βββ gmail-mcp-agent.service # systemd unit template
Files generated at runtime (git-ignored): token.json, lead_tracking.json,
gmail_sync_state.json, send_log.csv, mcp_server.log.
Prerequisites: Python 3.11+, a Google account, and (optionally) Docker.
git clone https://github.com/brandononchain/GMAIL-MCP-Agent.git
cd GMAIL-MCP-Agent
pip install -r requirements.txt- Open the Google Cloud Console and create (or select) a project.
- Enable the Gmail API.
- Create an OAuth client ID of type Desktop app.
- Download the JSON and save it as
credentials.jsonin the project root. (Seecredentials.example.jsonfor the expected shape.)
The first time you run a command, a browser window opens for you to authorize
access; a token.json is then cached locally for reuse.
nurturing_config.jsonβ setsender_name,company_name, follow-up timing, scoring, and automation toggles. Leavesender_emailblank to use the address of the authenticated Gmail account.templates/β editinitial.txt,followup_1.txt,followup_2.txt, andinterested.txt. They're Jinja2 templates; any CSV column is available (e.g.{{ first_name }},{{ company }}), plus{{ sender_name }}and{{ company_name }}.contacts.csvβ replace the sample rows with your list. Atocolumn is required;first_nameandcompanyare optional but used for personalization.
# Send the body.txt template to everyone in contacts.csv
python send_from_csv.py contacts.csv --subject "Quick question" --body_file body.txt# One cycle: check for replies, send any due follow-ups, print a report
python lead_nurturer.py
# Or keep it running on a schedule (interval from config)
python run_nurturing.pyRun the agent as an MCP server so any MCP-compatible client can control it:
python mcp_server.pyIt exposes these tools:
| Tool | Description |
|---|---|
start_nurturing |
Start the background loop (interval_hours) |
stop_nurturing |
Stop the background loop |
run_single_cycle |
Run one nurturing cycle now |
get_status |
System status and lead statistics |
get_lead_report |
Detailed lead report |
update_config |
Update nurturing_config.json (hot-reloaded) |
send_test_email |
Send a test email to an address |
get_logs |
Tail recent server logs |
A minimal CLI client is included:
python mcp_client.py start 4 # start, every 4 hours
python mcp_client.py status
python mcp_client.py report
python mcp_client.py test you@example.com
python mcp_client.py stopTo register the server with an MCP client (e.g. Claude Desktop), point it at
python /absolute/path/to/mcp_server.py.
Environment variables (see env.example) configure send_from_csv.py β
credentials/token paths, default sender, rate limiting (PER_MINUTE), and the
log file.
Docker (recommended):
./deploy.sh # build + run with docker-compose
# or
docker-compose up -ddocker-compose.yml mounts your credentials.json, contacts.csv, body.txt,
templates/, and nurturing_config.json into the container, so you can edit
copy without rebuilding.
systemd: edit the paths/user in gmail-mcp-agent.service, then:
sudo cp gmail-mcp-agent.service /etc/systemd/system/
sudo systemctl enable --now gmail-mcp-agent- OAuth2 is used for Gmail access β no passwords are stored.
credentials.json,token.json,.env, and all runtime state files are git-ignored. Never commit them.- All data stays local; nothing is sent to third parties.
SETUP.mdβ step-by-step setupNURTURING_README.mdβ how nurturing & scoring workDEPLOYMENT_GUIDE.mdβ production deployment & opstemplates/README.mdβ writing email templates
Contributions are welcome β open an issue or submit a pull request.
Released under the MIT License.
{ "sender_email": "", // blank = use the authenticated Gmail account "sender_name": "Your Name", "company_name": "Your Company", "contacts_file": "contacts.csv", "templates_dir": "templates", "subjects": { // Jinja2 subject lines per stage "followup_1": "Following up, {{ first_name }}", "followup_2": "One last note", "interested": "Re: Great to hear from you" }, "follow_up_schedule": { "followup_1_days": 3, "followup_2_days": 7, "max_follow_ups": 2 }, "response_keywords": { "interested": ["interested", "yes", "demo", "call"], "not_interested": ["not interested", "no thanks", "stop", "unsubscribe"] }, "lead_scoring": { "response_bonus": 10, "interest_bonus": 5, "follow_up_penalty": -1 }, "automation": { "check_responses_interval_hours": 4, "auto_respond_to_interest": true, "auto_send_follow_ups": true } }