Sponsored by Deepsite.site

Gmail Sender MCP Server

Created By
abhishekloiwal8 months ago
An MCP server for sending Gmail emails via Claude or other AI assistants
Content

Gmail Sender MCP Server

A Model Context Protocol (MCP) server that enables Claude and other AI assistants to send emails via Gmail API. This focused version only provides email sending capabilities.

Overview

This project creates an MCP server that allows AI assistants to:

  • Send new emails
  • Reply to existing emails

It's designed to be lightweight and easy to set up, using the Gmail API for email operations.

Prerequisites

  • Python 3.8 or higher
  • A Google Cloud account with Gmail API enabled
  • Docker (optional, for containerized deployment)

Setup Instructions

1. Create a Google Cloud Project and Enable the Gmail API

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. In the sidebar, navigate to "APIs & Services" > "Library"
  4. Search for "Gmail API" and enable it
  5. Go to "APIs & Services" > "Credentials"
  6. Click "Create Credentials" and select "OAuth client ID"
  7. For application type, choose "Desktop app"
  8. Name your OAuth client
  9. Click "Create"
  10. Download the credentials JSON file

2. Prepare Your Environment

Clone this repository:

git clone https://github.com/abhishekloiwal/gmail-sender-mcp.git
cd gmail-sender-mcp

Install dependencies:

pip install -r requirements.txt

3. Set Up Your Credentials

  1. Rename the downloaded credentials file to credentials.json and place it in the project root directory
  2. Run the helper script to get a refresh token:
python get_refresh_token.py
  1. Follow the authentication flow in your browser
  2. Copy the refresh token that appears in the terminal
  3. Create a .env file based on the example:
cp .env.example .env
  1. Edit the .env file and fill in your credentials:
GMAIL_CLIENT_ID=your-client-id.apps.googleusercontent.com
GMAIL_CLIENT_SECRET=your-client-secret
GMAIL_REFRESH_TOKEN=your-refresh-token
GMAIL_USER_EMAIL=your-email@gmail.com

4. Run the MCP Server

python gmail_sender.py

The server will start and listen for connections.

Docker Deployment

You can also run the server in a Docker container:

Build and Run with Docker

docker build -t gmail-sender-mcp .
docker run -d --name gmail-sender-mcp --env-file .env gmail-sender-mcp

Or Use Docker Compose

docker-compose up -d

Using with Claude or other AI Assistants

To use this MCP server with an AI assistant, you'll need to:

  1. Run the MCP server
  2. Connect your AI assistant to the MCP server (specific steps depend on your AI platform)

The MCP server provides the following tools:

send_email Tool

Sends a new email.

Parameters:

  • to: Recipient email address
  • subject: Email subject line
  • body: Email body content (HTML formatting supported)

reply_to_email Tool

Replies to an existing email.

Parameters:

  • email_id: ID of the email to reply to
  • body: Reply content (HTML formatting supported)

Security Considerations

  • Keep your .env file secure and never commit it to version control
  • The refresh token grants access to send emails from your account, so treat it like a password
  • Consider using a dedicated Google account for this integration if you're concerned about security

Troubleshooting

Common issues:

  • Authentication errors: Make sure your credentials in the .env file are correct
  • Permission errors: Verify that you've enabled the Gmail API in your Google Cloud project
  • Token expired: If your refresh token stops working, generate a new one using the helper script

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
WindsurfThe new purpose-built IDE to harness magic
ChatWiseThe second fastest AI chatbot™
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Playwright McpPlaywright MCP server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Amap Maps高德地图官方 MCP Server