Gmail MCP server

Integrates with Gmail to enable reading, sending, trashing, and opening emails through OAuth 2.0 authentication for seamless email management workflows.
Back to servers
Provider
Sanchi Singh
Release date
Mar 23, 2025
Language
Python

This MCP server enables Gmail integration through Model Context Protocol, allowing you to manage emails directly through MCP clients like Claude Desktop. It provides seamless access to Gmail's core functionality including reading, sending, and managing emails.

Installation

Prerequisites

  • Python 3.12 or higher
  • Gmail API credentials
  • MCP client (like Claude Desktop)

Getting Started

  1. Clone the repository:
git clone https://github.com/yourusername/gmail-plugin.git
cd gmail-plugin
  1. Install dependencies (choose one method):
# Method 1: Install in editable mode
uv pip install -e .

# Method 2: Install using requirements.txt
uv pip install -r requirements.txt

# Method 3: Install using uv sync (recommended)
uv sync --dev --all-extras
  1. Configure Gmail API credentials:
    • Go to Google Cloud Console
    • Create a new project or select existing one
    • Enable Gmail API
    • Configure OAuth consent screen:
      • Select "External" user type (no publishing required)
      • Go to the Audiences tab: Add your email as a "Test user"
      • Add OAuth scope: https://www.googleapis.com/auth/gmail/modify
    • Create OAuth 2.0 credentials:
      • Choose "Desktop App" as application type
      • Download the JSON credentials file
    • Save the credentials file for later use

Configuration

Setting Up Your MCP Client

For Development/Unpublished Servers

Add this to your MCP client configuration:

"mcpServers": {
  "gmail-plugin": {
    "command": "uv",
    "args": [
      "--directory",
      "[absolute path to working directory]",
      "run",
      "server.py"
      "--creds-file-path",
      "[absolute-path-to-credentials-file]",
      "--token-path",
      "[absolute-path-to-access-tokens-file]"
    ]
  }
}

For Published Servers

"mcpServers": {
  "gmail-plugin": {
    "command": "uvx",
    "args": [
      "gmail-plugin"
    ]
  }
}

Usage

Available Tools

The Gmail plugin provides the following tools:

Tool Name Description Required Arguments
send-email Send an email recipient_id, subject, message
get-unread-emails Retrieve unread emails None
read-email Read email content email_id
trash-email Move email to trash email_id
mark-email-as-read Mark email as read email_id
open-email Open email in browser email_id

Available Prompts

You can use these predefined prompts with your MCP client:

Prompt Name Description Arguments
manage-email Act as email administrator None
draft-email Draft a new email content, recipient, recipient_email
edit-draft Edit existing email draft changes, current_draft

Debugging

If you encounter issues, you can use the MCP Inspector for debugging:

npx @modelcontextprotocol/inspector uv --directory [path-to-plugin] run gmail-plugin

Example Usage Scenarios

Sending an Email

  1. Connect to the Gmail plugin through your MCP client
  2. Use the send-email tool with the following arguments:
    • recipient_id: email address of the recipient
    • subject: subject line of the email
    • message: content of the email

Managing Unread Emails

  1. Connect to the Gmail plugin
  2. Use the get-unread-emails tool to retrieve a list of unread messages
  3. For each email, you can:
    • Read it using read-email
    • Mark it as read using mark-email-as-read
    • Move it to trash using trash-email
    • Open it in browser using open-email

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later