MCP Gmail Server
A server that uses model context protocol[https://modelcontextprotocol.io/] to read and create drafts of emails from Gmail.
Project setup
Create Oauth client and add secrets:
Create a Google Cloud Project
- Go to https://console.cloud.google.com/
- In the top-left, open the project dropdown and click New Project
- Give your project a name (e.g., Gmail API Demo)
- Click Create Your project is now created; make sure it’s selected in the project dropdown.
Enable the Gmail API
- Go to the API Library: https://console.cloud.google.com/apis/library
- Search for Gmail API
- Click it → Enable
Configure OAuth 2.0 Credentials
-
Navigate to: APIs & Services → Credentials
-
You’ll be prompted to configure the OAuth Consent Screen (if first time creating OAuth credentials)
-
Choose External if users outside your Google Workspace will use it
-
Fill in details
-
Add test users (email addresses allowed to authorize during development)
-
Save the configuration
-
Click Create Credentials → OAuth client ID
-
Choose the application type: Desktop app (for testing/dev)
-
Name it
-
Click Create
You will now receive:
- Client ID
- Client Secret Download them as JSON for use in your code.
Save the JSON as "client_secret_oauth_gcp.json" in the root of this project. (note this should be stored securely and not commited to github.)
Install and run app
Install uv: https://docs.astral.sh/uv/getting-started/installation/
Install dependencies with uv:
uv sync
Start server:
uv run -m src.mcp_server_gmail
Claude desktop
Install Claude Desktop
Set claude_desktop_config.json file to:
{
"mcpServers": {
"gmail": {
"command": "/Users/myname/Documents/Coding/fac-mcp-gmail-server/.venv/bin/python",
"args": [
"-m",
"mcp_server_gmail"
],
"env": {
"PYTHONPATH": "/Users/myname/Documents/Coding/fac-mcp-gmail-server/src"
},
"cwd": "/Users/myname/Documents/Coding/fac-mcp-gmail-server"
}
}
}
Ensuring the directory paths are replaced appropriately with your local directory paths.
Test (manual)
Go to claude desktop
Try the following: "Get last 3 unread emails" "Create draft emails for these"
See /docs/working_examples, for examples screenshots of the mcp server
Features
- Gmail Oauth set up
- MCP server for read and drafting emails on gmail
