gmail-mcp-server
Web Tools
Description
Gmail Server for Model Context Protocol (MCP) integrates with Gmail to enable sending, removing, reading, drafting, and responding to emails.
Author
MCP-Mirror
Created Date
2024-12-01
Tutorial
Learn how to use this MCP server
Step-by-Step Guide to Set Up Gmail Server for MCP
Step 1: Gmail API Setup
- Create a new Google Cloud project
- Enable the Gmail API
- Configure an OAuth consent screen
- Select "external". However, we will not publish the app.
- Add your personal email address as a "Test user".
- Add OAuth scope
https://www.googleapis.com/auth/gmail/modify
- Create an OAuth Client ID for application type "Desktop App"
- Download the JSON file of your client's OAuth keys
- Rename the key file and save it to your local machine in a secure location. Take note of the location.
- The absolute path to this file will be passed as parameter
--creds-file-path
when the server is started.
- The absolute path to this file will be passed as parameter
Step 2: Authentication
When the server is started, an authentication flow will be launched in your system browser.
Token credentials will be subsequently saved (and later retrieved) in the absolute file path passed to parameter --token-path
.
For example, you may use a dot directory in your home folder, replacing [your-home-folder]
:
| Parameter | Example |
|-----------------|--------------------------------------------------|
| --creds-file-path
| /[your-home-folder]/.google/client_creds.json
|
| --token-path
| /[your-home-folder]/.google/app_tokens.json
|
Step 3: Usage with Desktop App
Using uv is recommended.
To integrate this server with Claude Desktop as the MCP Client, add the following to your app's server configuration. By default, this is stored as ~/Library/Application\ Support/Claude/claude_desktop_config.json
.
{ "mcpServers": { "gdrive": { "command": "uv", "args": [ "--directory", "[absolute-path-to-git-repo]", "run", "gmail", "--creds-file-path", "[absolute-path-to-credentials-file]", "--token-path", "[absolute-path-to-access-tokens-file]" ] } } }
The following parameters must be set
| Parameter | Example |
|-----------------|--------------------------------------------------|
| --directory
| Absolute path to gmail
directory containing server |
| --creds-file-path
| Absolute path to credentials file created in Gmail API Setup. |
| --token-path
| Absolute path to store and retrieve access and refresh tokens for application. |
Step 4: Troubleshooting with MCP Inspector
To test the server, use MCP Inspector. From the git repo, run the below changing the parameter arguments accordingly.
bash npx @modelcontextprotocol/inspector uv run [absolute-path-to-git-repo]/src/gmail/server.py --creds-file-path [absolute-path-to-credentials-file] --token-path [absolute-path-to-access-tokens-file]