gmail-mcp

gmail-mcp

Enables searching, reading, sending, drafting, and organizing emails across multiple Google accounts via MCP.

Category
Visit Server

README

gmail-mcp v1.0.0

Unified Multi-Account Google OAuth2 MCP Server for Gmail. Search, read, compose, send, draft, and organize emails across multiple Google accounts seamlessly.

Features (4 Unified Tools)

  • gmail_search: Search emails with official Gmail search syntax (is:unread, from:boss@corp.com, subject:invoice, newer_than:2d, has:attachment)
  • gmail_read: Read full email content and metadata (subject, sender, body text, HTML, CC, BCC, labels, attachment list)
  • gmail_send: Send emails or create drafts (supports HTML, CC, BCC, thread replies, and file attachments)
  • gmail_manage: Labeling, archiving, trash management, read/unread toggles, permanent deletion, and multi-account inventory

Multi-Account Architecture

A single Google Cloud OAuth client (credentials.json) can authenticate multiple Gmail accounts. Tokens are stored per-account in ~/.secrets/gmail/tokens/<account_name>.json.

1. Setup Google OAuth Credentials (One-time)

  1. Create a project in Google Cloud Console.
  2. Enable the Gmail API.
  3. Create an OAuth 2.0 Client ID (Desktop Application).
  4. Download the client secret JSON file and save it as ~/.secrets/gmail/credentials.json (or set GMAIL_CREDENTIALS_JSON).

2. Authenticate Accounts

Run the interactive authorization CLI for each account:

gmail-auth default    # Authenticates primary account
gmail-auth work       # Authenticates secondary work account
gmail-auth client_x   # Authenticates any additional account

List all authenticated accounts:

gmail-auth --list

Installation in MCP Clients (Claude Desktop, OpenCode, Cursor, Windsurf)

Option 1: Instant via uvx (Recommended)

{
  "mcpServers": {
    "gmail": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Steph-ux/gmail-mcp.git", "gmail-mcp"]
    }
  }
}

Option 2: Via pip install

pip install git+https://github.com/Steph-ux/gmail-mcp.git

Then in your MCP config:

{
  "mcpServers": {
    "gmail": {
      "command": "gmail-mcp"
    }
  }
}

Option 3: Local Clone (Development)

{
  "mcpServers": {
    "gmail": {
      "command": "python",
      "args": ["D:\\Steph\\script\\gmail-mcp\\server.py"]
    }
  }
}

Usage Examples

1. Search Messages

# Search in default account:
gmail_search(query='is:unread from:github')

# Search in work account:
gmail_search(account='work', query='subject:invoice newer_than:7d')

2. Read Message

gmail_read(account='work', message_id='18f2a9b4c10d')

3. Send Email or Create Draft

# Send direct email:
gmail_send(
    account='default',
    to='colleague@example.com',
    subject='Project Update',
    body_text='Here is the latest status...',
    body_html='<h1>Project Update</h1><p>Here is the latest status...</p>'
)

# Create a draft:
gmail_send(
    account='work',
    to='client@example.com',
    subject='Proposal draft',
    body_text='Please review the proposal.',
    draft=True
)

4. Organize & Manage

# Archive email:
gmail_manage(account='work', action='archive', message_id='18f2a9b4c10d')

# Mark as unread:
gmail_manage(account='default', action='mark_unread', message_id='18f2a9b4c10d')

# Move to trash:
gmail_manage(account='default', action='trash', message_id='18f2a9b4c10d')

# List active accounts:
gmail_manage(action='list_accounts')

Testing

pytest tests

License

MIT

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