Skip to main content
Glama

Gmail MCP Server

by jStrider

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

Related MCP server: Google Tasks MCP Server

šŸ“‹ 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

-
security - not tested
-
license - not tested
-
quality - not tested

Latest Blog Posts

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