Gmail MCP Server

$npm install && npm run build && node dist/index.js auth
README.md

A comprehensive MCP server providing 24 tools for full Gmail management

Gmail MCP Server

A comprehensive Model Context Protocol (MCP) server for Gmail, providing 24 tools for full email management including sending, receiving, labels, filters, attachments, and batch operations.

Features

  • 24 Gmail Tools: Full email operations, label management, filters, batch operations, and attachments
  • Multi-Account Support: Manage multiple Gmail accounts with --account flag
  • OAuth Authentication: Secure authentication with automatic token refresh
  • Attachment Support: Download and send attachments
  • Batch Operations: Efficiently modify or delete up to 1000 emails at once
  • Filter Templates: Pre-built filter templates for common use cases
  • MCP Resources: Access messages, threads, and labels via URI

Prerequisites

  • Node.js 18+
  • A Google Cloud Project with Gmail API enabled
  • OAuth 2.0 credentials (Desktop app type)

Setup

1. Create Google Cloud 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"
    • Click "Enable"
  4. Create OAuth credentials:
    • Go to "APIs & Services" > "Credentials"
    • Click "Create Credentials" > "OAuth Client ID"
    • If prompted, configure the OAuth consent screen:
      • Choose "External" user type (or "Internal" for Workspace)
      • Fill in required fields (app name, user support email, developer email)
      • Add scopes: gmail.modify and gmail.settings.basic
      • Add your email as a test user
    • Select "Desktop app" as the application type
    • Name it (e.g., "Gmail MCP")
    • Click "Create"
  5. Download the JSON credentials file

2. Install and Configure

# Clone or download the project
cd gmail-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Create config directory and save credentials
mkdir -p ~/.gmail-mcp
cp /path/to/downloaded/credentials.json ~/.gmail-mcp/credentials.json

# Authenticate (for a single account)
node dist/index.js auth

# Or authenticate with a named account (for multi-account support)
node dist/index.js auth --account work
node dist/index.js auth --account personal

The auth command will:

  1. Open your browser to Google's OAuth consent page
  2. Ask you to authorize the application
  3. Save the tokens to ~/.gmail-mcp/tokens/<account>.json

To list authenticated accounts:

node dist/index.js list

3. Add to Claude Code

For a single account:

claude mcp add gmail -- node /path/to/gmail-mcp/dist/index.js

For multiple accounts, add each with its own name:

claude mcp add gmail-work -- node /path/to/gmail-mcp/dist/index.js --account work
claude mcp add gmail-personal -- node /path/to/gmail-mcp/dist/index.js --account personal

Or add manually to your Claude Code MCP settings:

{
  "mcpServers": {
    "gmail-work": {
      "command": "node",
      "args": ["/path/to/gmail-mcp/dist/index.js", "--account", "work"]
    },
    "gmail-personal": {
      "command": "node",
      "args": ["/path/to/gmail-mcp/dist/index.js", "--account", "personal"]
    }
  }
}

Available Tools

Email Operations (7 tools)

Tool Description
search_emails Search with Gmail query syntax, pagination
read_email Full message with headers, body, attachment info
send_email Send with to/cc/bcc, attachments, threading
draft_email Create draft without sending
delete_email Trash or permanent delete
modify_email Add/remove labels from message
get_thread Get full conversation thread

Label Management (6 tools)

Tool Description
list_labels All labels (system + user)
create_label Create with color, visibility
update_label Rename, change settings
delete_label Remove custom label
get_or_create_label Idempotent label creation
get_label Get single label details

Filter Management (5 tools)

Tool Description
list_filters All Gmail filters
get_filter Single filter details
create_filter Custom criteria + actions
delete_filter Remove filter
create_filter_from_template Preset templates

Batch Operations (2 tools)

Tool Description
batch_modify_emails Bulk add/remove labels (50 at a time)
batch_delete_emails Bulk delete with fallback

Attachments (2 tools)

Tool Description
download_attachment Save to local filesystem
list_attachments Get attachment metadata for message

Utilities (2 tools)

Tool Description
get_profile User email address, history ID
get_quota Storage usage info

Resources

Resource URI Pattern
Message `gmail://messa

Tools (24)

search_emailsSearch with Gmail query syntax, pagination
read_emailFull message with headers, body, attachment info
send_emailSend with to/cc/bcc, attachments, threading
draft_emailCreate draft without sending
delete_emailTrash or permanent delete
modify_emailAdd/remove labels from message
get_threadGet full conversation thread
list_labelsAll labels (system + user)
create_labelCreate with color, visibility
update_labelRename, change settings
delete_labelRemove custom label
get_or_create_labelIdempotent label creation
get_labelGet single label details
list_filtersAll Gmail filters
get_filterSingle filter details
create_filterCustom criteria + actions
delete_filterRemove filter
create_filter_from_templatePreset templates
batch_modify_emailsBulk add/remove labels (50 at a time)
batch_delete_emailsBulk delete with fallback
download_attachmentSave to local filesystem
list_attachmentsGet attachment metadata for message
get_profileUser email address, history ID
get_quotaStorage usage info

Configuration

claude_desktop_config.json
{
  "mcpServers": {
    "gmail": {
      "command": "node",
      "args": ["/path/to/gmail-mcp/dist/index.js"]
    }
  }
}

Try it

Search for emails from 'Stripe' received in the last 7 days.
Draft a reply to the latest email from my boss about the project update.
Create a new label called 'Urgent' and apply it to all unread emails from 'Support'.
Download all attachments from the most recent email in the 'Invoices' thread.
List all my active Gmail filters and create a new one to archive emails from 'Newsletters'.

Frequently Asked Questions

What are the key features of Gmail MCP Server?

24 Gmail Tools covering email operations, label management, and filters.. Multi-Account Support allowing management of multiple mailboxes via the --account flag.. Secure OAuth Authentication with automatic token refresh and local storage.. Batch Operations for modifying or deleting up to 1000 emails efficiently.. Attachment Support for listing and downloading files to the local filesystem..

What can I use Gmail MCP Server for?

Automating email organization by creating filters and labels through natural language.. Managing multiple professional and personal Gmail accounts from a single AI interface.. Bulk cleaning an inbox by searching for specific criteria and performing batch deletions.. Retrieving and saving email attachments directly to a local machine for processing.. Drafting complex email responses based on conversation history retrieved via thread tools..

How do I install Gmail MCP Server?

Install Gmail MCP Server by running: npm install && npm run build && node dist/index.js auth

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.

Use Gmail MCP Server with Conare

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

Try Free