Get the FREE Ultimate OpenClaw Setup Guide →

Gmail

A Model Context Protocol (MCP) server for Gmail integration in Claude Desktop with auto authentication support. This server enables AI assistants to manage Gmail through natural language interactions.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio gongrzhe-gmail-mcp-server npx @gongrzhe/server-gmail-autoauth-mcp

How to use

The Gmail MCP Server provides tools to manage Gmail accounts via natural language interactions within Claude Desktop. It supports sending emails (including with attachments or HTML/multipart bodies), reading emails by ID, managing labels (create, update, delete, list), and performing batch operations on multiple messages. The server uses a simple OAuth2 authentication flow with automatic browser launches and supports both desktop and web application credentials, with credentials stored locally for reuse. To use it, configure the Gmail MCP server in Claude Desktop and invoke the available tools (send_email, read_email, draft_email, and label management) through natural language prompts that map to the underlying API calls.

Once set up, you can compose emails with attachments, HTML content, and multipart messages, fetch and read emails by ID (including MIME structure), search and filter messages by subjects or senders, and organize your inbox with labels. The authentication flow can be run globally or locally, and there are Docker-based options for deployment if you prefer containerization. The available tools include: sending emails with or without attachments, drafting emails without sending, reading emails by ID, and managing Gmail labels, all integrated to work with Claude Desktop prompts.

How to install

Prerequisites:

  • Node.js and npm installed on your machine
  • Internet access to install npm packages
  • Optional: Docker if you prefer containerized usage

Installation steps:

  1. Install via Smithery (recommended): npx -y @smithery/cli install @gongrzhe/server-gmail-autoauth-mcp --client claude

  2. Manual installation and setup:

    • Create a Google Cloud Project and enable the Gmail API
    • Create OAuth 2.0 credentials (Desktop or Web app) and download the JSON keys as gcp-oauth.keys.json
    • Place the keys in your home directory under ~/.gmail-mcp/ (for global/auth) or in your project directory for local auth
    • Run authentication (global): npx @gongrzhe/server-gmail-autoauth-mcp auth
    • Or run authentication (local): npx @gongrzhe/server-gmail-autoauth-mcp auth
  3. Configure in Claude Desktop: { "mcpServers": { "gmail": { "command": "npx", "args": [ "@gongrzhe/server-gmail-autoauth-mcp" ] } } }

  4. Docker-based usage (optional):

    • Authenticate inside a container using your OAuth keys mounted into the container
    • Run the server with the appropriate environment variables and mount points as shown in the Docker usage example from the README.
  5. Cloud / remote deployment: use the cloud authentication flow with a custom callback URL if needed, and configure the same mcpServers JSON object in Claude.

Additional notes

Tips and common issues:

  • Ensure Gmail API is enabled for your Google Cloud project and that the OAuth consent screen is configured as needed.
  • If you switch between Desktop and Web credentials, make sure the redirect URIs are updated in Google Cloud Console.
  • Credentials are stored under ~/.gmail-mcp/; keep this directory secure as it contains tokens.
  • When using Docker, ensure the credentials.json path is correctly mounted and that GMAIL_CREDENTIALS_PATH points to the mounted credentials file inside the container.
  • For cloud environments, use the cloud-specific auth flow or provide a reachable OAuth callback URL; local redirects may not work in containerized setups.
  • The npm package name is the source for installing or referencing the MCP server in automation flows.

Related MCP Servers

Sponsor this space

Reach thousands of developers