The Enhanced Gmail MCP Server provides a comprehensive integration with Gmail, allowing AI assistants like Claude to manage emails through natural language. This implementation enables everything from sending and reading emails to managing labels, drafts, folders, and advanced search capabilities.
Before you begin, ensure you have:
# Clone the repository
git clone https://github.com/theposch/gmail-mcp.git
cd gmail-mcp
# Set up a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the package
pip install -e .
Create a new project at the Google Cloud Console.
Navigate to the API Library and enable the Gmail API for your project.
Set up the OAuth consent screen:
https://www.googleapis.com/auth/gmail/modify
Generate OAuth 2.0 credentials:
Store your credentials in a secure location:
# Create a directory for credentials
mkdir -p ~/.gmail-mcp
# Move your downloaded credentials file
mv ~/Downloads/client_secret_*.json ~/.gmail-mcp/credentials.json
Add the MCP server configuration to your Claude Desktop config file (typically at ~/Library/Application Support/Claude/claude_desktop_config.json
):
{
"mcpServers": {
"gmail": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/gmail-mcp",
"run",
"gmail",
"--creds-file-path",
"/absolute/path/to/credentials.json",
"--token-path",
"/absolute/path/to/tokens.json"
]
}
}
}
For testing and debugging purposes:
npx @modelcontextprotocol/inspector uv run /path/to/gmail-mcp/src/gmail/server.py --creds-file-path /path/to/credentials.json --token-path /path/to/tokens.json
Once connected, you can use natural language to interact with Gmail. Try these example prompts with Claude:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.