Skip to main content

Gmail MCP Server

A resilient MCP (Model Context Protocol) server built with fastMCP for sending emails through Gmail's SMTP server using AI agents. This server uses stdio transport for seamless integration with MCP clients.

PyPI version Python 3.10+ License: MIT

Features

  • Send emails via Gmail SMTP
  • Fetch recent emails from Gmail folders
  • Handle email attachments (from URLs, local files, or pre-staged files)
  • stdio transport for MCP client integration

Gmail App Password Setup

To use this MCP server, you'll need to create a Gmail App Password:

  1. Go to your Google Account settings
  2. Select Security from the navigation panel
  3. Under "How you sign in to Google," select 2-Step Verification
  4. At the bottom, select App passwords
  5. Select the app and device you want to generate the app password for
  6. Select Generate
  7. Follow the instructions to enter the app password on your device
  8. Select Done

Use this app password as your SMTP_PASSWORD in the configuration.

Configuration Options

Environment Variables

  • SMTP_USERNAME: Your Gmail email address
  • SMTP_PASSWORD: Your Gmail app password (not your regular password)

Server Configuration

  • Transport: stdio for MCP client integration
  • Protocol: MCP (Model Context Protocol)

Installation

Option 1: Direct Installation with pip

Install the package from PyPI:

pip install rickjang-gmail-mcp-server

Then set up your Gmail credentials as environment variables:

export SMTP_USERNAME="your-email@gmail.com"
export SMTP_PASSWORD="your-app-password"

Run the server:

rickjang-gmail-mcp-server

Add the following to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "gmail-mcp": {
      "command": "uv",
      "args": [
        "tool", 
        "run", 
        "rickjang-gmail-mcp-server"
      ],
      "env": {
        "SMTP_USERNAME": "your-email@gmail.com",
        "SMTP_PASSWORD": "your-gmail-app-password"
      }
    }
  }
}

This method automatically installs the package using uv and sets the environment variables directly in the configuration.

Claude Desktop Configuration

For Claude Desktop, add this to your claude_desktop_config.json file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "gmail-mcp": {
      "command": "uv",
      "args": [
        "tool", 
        "run", 
        "rickjang-gmail-mcp-server"
      ],
      "env": {
        "SMTP_USERNAME": "jyjang@uengine.org",
        "SMTP_PASSWORD": "your-gmail-app-password"
      }
    }
  }
}

After adding this configuration, restart Claude Desktop to load the MCP server.

Local Development

  1. Clone the repository:

    git clone https://github.com/rickjang/Gmail-mcp-server.git
    cd Gmail-mcp-server
    
  2. Install in development mode:

    pip install -e .
    
  3. Set environment variables and run:

    export SMTP_USERNAME="your-email@gmail.com"
    export SMTP_PASSWORD="your-app-password"
    rickjang-gmail-mcp-server
    

Available Tools

This MCP server provides the following tools:

send_email_tool

Send emails via Gmail SMTP with optional attachments.

Parameters:

  • recipient (string): Email address to send to
  • subject (string): Email subject
  • body (string): Email body text
  • attachment_path (string, optional): Direct file path for attachment
  • attachment_url (string, optional): URL to download attachment from
  • attachment_name (string, optional): Filename for attachment

fetch_recent_emails

Fetch recent emails from a Gmail folder.

Parameters:

  • folder (string, optional): Email folder to fetch from (default: "INBOX")
  • limit (integer, optional): Maximum number of emails to fetch (default: 10)

Testing

Test the server locally:

# Basic functionality test
python test_local.py

# stdio transport test
python test_stdio.py

Metadata

Release files for rickjang-gmail-mcp-server 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rickjang-gmail-mcp-server 1.1.0
File Size Uploaded
rickjang_gmail_mcp_server-1.1.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rickjang-gmail-mcp-server 1.1.0
File Interpreter ABI Platform
rickjang_gmail_mcp_server-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / rickjang_gmail_mcp_server-1.1.0.tar.gz

Download URL rickjang_gmail_mcp_server-1.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1c7b10873b5b2ea0e7f64b6c49b02f76f17664e0f6a8f968c27715ad12686ab8
BLAKE2b-256 checksum
How to use checksums
83ce68c3cd87ab101ae91fa3af62015123914c5f42be6445e18d67b25e3a4fc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / rickjang_gmail_mcp_server-1.1.0-py3-none-any.whl

Download URL rickjang_gmail_mcp_server-1.1.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7aec32f64c56ec901fd6d2511982ed39f442c05309d7b6a07c8551d10631402c
BLAKE2b-256 checksum
How to use checksums
288ce2b4f14d3d2b1460d78d82ffc74aca69c343028246fd98ae853b13ec191b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page