This MCP server provides access to Gmail functionality through the Model Context Protocol, allowing LLMs like Claude to interact with your email.
Install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Set up Google API credentials:
credentials.json
in the project rootCreate a .env
file by copying the example:
cp .env.example .env
Run the server:
credentials.json:
{
"installed": {
"client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
"project_id": "your-project-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "YOUR_CLIENT_SECRET",
"redirect_uris": ["http://localhost"]
}
}
credentials.json.example
as a referencetoken.json:
{
"token": "ya29.a0AfB_byC...",
"refresh_token": "1//0eXxYz...",
"token_uri": "https://oauth2.googleapis.com/token",
"client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
"client_secret": "YOUR_CLIENT_SECRET",
"scopes": [
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.send",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.modify"
],
"expiry": "2025-03-05T14:30:00.000Z"
}
When you run the server for the first time:
token.json
filetoken.json
For subsequent runs:
token.json
filetoken.json
credentials.json
and token.json
files secure.gitignore
file is configured to exclude these filesRun the server:
source venv/bin/activate # On Windows: venv\Scripts\activate
python -m src.server
Configure Claude Desktop to use this server by adding it to your claude_desktop_config.json
:
{
"mcpServers": {
"gmail": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/gmail-mcp-server"
}
}
}
This project follows a lean, efficient design philosophy:
If you encounter authentication issues:
credentials.json
file is correctly placed in the project roottoken.json
file if it exists to force re-authenticationThe Gmail API has rate limits that may affect usage:
{
"mcpServers": {
"gmail": {
"env": {},
"args": [
"-m",
"src.server"
],
"command": "python"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.