Gmail AutoAuth MCP Server

$npx -y @smithery/cli install @raghavared/gmail-mcp --client claude
README.md

Manage Gmail through natural language with auto-authentication support.

Gmail AutoAuth MCP Server

A Model Context Protocol (MCP) server for Gmail integration in Claude Desktop with auto authentication support. This server enables AI assistants to manage Gmail through natural language interactions.

Features

  • Send emails with subject, content, attachments, and recipients
  • Full support for international characters in subject lines and email content
  • Read email messages by ID with advanced MIME structure handling
  • View email attachments information (filenames, types, sizes)
  • Search emails with various criteria (subject, sender, date range)
  • Comprehensive label management with ability to create, update, delete and list labels
  • List all available Gmail labels (system and user-defined)
  • List emails in inbox, sent, or custom labels
  • Mark emails as read/unread
  • Move emails to different labels/folders
  • Delete emails
  • Batch operations for efficiently processing multiple emails at once
  • Full integration with Gmail API
  • Simple OAuth2 authentication flow with auto browser launch
  • Support for both Desktop and Web application credentials
  • Global credential storage for convenience

Installation & Authentication

Installing via Smithery

To install Gmail AutoAuth for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @raghavared/gmail-mcp --client claude

Installing Manually

  1. Create a Google Cloud Project and obtain credentials:

    a. Create a Google Cloud Project:

    • Go to Google Cloud Console
    • Create a new project or select an existing one
    • Enable the Gmail API for your project

    b. Create OAuth 2.0 Credentials:

    • Go to "APIs & Services" > "Credentials"
    • Click "Create Credentials" > "OAuth client ID"
    • Choose either "Desktop app" or "Web application" as application type
    • Give it a name and click "Create"
    • For Web application, add http://localhost:3000/v2/auth/google/callback to the authorized redirect URIs
    • Download the JSON file of your client's OAuth keys
    • Rename the key file to token.json
  2. Run Authentication:

    You can authenticate in two ways:

    a. Global Authentication (Recommended):

    # First time: Place token.json in your home directory's .gmail-mcp folder
    mkdir -p ~/.gmail-mcp
    mv token.json ~/.gmail-mcp/
    
    # Run authentication from anywhere
    npx @raghavared/gmail-mcp auth
    

    b. Local Authentication:

    # Place token.json in your current directory
    # The file will be automatically copied to global config
    npx @raghavared/gmail-mcp auth
    

    The authentication process will:

    • Look for token.json in the current directory or ~/.gmail-mcp/
    • If found in current directory, copy it to ~/.gmail-mcp/
    • Open your default browser for Google authentication
    • Save credentials as ~/.gmail-mcp/credentials.json

    Note:

    • After successful authentication, credentials are stored globally in ~/.gmail-mcp/ and can be used from any directory
    • Both Desktop app and Web application credentials are supported
    • For Web application credentials, make sure to add http://localhost:3000/v2/auth/google/callback to your authorized redirect URIs
  3. Configure in Claude Desktop:

{
  "mcpServers": {
    "gmail": {
      "command": "npx",
      "args": [
        "@raghavared/gmail-mcp"
      ]
    }
  }
}

Docker Support

If you prefer using Docker:

  1. Authentication:
docker run -i --rm \
  --mount type=bind,source=/path/to/token.json,target=/token.json \
  -v gmail-mcp:/gmail-server \
  -e GMAIL_OAUTH_PATH=/token.json \
  -e "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json" \
  -p 3000:3000 \
  mcp/gmail auth
  1. Usage:
{
  "mcpServers": {
    "gmail": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "mcp-gmail:/gmail-server",
        "-e",
        "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json",
        "gmail-mcp"
      ]
    }
  }
}

Cloud Server Authentication

For cloud server environments (like n8n), you can specify a custom callback URL during authentication:

npx @raghavared/gmail-mcp auth {domain}/v2/auth/google/callback
Setup Instructions for Cloud Environment
  1. Configure Reverse Proxy:

    • Set up your n8n container to expose a port for authentication
    • Configure a reverse proxy to forward traffic from your domain (e.g., domain.com) to this port
  2. DNS Configuration:

    • Add an A record in your DNS settings to resolve your domain to your cloud server's IP address
  3. Google Cloud Platform Setup:

    • In your Google Cloud Console, add your c

Tools (5)

send_emailSend emails with subject, content, attachments, and recipients.
read_emailRead email messages by ID with advanced MIME structure handling.
search_emailsSearch emails with various criteria like subject, sender, and date range.
manage_labelsCreate, update, delete, and list Gmail labels.
batch_operationsEfficiently process multiple emails at once.

Environment Variables

GMAIL_OAUTH_PATHPath to the token.json file for authentication
GMAIL_CREDENTIALS_PATHPath where the generated credentials.json will be stored

Configuration

claude_desktop_config.json
{
  "mcpServers": {
    "gmail": {
      "command": "npx",
      "args": [
        "@raghavared/gmail-mcp"
      ]
    }
  }
}

Try it

Search my inbox for emails from 'Amazon' received in the last 7 days.
Read the content of the email with ID '12345' and list any attachments.
Send an email to example@gmail.com with the subject 'Project Update' and include the summary of our last meeting.
Create a new Gmail label called 'Urgent-AI' and move all unread emails from 'Boss' into it.
Batch delete all emails in my 'Spam' folder that are older than 30 days.

Frequently Asked Questions

What are the key features of Gmail AutoAuth MCP Server?

Comprehensive label management (create, update, delete, and list).. Batch operations for processing multiple emails efficiently.. Advanced MIME structure handling for reading messages and attachments.. Simple OAuth2 authentication flow with automatic browser launch.. Support for international characters in subjects and email content..

What can I use Gmail AutoAuth MCP Server for?

Automating email sorting and label organization via natural language.. Quickly searching and summarizing long email threads or attachments.. Sending personalized emails or newsletters directly from an AI chat interface.. Cleaning up inboxes by batch deleting or archiving old messages.. Integrating Gmail workflows into cloud environments like n8n..

How do I install Gmail AutoAuth MCP Server?

Install Gmail AutoAuth MCP Server by running: npx -y @smithery/cli install @raghavared/gmail-mcp --client claude

What MCP clients work with Gmail AutoAuth MCP Server?

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

Use Gmail AutoAuth MCP Server with Conare

Manage MCP servers visually, upload persistent context, and never start from zero with Claude Code & Codex.

Try Free