Skip to main content

MCP Email Client

A Model Context Protocol (MCP) server for sending and receiving emails, supporting IMAP/SMTP, with display name, reply, robust error handling, and full attachment support.

Features

  • Send emails (with display name and attachment support)
  • List inbox/sent emails (brief info, attachment count)
  • Read email details by UID (auto-save and list attachments)
  • Reply to emails (auto set headers, display name, attachments)
  • Environment variable based configuration
  • Robust error handling and IMAP/SMTP compatibility

Example JSON config for MCP/Claude/Inspector

This format is suitable for use with Claude Desktop, MCP Inspector, or any MCP client that supports multi-server JSON configuration:

{
  "mcpServers": {
    "mcp-email-client": {
      "command": "uvx",
      "args": [
        "mcp-email-client"
      ],
      "env": {
        "MAIL_USER_NAME": "your@email.com",
        "MAIL_PASS_WORD": "yourpassword",
        "MAIL_SMTP_ADDR": "smtp.example.com:465",
        "MAIL_IMAP_ADDR": "imap.example.com:993",
        "MAIL_FROM_NAME": "Your Name",
        "MAIL_FROM_ADDR": "your@email.com",
        "MAIL_SAVE_PATH": "/absolute/path/to/attachments"
      }
    }
  }
}
  • You can add multiple servers under mcpServers.
  • This config can be loaded directly by Claude Desktop, MCP Inspector, or compatible tools.

Environment Variables

Name Description Example
MAIL_USER_NAME Email account (login username) user@example.com
MAIL_PASS_WORD Email account password/app token yourpassword
MAIL_SMTP_ADDR SMTP host:port smtp.example.com:465
MAIL_IMAP_ADDR IMAP host:port imap.example.com:993
MAIL_FROM_ADDR (Optional) From email address user@example.com
MAIL_FROM_NAME (Optional) From display name Alice
MAIL_SAVE_PATH (Optional) Path to save attachments /absolute/path/to/dir

Installation

uv pip install fastmcp
# or
pip install fastmcp

Usage

  1. Set environment variables (see above)
  2. Run the server:
python server.py

API Endpoints (Tools)

send_email

Send an email, with optional attachments.

  • Args:
    • to: Recipient email address
    • subject: Email subject
    • content: Email body (plain text)
    • attachments: List of absolute file paths to attach (optional)
  • Returns: { "success": bool, "message": str }

reply_email

Reply to an email, with optional attachments.

  • Args:
    • uid: UID of the original email to reply to
    • subject: Email subject
    • content: Email body (plain text or HTML)
    • attachments: List of absolute file paths to attach (optional)
  • Returns: { "success": bool, "message": str }

list_inbox / list_sent

List inbox or sent emails (brief info, attachment count).

  • Args:
    • limit: Maximum number of emails to return (default 10)
    • start: Start index (0-based, from the latest email)
  • Returns: { "emails": [ { "uid", "subject", "snippet", "date", "seen", "attachment" } ] }
    • attachment: Number of attachments in the email

read_email

Read full details of an email by UID, auto-save and list attachments.

  • Args:
    • uid: UID of the email
  • Returns: { "uid", "message_id", "from", "to", "subject", "date", "seen", "in_reply_to", "references", "snippet", "attachments" }
    • attachments: List of all attachment filenames (auto-saved to MAIL_SAVE_PATH/uid/ if MAIL_SAVE_PATH is set)

Example .env

MAIL_USER_NAME=your@email.com
MAIL_PASS_WORD=yourpassword
MAIL_SMTP_ADDR=smtp.example.com:465
MAIL_IMAP_ADDR=imap.example.com:993
MAIL_FROM_NAME=Your Name
MAIL_FROM_ADDR=your@email.com
MAIL_SAVE_PATH=/absolute/path/to/attachments

FAQ

  • Q: Why do I get 'Email content is empty'?
    • A: The UID may not exist, or the email was deleted/moved. Make sure to use a valid UID from list_inbox/list_sent.
  • Q: How to set display name?
    • A: Set MAIL_FROM_NAME in your environment variables.
  • Q: How to send HTML email?
    • A: Just include HTML tags in content, the server will auto-detect and set the correct MIME type.
  • Q: How to send attachments?
    • A: Pass a list of absolute file paths to the attachments parameter in send_email or reply_email.
  • Q: How to auto-save received attachments?
    • A: Set MAIL_SAVE_PATH. All attachments will be saved to MAIL_SAVE_PATH/uid/ when reading emails.

License

MIT

Metadata

Release files for mcp-email-client 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-email-client 0.1.9
File Size Uploaded Provenance
mcp_email_client-0.1.9.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-email-client 0.1.9
File Interpreter ABI Platform
mcp_email_client-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 14.9 kB

Release files / mcp_email_client-0.1.9.tar.gz

Download URL mcp_email_client-0.1.9.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0fdc2f3850b18fa6144a4db0585e6f1a8fb911d9caa64c748a4fa3e0b5f4dd33
BLAKE2b-256 checksum
How to use checksums
3a4589194c0b73069cb270a4f5c429d7b8eac0de33abce69445b31b32935e288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / mcp_email_client-0.1.9-py3-none-any.whl

Download URL mcp_email_client-0.1.9-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83f3b10503b59c24a124d7932219b05db32f2b1d28d5f5c82866169ce4ce006c
BLAKE2b-256 checksum
How to use checksums
99fc002b9ef0bf41eac18dbf0a507305cc1c52b451b6b84e468a327faa1b605f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Security for mcp-email-client 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page