Gmail MCP server

Integrates with Gmail to enable email search, retrieval, and interaction for natural language-driven email management and analysis tasks.
Back to servers
Provider
Vinayak Mehta
Release date
Mar 04, 2025
Language
Python
Package
Stats
2.1K downloads
4 stars

The Gmail MCP server enables Claude to access and search your Gmail inbox, allowing it to retrieve your email content when needed. This integration connects Claude with your Gmail account through Google's secure API protocols.

Installation and Setup

Get Google API Credentials

  1. Visit the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Gmail API for your project:
    • Navigate to "APIs & Services" > "Library"
    • Search for "Gmail API" and enable it
  4. Create OAuth credentials:
    • Go to "APIs & Services" > "Credentials"
    • Click "Create Credentials" > "OAuth client ID"
    • Select "Desktop application" as the application type
    • Name your client and click "Create"
  5. Download the credentials JSON file
  6. Save it as credentials.json in your project directory

Authorize the Application

Run the authorization command to generate your authentication token:

uv run gmail-mcp auth --creds-path credentials.json --token-path token.json

This opens a browser window where you'll need to log in to your Google account and grant the necessary permissions. After successful authorization, a token.json file will be created in your project directory.

Configuration with Claude

Add the Gmail MCP server to your Claude configuration file:

{
  "mcpServers": {
    "gmail": {
      "args": [
        "--from",
        "git+https://github.com/vinayak-mehta/gmail-mcp",
        "gmail-mcp"
      ],
      "command": "/Users/username/.local/bin/uvx",
      "env": {
        "GMAIL_CREDS_PATH": "/Users/username/path/to/gmail-mcp/credentials.json",
        "GMAIL_TOKEN_PATH": "/Users/username/path/to/gmail-mcp/token.json"
      }
    }
  }
}

Important: Be sure to:

  • Replace /Users/username/path/to/gmail-mcp with your actual project path
  • Adjust the command path to your installed uvx executable location
  • Provide correct absolute paths to your credentials.json and token.json files

Using Gmail with Claude

After configuration, Claude gains access to these Gmail tools:

Search Emails

Find specific emails in your Gmail account.

Example prompt: "Search for all emails from [email protected]"

Get Email Content

Retrieve the full content of a specific email.

Example prompt: "Show me the full content of the email with the subject 'Meeting Tomorrow'"

List Messages

View recent messages from your Gmail inbox.

Example prompt: "List my 5 most recent emails"

Environment Variables

You can configure credential paths using environment variables:

  • GMAIL_CREDS_PATH: Path to your credentials.json file
  • GMAIL_TOKEN_PATH: Path to your token.json file

For convenience, create a .env file in the project root with these variables.

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