Gmail MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/XiangWanggithub/Gmail-mcp.git
cd Gmail-mcp
pip install -r requirements.txt
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}" gmail-mcp-ec57 -- node "<FULL_PATH_TO_GMAIL_MCP>/dist/index.js"

Replace <FULL_PATH_TO_GMAIL_MCP>/dist/index.js with the actual folder you prepared in step 1.

Required:GOOGLE_APPLICATION_CREDENTIALS
README.md

Enables AI assistants to manage Gmail accounts through natural language

Gmail MCP Server

A powerful Model Context Protocol (MCP) server that enables Claude AI to directly interact with Gmail.

📖 Table of Contents

📋 Overview

The Gmail MCP Server is a comprehensive implementation that enables AI assistants like Claude to directly interact with Gmail through natural language. It exposes a rich set of tools for email management, enabling seamless integration between conversational AI and your inbox.

💡 Key Features

  • Complete Email Management

    • Send plain text and HTML emails with attachments
    • Read emails with proper parsing of complex message structures
    • Search your inbox with Gmail's powerful query syntax
    • Create and update draft emails
    • Manage labels, read/unread status, and trash
    • Perform batch operations on multiple emails
  • Advanced Integration

    • Modern Python codebase with async/await pattern
    • Comprehensive error handling and recovery
    • Detailed progress reporting
    • Secure OAuth authentication flow
    • Multiple transport modes (STDIO and SSE)
    • Support for different deployment scenarios

🚀 Quick Start

Prerequisites

  • Python 3.8 or higher
  • A Google Cloud project with the Gmail API enabled
  • OAuth 2.0 credentials for the Gmail API

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/gmail-mcp-server.git
    cd gmail-mcp-server
    
  2. Set up a virtual environment

    python -m venv venv
    
    # On Windows
    venv\Scripts\activate
    
    # On macOS/Linux
    source venv/bin/activate
    
  3. Install dependencies

    pip install -r requirements.txt
    
  4. Set up Google Cloud and OAuth credentials

    Visit the Google Cloud Console to:

    • Create a new project
    • Enable the Gmail API
    • Set up OAuth consent screen
    • Create OAuth Client ID credentials (Desktop application)
    • Download credentials as credentials.json in project root

First Run and Authentication

Generate an OAuth token for the Gmail account you want to use. Copy the URL printed by the script into a web browser and complete the sign-in process:

python gmail_token_creator.py

Test the server:

python gmail_server.py

Configure Claude Desktop

  1. Edit your Claude Desktop configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add the Gmail MCP server to the configuration:

    {
      "mcpServers": {
        "gmail": {
          "command": "/absolute/path/to/gmail-mcp-server/venv/bin/python",
          "args": [
            "/absolute/path/to/gmail-mcp-server/gmail_server.py"
          ]
        }
      }
    }
    
  3. Save the file and restart Claude Desktop

Note: Replace "/absolute/path/to/gmail-mcp-server/gmail_server.py" with the actual absolute path to the gmail_server.py file in your cloned repository. Note: No need to run python gmail_server.py by yourself. Claude will run it automatically everytime it starts.

🧰 Available Tools

The Gmail MCP Server exposes the following tools to Claude:

Email Sending

  • send_email - Send basic emails with text/HTML content
  • send_email_with_attachment - Send emails with file attachments
  • send_email_with_multiple_attachments - Send emails with multiple attachments

Email Reading

  • read_email - Read the content of a specific email by ID
  • get_unread_emails - Get a list of unread emails
  • get_important_emails - Get emails marked as important
  • get_emails_with_attachments - Get emails that have attachments
  • get_recent_emails - Get emails from the last X days

Email Search and Organization

  • search_emails - Search emails using Gmail's query syntax
  • get_email_labels - List all Gmail labels/folders
  • `create_email_lab

Tools (5)

send_emailSend basic emails with text/HTML content
send_email_with_attachmentSend emails with file attachments
read_emailRead the content of a specific email by ID
search_emailsSearch emails using Gmail's query syntax
get_unread_emailsGet a list of unread emails

Environment Variables

GOOGLE_APPLICATION_CREDENTIALSrequiredPath to the OAuth credentials.json file

Configuration

claude_desktop_config.json
{"mcpServers": {"gmail": {"command": "/absolute/path/to/gmail-mcp-server/venv/bin/python", "args": ["/absolute/path/to/gmail-mcp-server/gmail_server.py"]}}}

Try it

Find all unread emails from my manager and summarize them.
Search for emails containing 'invoice' from last week and list their subjects.
Send an email to team@example.com with the subject 'Project Update' and body 'The report is attached.'
Get the content of the most recent email in my inbox.
List all my current Gmail labels.

Frequently Asked Questions

What are the key features of Gmail MCP Server?

Send plain text and HTML emails with attachments. Read and parse complex email message structures. Search inbox using native Gmail query syntax. Manage labels, read/unread status, and trash. Perform batch operations on multiple emails.

What can I use Gmail MCP Server for?

Automating email triage by having Claude summarize unread messages. Drafting and sending routine project updates directly from the Claude interface. Quickly searching through historical correspondence using natural language queries. Managing inbox organization by programmatically applying labels to specific emails.

How do I install Gmail MCP Server?

Install Gmail MCP Server by running: git clone https://github.com/XiangWanggithub/Gmail-mcp.git && cd Gmail-mcp && pip install -r requirements.txt

What MCP clients work with Gmail MCP Server?

Gmail MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Gmail MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare