Gmail MCP Server
An MCP server that provides Claude with access to your Gmail, featuring a full OAuth 2.1 authorization server with dynamic client registration and tools to list, read, search, send, reply, draft, archive, trash, manage labels, and download attachments.
README
Gmail MCP Server
An MCP (Model Context Protocol) server that provides Claude with access to your Gmail, featuring a full OAuth 2.1 authorization server with dynamic client registration.
Features
- Full OAuth 2.1 Authorization Server (RFC 8414, RFC 7591, RFC 9728)
- Dynamic Client Registration - Claude Code auto-registers
- PKCE Support (RFC 7636)
- First-class "Authenticate" button in Claude Code's
/mcpmenu - Gmail tools: list, read, search, send, reply, draft, archive, trash, labels, attachments
Prerequisites
Node.js 18+ is required. Install via nodejs.org or:
brew install node
Setup
-
Clone and install dependencies:
git clone <repo-url> gmail-mcp cd gmail-mcp npm install -
Build:
npm run build -
Start the server:
npm startThe server runs on
http://localhost:3100by default. Override withPORT=3200 npm start. -
Configure Claude Code (
~/.mcp.json):{ "mcpServers": { "gmail": { "type": "sse", "url": "http://localhost:3100/sse" } } } -
Authenticate via Claude Code:
- Run
/mcpin Claude Code - Click "Authenticate" on the gmail server
- Complete Google OAuth in your browser
Note: Google will show an "This app isn't verified" warning screen. This is normal for apps that haven't gone through Google's verification process. To proceed:
- Click Advanced
- Click Go to gmail-mcp (unsafe)
- Review the requested permissions (read and modify Gmail) and click Allow
Your credentials are stored locally on your machine and are never sent to any third-party server.
- Run
Configuration
Google OAuth credentials are built in — no setup required. On first use, you'll be prompted to authorize your Gmail through Google's consent screen.
User-specific config files are stored in ~/.config/gmail-mcp/:
| File | Description |
|---|---|
credentials.json |
Optional — Override the built-in Google OAuth credentials with your own |
token.json |
Your Google OAuth tokens (auto-generated after authorization) |
clients.json |
Registered MCP clients (auto-generated) |
access_tokens.json |
Issued access tokens (auto-generated) |
Auto-Start on Login (macOS)
Run the install script to set up the LaunchAgent:
./scripts/install.sh
This will:
- Detect your node installation
- Generate a plist with correct paths
- Install to
~/Library/LaunchAgents/ - Start the server immediately
To uninstall:
./scripts/uninstall.sh
Logs are written to ~/.config/gmail-mcp/stdout.log and stderr.log.
Available Tools
| Tool | Description |
|---|---|
list_emails |
List emails from inbox with optional filters |
read_email |
Read full email content by ID |
search_emails |
Search using Gmail query syntax |
send_email |
Compose and send a new email |
reply_to_email |
Reply to an existing email |
draft_email |
Create a draft without sending |
mark_as_read |
Mark an email as read |
mark_as_unread |
Mark an email as unread |
archive_email |
Archive an email (remove from inbox) |
trash_email |
Move an email to trash |
add_label |
Add a label to an email |
remove_label |
Remove a label from an email |
list_labels |
List all Gmail labels |
get_thread |
Get all emails in a conversation |
get_attachment |
Download an email attachment |
Gmail Search Syntax
The search_emails and list_emails tools support Gmail's query syntax:
is:unread- Unread emailsfrom:someone@example.com- From specific sendersubject:invoice- Subject contains "invoice"has:attachment- Has attachmentsafter:2025/01/01- After a datebefore:2025/12/31- Before a datelabel:important- Has specific label
Architecture
┌─────────────────┐ ┌──────────────────────────────────────┐
│ Claude Code │◄────►│ Gmail MCP Server │
│ │ SSE │ │
│ /mcp menu │ │ ┌─────────────────────────────────┐ │
│ shows │ │ │ OAuth 2.1 Authorization Server │ │
│ "Authenticate" │ │ │ - Dynamic client registration │ │
│ │ │ │ - PKCE support │ │
└─────────────────┘ │ │ - Token management │ │
│ └──────────────┬──────────────────┘ │
│ │ │
│ ┌──────────────▼──────────────────┐ │
│ │ Google OAuth Proxy │ │
│ │ - Redirects to Google │ │
│ │ - Stores Google tokens │ │
│ └──────────────┬──────────────────┘ │
│ │ │
│ ┌──────────────▼──────────────────┐ │
│ │ Gmail API Tools │ │
│ │ - list, read, search, etc. │ │
│ └─────────────────────────────────┘ │
└──────────────────────────────────────┘
Development
npm run build # Compile TypeScript
npm start # Run server
npm run auth # Standalone Google OAuth (alternative to browser flow)
Endpoints
| Endpoint | Description |
|---|---|
GET /health |
Health check & status |
GET /.well-known/oauth-protected-resource |
RFC 9728 metadata |
GET /.well-known/oauth-authorization-server |
RFC 8414 metadata |
POST /oauth/register |
Dynamic client registration |
GET /oauth/authorize |
Authorization endpoint |
POST /oauth/token |
Token endpoint |
GET /sse |
MCP SSE endpoint (protected) |
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.