Gmail MCP Server
by sejalpatole
README.md
# š§ Gmail MCP Server using FastMCP
A Model Context Protocol (MCP) server built with FastMCP that integrates with the Gmail API. This project demonstrates how to create AI-accessible tools for reading and sending emails using Google OAuth authentication.
## š Features
- š Google OAuth 2.0 authentication
- š© Send emails through Gmail
- š„ Read Gmail messages
- š ļø MCP tools using FastMCP
- ā” Lightweight Python implementation
- š Secure credential management using environment variables
## š ļø Tech Stack
- Python 3.13
- FastMCP
- Gmail API
- Google OAuth 2.0
- Uvicorn
- python-dotenv
## š Project Structure
```
.
āāā main.py
āāā oauth.py
āāā tools/
ā āāā gmail.py
ā āāā __init__.py
āāā .env
āāā requirements.txt
āāā README.md
```
## āļø Installation
1. Clone the repository
```bash
git clone https://github.com/your-username/mcp-practice.git
cd mcp-practice
```
2. Create a virtual environment
```bash
python -m venv .venv
```
3. Activate the environment
Windows
```bash
.venv\Scripts\activate
```
Linux/macOS
```bash
source .venv/bin/activate
```
4. Install dependencies
```bash
pip install -r requirements.txt
```
## š Configure Environment Variables
Create a `.env` file and add:
```env
GOOGLE_CLIENT_SECRET_PATH=client_secret.json
GOOGLE_TOKEN_PATH=token.json
```
## ā¶ļø Authenticate Gmail
```bash
python oauth.py
```
This will open a browser for Google authentication and generate `token.json`.
## ā¶ļø Run the MCP Server
```bash
python main.py
```
or
```bash
uv run fastmcp dev main.py:mcp
```
## š Learning Objectives
This project was created to practice:
- Model Context Protocol (MCP)
- FastMCP framework
- Tool decorators
- Prompt decorators
- Google OAuth
- Gmail API integration
- AI tool development
## š Future Improvements
- Email search
- Delete emails
- Mark emails as read/unread
- Attachment support
- Async MCP tools
- Better error handling
## š¤ Contributing
Contributions and suggestions are welcome.
## š License
This project is for educational and learning purposes.This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessSyncing