Gmail MCP Server
Provides native tool-level access to Gmail, allowing AI agents to search, read, send, and manage email messages, threads, labels, drafts, and attachments.
Click on "Install 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 Servershow me my unread emails from yesterday"
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 local MCP server that gives Claude native, tool-level access to Gmail. Runs locally via stdio transport — all tokens and credentials stay on your machine.
Prerequisites
Python 3.14+
uv for dependency management
A Google account with the Gmail API enabled
Quick Start
# Clone the repo
git clone https://github.com/stevesimpson418/gmail-mcp-server.git
cd gmail-mcp-server
# Install dependencies (creates .venv/ in the project directory)
uv syncNew to uv?
uv syncreadspyproject.toml, creates a.venv/virtualenv inside the project folder, and installs all dependencies into it. You don't need to activate it —uv run <command>handles that automatically.
Setting up Gmail
1. Create a Google Cloud project
Go to the Google Cloud Console and create a new project (or select an existing one).
2. Enable the Gmail API
Navigate to APIs & Services > Library, search for Gmail API, and click Enable.
3. Configure the OAuth consent screen
Before creating credentials, Google requires you to configure the OAuth consent screen. Go to APIs & Services > OAuth consent screen (or Google Auth Platform if prompted).
Click Get Started (or Configure Consent Screen)
Fill in the required fields:
App name — a name for your own reference (e.g. "Gmail MCP Server")
User support email — your email address
Select an Audience:
Internal — only available if you're in a Google Workspace organisation
External — select this for personal Google accounts. The app starts in testing mode, which is fine for personal use — you just need to add yourself as a test user
Contact information — your email (Google uses this to notify you of project changes)
Click Save
About testing mode: External apps in testing mode are limited to users you explicitly add to the test user list. This is perfectly fine for a local MCP server — you only need your own account. Tokens for test users expire after 7 days, requiring re-consent. If this becomes inconvenient, you can publish the app (no verification needed for sensitive scopes used with fewer than 100 users in testing mode, but publishing removes the 7-day expiry).
4. Add test users
Go to APIs & Services > OAuth consent screen > Test users (or Audience in the new Google Auth Platform UI) and add your Google account email address.
5. Add OAuth scopes
Go to APIs & Services > OAuth consent screen > Scopes (or Data Access in the new UI) and add the following scope:
Scope | Why it's needed |
| Read messages, modify labels (archive, star, mark read/unread, apply/remove labels), manage drafts, send emails, and move messages to trash. This is the minimum single scope that covers all server operations — narrower scopes like |
This server does not request mail.google.com (full unrestricted access) — gmail.modify
is scoped to read/write operations and cannot permanently delete messages.
6. Create OAuth 2.0 credentials
Go to APIs & Services > Credentials
Click Create Credentials > OAuth client ID
Application type: Desktop app
Give it a name for your own reference (e.g. "Gmail MCP — My Laptop")
Click Create, then Download JSON
Save the file as
credentials/gmail_credentials.jsonin this project
Security note: The
credentials/directory is gitignored — your credentials and tokens will never be committed to the repository.
7. Run the OAuth consent flow
uv run gmail-mcp-authA browser window will open — sign in with the Google account you added as a test user and
grant the requested permissions. The token is saved to credentials/token.json and
auto-refreshes after this.
To use custom paths:
uv run gmail-mcp-auth --credentials /path/to/creds.json --token /path/to/token.jsonAdding to Claude Desktop
Add the following to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS).
Tip: Run
uv run which pythonfrom the project directory to get the exact path forcommand.
{
"mcpServers": {
"gmail": {
"command": "/Users/you/gmail-mcp-server/.venv/bin/python",
"args": ["-m", "gmail_mcp.server"],
"env": {
"GMAIL_CREDENTIALS_PATH": "/Users/you/gmail-mcp-server/credentials/gmail_credentials.json",
"GMAIL_TOKEN_PATH": "/Users/you/gmail-mcp-server/credentials/token.json"
}
}
}
}The env block tells the server where to find your credentials at runtime. No .env file is
needed — the config passes these values directly.
Restart Claude Desktop after saving. You should see all Gmail tools in the tools menu.
Adding to Claude Code CLI
Use the claude mcp add command to register the server. This works from any directory.
claude mcp add --scope user gmail-mcp-server \
--transport stdio \
--env GMAIL_CREDENTIALS_PATH=/path/to/gmail-mcp-server/credentials/gmail_credentials.json \
--env GMAIL_TOKEN_PATH=/path/to/gmail-mcp-server/credentials/token.json \
-- /path/to/gmail-mcp-server/.venv/bin/python -m gmail_mcp.serverReplace /path/to/gmail-mcp-server with the actual path where you cloned the repo.
Tip: Run
uv run which pythonfrom the project directory to get the exact.venv/bin/pythonpath for the command.
The --scope user flag saves to ~/.claude.json so the server is available across all projects.
Without it, the command defaults to local scope (tied to whatever directory you run it from).
To scope it to a single project instead, use --scope project which writes to .mcp.json in
the project root.
To verify the server is registered:
claude mcp listRestart Claude Code after adding. The Gmail tools should appear in the /mcp menu.
Note: Claude Code CLI uses a different configuration from Claude Desktop. The
claude mcp addcommand is the recommended way to register MCP servers — do not add them to~/.claude/settings.jsonas that file is used for permissions and hooks only.
Updating
To pull the latest version and update dependencies:
cd /path/to/gmail-mcp-server
git pull
uv syncRestart Claude Desktop or Claude Code CLI after updating.
If a new version changes OAuth scopes, you'll need to re-consent by running
uv run gmail-mcp-auth again.
Available Tools
Tool | Description |
| Search messages using Gmail query syntax (e.g. |
| Read a full message including body text |
| Read all messages in a thread |
| List all labels (system and user-created) |
| List attachments on a message |
| Read attachment content inline |
| Archive messages (remove from inbox) |
| Search and archive all matching messages in one call |
| Apply a label to messages |
| Remove a label from messages |
| Create a new label |
| Mark messages as read |
| Mark messages as unread |
| Star messages |
| Mark messages as important |
| Create a draft email |
| Send an email directly |
| Send a previously created draft |
| Move messages to trash (recoverable for 30 days) |
Usage Examples
Triage your inbox:
1. search_gmail(query="is:unread in:inbox") → see what's new
2. read_gmail_message(message_id="msg_123") → read the full message
3. archive_gmail_messages(message_ids=["msg_123"]) → archive after readingBulk cleanup:
bulk_archive_gmail(query="from:noreply@marketing.com in:inbox")
bulk_archive_gmail(query="is:unread in:inbox older_than:7d subject:newsletter")Draft a reply:
create_gmail_draft(
to="alice@example.com",
subject="Re: Meeting",
body="Sounds good, see you then!",
thread_id="thread_abc"
)Development
# Install dev dependencies
uv sync --dev
# Run tests
uv run pytest -v
# Run tests with coverage
uv run pytest --cov=gmail_mcp --cov-report=term-missing
# Lint
uv run ruff check src/ tests/
# Format
uv run ruff format src/ tests/
# Install git hooks
lefthook installLocal .env file
When running the server manually outside Claude Desktop/Code (e.g., for development or
debugging), you can create a .env file in the project root so the server picks up
credential paths without passing environment variables:
GMAIL_CREDENTIALS_PATH=credentials/gmail_credentials.json
GMAIL_TOKEN_PATH=credentials/token.jsonThis is only needed for local development. The Claude Desktop and Claude Code CLI configs
pass these values directly via the env block.
Packaging & Distribution
This server is currently distributed as source via git. To install:
git clone https://github.com/stevesimpson418/gmail-mcp-server.git
cd gmail-mcp-server
uv syncThis is the standard distribution model for local-stdio MCP servers today. The project is already configured for wheel builds via hatchling, so future distribution options include:
PyPI — publish to PyPI, then install with
uv tool install gmail-mcp-serverorpip install gmail-mcp-server. Would require adding a publish workflow to CI.uvx — once on PyPI,
uvx gmail-mcp-serverruns the server without cloning the repo. Claude Desktop/Code config would point to the uvx-managed binary instead of a local.venv.
Releases
This project uses release-please for automated versioning and releases. The version is determined by Conventional Commits:
fix:commits bump the patch version (e.g. 0.1.0 → 0.1.1)feat:commits bump the minor version (e.g. 0.1.1 → 0.2.0)BREAKING CHANGEin the commit footer bumps the major version
When commits land on main, release-please opens (or updates) a Release PR that:
Bumps the version in
pyproject.tomlUpdates
CHANGELOG.mdwith grouped entries
Merging the Release PR creates a git tag and GitHub Release automatically.
License
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/stevesimpson418/gmail-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server