Send and Manage Gmail Communications
Gmail MCP Server sends, receives, and replies to Gmail messages with Service Account, OAuth 2.0, or ADC authentication.
release_0_1_1Add to Favorites
Why it matters
Automate your email operations by integrating with Gmail. This asset allows for sending, receiving, and managing emails programmatically, streamlining communication workflows.
Outcomes
What it gets done
Send emails to specified recipients.
Retrieve and list emails with search filters.
Reply to existing email threads.
Process today's messages for real-time updates.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Capabilities
Tools your agent gets
List unread messages with query filters and search capabilities
Send emails to recipients with subject and message text
Retrieve today's messages with configurable result limits
Reply to specific messages using message ID
Overview
Gmail MCP Server
Gmail MCP Server gives applications and LLMs a standardized interface for sending, receiving, and replying to Gmail messages, with multiple authentication methods. Use it when an application or LLM needs automated Gmail sending, receiving, or reply handling with configurable authentication.
What it does
Gmail MCP Server is an MCP implementation of a Gmail service, giving applications and LLMs a standardized interface for sending, receiving, and managing email through Gmail's API instead of writing Gmail API boilerplate themselves. It also handles Gmail authentication complexity through multiple supported methods, and supports flexible, environment-variable-based configuration so the same integration can be deployed across development, staging, and production without code changes. As an MCP-compliant service, it aims for consistent behavior and integration with other MCP-compliant services, since the Model Context Protocol provides a standardized way to handle context and state management across different services.
When to use - and when NOT to
Use it when an application or LLM needs automated Gmail handling: sending messages, listing and searching messages, replying to existing threads, pulling today's messages, or maintaining an email communication log, with configuration driven by environment variables across development, staging, and production. It supports Service Account, OAuth 2.0, and Application Default Credentials, so pick whichever fits your deployment's existing Google Cloud identity setup. It is Gmail-specific, built on the Model Context Protocol for consistent behavior with other MCP-compliant services, not a general email-provider abstraction.
Capabilities
- list_message(query, max_results): list messages with Gmail search syntax, for example is:unread
- send_message(to, subject, message_text): send an email
- reply_to_message(message_id, reply_text): reply to an existing message
- get_todays_messages(max_results): retrieve today's messages
- Multiple authentication methods: Service Account via GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_CREDENTIALS_CONFIG, OAuth 2.0 via credentials.json and token.json, and Application Default Credentials
- Environment-based configuration suited to different deployment environments
How to install
Install via pip:
pip install mcp-google-email
Then initialize and use it in Python:
from src.server import FastMCP
gmail_service = FastMCP("GMail")
messages = gmail_service.list_message(query='is:unread', max_results=10)
gmail_service.send_message(
to='recipient@example.com',
subject='Test Email',
message_text='Hello, this is a test email'
)
It requires Python 3.11+ along with google-api-python-client>=2.0.0, google-auth-httplib2>=0.1.0, google-auth-oauthlib>=0.4.6, mcp>=1.0.0, pydantic>=1.8.0, and python-dotenv>=0.19.0. For development, clone the repository, create and activate a virtual environment, and install the remaining dependencies from requirements.txt:
git clone https://github.com/yourusername/mcp-google-email.git
cd mcp-google-email
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Who it's for
Developers building applications or LLM-driven tools that need standardized, authenticated Gmail sending, receiving, and reply handling, without writing raw Gmail API integration code themselves. The project calls out several concrete fits: applications requiring automated email handling, systems integrating Gmail functionality, projects that need a standardized way to interact with Gmail, services maintaining email communication logs, applications doing real-time email processing, and LLM applications that need email context management. It is released under the MIT License.
Source README
MCP Google Email Service
A Gmail service implementation using MCP (Model Context Protocol) that provides functionality for sending, receiving, and managing emails through Gmail's API.
Motivation and Context
The MCP Google Email Service was developed to address several key needs in modern application development:
Standardized Email Integration: Provides a consistent interface for Gmail integration across different applications, eliminating the need to write boilerplate code for Gmail API interactions.
Simplified Authentication: Handles the complexity of Gmail API authentication through multiple methods (Service Account, OAuth 2.0, and Application Default Credentials), making it easier to integrate Gmail functionality into applications.
Environment-Based Configuration: Supports flexible configuration through environment variables, making it suitable for various deployment scenarios (development, staging, production).
Model Context Protocol (MCP) Integration: Implements the Model Context Protocol, ensuring consistent behavior and integration with other MCP-compliant services. MCP provides a standardized way to handle context and state management across different services.
This service is particularly useful for:
- Applications requiring automated email handling
- Systems needing to integrate Gmail functionality
- Projects requiring a standardized way to interact with Gmail
- Services that need to maintain email communication logs
- Applications requiring real-time email processing
- LLM applications needing email context management
Features
- Email sending and receiving
- Message listing with search capabilities
- Reply to existing messages
- Today's message retrieval
- Multiple authentication methods support
- Environment-based configuration
Installation
pip install mcp-google-email
Usage
from src.server import FastMCP
# Initialize the Gmail service
gmail_service = FastMCP("GMail")
# List unread messages
messages = gmail_service.list_message(query='is:unread', max_results=10)
# Send an email
gmail_service.send_message(
to='recipient@example.com',
subject='Test Email',
message_text='Hello, this is a test email'
)
# Get today's messages
todays_messages = gmail_service.get_todays_messages(max_results=20)
# Reply to a message
gmail_service.reply_to_message(
message_id='message_id_here',
reply_text='Thank you for your email'
)
Authentication
The package supports multiple authentication methods:
- Service Account (via GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_CREDENTIALS_CONFIG)
- OAuth 2.0 (via credentials.json and token.json)
- Application Default Credentials (ADC)
Environment Variables
The following environment variables can be used to configure the service:
GOOGLE_APPLICATION_CREDENTIALS: Path to your service account credentials JSON fileGOOGLE_CREDENTIALS_CONFIG: JSON string containing service account credentials
Requirements
- Python 3.11+
- google-api-python-client>=2.0.0
- google-auth-httplib2>=0.1.0
- google-auth-oauthlib>=0.4.6
- mcp>=1.0.0
- pydantic>=1.8.0
- python-dotenv>=0.19.0
Development
To set up the development environment:
- Clone the repository:
git clone https://github.com/yourusername/mcp-google-email.git
cd mcp-google-email
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.