IntegrationsAdvanced

How to give Claude access to your Gmail with an MCP server

Install a Gmail MCP server so Claude Desktop or Claude Code can read, search and draft email through your own credentials.

11 minAdvanced

The Model Context Protocol (MCP) lets Claude call external tools. A Gmail MCP server gives Claude functions like search messages, read a thread, and create a draft, all running locally with your Google OAuth credentials. This guide sets one up for Claude Desktop. Nothing is sent to Anthropic except the tool results Claude needs to answer you.

  • Claude Desktop installed
  • Node.js 18 or newer
  • A Google Cloud project with the Gmail API enabled
  • An OAuth client (Desktop app) credentials JSON file

Step 1: Enable the Gmail API and get OAuth credentials

In Google Cloud Console, create or pick a project, open APIs and Services, and enable the Gmail API. Then go to Credentials, create an OAuth client ID, choose Desktop app, and download the JSON. Add your own email as a test user on the OAuth consent screen so it works without a published app review.

Google Cloud Console - Credentials
APIs & Services > Credentials
+ CREATE CREDENTIALS > OAuth client ID
Application type: Desktop app
Name: claude-gmail
[ Download JSON ] -> gcp-oauth.keys.json
A Desktop app OAuth client gives you the JSON the server needs.

Step 2: Run the Gmail MCP server once to authorize

Most Gmail MCP servers ship on npm. Place the credentials file where the server expects it, then run the auth command. A browser window opens for the Google consent screen. Approve it and the server stores a refresh token locally.

zsh - gmail mcp setup
create the config dir and drop in your OAuth keys
$mkdir -p ~/.gmail-mcp
$mv ~/Downloads/gcp-oauth.keys.json ~/.gmail-mcp/
run the one-time auth flow
$npx @gongrzhe/server-gmail-autoauth-mcp auth
Opening browser for Google sign-in...
Authentication successful. Token saved to ~/.gmail-mcp/credentials.json
$

Step 3: Register the server in Claude Desktop

Open Claude Desktop, go to Settings, Developer, Edit Config. Add the Gmail server to the mcpServers block. The file is claude_desktop_config.json in your Application Support (macOS) or AppData (Windows) folder.

claude_desktop_config.json
{
  "mcpServers": {
    "gmail": {
      "command": "npx",
      "args": ["@gongrzhe/server-gmail-autoauth-mcp"]
    }
  }
}
Keep your tokens private
The credentials.json file holds a refresh token that can read and send your mail. Do not commit it to git, do not paste it into chats, and revoke it from your Google Account security page if your machine is lost.

Step 4: Restart Claude and try a command

Quit and reopen Claude Desktop. You should see a tools icon showing the Gmail server connected. Ask Claude to do something concrete and it will request permission to call the tool the first time.

Claude Desktop
You
Find unread emails from my boss this week and summarize them.
Agent
I searched your inbox. There are 2 unread from sarah@acme.com: one asks for the deck by Thursday, one approves your time off. Want me to draft a reply to the deck request?
Claude calls the Gmail tool and reports back the result.

Result: Claude can now triage, summarize and draft inside your real mailbox on demand, using your own Google credentials, without copying email text back and forth.

Watch related tutorials

Tags
#claude#gmail#mcp#oauth