Add Gmail Send Tool (send_email_gmail) with OAuth Authentication
Resolved 💬 2 comments Opened Jan 15, 2026 by ahmedyounis Closed Feb 13, 2026
Problem
Currently, emails sent via AWS SES (send_email tool) are not saved anywhere accessible. There's no way to retrieve what was sent later, and it requires separate AWS credentials.
Solution
Add a new send_email_gmail tool that sends emails via Gmail API using existing OAuth authentication (same tokens used for reading emails).
Benefits
- Sent emails appear in Gmail Sent folder automatically
- Can be retrieved later using existing Gmail tools (
list_emails,get_email) - Uses existing OAuth tokens (no additional credentials needed)
- Returns
message_idandthread_idfor conversation tracking
Implementation
Add new tool to merakey-mcp-server/src/tools/gmail.ts:
- Reuse
buildRawEmail()fromemail-builder.tsfor MIME email construction - Use existing
getGmailClient()for OAuth authentication - Call
gmail.users.messages.send()with base64-encoded email - Support both
merakeyandhealexaccounts - Auto-log activity to CRM if
log_to_client_idorlog_to_lead_idprovided
Technical Details
- Gmail API method:
gmail.users.messages.send({ userId: 'me', requestBody: { raw: base64Email } }) - Encoding: Base64URL encoding required
- Scope: Already granted (
gmail.modify) - Rate limits: 1000 messages/day (free tier), 10,000/day (Google Workspace)
Use Cases
Gmail send (send_email_gmail):
- Personal correspondence
- Client emails you need to reference later
- Emails that should appear in Sent folder
AWS SES (send_email):
- Bulk/transactional emails (invoices, notifications)
- Emails from verified sender identities (billing@merakey.io)
Files to Modify
merakey-mcp-server/src/tools/gmail.ts- Addsend_email_gmailtool- Import from
merakey-mcp-server/src/tools/utils/email-builder.ts(no changes needed)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗