Headless Gmail

v1.0.0Communicationstable

A headless server that enables reading and sending Gmail emails through API calls without requiring local credentials or browser access, designed to run remotely in containerized environments.

ai-assistantgmailgmail-botgoogle-suitemcp
Share:
54
Stars
0
Downloads
0
Weekly
0/5

What is Headless Gmail?

Headless Gmail is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to headless server that enables reading and sending gmail emails through api calls without requiring local credentials or browser access, designed to run remotely in containerized environments.

A headless server that enables reading and sending Gmail emails through API calls without requiring local credentials or browser access, designed to run remotely in containerized environments.

This server falls under the Communication category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • A headless server that enables reading and sending Gmail ema

Use Cases

Read and send Gmail emails via API without local credentials. Run securely in containerized environments.
baryhuang

Maintainer

LicenseMIT License
Languagepython
Versionv1.0.0
UpdatedMay 11, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-headless-gmail-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Headless Gmail

MCP Headless Gmail is a Python-based MCP server that enables AI assistants to read and send Gmail emails entirely through API calls, without requiring a local browser session or stored credentials on the server. Instead of environment variables, Google OAuth credentials (access token, refresh token, client ID, and client secret) are passed directly as parameters in each tool call, making the server safe to run in containerized or remote environments. It is designed for automation scenarios where Gmail access needs to be integrated into AI workflows running in cloud infrastructure.

Prerequisites

  • A Google Cloud project with the Gmail API enabled and an OAuth 2.0 client ID configured
  • Google OAuth credentials: client_id, client_secret, refresh_token, and a valid access_token
  • Docker installed (recommended for containerized deployment) OR Python 3.10+ with pip
  • Claude Desktop or another MCP-compatible AI client
  • Gmail account with API access authorized through the OAuth consent screen
1

Enable Gmail API and create OAuth credentials

In Google Cloud Console, create a project, enable the Gmail API, and create an OAuth 2.0 client ID (Desktop app type). Download the credentials JSON. Complete the OAuth flow once to obtain a refresh token using the Google OAuth Playground or a script.

2

Pull the Docker image

Pull the pre-built Docker image for the headless Gmail server. This is the recommended approach for running in containerized environments.

docker pull buryhuang/mcp-headless-gmail:latest
3

Alternative: install from source with pip

If not using Docker, clone the repository and install the Python package directly.

git clone https://github.com/baryhuang/mcp-headless-gmail.git
cd mcp-headless-gmail
pip install -e .
4

Configure Claude Desktop

Add the headless Gmail server to your Claude Desktop config. Credentials are passed per-call rather than in env vars, so no secrets are needed in the config file itself.

{
  "mcpServers": {
    "gmail": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "buryhuang/mcp-headless-gmail:latest"]
    }
  }
}
5

Use the token refresh tool before reading email

On first use, call the gmail_refresh_token tool with your refresh token and client credentials to get a fresh access token. Then use that access token in subsequent get_recent_emails and send_email calls.

Headless Gmail Examples

Client configuration

Claude Desktop configuration using the Docker image for MCP Headless Gmail. No credentials in the config — they are passed per tool call.

{
  "mcpServers": {
    "gmail": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "buryhuang/mcp-headless-gmail:latest"]
    }
  }
}

Prompts to try

Example prompts for reading and sending Gmail through Claude after providing your OAuth credentials.

- "Refresh my Gmail access token using my refresh token and client credentials"
- "Get my 5 most recent emails"
- "Show me only unread emails from the last 24 hours"
- "Read the full body of the email from John about the project proposal"
- "Send an email to [email protected] with subject 'Meeting Notes' and the summary we just discussed"
- "Get the full content of the third email in chunks"

Troubleshooting Headless Gmail

Access token expired error when fetching emails

Access tokens expire after 1 hour. Use the gmail_refresh_token tool first, passing your google_refresh_token, google_client_id, and google_client_secret. The tool returns a new access token to use in subsequent calls. You do not need to re-authorize the OAuth flow.

OAuth consent screen shows 'App not verified' warning

This is normal for personal/internal Google Cloud projects. Click 'Advanced' > 'Go to [your app] (unsafe)' to proceed during the initial authorization flow. The warning only appears during the one-time setup, not during normal MCP server operation.

Docker container exits immediately when added to Claude Desktop

Ensure the -i (interactive/stdin) flag is present in your Docker args. MCP servers communicate over stdin/stdout, and without -i the container will exit as soon as it starts because stdin is closed.

Frequently Asked Questions about Headless Gmail

What is Headless Gmail?

Headless Gmail is a Model Context Protocol (MCP) server that headless server that enables reading and sending gmail emails through api calls without requiring local credentials or browser access, designed to run remotely in containerized environments. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Headless Gmail?

Follow the installation instructions on the Headless Gmail GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Headless Gmail?

Headless Gmail works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Headless Gmail free to use?

Yes, Headless Gmail is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Communication MCP Servers

Explore all communication servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcp-headless-gmail-server": { "command": "npx", "args": ["-y", "mcp-headless-gmail-server"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Headless Gmail?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides