Gmail MCP Server

Gmail MCP Server

Enables interaction with Gmail through the Gmail API with OAuth2 authentication. Supports reading, sending, searching emails, and managing read status through natural language.

Category
Visit Server

README

Gmail MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with Gmail through the Gmail API.

Features

  • 🔐 OAuth2 Authentication - Secure authentication with Google's OAuth2
  • 📧 Read Emails - List and read emails from your Gmail inbox
  • ✉️ Send Emails - Send emails through Gmail
  • 🔍 Search Emails - Search emails using Gmail's powerful search syntax
  • 📌 Mark as Read/Unread - Manage email read status
  • 🛡️ Secure - Uses Google's official authentication flow

Quick Start

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Run the server:

    python gmail_mcp_server.py
    
  3. First time setup:

    • Use the authenticate_gmail tool to authorize access
    • This will open your browser for Google OAuth consent

Available Tools

authenticate_gmail

Authenticate with Gmail API using OAuth2. Must be run first.

list_emails

List emails from your Gmail inbox.

  • max_results (optional): Maximum number of emails to return (default: 10)
  • query (optional): Gmail search query

read_email

Read a specific email by its ID.

  • email_id (required): The ID of the email to read

send_email

Send an email through Gmail.

  • to (required): Recipient email address
  • subject (required): Email subject
  • body (required): Email body (plain text)
  • cc (optional): CC email addresses (comma-separated)
  • bcc (optional): BCC email addresses (comma-separated)

search_emails

Search emails using Gmail search syntax.

  • query (required): Gmail search query
  • max_results (optional): Maximum number of results (default: 10)

mark_as_read / mark_as_unread

Mark an email as read or unread.

  • email_id (required): The ID of the email to modify

Gmail Search Syntax

  • is:unread - Unread emails
  • from:example@gmail.com - Emails from specific sender
  • subject:important - Emails with "important" in subject
  • has:attachment - Emails with attachments
  • after:2024/01/01 - Emails after specific date

Configuration

  • Credentials file: gcp-oauth.keys.json (your GCP OAuth credentials - see gcp-oauth.keys.json.example)
  • Token file: token.pickle (created automatically after authentication)
  • MCP config: mcp_config.json (for MCP client configuration)

Setup Credentials

  1. Copy gcp-oauth.keys.json.example to gcp-oauth.keys.json
  2. Replace the placeholder values with your actual GCP OAuth credentials
  3. Ensure Gmail API is enabled in your Google Cloud project

Integration

To integrate this server with other projects:

  1. Copy the core files:

    • gmail_mcp_server.py - Main server
    • requirements.txt - Dependencies
    • gcp-oauth.keys.json - Your OAuth credentials
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Configure MCP client using mcp_config.json:

    {
      "mcpServers": {
        "gmail": {
          "command": "python",
          "args": ["gmail_mcp_server.py"],
          "cwd": "/path/to/your/gmail/mcp/server"
        }
      }
    }
    

Testing

Run the included test to verify functionality:

python direct_test.py

This will test authentication, email listing, searching, and sending.

Security

  • OAuth2 credentials are stored securely using Google's official libraries
  • Access tokens are refreshed automatically
  • All API calls use HTTPS
  • Keep token.pickle file secure

License

This project is provided as-is for educational and integration purposes.

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