Get the FREE Ultimate OpenClaw Setup Guide →

mcp -email

一个基于 MCP (Model Context Protocol) 的邮件服务,支持 LLM 发送带附件的电子邮件及在指定目录中搜索文件。提供安全的 SMTP 传输、多收件人支持和附件模式匹配搜索功能,适用于 Gmail、Outlook、Yahoo、QQ 邮箱和网易 126 邮箱等主流邮箱服务。

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio shy2593666979-mcp-server-email python -m mcp_email_server \
  --env SENDER="your_email@example.com" \
  --env PASSWORD="your_app_password_or_token"

How to use

The MCP Email Server provides two main tools to interact with email functionality via the Model Context Protocol. The send_email tool lets you compose and send emails to multiple recipients, with optional attachments. You supply the recipient addresses, a subject, a body, and optionally attachments (filenames). The search_attachments tool scans a specified directory for files whose names match a given pattern, helping you locate relevant attachments before sending. The server runs as a Python-based MCP server and is configured by environment variables for the sender address and password, enabling secure SMTP transmission through common providers. To use these tools, start the server and pass commands to it through your MCP client interface; the tools will be invoked by name with the appropriate arguments, and results (or errors) will be returned to your client.

How to install

Prerequisites:

  • Python 3.8+ installed on the host
  • Access to install Python packages via pip
  1. Install required Python dependencies
pip install pydantic python-dotenv
  1. Prepare environment configuration
  • Create an environment where the sender email and password can be read by the server.
  • Example values (replace with real credentials):
SENDER=your_email@example.com
PASSWORD=your_app_password_or_token
  1. Run the MCP Email Server
# From the project root, using the recommended module invocation
python -m mcp_email_server --dir /path/to/attachment/directory
  1. Optional: configure for Claude.app or other clients
  • Provide an MCP server definition (as shown in mcp_config) so your client can reference the server by name (e.g., email).
  1. Verify SMTP configuration
  • Ensure the email.json (or equivalent SMTP config) includes providers you intend to use, such as Gmail, Outlook, or Yahoo, and that the host/port match your provider’s requirements.

Additional notes

  • Environment variables SENDER and PASSWORD control the SMTP sender identity; keep these secrets secure and do not commit to version control.
  • The server supports the following attachment types: doc, docx, xls, xlsx, ppt, pptx, pdf, zip, rar, 7z, tar, gz, txt, log, csv, json, xml, jpg, jpeg, png, gif, bmp, md.
  • For Gmail and some providers, you may need an app-specific password or an OAuth flow depending on your account security settings.
  • The --dir option specifies the directory to search for attachments; ensure the server has read access to this directory.
  • If you encounter SMTP connection issues, verify network access, firewall rules, and that the SMTP server/port in your email configuration matches your provider's guidance.

Related MCP Servers

Sponsor this space

Reach thousands of developers