Logo vun Gmail MCP 服务器

Gmail MCP 服务器

Communautéit
PaulFidika

A single-file MCP-server for interacting with Gmail. Works with Claude Desktop and Cursor.

EditeurPaulFidika
Repositorygmail-mcp-server
SproochGo
Forks
13
Stären
22
Disponibel Tools
0
Transporttypstdio, streamable-http
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    Gmail MCP 服务器 stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    22 Stären an 13 Forks aus dem verlinkte Repository.

Gmail MCP Server

An MCP server that lets AI agents search Gmail threads, understand your email writing style, and create draft emails.

1. Get Google Authentication

Step 1: Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Click "Select a project" dropdown at the top
  3. Click "New Project"
  4. Enter a project name (e.g., "Gmail MCP Server")
  5. Click "Create"

Step 2: Enable Gmail API

  1. In your new project, go to "APIs & Services" → "Library"
  2. Search for "Gmail API"
  3. Click on "Gmail API" and click "Enable"

Step 3: Create OAuth2 Credentials

  1. Go to "APIs & Services" → "Credentials"
  2. Click "Create Credentials" → "OAuth Client ID"
  3. If prompted, configure the OAuth consent screen:
    • Choose "External" user type
    • Fill in required fields (App name, User support email, Developer email)
    • Add your email to "Test users" section
    • Save and continue through all steps
  4. Back in Credentials, click "Create Credentials" → "OAuth Client ID"
  5. Choose "Desktop application" as the application type
  6. Enter a name (e.g., "Gmail MCP Client")
  7. Click "Create"
  8. Important: Copy the Client ID and Client Secret from the confirmation dialog (you'll need these for configuration)

Step 4: Grant OAuth Scopes

When you first run the server, it will open your browser for authorization. The server requests only these minimal permissions:

What We Request:

  • ✅ Gmail Readonly Access (gmail.readonly)

    • Search and read your email messages
    • Download email attachments
    • View email metadata (subjects, senders, dates)
  • ✅ Gmail Compose Access (gmail.compose)

    • Create email drafts
    • Update existing drafts
    • Delete drafts
    • Send emails (permission granted but not used by this server)

What This Server Actualy Implements:

  • ✅ Search and read emails - Full search capabilities
  • ✅ Extract attachment text - Safe PDF/DOCX/TXT text extraction
  • ✅ Create/update drafts - Smart draft management with thread awareness
  • ❌ Send emails - Server doesn't implement sending (though permission is granted)
  • ❌ Delete emails - Server doesn't implement deletion
  • ❌ Modify labels - Server doesn't implement label management

2. Add to MCP Clients

Build the server first: go build .

You'll want to add this to your agent's configuration file:

json
{
  "mcpServers": {
    "gmail": {
      "command": "C:/path/to/your/auto-gmail.exe",
      "env": {
        "GMAIL_CLIENT_ID": "your_client_id_here.apps.googleusercontent.com",
        "GMAIL_CLIENT_SECRET": "your_client_secret_here",
        "OPENAI_API_KEY": "your_openai_api_key_here"
      }
    }
  }
}

⚡ Persistent HTTP Mode (Recommended to Avoid OAuth Popups)

Problem: In stdio mode, Cursor starts a fresh server process each time (and for each tab), causing OAuth popup spam.

Solution: Run the server as a persistent HTTP daemon that authenticates once and stays running.

Quick Start:

bash
# Build the server
go build -o gmail-mcp-server

# Start persistent server (OAuth only once!)
./gmail-mcp-server --http

# Or with custom port
./gmail-mcp-server --http 3000

What Happens:

  1. ✅ OAuth popup appears ONCE when server starts
  2. ✅ Server runs persistently on http://localhost:8080
  3. ✅ No more OAuth popups - server stays authenticated
  4. ✅ Multiple Cursor tabs/windows can connect to same server

Cursor Configuration (Still Use stdio for now):

json
{
  "mcpServers": {
    "gmail": {
      "command": "C:/path/to/your/gmail-mcp-server",
      "env": {
        "GMAIL_CLIENT_ID": "your_client_id_here.apps.googleusercontent.com", 
        "GMAIL_CLIENT_SECRET": "your_client_secret_here",
        "OPENAI_API_KEY": "your_openai_api_key_here"
      }
    }
  }
}

The difference: You start the server manually once instead of letting Cursor start it fresh each time.

Server Status:

Add to Cursor

  • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
  • Click the MCP-tab
  • Click '+ Add new global MCP server'
  • Edit config file

Add to Claude Desktop

  • Go to File > Settings > Developer > Edit Config
  • Edit Config file

Manual Configuration Alternative:

You can edit these config files directly if you know where to find them:

  • Cursor: C:\Users\[User]\.cursor\mcp.json
  • Claude Desktop: %APPDATA%\Claude\claude_desktop_config.json (Windows)

3. MCP Tools and Resources

Tools:

  • search_threads - Search Gmail with queries like "from:email@example.com" or "subject:meeting" (includes draft info)
  • create_draft - Create email drafts or update existing drafts (AI will request style guide first)
  • extract_attachment_by_filename - Safely extract text from PDF, DOCX, and TXT attachments using filename
  • get_personal_email_style_guide - Get your email writing style guide (this is a temporary tool, created because most agents do not yet support fetching resources--once agents implement MCP resources better, then thsi tool can be removed)

Resources:

  • file://personal-email-style-guide - Your personal email writing style (auto-generated or manual)

Prompts:

  • /generate-email-tone - Analyze your sent emails to create personalized writing style
  • /server-status - Show file locations and server status

4. Personal Email Style Guide

The server will create a style-guide file based on the last 25 emails you've sent, so that newly drafted emails will hopefully sound like you. Honestly, so far LLM-written emails still don't sound very authentic.

Manual Generation:

  • Run /generate-email-tone prompt in your MCP client anytime to regenerate
  • The file is saved to your app data directory (see File Storage Locations above)

AI Integration:

  • AI always calls get_personal_email_style_guide tool before writing emails
  • Ensures consistent personal style across all communications
  • Resource also available at file://personal-email-style-guide

5. Alternative way to Setup Environment Variables

If you want to run this MCP server outside of an agent, you can create a .env file based on the .env.example file and supply the environment variables that way, or export them into your environment prior to running:

bash
export GMAIL_CLIENT_ID=your_client_id_here.apps.googleusercontent.com
export GMAIL_CLIENT_SECRET=your_client_secret_here
export OPENAI_API_KEY=your_openai_api_key_here

6. File Storage Locations

The server stores authentication and configuration files in standard application directories:

File Locations:

  • Windows: C:\Users\[YourUsername]\AppData\Roaming\auto-gmail\
  • Mac: ~/.auto-gmail/
  • Linux: ~/.auto-gmail/

Important Files:

  • token.json - OAuth authentication token (auto-generated)
  • personal-email-style-guide.md - Your email writing style guide (auto-generated or manual)

Quick Commands:

  • Use /server-status in your MCP client to see exact file paths
  • Delete token.json to force re-authentication with updated permissions

7. TODOs

  • Improve OAuth login flow - ✅ SOLVED! Use persistent HTTP mode (./gmail-mcp-server --http) to avoid OAuth popups. Server authenticates once and stays running.
  • Full HTTP MCP Transport - Waiting for mark3labs/mcp-go to expose complete HTTP transport APIs
  • Better Email Authenticity - LLM-written emails still don't sound perfectly authentic despite style guides

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "paulfidika-gmail-mcp-server": {
      "command": "",
      "args": []
    }
  }
}

Gmail MCP 服务器 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal Gmail MCP 服务器 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dir kënnt MCP lokal op Ärem Apparat ausféieren oder Iech mat enger Remote-MCP-Server-URL verbannen.

Optioun 1: De lokale Connector benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

Gmail MCP 服务器 als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu Gmail MCP 服务器 an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "paulfidika-gmail-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "gmail-mcp-server"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu Gmail MCP 服务器. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu Gmail MCP 服务器.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat Gmail MCP 服务器?
Gmail MCP 服务器
Jo. Ech hunn et gelies.
Dat hunn ech mat Gmail MCP 服务器 fonnt.

Optioun 2: Eng MCP-Server-URL derbäisetzen

Benotzt dës Optioun, wann Gmail MCP 服务器 scho remote gehost gëtt oder Är Ekipp ee gemeinsame Connector wëllt, op dee méi Benotzer kënnen zougräifen.

1

MCP-Connectoren opmaachen

Gitt an TypingMind op „Plugins“, maacht „MCP-Connectoren“ op a wielt dann „URL derbäisetzen“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Gitt op „Plugins“.
  3. Maacht „MCP-Connectoren“ op.
  4. Klickt op „URL derbäisetzen“.
TypingMind-Formulaire fir eng benotzerdefinéiert MCP-Server-URL derbäizesetzen
2

D'Server-URL apeschen

Gitt Är Server-URL am Feld „Server-URL“ an. Setzt e Verbindungsnumm, eng Beschreiwung, e Symbol, benotzerdefinéiert HTTP-Headeren oder OAuth-Clientastellungen derbäi, wann de Server se erfuerdert.

  1. Pescht Är Server-URL an d'Feld „Server-URL“.
  2. Gitt en Numm fir d'Verbindung mat Gmail MCP 服务器 an.
  3. Setzt eng Beschreiwung an e Symbol derbäi, fir d'Verbindung méi einfach erëmzeerkennen.
  4. Setzt benotzerdefinéiert HTTP-Headeren oder OAuth-Clientdetailer derbäi, wann de Server eng Authentifizéierung erfuerdert.
3

D'Verbindung erstellen

Klickt op „Verbindung erstellen“, gitt dann zeréck op d'Plugin-Lëscht a kontrolléiert, ob déi nei MCP-Verbindung aktiv ass.

  1. Klickt op „Verbindung erstellen“.
  2. Gitt zeréck op d'Lëscht vun de MCP-Connectoren.
  3. Kontrolléiert, ob d'Verbindung mat Gmail MCP 服务器 als aktiv ugewise gëtt.
  4. Aktualiséiert d'Plugin-Lëscht, wann d'Verbindung net direkt ugewise gëtt.
4

Modeller wiesselen ouni nei ze verbannen

Start e Chat mat Ärem bevorzugte Modell, aktivéiert d'Tools vu Gmail MCP 服务器 ënner „Plugins“ a wiesselt bei Bedarf op en anere Modell. D'MCP-Verbindung bleift am TypingMind-Aarbechtsberäich disponibel.

  1. Start en neie Chat an TypingMind.
  2. Wielt de KI-Modell, deen Dir benotze wëllt.
  3. Aktivéiert d'Tools vu Gmail MCP 服务器 ënner „Plugins“.
  4. Biet de Modell, den Tool ze benotzen, wann néideg.
  5. Wiesselt op en anere KI-Modell a benotzt déiselwecht MCP-Verbindung weider.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat Gmail MCP 服务器?
Gmail MCP 服务器
Jo. Ech hunn et gelies.
Dat hunn ech mat Gmail MCP 服务器 fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server Gmail MCP 服务器 benotzt?

Gmail MCP 服务器 ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech Gmail MCP 服务器 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir Gmail MCP 服务器 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat Gmail MCP 服务器 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann Gmail MCP 服务器 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech Gmail MCP 服务器 MCP mat TypingMind?

Dir kënnt Gmail MCP 服务器 iwwer de lokale MCP-Connector oder iwwer d'URL vun engem Remote-MCP-Server mat TypingMind verbannen. Benotzt de lokale Connector, wann de Server Zougrëff op Fichieren, Apps oder privat Ressourcen op Ärem Apparat brauch, an eng Server-URL, wann de MCP-Server op Distanz gehost gëtt.

Wéi eng Tools stellt Gmail MCP 服务器 MCP an TypingMind zur Verfügung?

Gmail MCP 服务器 stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir Gmail MCP 服务器 MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann Gmail MCP 服务器 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇