Your Gmail accounts, served to any MCP client, from your own Cloudflare Worker. Roughly ten minutes to deploy.
Every connection performs its own Google sign-in, so two mailboxes can be connected to one deployment at the same time — each permanently bound to the account chosen at its consent screen. Your refresh tokens stay in your own Cloudflare account.
Create a project and switch the Gmail API on.
PROJECT="gmail-mcp-$(openssl rand -hex 3)" gcloud auth login gcloud projects create "$PROJECT" --name="gmail-mcp" gcloud config set project "$PROJECT" gcloud services enable gmail.googleapis.com
The consent screen and the OAuth client have no API, so these two are browser steps:
https://<your-domain>/callbackKeep the client ID and secret for the next step.
http://localhost:8788/callback as a second redirect URI now saves a trip back if you ever run bun run dev.Clone, point the Worker at your domain, and let the setup script do the rest.
git clone https://github.com/mkpoli/gmail-mcp && cd gmail-mcp bun install # edit wrangler.jsonc — set `name` and the routes `pattern` to your domain bun run setup
bun run setup creates the KV namespace, prompts for each secret, generates the cookie key, and deploys. It is safe to re-run — every step can be skipped.
ALLOWED_EMAILS is checked against the address Google reports as verified, after consent and before any grant exists.
| Value | Who gets in |
|---|---|
| empty | nobody — fail-closed default |
you@gmail.com, work@co.com | exactly those accounts |
*@your-company.com | any account in that domain |
* | any verified Google account |
* hands strangers is the use of your deployment, and your Google client's quota, for their own mail.No client ID or secret on the client side — MCP clients register themselves.
claude mcp add --transport http gmail-personal https://<your-domain>/mcp claude mcp add --transport http gmail-work https://<your-domain>/mcp/work
Run /mcp in Claude Code to authenticate each one, signing in with the matching Google account. In claude.ai: Settings → Connectors → Add custom connector, paste the URL, leave the credential fields empty.
/mcp/work, /mcp/family. It exists so clients that refuse two servers sharing a URL can still hold several mailboxes.Japanese, Chinese, emoji, and right-to-left text survive the round trip: subjects and filenames are RFC 2047 encoded, bodies carry their declared charset.