Gmail MCP Server
Provides tools for interacting with a Gmail account, including searching and reading emails, sending emails, creating drafts, listing labels, modifying labels, and trashing messages.
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 MCP Servercheck my unread emails from this week"
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 MCP Server
A custom, open-source Model Context Protocol (MCP) server that connects AI assistants (Google Antigravity IDE, Claude Desktop, Cursor) directly to your Gmail account using the official Google Workspace APIs.
š Highlights
Complete Email Actions: Search, read, compose drafts, send emails, modify labels, and trash messages.
Smart Content Extraction: Automatically handles multipart MIME messages, decodes Base64 data, extracts attachment metadata, and formats HTML into clean text.
Local & Secure: Runs completely locally over
stdiotransport. Your credentials and tokens never leave your machine.Automatic Token Management: Performs interactive browser OAuth on the first run and silently refreshes expired tokens thereafter.
Multi-Client Support: Works with Antigravity IDE, Claude Desktop, Cursor, and any MCP-compliant client.
Related MCP server: Gmail MCP Server
š ļø Available MCP Tools
Tool Name | Parameters | Description |
|
| Search emails using standard Gmail filters ( |
|
| Fetch full message headers, body (plain text / HTML), and attachments metadata by message ID. |
|
| Send an email directly via the authenticated Gmail account. |
|
| Create a draft in Gmail for review before sending. |
| none | List all Gmail labels (system labels like |
|
| Add or remove label IDs (e.g. mark as read, star, archive). |
|
| Move an email to the Gmail Trash by its message ID. |
| none | List all Google Calendar calendars the user has access to. |
| `calendar_id: str = "primary", time_min: str | None = None, time_max: str |
| `calendar_id: str = "primary", summary: str = "Untitled Event", start: str = "", end: str = "", description: str = "", attendees: list[dict] | None = None, send_updates: str = "all"` |
|
| Delete an existing calendar event by its ID. |
š Documentation & Guides
Complete Run & Setup Guide (RUN_GUIDE.md) ā Step-by-step instructions for running OAuth login and testing.
š Quickstart
1. Clone & Set Up the Virtual Environment
git clone https://github.com/your-username/Gmail-mcp.git
cd Gmail-mcp
# Create virtual environment and install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r <(python3 -c "import tomllib; [print(d) for d in tomllib.load(open('pyproject.toml','rb'))['project']['dependencies']]")
# Or using uv:
# uv sync2. Add Google OAuth Credentials
Go to the Google Cloud Console.
Create a project and enable the Gmail API.
Configure the OAuth Consent Screen (add your Gmail address under Test users).
Go to Credentials ā Create Credentials ā OAuth client ID ā Application type: Desktop app.
Download the JSON file, copy it into this repository folder, and name it
credentials.json(or keep itsclient_secret_*.jsonname).
ā ļø Security Warning: Never commit
credentials.json,client_secret_*.json, ortoken.jsonto GitHub. They are already listed in.gitignore.
3. One-Time Authentication
Run the authentication helper in your terminal:
.venv/bin/python auth.pyA browser window will open asking you to sign in with your Google account. Once granted, it saves your credentials locally to token.json.
4. Test Email Operations (Optional)
Verify that your connection and tools work:
.venv/bin/python example_usage.pyš¤ AI Assistant Configuration
Google Antigravity IDE
Add the server to ~/.gemini/config/mcp_config.json:
{
"mcpServers": {
"gmail": {
"command": "/absolute/path/to/Gmail-mcp/.venv/bin/python",
"args": ["/absolute/path/to/Gmail-mcp/server.py"],
"env": {
"PYTHONUNBUFFERED": "1"
}
}
}
}Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"gmail": {
"command": "/absolute/path/to/Gmail-mcp/.venv/bin/python",
"args": ["/absolute/path/to/Gmail-mcp/server.py"]
}
}
}Cursor
Add to ~/.cursor/mcp.json or your project .cursor/mcp.json:
{
"mcpServers": {
"gmail": {
"command": "/absolute/path/to/Gmail-mcp/.venv/bin/python",
"args": ["/absolute/path/to/Gmail-mcp/server.py"]
}
}
}š Repository Structure
āāā auth.py # OAuth 2.0 flow & token management
āāā tools/ # Pure Python Gmail API tool operations
ā āāā reader.py # Search & read email operations
ā āāā sender.py # Send & draft email operations
ā āāā manager.py # Trash & label management
ā āāā __init__.py # Exported tools package
āāā server.py # MCP Server entrypoint exposing tools via stdio
āāā example_usage.py # Standalone script demonstrating tool usage
āāā credentials.template.json# Sample template for credentials
āāā pyproject.toml # Project dependencies & packaging config
āāā RUN_GUIDE.md # Detailed run & troubleshooting guide
āāā MCP_GUIDE.md # Beginner's guide to MCP & building new servers
āāā README.md # Project documentationš”ļø License
This project is open-source under the MIT License.
This server cannot be deployed
Maintenance
Related MCP Connectors
- MailowsOAuthcom.mailows
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Email 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 gradedqualityNot gradedmaintenanceEnables AI assistants to interact with Gmail through natural language, supporting email sending/reading, searching, draft management, label organization, and batch operations with secure OAuth authentication.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage Gmail accounts through natural language for tasks like sending, reading, searching, and organizing emails. It supports advanced features including draft management, label operations, and batch actions via secure OAuth 2.0 authentication.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to manage Gmail emails, including sending, searching, and organizing with labels and attachments via OAuth2.73 npm2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to manage Gmail accounts programmatically, including sending emails, managing labels, creating filters, and handling attachments via OAuth2 authentication.73 npm4MIT