Gmail MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gmail MCP Serverread my last 3 emails"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π§ 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
Related MCP server: Gmail MCP Server
π οΈ 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.
This server cannot be deployed
Maintenance
Related MCP Connectors
Email infrastructure for AI agents β send, receive, search, and reply to email over MCP.
A MCP server for Gmail that lets you search, read, and draft emails and replies.
Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organizβ¦
Permissioned access to Gmail, Drive and Calendar via the user's own Google account
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that integrates with Gmail to enable sending, reading, and managing emails through tools like send-email, trash-email, get-unread-emails, and read-email.72GPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Gmail through the MCP protocol, supporting sending, reading, searching, replying, forwarding, managing drafts and labels, and saving attachments.5 npm3MIT
- AlicenseNot gradedqualityDmaintenanceEnables Gmail operations such as reading, sending, searching, and managing emails, threads, labels, and drafts via MCP tools.1MIT
- AlicenseNot gradedqualityFmaintenanceEnables AI agents and Telegram bots to read and send Gmail messages via MCP with OAuth authentication.27 npmMIT