Gmail MCP Server

Gmail MCP Server

An MCP server that provides Claude with access to your Gmail, featuring a full OAuth 2.1 authorization server with dynamic client registration and tools to list, read, search, send, reply, draft, archive, trash, manage labels, and download attachments.

Category
Visit Server

README

Gmail MCP Server

An MCP (Model Context Protocol) server that provides Claude with access to your Gmail, featuring a full OAuth 2.1 authorization server with dynamic client registration.

Features

  • Full OAuth 2.1 Authorization Server (RFC 8414, RFC 7591, RFC 9728)
  • Dynamic Client Registration - Claude Code auto-registers
  • PKCE Support (RFC 7636)
  • First-class "Authenticate" button in Claude Code's /mcp menu
  • Gmail tools: list, read, search, send, reply, draft, archive, trash, labels, attachments

Prerequisites

Node.js 18+ is required. Install via nodejs.org or:

brew install node

Setup

  1. Clone and install dependencies:

    git clone <repo-url> gmail-mcp
    cd gmail-mcp
    npm install
    
  2. Build:

    npm run build
    
  3. Start the server:

    npm start
    

    The server runs on http://localhost:3100 by default. Override with PORT=3200 npm start.

  4. Configure Claude Code (~/.mcp.json):

    {
      "mcpServers": {
        "gmail": {
          "type": "sse",
          "url": "http://localhost:3100/sse"
        }
      }
    }
    
  5. Authenticate via Claude Code:

    • Run /mcp in Claude Code
    • Click "Authenticate" on the gmail server
    • Complete Google OAuth in your browser

    Note: Google will show an "This app isn't verified" warning screen. This is normal for apps that haven't gone through Google's verification process. To proceed:

    1. Click Advanced
    2. Click Go to gmail-mcp (unsafe)
    3. Review the requested permissions (read and modify Gmail) and click Allow

    Your credentials are stored locally on your machine and are never sent to any third-party server.

Configuration

Google OAuth credentials are built in — no setup required. On first use, you'll be prompted to authorize your Gmail through Google's consent screen.

User-specific config files are stored in ~/.config/gmail-mcp/:

File Description
credentials.json Optional — Override the built-in Google OAuth credentials with your own
token.json Your Google OAuth tokens (auto-generated after authorization)
clients.json Registered MCP clients (auto-generated)
access_tokens.json Issued access tokens (auto-generated)

Auto-Start on Login (macOS)

Run the install script to set up the LaunchAgent:

./scripts/install.sh

This will:

  • Detect your node installation
  • Generate a plist with correct paths
  • Install to ~/Library/LaunchAgents/
  • Start the server immediately

To uninstall:

./scripts/uninstall.sh

Logs are written to ~/.config/gmail-mcp/stdout.log and stderr.log.

Available Tools

Tool Description
list_emails List emails from inbox with optional filters
read_email Read full email content by ID
search_emails Search using Gmail query syntax
send_email Compose and send a new email
reply_to_email Reply to an existing email
draft_email Create a draft without sending
mark_as_read Mark an email as read
mark_as_unread Mark an email as unread
archive_email Archive an email (remove from inbox)
trash_email Move an email to trash
add_label Add a label to an email
remove_label Remove a label from an email
list_labels List all Gmail labels
get_thread Get all emails in a conversation
get_attachment Download an email attachment

Gmail Search Syntax

The search_emails and list_emails tools support Gmail's query syntax:

  • is:unread - Unread emails
  • from:someone@example.com - From specific sender
  • subject:invoice - Subject contains "invoice"
  • has:attachment - Has attachments
  • after:2025/01/01 - After a date
  • before:2025/12/31 - Before a date
  • label:important - Has specific label

Architecture

┌─────────────────┐      ┌──────────────────────────────────────┐
│   Claude Code   │◄────►│         Gmail MCP Server             │
│                 │ SSE  │                                      │
│  /mcp menu      │      │  ┌─────────────────────────────────┐ │
│  shows          │      │  │ OAuth 2.1 Authorization Server  │ │
│  "Authenticate" │      │  │  - Dynamic client registration  │ │
│                 │      │  │  - PKCE support                 │ │
└─────────────────┘      │  │  - Token management             │ │
                         │  └──────────────┬──────────────────┘ │
                         │                 │                    │
                         │  ┌──────────────▼──────────────────┐ │
                         │  │      Google OAuth Proxy         │ │
                         │  │  - Redirects to Google          │ │
                         │  │  - Stores Google tokens         │ │
                         │  └──────────────┬──────────────────┘ │
                         │                 │                    │
                         │  ┌──────────────▼──────────────────┐ │
                         │  │        Gmail API Tools          │ │
                         │  │  - list, read, search, etc.     │ │
                         │  └─────────────────────────────────┘ │
                         └──────────────────────────────────────┘

Development

npm run build   # Compile TypeScript
npm start       # Run server
npm run auth    # Standalone Google OAuth (alternative to browser flow)

Endpoints

Endpoint Description
GET /health Health check & status
GET /.well-known/oauth-protected-resource RFC 9728 metadata
GET /.well-known/oauth-authorization-server RFC 8414 metadata
POST /oauth/register Dynamic client registration
GET /oauth/authorize Authorization endpoint
POST /oauth/token Token endpoint
GET /sse MCP SSE endpoint (protected)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured