Gmail MCP Server
An MCP (Model Context Protocol) server that provides Gmail integration for AI assistants like Claude. Search emails, read messages, and download attachments directly from your Gmail account.
Features
- Search emails using Gmail's powerful search syntax (
from:,subject:,has:attachment, etc.) - Read full email content including body and attachment metadata
- Download attachments to your local filesystem
Requirements
- Python 3.10+
- uv (recommended) or pip
- A Google Cloud project with Gmail API enabled
Installation
1. Clone and install dependencies
git clone https://github.com/yourusername/gmail-mcp.git
cd gmail-mcp
uv sync
2. Set up Google Cloud credentials
- Go to Google Cloud Console
- Create a new project (or select existing)
- Enable the Gmail API
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Desktop app as application type
- Download the JSON file
3. Configure credentials
Save the downloaded credentials file:
mkdir -p ~/.gmail-mcp
mv ~/Downloads/client_secret_*.json ~/.gmail-mcp/gcp-oauth.keys.json
Or set via environment variable:
export GMAIL_CREDENTIALS_PATH=/path/to/your/credentials.json
4. First-time authorization
Run the server once to complete OAuth:
uv run python -m gmail_mcp
A browser window will open for you to authorize access. The token is saved to ~/.gmail-mcp/token.json for future use.
Usage with Claude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
macOS/Linux:
{
"mcpServers": {
"gmail": {
"command": "uv",
"args": ["run", "--directory", "/path/to/gmail-mcp", "python", "-m", "gmail_mcp"]
}
}
}
Windows:
{
"mcpServers": {
"gmail": {
"command": "uv",
"args": ["run", "--directory", "C:/path/to/gmail-mcp", "python", "-m", "gmail_mcp"]
}
}
}
Available Tools
search_emails
Search Gmail using Gmail search syntax.
search_emails(query="from:example@gmail.com", max_results=10)
Query examples:
from:example@gmail.com- emails from specific sendersubject:invoice- emails with subject containing "invoice"has:attachment- emails with attachmentsafter:2024/01/01- emails after dateis:unread- unread emailslabel:important- emails with specific label
get_email
Get full email content by message ID.
get_email(message_id="abc123")
Returns: id, from, to, subject, date, body, attachments
download_attachment
Download email attachment to specified path.
download_attachment(
message_id="abc123",
attachment_id="xyz789",
save_path="/path/to/save/file.pdf"
)
Development
# Run with MCP inspector
uv run mcp dev src/gmail_mcp/server.py
# Run tests
uv run pytest
# Lint
uv run ruff check src/
Security Notes
- Only
gmail.readonlyscope is used - this server cannot send or modify emails - OAuth tokens are stored locally in
~/.gmail-mcp/token.json - Never commit credentials or tokens to version control
License
MIT
Metadata
Release files for mcp-gmail-reader 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_gmail_reader-0.1.0.tar.gz | 6.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_gmail_reader-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / mcp_gmail_reader-0.1.0.tar.gz
| Download URL | mcp_gmail_reader-0.1.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d40542087c1c7517380bb4b098a53c7121f24885cf55e92195c2ac8090f71faa
|
|
BLAKE2b-256 checksum How to use checksums |
06bd46c2fbf401ce8f453257a0bc04fa77cba8c01b9217c625aa735233e68131
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / mcp_gmail_reader-0.1.0-py3-none-any.whl
| Download URL | mcp_gmail_reader-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8b3e889ab3bc295082402d5bd96ea48d917c85ac376ef63efbfec24559f2cba
|
|
BLAKE2b-256 checksum How to use checksums |
95e43948b023f9112b2a88c79e162d3afedf72cd78f16726bb68527d203fa417
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for mcp-gmail-reader 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.