Gmail MCP Server
by gkdivya
A Gmail integration with FastMCP (Model Control Protocol) that enables AI assistants to interact with Gmail through a set of tools and prompts. It provides a server-client architecture that allows AI assistants to perform Gmail operations using natural language requests.
Last updated: N/A
What is Gmail MCP Server?
This project provides a server-client architecture that allows AI assistants to perform Gmail operations such as sending emails, reading unread emails, viewing email content, moving emails to trash, opening emails in browser, and marking emails as read. It uses Google's OAuth 2.0 for authentication and the Gmail API for email operations, and includes an LLM-powered client that understands natural language requests.
How to use Gmail MCP Server?
- Install dependencies using
pip install -r requirements.txt
. 2. Set up Gmail API credentials in Google Cloud Console and placecredentials.json
in the project root. 3. Set up Gemini API key in Google AI Studio and add it to the.env
file. 4. Runpython gmail_server.py --creds credentials.json --token token.json
to start the server. 5. Usepython test_gmail_server.py
to interact with Gmail using natural language commands.
Key features of Gmail MCP Server
FastMCP Integration for Gmail operations
OAuth Authentication for secure Gmail API access
LLM Integration (Gemini) for natural language understanding
Natural Language Understanding to convert plain English requests into tool calls
Comprehensive Logging for debugging communication
Use cases of Gmail MCP Server
Automating email sending and management tasks
Integrating Gmail with AI assistants for hands-free email control
Creating custom email workflows based on natural language commands
Building conversational interfaces for interacting with Gmail
FAQ from Gmail MCP Server
What is FastMCP?
What is FastMCP?
FastMCP (Model Control Protocol) is a framework used to expose Gmail operations as tools.
What authentication files are required?
What authentication files are required?
The system requires credentials.json
, token.json
, and .env
.
How do I add support for new Gmail operations?
How do I add support for new Gmail operations?
Add the appropriate tool implementation in gmail_server.py
. The smart client will automatically discover and expose the new tools.
What LLM is used?
What LLM is used?
Gemini 1.5 Flash is used for natural language understanding.
How do I handle errors?
How do I handle errors?
The application has comprehensive logging, graceful handling of HTTP errors from the Gmail API, and fallback mechanisms when the LLM response isn't formatted as expected.