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.
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
- Create a Google Cloud project, enable the Gmail API, and create a Web Application OAuth client.
- Register
http://localhost:8080/admin/oauth/callbackor your LAN hostname equivalent as an authorized redirect URI. - 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
-
Save the generated values and Google credentials in
~/.config/dev-secrets/gmail_mcp.envon the VM, then set mode0600. -
Start the server with command-scoped secret injection:
./scripts/dev-compose up --build
- Add accounts through the admin OAuth flow:
http://localhost:8080/admin/oauth/start?alias=personal&token=<ADMIN_TOKEN>
- 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_IDGOOGLE_CLIENT_SECRETGOOGLE_REDIRECT_URIGMAIL_MCP_ENCRYPTION_KEYADMIN_TOKENMCP_BEARER_TOKEN
Optional:
DATABASE_URL, defaultsqlite:////data/gmail_mcp.sqlite3MCP_ALLOWED_HOSTS, comma-separated, defaultlocalhost,localhost:*,127.0.0.1,127.0.0.1:*MCP_ALLOWED_ORIGINS, comma-separated, default emptyLOG_LEVEL, defaultINFO
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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.