Gmail MCP 服务器 logo

Gmail MCP 服务器

Community
PaulFidika

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

PublisherPaulFidika
Repositorygmail-mcp-server
LanguageGo
Forks
13
Stars
22
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Gmail MCP 服务器 exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    22 stars and 13 forks from the linked 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

Installation

TypingMind
Prerequisites:

Node.js 18+

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

Use Gmail MCP 服务器 MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Gmail MCP 服务器 is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Gmail MCP 服务器 as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Gmail MCP 服务器 MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "paulfidika-gmail-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "gmail-mcp-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Gmail MCP 服务器 MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Gmail MCP 服务器 MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Gmail MCP 服务器 to help me with this task?
Gmail MCP 服务器
Sure. I read it.
Here is what I found using Gmail MCP 服务器.

Option 2: Add an MCP server URL

Use this when Gmail MCP 服务器 is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter your server URL in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste your server URL into the Server URL field.
  2. Enter a connection name for Gmail MCP 服务器.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the Gmail MCP 服务器 connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the Gmail MCP 服务器 tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the Gmail MCP 服务器 tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Gmail MCP 服务器 to help me with this task?
Gmail MCP 服务器
Sure. I read it.
Here is what I found using Gmail MCP 服务器.

Frequently asked questions

What is the Gmail MCP 服务器 MCP server used for?

Gmail MCP 服务器 is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Gmail MCP 服务器 MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Gmail MCP 服务器 with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Gmail MCP 服务器 MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Gmail MCP 服务器 connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Gmail MCP 服务器 MCP to TypingMind?

Gmail MCP 服务器 can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does Gmail MCP 服务器 MCP provide in TypingMind?

Gmail MCP 服务器 exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Gmail MCP 服务器 MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Gmail MCP 服务器 requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇