Gmail MCP Connector
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gmail MCP Connectorsearch for unread emails from last week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Gmail MCP Connector
A full Gmail MCP connector running as a Cloudflare Worker. It reads, searches, labels, drafts, sends, and manages Gmail — including minting short-lived download URLs for attachments so the raw bytes can be fetched out-of-band without ever entering the model's context, a key capability this connector adds over generic Gmail integrations.
Authorization follows the MCP authorization spec (OAuth 2.1): each user who connects runs the OAuth handshake themselves, and the client holds the token — this connector is multi-user and does not use a shared account secret.
How auth works
This Worker plays two OAuth roles at once (via @cloudflare/workers-oauth-provider):
To the MCP client, it is the authorization server + resource server. It issues its own token to the client and validates that token on every
/api/mcprequest.To Google, it is an OAuth client. It bridges the user to Google's consent screen and obtains a separate Google token.
Per the spec, the client's token is never passed through to Google. Each user's Google tokens are stored encrypted in KV (in the grant props) and used to call Gmail on their behalf. The client only ever holds the Worker's token.
MCP client ──token(A)──▶ Worker (RS/AS) ──token(B)──▶ Google/Gmail
◀─issues A── ◀──issues B──
token A never forwarded to GoogleRelated MCP server: Gmail MCP Server
Endpoints
Endpoint | Purpose |
| MCP JSON-RPC endpoint (requires a valid access token) |
| Redeem a one-time attachment download ticket; streams the raw bytes (no auth header — the ticket is the credential) |
| Authorization UI — bridges the user to Google consent |
| Google redirect target; completes the grant |
| Token + dynamic client registration (library-served) |
| RFC 9728 metadata (library-served) |
| RFC 8414 metadata (library-served) |
Setup
Create a KV namespace for token storage and put its id in
wrangler.toml:wrangler kv namespace create OAUTH_KV # paste the returned id into the [[kv_namespaces]] block in wrangler.tomlCreate a Google OAuth client (type: Web application) in the Google Cloud console, and enable the Gmail API. Add this authorized redirect URI:
{your-worker-origin}/oauth/callback/google(e.g.
https://gmail-mcp.your-subdomain.workers.dev/oauth/callback/google, or your custom domain.)Set the client secrets:
wrangler secret put GOOGLE_CLIENT_ID wrangler secret put GOOGLE_CLIENT_SECRETNo
GOOGLE_REFRESH_TOKEN— tokens are now obtained per-user at connect time.(Optional) Set
BASE_URLinwrangler.tomlif you serve behind a custom domain. If left empty, the Worker derives redirect URIs from the incoming request origin.Deploy:
wrangler deployConnect a client. Add
{your-worker-origin}/api/mcpas a custom MCP server. The client performs dynamic client registration + the OAuth flow automatically; you'll be sent to Google to sign in and consent on first connect.
Tools
search_threads, get_thread, get_message, get_attachment, send_email, reply_to_thread, create_draft, list_drafts, trash_message, list_labels, create_label, label_message, unlabel_message, label_thread, unlabel_thread.
Attachments
get_attachment does not return bytes — it returns a short-lived download URL:
{ "download_url": "https://<worker>/attachment?ticket=<id>", "method": "GET", "expires_in_seconds": 600 }Do a plain HTTP GET on download_url to stream the raw bytes. No auth header is needed — the opaque, high-entropy ticket in the URL is the credential. The ticket is one-time use and expires after 10 minutes.
This keeps the attachment bytes out of the tool result (and therefore out of the model's context): the consuming agent fetches them out-of-band into its own runtime, so large attachments that would blow the MCP tool-result size cap are no longer a problem. Under the hood, minting the URL writes a ticket into OAUTH_KV carrying that grant's Google access token; the GET /attachment endpoint redeems it server-side, fetches the bytes from Gmail, and deletes the ticket. The Google access token never appears in a URL, a tool result, or logs.
If the ticket's copied access token has expired by download time (rare within the 10-minute window), the endpoint returns 401 — just call get_attachment again for a fresh URL.
Optionally pass file_name and mime_type (from get_message's attachment metadata) so the download response sets a correct Content-Type and Content-Disposition.
Development
pnpm install
./node_modules/.bin/tsc --noEmit # typecheck
wrangler dev # local dev serverThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Gchahm/gmail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server