Gmail MCP Server
Provides read-only access to Gmail, enabling email search, unread listing, message and thread retrieval, and draft reply preparation without sending.
README
Gmail MCP Server
A Model Context Protocol (MCP) server that provides read-only access to Gmail. Allows Claude Code to safely search, read, and analyze your Gmail inbox.
Features
- search_emails - Search using Gmail query syntax
- list_unread - List unread emails
- get_message - Get full message content with attachments metadata
- get_thread - Get all messages in a conversation thread
- draft_reply - Prepare draft reply content (does NOT send)
Prerequisites
- Node.js 18+
- A Google Cloud project with Gmail API enabled
- OAuth 2.0 Desktop App credentials
Google Cloud Setup
1. Create a Google Cloud Project
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Name your project (e.g., "Gmail MCP Server")
- Click "Create"
2. Enable Gmail API
- In your project, go to "APIs & Services" → "Library"
- Search for "Gmail API"
- Click on it and press "Enable"
3. Configure OAuth Consent Screen
- Go to "APIs & Services" → "OAuth consent screen"
- Select "External" (or "Internal" if using Google Workspace)
- Fill in the required fields:
- App name: "Gmail MCP Server"
- User support email: your email
- Developer contact: your email
- Click "Save and Continue"
- Add scopes:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.compose
- Add your email as a test user (if External)
- Complete the setup
4. Create OAuth Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Select "Desktop app" as application type
- Name it (e.g., "Gmail MCP Desktop")
- Click "Create"
- Download or copy the Client ID and Client Secret
Installation
# Clone or navigate to the project
cd gmail-mcp
# Install dependencies
npm install
# Build the project
npm run build
Configuration
- Copy the example environment file:
cp .env.example .env
- Edit
.envwith your OAuth credentials:
CLIENT_ID=your-client-id.apps.googleusercontent.com
CLIENT_SECRET=your-client-secret
First Run (Authorization)
The first time you run the server, it will:
- Open your browser for Google authorization
- Ask you to sign in and grant permissions
- Save the tokens locally in
token.json
Subsequent runs will reuse the saved tokens automatically.
Usage with Claude Code
Add the MCP Server
claude mcp add gmail node ./dist/index.js
Or add to your Claude Code configuration manually:
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["./dist/index.js"],
"cwd": "/path/to/gmail-mcp"
}
}
}
Available Tools
search_emails
Search emails using Gmail query syntax.
Query examples:
- "from:user@example.com"
- "subject:meeting"
- "is:unread"
- "after:2024/01/01 before:2024/12/31"
- "has:attachment filename:pdf"
- "in:inbox -category:promotions"
list_unread
List unread emails (shortcut for is:unread search).
get_message
Get full content of a specific email by message ID.
get_thread
Get all messages in a conversation thread by thread ID.
draft_reply
Prepare a draft reply to a thread. Provides context for composing a response but does NOT send any email.
Development
# Run in development mode (with hot reload)
npm run dev
# Type check
npm run typecheck
# Build for production
npm run build
# Run production build
npm start
Security Notes
- OAuth tokens are stored locally in
token.json - Never commit
.envortoken.jsonto version control - The server only requests read and compose permissions
- No emails are sent - draft_reply only prepares content
- Email content is not logged
Troubleshooting
"Missing CLIENT_ID or CLIENT_SECRET"
Ensure your .env file exists and contains valid credentials.
"Authorization timeout"
The OAuth flow has a 5-minute timeout. Restart the server and complete authorization promptly.
"Token refresh failed"
Delete token.json and re-authorize.
"Access blocked: This app's request is invalid"
Ensure your OAuth consent screen is properly configured and your email is added as a test user.
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
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.