Skip to main content
Glama

Gmail MCP Server

by jStrider
MIT License

MCP Gmail Server

A Model Context Protocol (MCP) server for integrating Gmail with Claude and other MCP-compatible AI assistants.

🚀 Features

  • List emails: Retrieve emails from your inbox
  • Send emails: Compose and send emails
  • Email management: Delete, archive, mark as read
  • Batch operations: Process multiple emails in a single operation
  • Label management: List and move emails to specific labels

📋 Prerequisites

  • Node.js 18 or higher
  • A Google account with Gmail API enabled
  • OAuth2 credentials (Client ID, Client Secret)

🔧 Installation

  1. Clone the repository:
git clone https://github.com/jStrider/gmail-mcp.git cd gmail-mcp
  1. Install dependencies:
npm install
  1. Configure your OAuth2 credentials (see Configuration section)

⚙️ Configuration

Step 1: Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Gmail API for your project
  4. Go to "Credentials" and create an OAuth2 Client ID
  5. Application type: "Desktop app"
  6. Important: Add http://localhost:3000 to the authorized redirect URIs

Step 2: Get the Refresh Token

Run the authentication script:

npm run get-token

Follow the on-screen instructions to:

  1. Enter your Client ID
  2. Enter your Client Secret
  3. Authorize access in your browser
  4. Retrieve your Refresh Token

Step 3: Configure Environment Variables

Create a .env file at the project root:

GMAIL_CLIENT_ID=your_client_id GMAIL_CLIENT_SECRET=your_client_secret GMAIL_REFRESH_TOKEN=your_refresh_token

🎯 Usage with Claude Desktop

  1. Add the server to your Claude Desktop configuration (claude_desktop_config.json):
{ "mcpServers": { "gmail": { "command": "node", "args": ["/path/to/gmail-mcp/build/src/index.js"], "env": { "GMAIL_CLIENT_ID": "your_client_id", "GMAIL_CLIENT_SECRET": "your_client_secret", "GMAIL_REFRESH_TOKEN": "your_refresh_token" } } } }
  1. Restart Claude Desktop

📚 Available Tools

list_emails

List emails from inbox

  • maxResults: Maximum number of emails (default: 10)
  • query: Gmail search query (optional)

send_email

Send an email

  • to: Recipient email address
  • subject: Email subject
  • body: Email body

delete_email

Delete an email

  • id: Email ID

archive_email

Archive an email

  • id: Email ID

mark_as_read

Mark an email as read

  • id: Email ID

Batch Operations

  • delete_emails_batch: Delete multiple emails
  • archive_emails_batch: Archive multiple emails
  • mark_as_read_batch: Mark multiple emails as read

Label Management

  • list_labels: List all available labels
  • move_to_label: Move an email to a label
  • move_to_label_batch: Move multiple emails to a label

🛠️ Useful Scripts

# Build the project npm run build # Build in watch mode npm run watch # Get a new refresh token npm run get-token # Clean and rebuild npm run rebuild # Inspect the MCP server npm run inspector

📁 Project Structure

mcp-gmail/ ├── src/ # TypeScript source code │ └── index.ts # MCP server entry point ├── scripts/ # Utility scripts │ └── get-refresh-token.ts ├── build/ # Compiled JavaScript code ├── .env # Environment variables (ignored by git) ├── .env.example # Configuration example ├── package.json # npm configuration ├── tsconfig.json # TypeScript configuration └── README.md # This file

🔒 Security

  • Never share your OAuth2 credentials
  • The .env file is automatically ignored by Git
  • Use minimal permissions for the Gmail API

📝 License

MIT - See the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Feel free to open an issue or pull request.

🐛 Troubleshooting

If you encounter issues:

  1. Verify that the Gmail API is enabled in your Google Cloud project
  2. Ensure redirect URIs include http://localhost:3000
  3. Check that your refresh token is valid

📧 Contact

Julien Renaud - GitHub

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    Model Context Protocol server for Gmail integration. This allows Claude Desktop (or any MCP client) to interact with your Gmail account through Google Apps Script.
    Last updated -
    3
    552
    11
    JavaScript
    MIT License
    • Apple
  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol server that bridges Claude with Google Tasks, allowing users to manage task lists and tasks directly through Claude interface.
    Last updated -
    15
    15
    TypeScript
    MIT License
    • Apple
  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol server that provides a seamless email management interface through Claude, allowing users to search, read, and send emails directly through natural language conversations.
    Last updated -
    4
    90
    Python
    MIT License
    • Apple
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that enables AI assistants like Claude to interact with Gmail through natural language, providing comprehensive email management capabilities including sending, reading, organizing, searching, and managing drafts and labels.
    Last updated -
    4
    Python
    GPL 3.0
    • Apple

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jStrider/gmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server