Gmail MCP Server

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.

Category
Visit Server

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_emails and save_draft_reply_to_gmail work, but create_suggested_draft_reply will not function

Email classification uses HuggingFace transformers with AI fallback for low-confidence predictions (< 0.7) and works in all clients.

Prerequisites

  1. Node.js (v18 or higher)
  2. Google Cloud Project with Gmail API enabled
  3. OAuth 2.0 credentials from Google Cloud Console

Setting up Google OAuth Credentials

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Gmail API:
    • Navigate to "APIs & Services" > "Library"
    • Search for "Gmail API" and enable it
  4. 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://localhost to "Authorized redirect URIs"
    • Download the credentials JSON file
  5. Save the downloaded file as secrets/google-credentials.json in this project

Installation

  1. Clone this repository
  2. Install dependencies:
    npm install
    
  3. Build the project:
    npm run build
    
  4. Create a secrets directory and add your google-credentials.json file

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.

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.

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:

  1. The server will detect that you're not authorized
  2. Your default browser will open automatically to Google's authorization page
  3. Sign in with your Google account and authorize the application
  4. The browser will show "Authorization successful! You can close this window."
  5. 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 to
  • instructions (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 content
  • email (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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured