Gmail Inbox Triage MCP
Provides tools for triaging Gmail inboxes, including listing new emails, retrieving full email content, marking emails as processed with notes, and retrieving triage instructions.
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 Inbox Triage MCPList my new emails from the last hour."
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 Inbox Triage MCP
A small, single-process Python service that polls one or more Gmail inboxes over IMAP and exposes the queued mail through the official Model Context Protocol (MCP) Python SDK using Streamable HTTP at /mcp.
What is included
FastAPI admin panel at
/with a single admin password.SQLite database for accounts, UID checkpoints, queue, notes, settings, and activity logs.
Background poller in the same process as the UI and MCP endpoint.
IMAP over TLS to
imap.gmail.com:993usingBODY.PEEK[], so mail stays unread.First sync for a newly registered account records the current highest UID and imports nothing.
Subsequent cycles import only UIDs greater than the saved checkpoint.
MIME header decoding,
text/plainpreference, and HTML-to-text fallback.MCP tools:
list_new_emails,get_email,mark_processed, andget_instructions.
Related MCP server: Moist
Local run
cd email_automation_mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env and set both secrets to long random values.
python -m appOpen http://localhost:8000/. The MCP endpoint is http://localhost:8000/mcp.
Generate secrets with:
python -c 'import secrets; print(secrets.token_urlsafe(32))'Run checks:
pytest -qGmail prerequisites
For every Gmail account you add:
Turn on 2-Step Verification for the Google account.
Create a Gmail App Password (Google Account → Security → App passwords).
Enter the 16-character app password in the admin form. The service stores it only for IMAP login and never returns it in the UI, MCP responses, or logs.
Confirm IMAP is enabled in Gmail settings if the account exposes that setting.
Use the full Gmail address and a descriptive label such as Personal or Support.
MCP tools
list_new_emails(account?: string, limit?: int)returnsid, account label/email, sender, recipient, date, subject, a body truncated to 3,000 characters, status, and that account's instructions.get_email(id)returns the full stored email body and metadata.mark_processed(ids: string[], note?: string)marks records processed and stores an optional note. Processed records are never returned bylist_new_emails.get_instructions()returns global triage instructions, per-account overrides, and the poll interval.
Direct MCP clients may authenticate to /mcp with the static bearer token:
Authorization: Bearer YOUR_MCP_BEARER_TOKENChatGPT custom MCP connections use OAuth 2.1. This app includes a small
SQLite-backed OAuth authorization server with PKCE and dynamic client
registration. On the first connection ChatGPT opens the app's consent page;
approve it once, then ChatGPT uses the issued access token. Set
PUBLIC_BASE_URL (and, when it differs, MCP_ISSUER_URL and
MCP_RESOURCE_URL) to the deployed HTTPS origin.
Recommended deployment: Render
Render is the recommended cheap host because it runs the container as one long-lived process and can attach a persistent disk for SQLite. Create a Web Service from this repository; render.yaml is included as a blueprint.
Push this folder to a Git repository.
In Render, choose New → Blueprint and select the repository.
Set
MCP_BEARER_TOKEN,ADMIN_PASSWORD, andADMIN_SESSION_SECRETas secret environment variables.Set
PUBLIC_BASE_URLto the Render HTTPS URL, keepMCP_ISSUER_URLequal to it, and setMCP_RESOURCE_URLto<URL>/mcp.Keep
DATABASE_PATH=/app/data/app.dband use the included 1 GB disk. The disk requires Render's paid starter plan; the free plan runs but does not persist SQLite between deploys or restarts.Deploy. Render's built-in TLS gives you an HTTPS URL such as
https://gmail-triage-mcp.onrender.com.Visit the URL, sign in, add Gmail accounts, and use the MCP URL (
https://.../mcp).
Railway and Fly.io can run the same Dockerfile. Railway reads railway.json; for Fly, create a volume mounted at /app/data, set DATABASE_PATH=/app/data/app.db, and expose port 8000.
Vercel project (included)
The repository includes api/index.py and vercel.json, so it can be imported as a Vercel project:
npm install -g vercel
vercel login
vercel --prodSet MCP_BEARER_TOKEN, ADMIN_PASSWORD, ADMIN_SESSION_SECRET, MCP_ALLOWED_HOSTS (your Vercel hostname), and COOKIE_SECURE=true in the Vercel project settings, then redeploy. The resulting MCP URL is https://YOUR_PROJECT.vercel.app/mcp.
Operational limitation: Vercel Python Functions are request-scoped. They do not keep the background IMAP poller alive between requests, and a local SQLite file is not durable across instances. The Vercel adapter is useful for a project preview or MCP/UI smoke test; use Render/Railway/Fly with persistent storage for the required continuous polling behavior. If you need Vercel for the frontend, keep the long-running worker on Render and point ChatGPT at the worker's /mcp URL.
Add it to ChatGPT as a custom connector
The exact menu wording can vary by ChatGPT version, but the flow is:
Turn on Developer mode in ChatGPT under Settings → Security and login if your account or workspace requires it.
Open Settings → Connectors (the UI may call this Plugins) and choose Add custom connector.
Name it
Gmail Inbox Triageand enter the deployed MCP URL, including/mcp.Choose the OAuth connection option. ChatGPT discovers the authorization and registration endpoints from the server metadata.
Complete the consent page in the browser. Do not enter a Gmail app password in ChatGPT; Gmail credentials stay in the admin panel.
Confirm that ChatGPT discovers
list_new_emails,get_email,mark_processed, andget_instructions.
The static bearer token remains available for direct MCP clients and smoke tests. ChatGPT does not accept a customer-supplied API key for an MCP connection, so use the built-in OAuth flow.
Example scheduled-task prompt:
Every 30 minutes, call
list_new_emails(use a reasonable limit), callget_instructions, process each queued email according to the global instructions and the matching account instructions, then callmark_processedfor every email with a short note summarizing what you did. Do not mark an email processed if you could not complete the requested triage.
Security and operations
Keep
.envand the SQLite data directory private.Use a long random MCP bearer token and admin password; rotate them by updating environment variables and redeploying.
The poller catches per-account authentication, network, and parsing errors, records them in the activity log, and continues with the other accounts.
Activity logs contain connection state, queued subjects, errors, and MCP tool calls, but never app passwords.
This server cannot be deployed
Maintenance
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Your agent needs a mailbox of its own — to receive, thread, draft and send, with attachments, without borrowing your personal inbox or your company's SMTP. **What you can ask for** • "Create an inbox for this agent and tell me its address." • "Read the new messages in this thread and draft a reply." • "Send this message with the attachment and wait for the response." • "Search this inbox for everything from that domain." • "Show delivery metrics and the events on this inbox." **How to use it** Point any MCP client at https://mcp.aisa.one/mail/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: create and delete inboxes, list and read messages, raw message bodies, attachments, threads, drafts and draft attachments, send and reply, message search, inbox events, metrics, and list entries — reads and writes. **Why this rather than the source** A real inbox an agent owns, rather than an SMTP credential it borrows from a human. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the contact elsewhere in the catalogue, then write to them from here — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/sales/mcp finds the person to write to.
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that integrates with Gmail to enable sending, reading, and managing emails through tools like send-email, trash-email, get-unread-emails, and read-email.72GPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables Gmail operations such as reading, sending, searching, and managing emails, threads, labels, and drafts via MCP tools.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables searching, reading, and drafting emails across multiple Gmail accounts through a single MCP server.-
- FlicenseNot gradedqualityCmaintenanceIntegrates with the Gmail API to send and read emails through MCP tools using Google OAuth authentication.-