Skip to main content
MCP server CX Codex

gmail — Claude Code MCP server: Gmail inside your agent

Hooks Gmail into an AI assistant: read threads, search, label, draft and send. Works for personal accounts and Google Workspace.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add --env GMAIL_OAUTH_CLIENT_ID=<GMAIL_OAUTH_CLIENT_ID> --env GMAIL_OAUTH_CLIENT_SECRET=<GMAIL_OAUTH_CLIENT_SECRET> --env GMAIL_OAUTH_REFRESH_TOKEN=<GMAIL_OAUTH_REFRESH_TOKEN> --env GMAIL_SERVICE_ACCOUNT_CLIENT_EMAIL=<GMAIL_SERVICE_ACCOUNT_CLIENT_EMAIL> --env GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY=<GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY> --transport stdio gmail -- npx -y gmail-workspace-mcp-server
Open on GitHub

What gmail does

The server hands your agent a set of Gmail tools. It can pull conversation lists filtered by label, fetch a full message with attachment details, and run searches in Gmail query syntax. Labels, read/unread state, stars and archiving are all writable, and drafts or replies can be created and sent.

Auth comes in two flavours. A personal @gmail.com mailbox uses OAuth2: enable the Gmail API in a Google Cloud project, set up and publish the consent screen, then make Desktop app credentials. Grab the refresh token with npx gmail-workspace-mcp-server oauth-setup <client_id> <client_secret>; the server listens on port 3000 unless you override it with PORT. Workspace setups go through a service account with domain-wide delegation and the four Gmail scopes.

Permissions are split into tool groups picked with GMAIL_ENABLED_TOOLGROUPS: readonly, readwrite, and readwrite_external, which adds sending. All of them are on out of the box, so the agent can send mail on the first run. Skip publishing the consent screen and the refresh token lapses every 7 days.

What it helps with

  • locate a message using Gmail search syntax
  • read a thread and list its attachments
  • prepare a reply draft from task context
  • file incoming mail under the right labels
  • lock an agent down to read-only mailbox access

Example prompts for the agent

  • Search Gmail for the thread with the contractor from March and show the latest message
  • Draft a reply to that message and save it in Gmail
  • Send an email to the address in contacts.md with the subject “Friday call”

How to install gmail

Platform CLI

claude mcp add --env GMAIL_OAUTH_CLIENT_ID=<GMAIL_OAUTH_CLIENT_ID> --env GMAIL_OAUTH_CLIENT_SECRET=<GMAIL_OAUTH_CLIENT_SECRET> --env GMAIL_OAUTH_REFRESH_TOKEN=<GMAIL_OAUTH_REFRESH_TOKEN> --env GMAIL_SERVICE_ACCOUNT_CLIENT_EMAIL=<GMAIL_SERVICE_ACCOUNT_CLIENT_EMAIL> --env GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY=<GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY> --transport stdio gmail -- npx -y gmail-workspace-mcp-server

Replace <…> with your own values. 2 more environment variables are in the server README

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about gmail

How do I install gmail in Claude Code?

Run `claude mcp add gmail -e GMAIL_OAUTH_CLIENT_ID=<GMAIL_OAUTH_CLIENT_ID> -e GMAIL_OAUTH_CLIENT_SECRET=<GMAIL_OAUTH_CLIENT_SECRET> -e GMAIL_OAUTH_REFRESH_TOKEN=<GMAIL_OAUTH_REFRESH_TOKEN> -e GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY=<GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY> -- npx -y gmail-workspace-mcp-server` with your own credential values filled in.

What does the gmail MCP server do?

It lets your assistant work with a mailbox: read conversations, search, change labels and message state, write drafts, send mail. Every call goes through the Gmail API under your credentials.

Should I use OAuth2 or a service account?

Pick OAuth2 for a personal mailbox where you grant access yourself. A service account with domain-wide delegation is the route inside Google Workspace, where a domain admin hands out the scopes.

Similar MCP servers

All MCP servers for Agent setup: memory, context, orchestration →

From the same set9

twist Bridges your Twist workspace and an AI agent: list channels, open threads, post messages through MCP tools. Handy when discussion lives in Twist but you work from the chat. CX Codex +1 ★ 81repo stars slack An MCP server for Slack that reads channels and threads, posts and edits messages, and adds reactions. Useful when your agent has to work with chat without leaving the editor. CX Codex +1 ★ 81repo stars remote-filesystem An MCP server that lets your agent work with a Google Cloud Storage bucket: upload, download, list, edit properties and delete files. CX Codex +1 ★ 81repo stars proctor Runs Proctor exams against MCP servers, keeps the results for comparison, and manages the Fly.io machines that host the runs. Internal to PulseMCP. CX Codex +1 ★ 81repo stars onepassword MCP server that reads and writes 1Password vault data via CLI. The agent can pull credentials, create new items, or mint share links. CX Codex +1 ★ 81repo stars image-diff Compares two images pixel by pixel, groups the differences into clusters and renders a heatmap. Handy for checking a UI screenshot against its design mock. CX Codex +1 ★ 81repo stars google-docs Lets your coding agent work with Google Docs: read, create, edit, delete and export files, authorized through OAuth2 or a Workspace service account. CX Codex +1 ★ 81repo stars fetchpet Automates Fetch Pet insurance claim workflows: submission, status tracking, EOB and invoice downloads via browser automation. CX Codex +1 ★ 81repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor