Skip to main content

email-mcp

Release Build status codecov Commit activity License smithery badge

IMAP and SMTP via MCP Server

Installation

Manual Installation

We recommend using uv to manage your environment.

Run with uvx --from flora535-email-mcp@latest email-mcp stdio, and use the following MCP client configuration:

{
  "mcpServers": {
    "email-mcp": {
      "command": "uvx",
      "args": ["--from", "flora535-email-mcp@latest", "email-mcp", "stdio"]
    }
  }
}

This package is available on PyPI, so you can install it using pip install flora535-email-mcp

Environment Variable Configuration

You can also configure the email server using environment variables, which is particularly useful for CI/CD environments like Jenkins. email-mcp supports both TOML file configuration and environment variables, with environment variables taking precedence.

{
  "mcpServers": {
    "email-mcp": {
      "command": "uvx",
      "args": ["--from", "flora535-email-mcp@latest", "email-mcp", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_ACCOUNT_NAME": "work",
        "MCP_EMAIL_SERVER_FULL_NAME": "John Doe",
        "MCP_EMAIL_SERVER_EMAIL_ADDRESS": "john@example.com",
        "MCP_EMAIL_SERVER_USER_NAME": "john@example.com",
        "MCP_EMAIL_SERVER_PASSWORD": "your_password",
        "MCP_EMAIL_SERVER_IMAP_HOST": "imap.gmail.com",
        "MCP_EMAIL_SERVER_IMAP_PORT": "993",
        "MCP_EMAIL_SERVER_SMTP_HOST": "smtp.gmail.com",
        "MCP_EMAIL_SERVER_SMTP_PORT": "465"
      }
    }
  }
}

Available Environment Variables

Variable Description Default Required
MCP_EMAIL_SERVER_ACCOUNT_NAME Account identifier "default" No
MCP_EMAIL_SERVER_FULL_NAME Display name Email prefix No
MCP_EMAIL_SERVER_EMAIL_ADDRESS Email address - Yes
MCP_EMAIL_SERVER_USER_NAME Login username Same as email No
MCP_EMAIL_SERVER_PASSWORD Email password - Yes
MCP_EMAIL_SERVER_IMAP_HOST IMAP server host - Yes
MCP_EMAIL_SERVER_IMAP_PORT IMAP server port 993 No
MCP_EMAIL_SERVER_IMAP_SSL Enable IMAP SSL true No
MCP_EMAIL_SERVER_IMAP_VERIFY_SSL Verify IMAP SSL certificates (disable for self-signed) true No
MCP_EMAIL_SERVER_SMTP_HOST SMTP server host - Yes
MCP_EMAIL_SERVER_SMTP_PORT SMTP server port 465 No
MCP_EMAIL_SERVER_SMTP_SSL Enable SMTP SSL true No
MCP_EMAIL_SERVER_SMTP_START_SSL Enable STARTTLS false No
MCP_EMAIL_SERVER_SMTP_VERIFY_SSL Verify SSL certificates (disable for self-signed) true No
MCP_EMAIL_SERVER_ENABLE_ATTACHMENT_DOWNLOAD Enable attachment download false No
MCP_EMAIL_SERVER_SAVE_TO_SENT Save sent emails to IMAP Sent folder true No
MCP_EMAIL_SERVER_SENT_FOLDER_NAME Custom Sent folder name (auto-detect if not set) - No

Enabling Attachment Downloads

By default, downloading email attachments is disabled for security reasons. To enable this feature, you can either:

Option 1: Environment Variable

{
  "mcpServers": {
    "email-mcp": {
      "command": "uvx",
      "args": ["--from", "flora535-email-mcp@latest", "email-mcp", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_ENABLE_ATTACHMENT_DOWNLOAD": "true"
      }
    }
  }
}

Option 2: TOML Configuration

Add enable_attachment_download = true to your TOML configuration file (~/.config/email-mcp/config.toml):

enable_attachment_download = true

[[emails]]
# ... your email configuration

Once enabled, you can use the download_attachment tool to save email attachments to a specified path.

Saving Sent Emails to IMAP Sent Folder

By default, sent emails are automatically saved to your IMAP Sent folder. This ensures that emails sent via the MCP server appear in your email client (Thunderbird, webmail, etc.).

The server auto-detects common Sent folder names: Sent, INBOX.Sent, Sent Items, Sent Mail, [Gmail]/Sent Mail.

To specify a custom Sent folder name (useful for providers with non-standard folder names):

Option 1: Environment Variable

{
  "mcpServers": {
    "email-mcp": {
      "command": "uvx",
      "args": ["--from", "flora535-email-mcp@latest", "email-mcp", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_SENT_FOLDER_NAME": "INBOX.Sent"
      }
    }
  }
}

Option 2: TOML Configuration

[[emails]]
account_name = "work"
save_to_sent = true
sent_folder_name = "INBOX.Sent"
# ... rest of your email configuration

To disable saving to Sent folder, set MCP_EMAIL_SERVER_SAVE_TO_SENT=false or save_to_sent = false in your TOML config.

Self-Signed Certificates (e.g., ProtonMail Bridge)

If you're using a local mail server with self-signed certificates (like ProtonMail Bridge), you'll need to disable SSL certificate verification:

{
  "mcpServers": {
    "email-mcp": {
      "command": "uvx",
      "args": ["--from", "flora535-email-mcp@latest", "email-mcp", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_IMAP_VERIFY_SSL": "false",
        "MCP_EMAIL_SERVER_SMTP_VERIFY_SSL": "false"
      }
    }
  }
}

Or in TOML configuration:

[[emails]]
account_name = "protonmail"
# ... other settings ...

[emails.incoming]
verify_ssl = false

[emails.outgoing]
verify_ssl = false

For separate IMAP/SMTP credentials, you can also use:

  • MCP_EMAIL_SERVER_IMAP_USER_NAME / MCP_EMAIL_SERVER_IMAP_PASSWORD
  • MCP_EMAIL_SERVER_SMTP_USER_NAME / MCP_EMAIL_SERVER_SMTP_PASSWORD

Then you can try it in Claude Desktop. If you want to intergrate it with other mcp client, run $which email-mcp for the path and configure it in your client like:

{
  "mcpServers": {
    "email-mcp": {
      "command": "{{ ENTRYPOINT }}",
      "args": ["stdio"]
    }
  }
}

Installing via Smithery

To install Email Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @flora535/email-mcp --client claude

Usage

Replying to Emails

To reply to an email with proper threading (so it appears in the same conversation in email clients):

  1. First, fetch the original email to get its message_id:
emails = await get_emails_content(account_name="work", email_ids=["123"])
original = emails.emails[0]
  1. Send your reply using in_reply_to and references:
await send_email(
    account_name="work",
    recipients=[original.sender],
    subject=f"Re: {original.subject}",
    body="Thank you for your email...",
    in_reply_to=original.message_id,
    references=original.message_id,
)

The in_reply_to parameter sets the In-Reply-To header, and references sets the References header. Both are used by email clients to thread conversations properly.

Development

This project is managed using uv.

Try make install to install the virtual environment and install the pre-commit hooks.

Use uv run email-mcp for local development.

Releasing a new version

  • Create an API Token on PyPI.
  • Add the API Token to your projects secrets with the name PYPI_TOKEN by visiting this page.
  • Create a new release on Github.
  • Create a new tag in the form *.*.*.

For more details, see here.

Metadata

Release files for flora535-email-mcp 0.1.2

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

Source distribution (sdist)

Source distribution for flora535-email-mcp 0.1.2
File Size Uploaded Provenance
flora535_email_mcp-0.1.2.tar.gz 144.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flora535-email-mcp 0.1.2
File Interpreter ABI Platform
flora535_email_mcp-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 170.2 kB

Release files / flora535_email_mcp-0.1.2.tar.gz

Download URL flora535_email_mcp-0.1.2.tar.gz
Size 144.2 kB
Tags Source
SHA-256 checksum
How to use checksums
de0e016817ec1593bef98f57d1d767b6b81461dcec4b9b080d9f84b9c135ca13
BLAKE2b-256 checksum
How to use checksums
7dae850983d746dddaa634c69c4a939baa86bfb5ff59a62ada05400f7824e288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Release files / flora535_email_mcp-0.1.2-py3-none-any.whl

Download URL flora535_email_mcp-0.1.2-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bd0689c9b1cf4133bbef6ebaa24b9112a37ecc3bb15236aa89f2200ea5a3e95
BLAKE2b-256 checksum
How to use checksums
d368077e672c1aaaef75fd85a551637baf951feeb490898dab9533d87a28fed4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Security for flora535-email-mcp 0.1.2

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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