A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) implementation for the [Gmail](https://developers.google.com/gmail/api) API, providing a standardized interface for email management, sending, and retrieval.
Features
Complete Gmail API coverage including messages, threads, labels, drafts, and settings
Support for sending, drafting, and managing emails
Label management with customizable colors and visibility settings
Thread operations for conversation management
Settings management including vacation responder, IMAP/POP, and language settings
History tracking for mailbox changes
Secure OAuth2 authentication using your Google Cloud credentials
Installation
<strong>NOTE:</strong> Due to the large number of endpoints available on this server, it is recommended that you install and setup [Heimdall](https://github.com/shinzo-labs/heimdall) to limit the number of endpoints exposed to your client applications.
To use this MCP, you'll need to set up authentication with Gmail:
Go to the [Google Cloud Console](https://console.cloud.google.com)
Create a new project or select an existing one
Enable the Gmail API for your project
Go to Credentials and create an OAuth 2.0 Client ID
- Choose "Desktop app" as the application type (*Warning*: if you don't choose this type the server will not be able to parse the keys from your JSON file)
- Download the client credentials JSON file
Save the downloaded credentials file to `~/.gmail-mcp/gcp-oauth.keys.json`
NPX (Recommended)
Add the following to your MCP client `config.json` (`~/.heimdall/config.json` if using Heimdall):
Manual Download
Download the repo:
Install packages and build (inside cloned repo):
Add the following to your MCP client `config.json` (`~/.heimdall/config.json` if using Heimdall):
Smithery
To install for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@shinzo-labs/gmail-mcp):
Authentication
Automated (recommended)
This MCP provides an automated authentication flow:
First, acquire OAuth credentials and download the JSON file.
Rename the JSON file to `gcp-oauth.keys.json` and copy it to `$HOME/.gmail-mcp/`, or wherever you've set it in `MCP_CONFIG_DIR`.
Run the authentication command:
A browser window will automatically open to the Google OAuth consent screen
After granting access, you can close the browser window
The tokens will be automatically saved to `$HOME/.gmail-mcp/credentials.json`
The MCP will automatically:
Manage token refresh
Save credentials to disk
Handle the OAuth callback
Open the authentication URL in your default browser
Note: by default this server uses port `3000` to listen for the OAuth response. You can set `AUTH_SERVER_PORT` to something else if you are running another service on `3000`.
You can customize the config location by setting `MCP_CONFIG_DIR` before running the command (optional):
Manual (suggested for Docker usage)
If you wish, you may also provide credentials directly through the environment variables:
Supported Endpoints
User Management
`get_profile`: Get the current user's Gmail profile