gmail-mcp
# gmail-mcp
MCP server for Gmail operations.
## Tools
| Tool | Description |
|------|-------------|
| `gmail_list_labels` | List system and user Gmail labels |
| `gmail_list_inbox` | List messages from a label (optionally unread only) |
| `gmail_search_emails` | Search emails with Gmail query syntax |
| `gmail_read_email` | Read a full email by message ID |
| `gmail_create_draft` | Compose a new email draft |
| `gmail_create_reply_draft` | Compose a reply draft for a message/thread |
| `gmail_send_draft` | Send an existing draft after review with its confirmation token |
| `gmail_manage_labels` | Add or remove labels on a message |
| `gmail_manage_labels_bulk` | Add or remove labels on multiple messages |
| `gmail_delete_email` | Move message to trash or permanently delete |
## Setup
### Prerequisites
- Python 3.10+
- Gmail account with API access
- OAuth desktop client credentials from Google Cloud Console
### Installation
```bash
git clone https://github.com/<your-user>/gmail-mcp.git
cd gmail-mcp
"$(uv python find --system --managed-python 3.13.15)" -m venv --copies venv
venv/bin/python -m pip install -e .
```
### Authentication
1. Save OAuth credentials outside the repository at
`~/.config/gmail-mcp/gmail_credentials.json` and restrict the file to your user:
```bash
mkdir -p ~/.config/gmail-mcp
chmod 700 ~/.config/gmail-mcp
chmod 600 ~/.config/gmail-mcp/gmail_credentials.json
```
2. Run initial authentication once:
```bash
venv/bin/python -c "from src import gmail_client; gmail_client.authenticate()"
```
3. Complete browser consent. The token cache is written to
`~/.config/gmail-mcp/gmail_token.pickle` with mode `0600`.
Set `GMAIL_CONFIG_DIR` to relocate both defaults, or use
`GMAIL_CREDENTIALS_FILE` and `GMAIL_TOKEN_FILE` for per-process overrides.
### Claude Code Configuration
Add to `~/.claude.json`:
```json
{
"mcpServers": {
"gmail-mcp": {
"type": "stdio",
"command": "/path/to/gmail-mcp/venv/bin/python",
"args": ["/path/to/gmail-mcp/run_server.py"]
}
}
}
```
## Development
```bash
venv/bin/python -c "from src.server import mcp; print([t.name for t in mcp._tool_manager._tools.values()])"
venv/bin/python run_server.py
```
## License
MIT
TDQS
Scored across 15 tools
Most tools have crisply distinct scopes, and the descriptions explicitly cross-reference siblings and call out anti-patterns (e.g. create_draft vs create_reply_draft vs send_draft). The only real overlap is between gmail_list_inbox (browse a label) and gmail_search_emails (query), which both return message lists, though the docs steer agents toward the right one. Manage_labels vs manage_labels_bulk and delete_email vs delete_filter are clearly delineated.
All names use snake_case with a consistent gmail_ prefix and verb_noun structure (list/create/read/delete/manage). Minor deviations only: gmail_list_inbox names a mailbox section rather than a resource, and pluralization is inconsistent (read_email vs search_emails, list_labels). Nothing that impedes comprehension.
15 tools sits at the top of the well-scoped range and each one maps to a concrete operation (message browse/read/search/delete/restore, label apply, label/filter CRUD, draft compose/send). No redundant or filler tools; bulk label management is justified separately from single-message management.
Message lifecycle (list, search, read, label, delete, restore) and filter lifecycle (list, create, delete) are fully covered, with a safe draft-then-send flow. Gaps remain in label lifecycle (no delete or rename label despite gmail_create_label) and draft lifecycle (no list/update/delete draft). These are workable around but are notable absences.