An MCP (Model Context Protocol) server that lets an AI assistant:
- Read unread emails from a Gmail inbox
- Create correctly-threaded draft replies in Gmail
This project is designed to be run locally and connected to Claude Desktop.
-
Tool:
get_unread_emails- Returns unread inbox emails with:
- sender, subject, snippet, message id, thread id, date
- Supports a
max_resultsparameter (defaults toMAX_UNREAD)
- Returns unread inbox emails with:
-
Tool:
create_draft_reply- Creates a Gmail draft reply to a given email
message_id - Ensures correct threading by setting:
threadIdIn-Reply-ToReferencesSubject(Re:handling)
- Creates a Gmail draft reply to a given email
- Python 3.11+
- MCP Python SDK
- Google Gmail API (OAuth 2.0)
- Claude Desktop (local MCP connection)
- Windows 10/11
- Python 3.11+ installed
- A Gmail account
- Claude Desktop installed
- A Google Cloud project with:
- Gmail API enabled
- OAuth consent screen configured
- OAuth Client ID created (Desktop app)
- MCP_Server/
- server.py
- gmail_client.py
- requirements.txt
- .env
- .gitignore
- claude_desktop_config.example.json
- screenshots/
- Create a Google Cloud project
- Enable the Gmail API
- Configure the OAuth consent screen
- If in Testing, add your Gmail address under Test users
- Create OAuth credentials:
- Type: Desktop app
- Download the OAuth client JSON and save it as: credentials.json
Open PowerShell in the project folder:
powershell python -m venv .venv ..venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
Update .env to use absolute paths
Run the Server Locally
D:\MCP_Server.venv\Scripts\python.exe D:\MCP_Server\server.py
The process will stay running and wait for Claude Desktop to connect.
Claude Desktop reads MCP server config from: %APPDATA%\Claude\claude_desktop_config.json
After updating the config:
Fully quit Claude Desktop (tray icon → Quit)
A copy of this config is included in the repo as: claude_desktop_config.example.json
Screenshots are included in screenshots/:
01-tools.png — Claude shows MCP tools
02-unread_emails.png — Claude reads unread emails via tool call
03-reply_mail.png — Claude generates reply text
04-gmail_draftCreated.png — Gmail UI showing the created draft
This server only reads emails (gmail.readonly) and creates drafts (gmail.compose).
OAuth 403 access_denied
Ensure OAuth consent screen is configured
If status is Testing, add your Gmail address under Test users
Confirm OAuth client type is Desktop app
Claude says credentials are missing
Use absolute paths in .env
Confirm credentials.json exists in the configured location