Gmail MCP Server
Enables AI assistants to manage Gmail by reading unread emails with automatic classification, creating AI-generated draft replies, and saving drafts directly to Gmail through the Gmail API.
README
Gmail MCP Server
A Model Context Protocol (MCP) server that provides Gmail integration for AI assistants. This server allows AI assistants to read unread emails, classify them, create draft replies, and save drafts to Gmail.
Features
- Get Unread Emails: Retrieve the latest unread emails from your inbox
- Classify Emails: Automatically categorize emails as urgent, newsletter, work, personal, or unknown using HuggingFace transformers (BART-large-MNLI) with AI fallback for low-confidence predictions
- Create Draft Replies: Generate suggested email replies using AI (requires sampling support)
- Save Drafts: Save draft replies directly to Gmail
Important: Client Compatibility
Note about Sampling Support: This server uses MCP's sampling feature for the create_suggested_draft_reply tool. Different MCP clients have different levels of support:
Full Support (Sampling Enabled):
- GitHub Copilot (VS Code extension) - All tools work including AI-powered draft replies
- Other clients listed at https://modelcontextprotocol.io/clients with sampling support
Limited Support (No Sampling):
- Claude Desktop -
get_unread_emailsandsave_draft_reply_to_gmailwork, butcreate_suggested_draft_replywill not function
Email classification uses HuggingFace transformers with AI fallback for low-confidence predictions (< 0.7) and works in all clients.
Prerequisites
- Node.js (v18 or higher)
- Google Cloud Project with Gmail API enabled
- OAuth 2.0 credentials from Google Cloud Console
Setting up Google OAuth Credentials
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API:
- Navigate to "APIs & Services" > "Library"
- Search for "Gmail API" and enable it
- Create OAuth 2.0 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Desktop app" as the application type
- Important: Add
http://localhostto "Authorized redirect URIs" - Download the credentials JSON file
- Save the downloaded file as
secrets/google-credentials.jsonin this project
Installation
- Clone this repository
- Install dependencies:
npm install - Build the project:
npm run build - Create a
secretsdirectory and add yourgoogle-credentials.jsonfile
Configuration
For Claude Desktop and GitHub Copilot
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["/absolute/path/to/gmail-mcp-server/dist/index.js"]
}
}
}
Note: Replace /absolute/path/to/gmail-mcp-server with the actual path to your cloned repository.
GitHub Copilot can also access MCP servers configured in the Claude Desktop config file, so this single configuration works for both tools.
Demo & Examples
This server has been tested with both GitHub Copilot and Claude Desktop. See the screen-shots folder for working examples:
GitHub Copilot (Full Support with Sampling)
Shows all tools working including AI-powered draft generation.
- See examples in
screen-shots/copilot-sampling/
Claude Desktop (Limited Support - No Sampling)
Shows get_unread_emails and save_draft_reply_to_gmail working. The create_suggested_draft_reply tool does not work due to lack of sampling support.
- See examples in
screen-shots/claude-desktop/
Example Prompts:
- "Get my last 10 unread emails"
- "Create a professional draft reply to the email from [sender] saying I'll review it tomorrow"
- "Save this draft reply to gmail"
Gmail Authorization
When you first start the server, it will automatically handle authorization:
- The server will detect that you're not authorized
- Your default browser will open automatically to Google's authorization page
- Sign in with your Google account and authorize the application
- The browser will show "Authorization successful! You can close this window."
- The server will automatically save the token
You won't need to authorize again unless you revoke access or delete secrets/token.json.
Available Tools
get_unread_emails
Retrieves the latest unread emails from your Gmail inbox. Emails are automatically classified into categories (urgent, newsletter, work, personal, or unknown).
Parameters:
numberOfEmails(number, 1-100): Number of emails to retrieve
create_suggested_draft_reply
Creates an AI-generated draft reply to an email.
Parameters:
email(object): Email object to reply toinstructions(string, optional): Additional instructions for the reply
save_draft_reply_to_gmail
Saves a draft reply to Gmail as a threaded response.
Parameters:
draftEmail(string): The draft email contentemail(object): The email object to reply to (contains threadId for threading)
Development
Run the server in development mode:
npm run dev
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.