Gmail MCP Server
š§ 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
Clone the repository
git clone https://github.com/your-username/mcp-practice.git
cd mcp-practiceCreate a virtual environment
python -m venv .venvActivate the environment
Windows
.venv\Scripts\activateLinux/macOS
source .venv/bin/activateInstall dependencies
pip install -r requirements.txtš Configure Environment Variables
Create a .env file and add:
GOOGLE_CLIENT_SECRET_PATH=client_secret.json
GOOGLE_TOKEN_PATH=token.jsonā¶ļø Authenticate Gmail
python oauth.pyThis will open a browser for Google authentication and generate token.json.
ā¶ļø Run the MCP Server
python main.pyor
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sejalpatole/Gmail-MCP-Server-using-FastMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server