dang-hai/gmail-mcp-server
If you are the rightful owner of gmail-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Gmail Voice Messaging Server is a dual-interface server that integrates with the Gmail API to facilitate reading and sending messages through both a web interface and an MCP server.
Gmail Voice Messaging Server
A Flask server and MCP (Model Context Protocol) server that integrates with Gmail API to read and send messages using desktop authentication.
Setup
-
Install dependencies:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt -
Set up Google OAuth credentials:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API
- Create OAuth 2.0 credentials (Desktop application, not Web application)
- Copy
.env.exampleto.envand fill in your credentials
-
Authenticate with Gmail:
python desktop_auth.pyThis will open your browser for Gmail authentication and save credentials locally.
Usage Options
Option 1: Web Interface
-
Run the Flask server:
python run.py -
Use the web application:
- Visit http://localhost:5000
- Access Gmail features through the web interface
- Authentication happens automatically using saved credentials
Option 2: MCP Server
-
Run the MCP server:
python mcp_run.py -
Connect with MCP clients:
- The server provides Gmail tools via the Model Context Protocol
- Connect using any MCP-compatible client or framework
- Use the tools for reading and sending Gmail messages
Features
- Authentication: Desktop OAuth authentication (no web callback required)
- Gmail Operations: Read messages, send messages, search with filters
- Dual Interface: Both web UI and MCP server functionality
- Auto Refresh: Automatic credential refresh
- Search: Advanced Gmail search with filters (sender, subject, attachments, etc.)
Files
Core Components
desktop_auth.py- Standalone authentication scriptsrc/auth.py- Authentication module using InstalledAppFlowsrc/gmail_service.py- Gmail API operations
Web Interface
src/app.py- Flask web interfacerun.py- Flask server entry point
MCP Server
src/mcp_server.py- MCP server implementationmcp_run.py- MCP server entry pointmcp_config.json- MCP server configuration
Web API Endpoints
GET /- Home page with connection statusGET /messages- View recent messagesGET|POST /send- Send message form/handlerGET /logout- Disconnect Gmail account
MCP Tools
The MCP server provides these tools for AI assistants and clients:
get_gmail_messages
Retrieve Gmail messages with optional query filtering.
- Parameters:
query(string),max_results(integer) - Returns: List of message objects with id, subject, sender, date, body
send_gmail_message
Send a Gmail message.
- Parameters:
to(string),subject(string),body(string) - Returns: Message status and ID
get_gmail_auth_status
Check Gmail authentication status.
- Parameters: None
- Returns: Authentication status and expiry info
search_gmail_messages
Search Gmail messages with specific criteria.
- Parameters:
from_email,subject_contains,has_attachment,is_unread,newer_than,max_results - Returns: List of matching messages
Integration with Claude Desktop
To use this as an MCP server with Claude Desktop, add to your configuration:
{
"mcpServers": {
"gmail-voice-messaging": {
"command": "python",
"args": ["/path/to/voice-messaging/python-server/mcp_run.py"],
"env": {
"PYTHONPATH": "/path/to/voice-messaging/python-server"
}
}
}
}