Gmail MCP

Gmail MCP

Enables users to manage multiple Gmail accounts via MCP, including drafting, sending, and organizing emails with a safety confirmation flow for state-changing actions.

Category
Visit Server

README

Gmail MCP

Private multi-account Gmail MCP server for Codex.

Development

Open this repository through Remote SSH and choose Dev Containers: Reopen in Container. The container exposes only this repository, runs as the unprivileged vscode user, and uses a repository-specific Codex home on the VM. Its sole Docker security override relaxes seccomp because the real Codex workspace sandbox was verified to require nested user namespaces on this VM. No capabilities, privileged mode, AppArmor override, or Docker socket are used.

The central development image provides Python, uv, Codex, and generic build tools. Project dependencies are installed from the checked-in uv.lock into this repository's ignored .venv. The devcontainer creates that environment automatically and keeps it isolated from every other repository and worktree.

The project commands are:

uv lock --check
uv sync --frozen --group dev
uv run --frozen pytest
uv run --frozen flake8 src tests
uv build

The first time this repository is opened, authenticate its isolated Codex state with the primary development ChatGPT account by running codex login in the container. Do not put API keys in the devcontainer configuration.

Quick Start

  1. Create a Google Cloud project, enable the Gmail API, and create a Web Application OAuth client.
  2. Register http://localhost:8080/admin/oauth/callback or your LAN hostname equivalent as an authorized redirect URI.
  3. Generate secrets:
uv run --frozen python - <<'PY'
from cryptography.fernet import Fernet
import secrets
print("GMAIL_MCP_ENCRYPTION_KEY=" + Fernet.generate_key().decode())
print("ADMIN_TOKEN=" + secrets.token_urlsafe(32))
print("MCP_BEARER_TOKEN=" + secrets.token_urlsafe(32))
PY
  1. Save the generated values and Google credentials in ~/.config/dev-secrets/gmail_mcp.env on the VM, then set mode 0600.

  2. Start the server with command-scoped secret injection:

./scripts/dev-compose up --build
  1. Add accounts through the admin OAuth flow:
http://localhost:8080/admin/oauth/start?alias=personal&token=<ADMIN_TOKEN>
  1. Connect Codex:
export MCP_BEARER_TOKEN="<same token>"
codex mcp add gmail --url http://localhost:8080/mcp --bearer-token-env-var MCP_BEARER_TOKEN

Required Environment

  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • GOOGLE_REDIRECT_URI
  • GMAIL_MCP_ENCRYPTION_KEY
  • ADMIN_TOKEN
  • MCP_BEARER_TOKEN

Optional:

  • DATABASE_URL, default sqlite:////data/gmail_mcp.sqlite3
  • MCP_ALLOWED_HOSTS, comma-separated, default localhost,localhost:*,127.0.0.1,127.0.0.1:*
  • MCP_ALLOWED_ORIGINS, comma-separated, default empty
  • LOG_LEVEL, default INFO

Safety Model

Draft creation happens immediately. Sending mail, sending drafts, label changes, archive, mark read/unread, star/unstar, and trash create pending actions first. A caller must execute gmail_pending_action_confirm with the returned pending_action_id before Gmail state changes.

The committed .env.example is a variable-name contract only. Real values stay outside Git and are passed to Docker Compose only for the command being run.

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
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

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