Skip to main content
Glama
Gmail MCP Server

Gmail MCP Server

by saidulalam01

Gmail MCP Server

Let your AI assistant manage your Gmail — search, read, send, label, archive, and more through natural conversation.

Works with Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP-compatible app.

Python License MCP Tests


Setup

1. Clone & Install

git clone https://github.com/saidulalam01/gmail-mcp-server.git
cd gmail-mcp-server
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -r requirements.txt

No git? Click the green Code button on GitHub → Download ZIP.

2. Get Google Credentials

  1. Go to console.cloud.google.com and create a project

  2. Go to APIs & Services → Library → search Gmail API → Enable

  3. Go to APIs & Services → OAuth consent screen → choose External → fill in app name and your email → Save and Continue

  4. On the Scopes page, add these three then save:

    https://www.googleapis.com/auth/gmail.modify
    https://www.googleapis.com/auth/gmail.compose
    https://www.googleapis.com/auth/gmail.labels
  5. On the Test users page, add your Gmail address → save

  6. Go to APIs & Services → Credentials → + Create Credentials → OAuth client ID → type: Desktop app → Create

  7. Download the JSON file and move it into the project folder

3. Authenticate

python gmail_mcp_server.py --auth

Your browser opens for Google sign-in. If you see "This app isn't verified", click Advanced → Go to Gmail MCP Server (unsafe) — this is normal for personal projects.

4. Connect to Your AI App

Get your paths first:

echo "$(pwd)/.venv/bin/python $(pwd)/gmail_mcp_server.py"

Then add to your app's config:

{
  "mcpServers": {
    "gmail": {
      "command": "/Users/yourname/gmail-mcp-server/.venv/bin/python",
      "args": ["/Users/yourname/gmail-mcp-server/gmail_mcp_server.py"]
    }
  }
}
{
  "mcpServers": {
    "gmail": {
      "command": "/Users/yourname/gmail-mcp-server/.venv/bin/python",
      "args": ["/Users/yourname/gmail-mcp-server/gmail_mcp_server.py"]
    }
  }
}

Windows config path: %APPDATA%\Claude\claude_desktop_config.json

Point your MCP client to the server as a stdio process using the two paths from above.

Use full absolute paths — relative paths won't work because the AI app launches the server from its own directory.

5. Try It

  • "Show me my unread emails"

  • "Read the latest email from Sarah"

  • "Draft a reply saying I'll be there at 3pm"

  • "Archive all emails from noreply"


Related MCP server: Gmail AutoAuth MCP Server

Available Tools

Tool

What It Does

search_emails

Search with Gmail syntax (from:, is:unread, newer_than:2d, etc.)

read_email

Read full email content

list_labels

List all labels

create_label

Create a new label

apply_label

Add a label to an email

remove_label

Remove a label

archive_email

Archive an email

move_email

Move between folders

mark_as_read

Mark as read

mark_as_unread

Mark as unread

draft_reply

Draft a threaded reply

send_email

Send a new email (CC/BCC supported)

send_draft

Send an existing draft

You don't call these directly — just describe what you want and the AI picks the right tool.


Troubleshooting

Token expires every 7 days — Your Google app is in "Testing" mode. Just re-run python gmail_mcp_server.py --auth. To fix permanently: switch to "Internal" in Google Cloud (requires Workspace), or publish the app.

"Access blocked" during auth — Add your email as a test user: Google Cloud → OAuth consent screen → Test users.

"invalid_grant" or "token revoked" — Delete token.json and re-run python gmail_mcp_server.py --auth.

AI app can't find the server — Make sure you're using full absolute paths in the config, not relative.


Security

  • token.json and credentials are git-ignored — never committed

  • The server runs locally over stdio — no ports opened, no network exposure

  • The server cannot permanently delete emails — only archive, label, and send

  • To revoke access: Google Account Permissions → remove the app


Contributing

See CONTRIBUTING.md. Run tests with pip install -e ".[dev]" && pytest.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to manage Gmail through natural language interactions, including sending, reading, searching emails, and managing labels with auto authentication support.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to manage Gmail through natural language, including sending, reading, searching, labeling emails, managing attachments, and performing thread operations.
      3
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI assistants to review unread emails and perform email management operations like delete, archive, and label through Gmail integration.
      7
      Apache 2.0