Cover image
Try Now
2025-03-29

使用FASTMCP构建的弹性MCP服务器,用于使用AI代理通过Gmail的SMTP服务器发送电子邮件。

3 years

Works with Finder

1

Github Watches

1

Github Forks

2

Github Stars

Gmail-mcp-server

A resilient MCP server built with fastMCP for sending emails through Gmail's SMTP server using AI agents. smithery badge

Gmail MCP Server

This repository contains a resilient MCP server implementation using fastMCP. The server is designed to send emails via Gmail's SMTP server and supports various methods for attaching files, including:

  • Direct File Path: Attach files that exist on the local filesystem.
  • URL-Based Attachments: Download files from a given URL and attach them.
  • Pre-Staged Attachments: Use attachments stored in a designated directory.

The server is built with resilience in mind, featuring an increased timeout and graceful shutdown handling.

Features

  • Gmail SMTP Integration: Sends emails using Gmail’s SMTP server with TLS. ( MAKE SURE YOU HAVE SETUP GMAIL SMTP ON YOUR ACCOUNT AND GENERATE APP password )
  • Multiple Attachment Methods:
    • Directly from a file path.
    • By downloading from a public URL.
    • Using pre-staged attachments stored locally.
  • Resilient Design: Increased timeout and signal handling for graceful shutdown.
  • Environment-Based Configuration: Securely manage your Gmail credentials using environment variables.

Requirements

  • Python 3.x
  • fastMCP (install via pip install mcp)
  • python-dotenv (install via pip install python-dotenv)
  • requests (install via pip install requests)

Setup

  1. Clone the Repository:

    git clone <remote-repository-URL>
    cd gmail-mcp-server
    
    
    

Set Up Environment Variables:

Create a .env file in the root directory and add your Gmail SMTP credentials:

SMTP_USERNAME=your.email@gmail.com SMTP_PASSWORD=your_app_password

Note: If you use 2-Step Verification on your Gmail account, you must generate and use an App Password.

OPEN CLAUDE > SETTINGS > MCP > Configure > OPEN claude_desktop_config.json > Paste the file with your path below { "mcpServers": { "gmail-mcp": { "command": "python", "args": ["PATH_TO_gmail_mcp.py"], "host": "127.0.0.1", "port": 5000, "timeout": 30000 } } }

(Optional) Prepare Attachment Directories:

For pre-staged attachments, create a directory named available_attachments in the root. The server will automatically create a temp_attachments directory when downloading files from URLs.

Running the Server: To start the MCP server, run:

python server.py

The server will start on 127.0.0.1:5000 and can be accessed by your MCP clients or agents.

### Installing via Smithery

To install Gmail MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@MaitreyaM/gmail-mcp-server):

```bash
npx -y @smithery/cli install @MaitreyaM/gmail-mcp-server --client claude

Usage Sending Emails

You can send emails using the send_email_tool with the following parameters:

recipient: Email address of the recipient. subject: Email subject. body: Email body text. attachment_path (optional): Direct file path to the attachment. attachment_url (optional): Public URL from which to download the attachment. attachment_name (optional): Filename to use for the attachment (required when using URL-based or pre-staged attachments). Example Scenarios:

Direct File Attachment:

json Copy { "recipient": "friend@example.com", "subject": "Hello with attachment", "body": "Please see the attached document.", "attachment_path": "C:\path\to\document.pdf" }

URL-Based Attachment:

json Copy { "recipient": "friend@example.com", "subject": "Hello with attachment", "body": "Please see the attached image.", "attachment_url": "https://example.com/image.png", "attachment_name": "image.png" } Pre-Staged Attachment:

Place your file in the available_attachments directory and reference it by name:

json Copy { "recipient": "friend@example.com", "subject": "Hello with attachment", "body": "Please see the attached file.", "attachment_name": "document.pdf" } License: This project is licensed under the MIT License.

Contributing: Contributions are welcome! Feel free to open issues or submit pull requests.

Acknowledgments: Built with fastMCP. Inspired by resilient design patterns for server applications.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Khalid kalib
  • Write professional emails

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • INFOLAB OPERATIONS 2
  • A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • zhaoyunxing92
  • MCP(消息连接器协议)服务

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

    Reviews

    5 (1)
    Avatar
    user_bSnIFISb
    2025-04-15

    Excel Reader MCP Server by seanmars is absolutely fantastic! It seamlessly integrates with our workflows, making data extraction from Excel files quick and efficient. The user-friendly interface and robust performance have significantly improved our productivity. Highly recommended for anyone looking to streamline their data management processes!